Move fetching of revocation data, guess size of signature

This commit is contained in:
Jeroen Bobbeldijk
2017-07-23 13:10:35 +02:00
parent 2211295c9a
commit 1c9a9d60b1
3 changed files with 57 additions and 52 deletions

View File

@@ -73,6 +73,7 @@ type SignContext struct {
ByteRangeStartByte int64
SignatureContentsStartByte int64
ByteRangeValues []int64
SignatureMaxLength uint32
}
func SignFile(input string, output string, sign_data SignData) error {
@@ -143,6 +144,19 @@ func (context *SignContext) SignPDF() error {
return err
}
// Base size for signature.
context.SignatureMaxLength = 100000
// Add estimated size for TSA.
// We can't kow actual size of TSA until after signing.
if context.SignData.TSA.URL != "" {
context.SignatureMaxLength += 10000
}
// Fetch revocation data before adding signature placeholder.
// Revocation data can be quite large and we need to create enough space in the placeholder.
context.fetchRevocationData()
visual_signature, err := context.createVisualSignature()
if err != nil {
return err