hash = dig.digest();
_digests.put(digestOID, hash.clone());
}
AttributeTable signed;
if (addDefaultAttributes)
{
Map parameters = getBaseParameters(contentType, digAlgId, hash);
signed = (sAttr != null) ? sAttr.getAttributes(Collections.unmodifiableMap(parameters)) : null;
}
else
{
signed = baseSignedTable;
}
if (isCounterSignature)
{
Hashtable ats = signed.toHashtable();
ats.remove(CMSAttributes.contentType);
signed = new AttributeTable(ats);
}
ASN1Set signedAttr = getAttributeSet(signed);
//
// sig must be composed from the DER encoding.
//
byte[] tmp;
if (signedAttr != null)
{
tmp = signedAttr.getEncoded(ASN1Encodable.DER);
}
else
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
content.write(bOut);
tmp = bOut.toByteArray();
}
sig.initSign(key, random);
sig.update(tmp);
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());