Add signature context for embedded signatures
This commit is contained in:
parent
49211b24ff
commit
97323a4c2b
11 changed files with 931 additions and 169 deletions
|
|
@ -36,3 +36,45 @@ func TestAEADKeyRingDecryption(t *testing.T) {
|
|||
|
||||
assert.Exactly(t, "hello world\n", decrypted.GetString())
|
||||
}
|
||||
|
||||
func TestTextMessageEncryptionWithSignatureAndContext(t *testing.T) {
|
||||
var message = NewPlainMessageFromString("plain text")
|
||||
var testContext = "test-context"
|
||||
|
||||
ciphertext, err := keyRingTestPublic.EncryptWithContext(message, keyRingTestPrivate, NewSigningContext(testContext, true))
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error when encrypting, got:", err)
|
||||
}
|
||||
|
||||
decrypted, err := keyRingTestPrivate.DecryptWithContext(
|
||||
ciphertext,
|
||||
keyRingTestPublic,
|
||||
GetUnixTime(),
|
||||
NewVerificationContext(testContext, true, 0),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error when decrypting, got:", err)
|
||||
}
|
||||
assert.Exactly(t, message.GetString(), decrypted.GetString())
|
||||
}
|
||||
|
||||
func TestTextMessageEncryptionWithSignatureAndContextAndCompression(t *testing.T) {
|
||||
var message = NewPlainMessageFromString("plain text")
|
||||
var testContext = "test-context"
|
||||
|
||||
ciphertext, err := keyRingTestPublic.EncryptWithContextAndCompression(message, keyRingTestPrivate, NewSigningContext(testContext, true))
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error when encrypting, got:", err)
|
||||
}
|
||||
|
||||
decrypted, err := keyRingTestPrivate.DecryptWithContext(
|
||||
ciphertext,
|
||||
keyRingTestPublic,
|
||||
GetUnixTime(),
|
||||
NewVerificationContext(testContext, true, 0),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal("Expected no error when decrypting, got:", err)
|
||||
}
|
||||
assert.Exactly(t, message.GetString(), decrypted.GetString())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue