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());
ASN1InputStream aIn = new ASN1InputStream(bIn);
TBSCertificateStructure tbs = TBSCertificateStructure.getInstance(aIn.readObject());