_digests.put(_digestOID, hash.clone());
        SignerInfo toSignerInfo(            DERObjectIdentifier  contentType)            throws IOException, SignatureException, CertificateEncodingException        {            AlgorithmIdentifier digAlgId = new AlgorithmIdentifier(                  new DERObjectIdentifier(this.getDigestAlgOID()), new DERNull());            AlgorithmIdentifier encAlgId = getEncAlgorithmIdentifier(this.getEncryptionAlgOID());            byte[]          hash = _digest.digest();            Map  parameters = getBaseParameters(contentType, digAlgId, hash);            AttributeTable signed = (_sAttr != null) ? _sAttr.getAttributes(Collections.unmodifiableMap(parameters)) : null;            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            {                throw new RuntimeException("signatures without signed attributes not implemented.");            }            _signature.update(bOut.toByteArray());            ASN1OctetString         encDigest = new DEROctetString(_signature.sign());            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();            ASN1InputStream         aIn = new ASN1InputStream(cert.getTBSCertificate());            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);        }