aboutsummaryrefslogtreecommitdiff
path: root/internal/util
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-04-13 16:33:03 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-04-13 16:33:03 +0200
commitb1bcc5d12fc57f0d39f3dadc0d159f4c71ae37d7 (patch)
treeb32b07c221dcccdb3bbd8f6f2dd28f7709e2af65 /internal/util
parent10317e6bcbd391c80c573816d5d16c989f75a899 (diff)
one util file for now
Diffstat (limited to 'internal/util')
-rw-r--r--internal/util/io.go30
-rw-r--r--internal/util/util.go (renamed from internal/util/crypto.go)22
2 files changed, 22 insertions, 30 deletions
diff --git a/internal/util/io.go b/internal/util/io.go
deleted file mode 100644
index 143a520..0000000
--- a/internal/util/io.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package util
-
-import (
- "bytes"
- "fmt"
- "io/ioutil"
- "os"
-
- "git.sigsum.org/sigsum-go/pkg/hex"
-)
-
-func BytesFromStdin() ([]byte, error) {
- b, err := ioutil.ReadAll(os.Stdin)
- if err != nil {
- return nil, fmt.Errorf("util: read stdin: %v", err)
- }
- return b, nil
-}
-
-func HexFromStdin() ([]byte, error) {
- b, err := BytesFromStdin()
- if err != nil {
- return nil, err
- }
- b, err = hex.Deserialize(string(bytes.TrimSpace(b)))
- if err != nil {
- return nil, fmt.Errorf("util: parse stdin: %v", err)
- }
- return b, nil
-}
diff --git a/internal/util/crypto.go b/internal/util/util.go
index a8c8fac..4d52245 100644
--- a/internal/util/crypto.go
+++ b/internal/util/util.go
@@ -1,15 +1,37 @@
package util
import (
+ "bytes"
"crypto"
"crypto/ed25519"
"fmt"
"io/ioutil"
+ "os"
"git.sigsum.org/sigsum-go/pkg/hex"
"git.sigsum.org/sigsum-go/pkg/types"
)
+func BytesFromStdin() ([]byte, error) {
+ b, err := ioutil.ReadAll(os.Stdin)
+ if err != nil {
+ return nil, fmt.Errorf("util: read stdin: %v", err)
+ }
+ return b, nil
+}
+
+func HexFromStdin() ([]byte, error) {
+ b, err := BytesFromStdin()
+ if err != nil {
+ return nil, err
+ }
+ b, err = hex.Deserialize(string(bytes.TrimSpace(b)))
+ if err != nil {
+ return nil, fmt.Errorf("util: parse stdin: %v", err)
+ }
+ return b, nil
+}
+
func SignerFromHex(s string) (crypto.Signer, error) {
b, err := hex.Deserialize(s)
if err != nil {