diff options
author | cyberta <cyberta@riseup.net> | 2021-11-12 00:46:35 +0000 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2021-11-12 00:46:35 +0000 |
commit | c5d722f555b952407dade3abb1ffd537e6747317 (patch) | |
tree | a9ebb8b33438589a33ed9ce54ade50371c9fe147 /go/src/se.leap.bitmaskclient/pgpverify/pgpverify.go | |
parent | 571c0479f7400e56cfdb27408160d8a816cc8610 (diff) | |
parent | 8aeb4791b6e024de9aa9c61b574d8c798a3c0a2c (diff) |
Merge branch 'tor-snowflake' into 'master'
tor-over-snowflake
Closes #9045
See merge request leap/bitmask_android!138
Diffstat (limited to 'go/src/se.leap.bitmaskclient/pgpverify/pgpverify.go')
-rw-r--r-- | go/src/se.leap.bitmaskclient/pgpverify/pgpverify.go | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/go/src/se.leap.bitmaskclient/pgpverify/pgpverify.go b/go/src/se.leap.bitmaskclient/pgpverify/pgpverify.go deleted file mode 100644 index 1388a33c..00000000 --- a/go/src/se.leap.bitmaskclient/pgpverify/pgpverify.go +++ /dev/null @@ -1,45 +0,0 @@ -package pgpverify - -import ( - "os" - "strings" - - "golang.org/x/crypto/openpgp" -) - -// PgpVerifier - exported struct used for file verification -type PgpVerifier struct { - Logger Logger -} - -// Logger - logging interface -type Logger interface { - Log(msg string) -} - -// Verify checks if a file was signed with the correct pgp key -// using a PEM formatted signature and a corresponding public key -func (pgpv *PgpVerifier) Verify(signature string, publicKey string, targetPath string) bool { - keyRingReader := strings.NewReader(publicKey) - signatureReader := strings.NewReader(signature) - - verificationTarget, err := os.Open(targetPath) - if err != nil { - pgpv.Logger.Log("Open verification target: " + err.Error()) - return false - } - - keyring, err := openpgp.ReadArmoredKeyRing(keyRingReader) - if err != nil { - pgpv.Logger.Log("Read Armored Key Ring: " + err.Error()) - return false - } - _, err = openpgp.CheckArmoredDetachedSignature(keyring, verificationTarget, signatureReader) - if err != nil { - pgpv.Logger.Log("Verification failed: " + err.Error()) - return false - } - pgpv.Logger.Log("Successfully verified: entity.Identities") - return true -} - |