Wrote a test that invalid signature won't pollute state

This commit is contained in:
Ivan Tomilov 2017-06-14 09:37:45 +07:00
parent ed1bff8998
commit 4151180300
2 changed files with 5 additions and 2 deletions

View File

@ -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
}

View File

@ -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)