Add mobile helpers to verify signature contexts.

This commit is contained in:
M. Thiercelin 2023-04-21 10:57:23 +02:00
parent 753a3fedff
commit 2cf7a8caee
No known key found for this signature in database
GPG key ID: 29581E7E24EBEC0A
4 changed files with 35 additions and 2 deletions

View file

@ -26,6 +26,20 @@ func DecryptExplicitVerify(
return newExplicitVerifyMessage(message, err)
}
// DecryptExplicitVerifyWithContext decrypts a PGP message given a private keyring
// and a public keyring to verify the embedded signature. Returns the plain
// data and an error on signature verification failure.
// The caller can provide a context that will be used to verify the signature.
func DecryptExplicitVerifyWithContext(
pgpMessage *crypto.PGPMessage,
privateKeyRing, publicKeyRing *crypto.KeyRing,
verifyTime int64,
verificationContext *crypto.VerificationContext,
) (*ExplicitVerifyMessage, error) {
message, err := privateKeyRing.DecryptWithContext(pgpMessage, publicKeyRing, verifyTime, verificationContext)
return newExplicitVerifyMessage(message, err)
}
// DecryptSessionKeyExplicitVerify decrypts a PGP data packet given a session key
// and a public keyring to verify the embedded signature. Returns the plain data and
// an error on signature verification failure.
@ -39,6 +53,21 @@ func DecryptSessionKeyExplicitVerify(
return newExplicitVerifyMessage(message, err)
}
// DecryptSessionKeyExplicitVerifyWithContext decrypts a PGP data packet given a session key
// and a public keyring to verify the embedded signature. Returns the plain data and
// an error on signature verification failure.
// The caller can provide a context that will be used to verify the signature.
func DecryptSessionKeyExplicitVerifyWithContext(
dataPacket []byte,
sessionKey *crypto.SessionKey,
publicKeyRing *crypto.KeyRing,
verifyTime int64,
verificationContext *crypto.VerificationContext,
) (*ExplicitVerifyMessage, error) {
message, err := sessionKey.DecryptAndVerifyWithContext(dataPacket, publicKeyRing, verifyTime, verificationContext)
return newExplicitVerifyMessage(message, err)
}
func newExplicitVerifyMessage(message *crypto.PlainMessage, err error) (*ExplicitVerifyMessage, error) {
var explicitVerify *ExplicitVerifyMessage
if err != nil {