dic.setDate(new PdfDate(sap.getSignDate()));
sap.setCryptoDictionary(dic);
final Proxy tmpProxy = options.createProxy();
final CRLInfo crlInfo = new CRLInfo(options, chain);
// CRLs are stored twice in PDF c.f.
// PdfPKCS7.getAuthenticatedAttributeBytes
final int contentEstimated = (int) (Constants.DEFVAL_SIG_SIZE + 2L * crlInfo.getByteCount());
HashMap exc = new HashMap();
exc.put(PdfName.CONTENTS, new Integer(contentEstimated * 2 + 2));
sap.preClose(exc);
PdfPKCS7 sgn = new PdfPKCS7(key, chain, crlInfo.getCrls(), hashAlgorithm.getAlgorithmName(), null, false);
InputStream data = sap.getRangeStream();
final MessageDigest messageDigest = MessageDigest.getInstance(hashAlgorithm.getAlgorithmName());
byte buf[] = new byte[8192];
int n;
while ((n = data.read(buf)) > 0) {