-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct chacha20poly1305's empty padding case
Add a bunch of tests generated with libsodium.
- Loading branch information
Showing
3 changed files
with
503 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pysodium | ||
|
||
def test(msg, aad, nonce, key): | ||
ct = pysodium.crypto_aead_chacha20poly1305_ietf_encrypt(msg, aad, nonce, key) | ||
ct, tag = ct[:len(msg)], ct[len(msg):] | ||
|
||
print """ | ||
vector("%s", | ||
"%s", | ||
"%s", | ||
"%s", | ||
"%s", | ||
"%s");""" % (key.encode('hex'), nonce.encode('hex'), aad.encode('hex'), msg.encode('hex'), ct.encode('hex'), tag.encode('hex')) | ||
|
||
key = 'key.' * 8 | ||
nonce = 'nonce.' * 2 | ||
msg = 'message' * 5 | ||
aad = 'aad' * 12 | ||
|
||
for msgl in range(32): | ||
test(msg[:msgl], aad, nonce, key) | ||
|
||
for aadl in range(32): | ||
test(msg, aad[:aadl], nonce, key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.