-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a70030
commit 66b1559
Showing
4 changed files
with
150 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
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
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,37 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
from ... import TestUnitBase | ||
|
||
|
||
class TestChaCha(TestUnitBase): | ||
|
||
def test_xchacha(self): | ||
key = bytes.fromhex( | ||
'808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f') | ||
nonce = bytes.fromhex( | ||
'404142434445464748494a4b4c4d4e4f5051525354555658') | ||
data = bytes.fromhex( | ||
'5468652064686f6c65202870726f6e6f756e6365642022646f6c652229206973' | ||
'20616c736f206b6e6f776e2061732074686520417369617469632077696c6420' | ||
'646f672c2072656420646f672c20616e642077686973746c696e6720646f672e' | ||
'2049742069732061626f7574207468652073697a65206f662061204765726d61' | ||
'6e20736865706865726420627574206c6f6f6b73206d6f7265206c696b652061' | ||
'206c6f6e672d6c656767656420666f782e205468697320686967686c7920656c' | ||
'757369766520616e6420736b696c6c6564206a756d70657220697320636c6173' | ||
'736966696564207769746820776f6c7665732c20636f796f7465732c206a6163' | ||
'6b616c732c20616e6420666f78657320696e20746865207461786f6e6f6d6963' | ||
'2066616d696c792043616e696461652e') | ||
goal = bytes.fromhex( | ||
'7d0a2e6b7f7c65a236542630294e063b7ab9b555a5d5149aa21e4ae1e4fbce87' | ||
'ecc8e08a8b5e350abe622b2ffa617b202cfad72032a3037e76ffdcdc4376ee05' | ||
'3a190d7e46ca1de04144850381b9cb29f051915386b8a710b8ac4d027b8b050f' | ||
'7cba5854e028d564e453b8a968824173fc16488b8970cac828f11ae53cabd201' | ||
'12f87107df24ee6183d2274fe4c8b1485534ef2c5fbc1ec24bfc3663efaa08bc' | ||
'047d29d25043532db8391a8a3d776bf4372a6955827ccb0cdd4af403a7ce4c63' | ||
'd595c75a43e045f0cce1f29c8b93bd65afc5974922f214a40b7c402cdb91ae73' | ||
'c0b63615cdad0480680f16515a7ace9d39236464328a37743ffc28f4ddb324f4' | ||
'd0f5bbdc270c65b1749a6efff1fbaa09536175ccd29fb9e6057b307320d31683' | ||
'8a9c71f70b5b5907a66f7ea49aadc409' | ||
) | ||
test = data | self.ldu('xchacha', offset=1, key=key, nonce=nonce) | bytes | ||
self.assertEqual(test, goal) |
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,28 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
from ... import TestUnitBase | ||
|
||
|
||
class TestSalsa(TestUnitBase): | ||
|
||
def test_xsalsa(self): | ||
key = B'this is 32-byte key for xsalsa20' | ||
nonce = B'24-byte nonce for xsalsa' | ||
data = [B'Hello world!', bytearray(64)] | ||
goal = [ | ||
bytes(( | ||
0x00, 0x2d, 0x45, 0x13, 0x84, 0x3f, 0xc2, 0x40, | ||
0xc4, 0x01, 0xe5, 0x41)), | ||
bytes(( | ||
0x48, 0x48, 0x29, 0x7f, 0xeb, 0x1f, 0xb5, 0x2f, | ||
0xb6, 0x6d, 0x81, 0x60, 0x9b, 0xd5, 0x47, 0xfa, | ||
0xbc, 0xbe, 0x70, 0x26, 0xed, 0xc8, 0xb5, 0xe5, | ||
0xe4, 0x49, 0xd0, 0x88, 0xbf, 0xa6, 0x9c, 0x08, | ||
0x8f, 0x5d, 0x8d, 0xa1, 0xd7, 0x91, 0x26, 0x7c, | ||
0x2c, 0x19, 0x5a, 0x7f, 0x8c, 0xae, 0x9c, 0x4b, | ||
0x40, 0x50, 0xd0, 0x8c, 0xe6, 0xd3, 0xa1, 0x51, | ||
0xec, 0x26, 0x5f, 0x3a, 0x58, 0xe4, 0x76, 0x48)) | ||
] | ||
for d, g in zip(data, goal): | ||
test = d | self.ldu('xsalsa', key=key, nonce=nonce) | bytes | ||
self.assertEqual(test, g) |