SequenceInputStream signStream = new SequenceInputStream(new ByteArrayInputStream(inputBytes),
new ByteArrayInputStream(signBuffer));
// sign the bytes
SignatureInterface signatureInterface = doc.getSignatureInterface();
byte[] sign = signatureInterface.sign(signStream);
String signature = new COSString(sign).getHexString();
// substract 2 bytes because of the enclosing "<>"
if (signature.length() > signatureLength - 2)
{
throw new IOException("Can't write signature, not enough space");