Wrote a test that invalid signature won't pollute state
This commit is contained in:
parent
ed1bff8998
commit
4151180300
2
state.go
2
state.go
|
@ -21,7 +21,7 @@ type State interface {
|
|||
// RatchetDecrypt is called to AEAD-decrypt messages.
|
||||
RatchetDecrypt(m Message, ad AssociatedData) ([]byte, error)
|
||||
|
||||
// PublicKey returns the session public key.
|
||||
// PublicKey returns the session's ratchet public key.
|
||||
PublicKey() [32]byte
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,10 @@ func TestState_RatchetDecrypt_CommunicationSkippedMessages(t *testing.T) {
|
|||
require.Nil(t, err)
|
||||
require.Equal(t, []byte("how are you?"), d)
|
||||
|
||||
// TODO: Invalid signature to test state atomicity.
|
||||
m3.Ciphertext[len(m3.Ciphertext)-1] ^= 10
|
||||
_, err = bob.RatchetDecrypt(m3, nil) // Error: invalid signature.
|
||||
require.NotNil(t, err)
|
||||
m3.Ciphertext[len(m3.Ciphertext)-1] ^= 10
|
||||
|
||||
d, err = bob.RatchetDecrypt(m3, nil) // Decrypted.
|
||||
require.Nil(t, err)
|
||||
|
|
Loading…
Reference in New Issue