_digests.put(digestOID, hash.clone());
        SignerInfo toSignerInfo(            DERObjectIdentifier contentType,            CMSProcessable      content,            String              sigProvider,            boolean             addDefaultAttributes)            throws IOException, SignatureException, InvalidKeyException, NoSuchProviderException, NoSuchAlgorithmException, CertificateEncodingException, CMSException        {            AlgorithmIdentifier digAlgId = new AlgorithmIdentifier(                  new DERObjectIdentifier(this.getDigestAlgOID()), new DERNull());            AlgorithmIdentifier encAlgId = getEncAlgorithmIdentifier(this.getEncryptionAlgOID());            String              digestName = CMSSignedHelper.INSTANCE.getDigestAlgName(digestOID);            String              signatureName = digestName + "with" + CMSSignedHelper.INSTANCE.getEncryptionAlgName(encOID);            Signature           sig = CMSSignedHelper.INSTANCE.getSignatureInstance(signatureName, sigProvider);            MessageDigest       dig = CMSSignedHelper.INSTANCE.getDigestInstance(digestName, sigProvider);                           byte[]      hash = null;            if (content != null)            {                content.write(new DigOutputStream(dig));                hash = dig.digest();            }            AttributeTable signed;            if (addDefaultAttributes)            {                Map parameters = getBaseParameters(contentType, digAlgId, hash);                signed = (sAttr != null) ? sAttr.getAttributes(Collections.unmodifiableMap(parameters)) : null;            }            else            {                signed = baseSignedTable;            }            ASN1Set signedAttr = getAttributeSet(signed);            //            // sig must be composed from the DER encoding.            //            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();             if (signedAttr != null)             {                DEROutputStream         dOut = new DEROutputStream(bOut);                dOut.writeObject(signedAttr);            }             else            {                content.write(bOut);            }            sig.initSign(key);            sig.update(bOut.toByteArray());            ASN1OctetString         encDigest = new DEROctetString(sig.sign());            Map parameters = getBaseParameters(contentType, digAlgId, hash);            parameters.put(CMSAttributeTableGenerator.SIGNATURE, encDigest.getOctets().clone());            AttributeTable unsigned = (unsAttr != null) ? unsAttr.getAttributes(Collections.unmodifiableMap(parameters)) : null;            ASN1Set unsignedAttr = getAttributeSet(unsigned);            X509Certificate         cert = this.getCertificate();            ByteArrayInputStream    bIn = new ByteArrayInputStream(cert.getTBSCertificate());            ASN1InputStream         aIn = new ASN1InputStream(bIn);            TBSCertificateStructure tbs = TBSCertificateStructure.getInstance(aIn.readObject());            IssuerAndSerialNumber   encSid = new IssuerAndSerialNumber(tbs.getIssuer(), tbs.getSerialNumber().getValue());            return new SignerInfo(new SignerIdentifier(encSid), digAlgId,                        signedAttr, encAlgId, encDigest, unsignedAttr);        }