aboutsummaryrefslogtreecommitdiff
path: root/cmd/pdf-simple-sign
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-09-04 18:33:12 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-09-04 18:33:12 +0200
commit796a9640d36328465cef66752a811eac5f7b3da5 (patch)
tree269a5090a5fc6f0dcf7ef78273901ae124fdc036 /cmd/pdf-simple-sign
parent2d08100b58b6c7e06f124aef3e2761bcdaeac85b (diff)
downloadpdf-simple-sign-796a9640d36328465cef66752a811eac5f7b3da5.tar.gz
pdf-simple-sign-796a9640d36328465cef66752a811eac5f7b3da5.tar.xz
pdf-simple-sign-796a9640d36328465cef66752a811eac5f7b3da5.zip
Make it possible to change the signature reservation
Diffstat (limited to 'cmd/pdf-simple-sign')
-rw-r--r--cmd/pdf-simple-sign/main.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/cmd/pdf-simple-sign/main.go b/cmd/pdf-simple-sign/main.go
index 3257a66..5141a12 100644
--- a/cmd/pdf-simple-sign/main.go
+++ b/cmd/pdf-simple-sign/main.go
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2018, Přemysl Eric Janouch <p@janouch.name>
+// Copyright (c) 2018 - 2020, Přemysl Eric Janouch <p@janouch.name>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted.
@@ -20,8 +20,9 @@ import (
"flag"
"fmt"
"io/ioutil"
- "janouch.name/pdf-simple-sign/pdf"
"os"
+
+ "janouch.name/pdf-simple-sign/pdf"
)
// #include <unistd.h>
@@ -39,10 +40,13 @@ func die(status int, format string, args ...interface{}) {
}
func usage() {
- die(1, "Usage: %s [-h] INPUT-FILENAME OUTPUT-FILENAME "+
+ die(1, "Usage: %s [-h] [-r RESERVATION] INPUT-FILENAME OUTPUT-FILENAME "+
"PKCS12-PATH PKCS12-PASS", os.Args[0])
}
+var reservation = flag.Int(
+ "r", 4096, "signature reservation as a number of bytes")
+
func main() {
flag.Usage = usage
flag.Parse()
@@ -51,7 +55,7 @@ func main() {
}
inputPath, outputPath := flag.Arg(0), flag.Arg(1)
- pdfDocument, err := ioutil.ReadFile(inputPath)
+ doc, err := ioutil.ReadFile(inputPath)
if err != nil {
die(1, "%s", err)
}
@@ -63,10 +67,10 @@ func main() {
if err != nil {
die(3, "%s", err)
}
- if pdfDocument, err = pdf.Sign(pdfDocument, key, certs); err != nil {
+ if doc, err = pdf.Sign(doc, key, certs, *reservation); err != nil {
die(4, "error: %s", err)
}
- if err = ioutil.WriteFile(outputPath, pdfDocument, 0666); err != nil {
+ if err = ioutil.WriteFile(outputPath, doc, 0666); err != nil {
die(5, "%s", err)
}
}