Browse Source

Merge pull request #1787 from tendermint/dev/hkdfchachapoly_testvector_seal

crypto/hkdfchachapoly: Add testing seal to the test vector
pull/1797/head
Alexander Simmerl 7 years ago
committed by GitHub
parent
commit
7e3de2027e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      crypto/hkdfchacha20poly1305/hkdfchachapoly_test.go

+ 4
- 0
crypto/hkdfchacha20poly1305/hkdfchachapoly_test.go View File

@ -36,12 +36,16 @@ func TestVector(t *testing.T) {
nonce := make([]byte, 24) nonce := make([]byte, 24)
nonce[0] = byteArr[0] nonce[0] = byteArr[0]
// Test that we get the expected plaintext on open
plaintext, err := aead.Open(nil, nonce, ct, byteArr) plaintext, err := aead.Open(nil, nonce, ct, byteArr)
if err != nil { if err != nil {
t.Errorf("%dth Open failed", i) t.Errorf("%dth Open failed", i)
continue continue
} }
assert.Equal(t, byteArr, plaintext) assert.Equal(t, byteArr, plaintext)
// Test that sealing yields the expected ciphertext
ciphertext := aead.Seal(nil, nonce, plaintext, byteArr)
assert.Equal(t, ct, ciphertext)
} }
} }


Loading…
Cancel
Save