diff --git a/CHANGELOG.md b/CHANGELOG.md index b85666d..9c7800a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Changed the returned `SignatureVerificationError.Status` when trying to verify a message with no embedded signature. It used to return `constants.SIGNATURE_NO_VERIFIER` and now returns `constants.SIGNATURE_NOT_SIGNED`. +This change impacts : + - `func (sk *SessionKey) DecryptAndVerify(...)` + - `func (msg *PlainMessageReader) VerifySignature(...)` + - `func (keyRing *KeyRing) Decrypt(...)` + ### Added - Helper to access the SignatureVerificationError explicitly when decrypting streams in mobile apps: ```go diff --git a/crypto/signature.go b/crypto/signature.go index a9db54e..67c1d7c 100644 --- a/crypto/signature.go +++ b/crypto/signature.go @@ -99,8 +99,10 @@ func processSignatureExpiration(md *openpgp.MessageDetails, verifyTime int64) { // verifyDetailsSignature verifies signature from message details. func verifyDetailsSignature(md *openpgp.MessageDetails, verifierKey *KeyRing) error { - if !md.IsSigned || - md.SignedBy == nil || + if !md.IsSigned { + return newSignatureNotSigned() + } + if md.SignedBy == nil || len(verifierKey.entities) == 0 || len(verifierKey.entities.KeysById(md.SignedByKeyId)) == 0 { return newSignatureNoVerifier() diff --git a/helper/mobile_test.go b/helper/mobile_test.go index c8eec57..54751b2 100644 --- a/helper/mobile_test.go +++ b/helper/mobile_test.go @@ -85,7 +85,7 @@ func TestMobileSignedMessageDecryptionWithSessionKey(t *testing.T) { t.Fatal("Expected no error when decrypting, got:", err) } - assert.Exactly(t, constants.SIGNATURE_NO_VERIFIER, decrypted.SignatureVerificationError.Status) + assert.Exactly(t, constants.SIGNATURE_NOT_SIGNED, decrypted.SignatureVerificationError.Status) assert.Exactly(t, message.GetString(), decrypted.Message.GetString()) publicKey, _ = crypto.NewKeyFromArmored(readTestFile("keyring_publicKey", false))