Skip to content

Commit d37f4eb

Browse files
author
marinthiercelin
authored
Merge pull request #237 from ProtonMail/feat/signature-context-mobile-helpers
Add mobile helpers to verify signature contexts and prepare v2.7.1
2 parents 753a3fe + 2cf7a8c commit d37f4eb

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.7.1] 2023-04-21
8+
9+
- Add mobile helpers for signature verification with contexts.
10+
711
## [2.7.0] 2023-04-14
812
### Changed
913
- The `SignatureVerificationError` struct now has a `Cause error` field, which is returned by the the Unwrap function. The cause is also included in the error message.

constants/armor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package constants
33

44
// Constants for armored data.
55
const (
6-
ArmorHeaderVersion = "GopenPGP 2.7.0"
6+
ArmorHeaderVersion = "GopenPGP 2.7.1"
77
ArmorHeaderComment = "https://gopenpgp.org"
88
PGPMessageHeader = "PGP MESSAGE"
99
PGPSignatureHeader = "PGP SIGNATURE"

constants/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package constants
22

3-
const Version = "2.7.0"
3+
const Version = "2.7.1"

helper/mobile.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ func DecryptExplicitVerify(
2626
return newExplicitVerifyMessage(message, err)
2727
}
2828

29+
// DecryptExplicitVerifyWithContext decrypts a PGP message given a private keyring
30+
// and a public keyring to verify the embedded signature. Returns the plain
31+
// data and an error on signature verification failure.
32+
// The caller can provide a context that will be used to verify the signature.
33+
func DecryptExplicitVerifyWithContext(
34+
pgpMessage *crypto.PGPMessage,
35+
privateKeyRing, publicKeyRing *crypto.KeyRing,
36+
verifyTime int64,
37+
verificationContext *crypto.VerificationContext,
38+
) (*ExplicitVerifyMessage, error) {
39+
message, err := privateKeyRing.DecryptWithContext(pgpMessage, publicKeyRing, verifyTime, verificationContext)
40+
return newExplicitVerifyMessage(message, err)
41+
}
42+
2943
// DecryptSessionKeyExplicitVerify decrypts a PGP data packet given a session key
3044
// and a public keyring to verify the embedded signature. Returns the plain data and
3145
// an error on signature verification failure.
@@ -39,6 +53,21 @@ func DecryptSessionKeyExplicitVerify(
3953
return newExplicitVerifyMessage(message, err)
4054
}
4155

56+
// DecryptSessionKeyExplicitVerifyWithContext decrypts a PGP data packet given a session key
57+
// and a public keyring to verify the embedded signature. Returns the plain data and
58+
// an error on signature verification failure.
59+
// The caller can provide a context that will be used to verify the signature.
60+
func DecryptSessionKeyExplicitVerifyWithContext(
61+
dataPacket []byte,
62+
sessionKey *crypto.SessionKey,
63+
publicKeyRing *crypto.KeyRing,
64+
verifyTime int64,
65+
verificationContext *crypto.VerificationContext,
66+
) (*ExplicitVerifyMessage, error) {
67+
message, err := sessionKey.DecryptAndVerifyWithContext(dataPacket, publicKeyRing, verifyTime, verificationContext)
68+
return newExplicitVerifyMessage(message, err)
69+
}
70+
4271
func newExplicitVerifyMessage(message *crypto.PlainMessage, err error) (*ExplicitVerifyMessage, error) {
4372
var explicitVerify *ExplicitVerifyMessage
4473
if err != nil {

0 commit comments

Comments
 (0)