Add signature context for embedded signatures
This commit is contained in:
parent
49211b24ff
commit
97323a4c2b
11 changed files with 931 additions and 169 deletions
|
|
@ -249,6 +249,30 @@ func TestDataPacketEncryptionAndSignature(t *testing.T) {
|
|||
assert.Exactly(t, message.GetString(), finalMessage.GetString())
|
||||
}
|
||||
|
||||
func TestDataPacketEncryptionAndSignatureWithContext(t *testing.T) {
|
||||
var message = NewPlainMessageFromString(
|
||||
"The secret code is... 1, 2, 3, 4, 5. I repeat: the secret code is... 1, 2, 3, 4, 5",
|
||||
)
|
||||
var testContext = "test-context"
|
||||
// Encrypt data with session key
|
||||
dataPacket, err := testSessionKey.EncryptAndSignWithContext(message, keyRingTestPrivate, NewSigningContext(testContext, true))
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error when encrypting and signing, got:", err)
|
||||
}
|
||||
|
||||
// Decrypt & verify data with the good session key and keyring
|
||||
decrypted, err := testSessionKey.DecryptAndVerifyWithContext(
|
||||
dataPacket,
|
||||
keyRingTestPublic,
|
||||
GetUnixTime(),
|
||||
NewVerificationContext(testContext, true, 0),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error when decrypting & verifying, got:", err)
|
||||
}
|
||||
assert.Exactly(t, message.GetString(), decrypted.GetString())
|
||||
}
|
||||
|
||||
func TestDataPacketDecryption(t *testing.T) {
|
||||
pgpMessage, err := NewPGPMessageFromArmored(readTestFile("message_signed", false))
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue