mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-19 10:05:05 -07:00
Add tests for chacha&salsa with a counter around 2^32
This commit is contained in:
parent
36c038ccd1
commit
e46bc4c5dd
@ -102,7 +102,10 @@ void tv_ietf(void)
|
||||
0U },
|
||||
{ "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
|
||||
"000000090000004a00000000",
|
||||
1U }};
|
||||
1U },
|
||||
{ "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
|
||||
"000000090000004a00000000",
|
||||
0x100000000UL }};
|
||||
unsigned char key[crypto_stream_chacha20_KEYBYTES];
|
||||
unsigned char nonce[crypto_stream_chacha20_IETF_NONCEBYTES];
|
||||
unsigned char *part;
|
||||
|
@ -35,6 +35,7 @@
|
||||
[72d54dfbf12ec44b362692df94137f328fea8da73990265ec1bbbea1ae9af0ca13b25aa26cb4a648cb9b9d1be65b2c0924a66c54d545ec1b7374f4872e99f096bf74dbd52cc4fc95ceb6097fe5e65358c9dbc0a5ecbf7894a132a9a54ae3e951f2e9f209aa9c3d9a877ac9dab62433d2961a17d103e455dfb7337c90f6857aad233065955a212b5c7a8eab4dc8a629e5b6b8ba914afd06de7177054b33d21c96]
|
||||
[c2c64d378cd536374ae204b9ef933fcd1a8b2288b3dfa49672ab765b54ee27c78a970e0e955c14f3a88e741b97c286f75f8fc299e8148362fa198a39531bed6d1a91288c874ec254f322c2a197340c55bb3e9b3998f7de2309486a0bb494abd20c9c5ef99c1370d61e77f408ac5514f49202bcc6828d45409d2d1416f8ae106b06ebd2541256264fa415bd54cb12e1d4449ed85299a1b7a249b75ff6c89b2e3f]
|
||||
[10f1e7e4d13b5915500fdd1fa32071c4c7d1f4c733c068030422aa9ac3d46c4ed2826446079faa0914c2d705d98b02a2b5129cd1de164eb9cbd083e8a2503c4e0a88837739d7bf4ef8ccacb0ea2bb9d69d56c394aa351dfda5bf459f0a2e9fe8e721f89255f9c486bf21679c683d4f9c5cf2fa27865526005b06ca374c86af3bdcbfbdcb83be65862ed5c20eae5a43241d6a92da6dca9a156be25297f51c2718]
|
||||
[8adc91fd9ff4f0f51b0fad50ff15d637e40efda206cc52c783a74200503c1582cd9833367d0a54d57d3c9e998f490ee69ca34c1ff9e939a75584c52d690a35d410f1e7e4d13b5915500fdd1fa32071c4c7d1f4c733c068030422aa9ac3d46c4ed2826446079faa0914c2d705d98b02a2b5129cd1de164eb9cbd083e8a2503c4e0a88837739d7bf4ef8ccacb0ea2bb9d69d56c394aa351dfda5bf459f0a2e9fe8]
|
||||
[61010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101]
|
||||
[6146f256040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404]
|
||||
[6146f2564fe1bd070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707070707]
|
||||
|
@ -16,7 +16,7 @@ static unsigned char nonce[24] = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6,
|
||||
static unsigned char output[4194304];
|
||||
|
||||
static unsigned char h[32];
|
||||
static char hex[2 * 64 + 1];
|
||||
static char hex[2 * 192 + 1];
|
||||
|
||||
int
|
||||
main(void)
|
||||
@ -47,6 +47,12 @@ main(void)
|
||||
printf("%s\n", hex);
|
||||
}
|
||||
|
||||
memset(output, 0, 192);
|
||||
crypto_stream_xsalsa20_xor_ic(output, output, 192, nonce,
|
||||
(1ULL << 32) - 1ULL, firstkey);
|
||||
sodium_bin2hex(hex, 192 * 2 + 1, output, 192);
|
||||
printf("%s\n", hex);
|
||||
|
||||
assert(crypto_stream_keybytes() > 0U);
|
||||
assert(crypto_stream_noncebytes() > 0U);
|
||||
assert(strcmp(crypto_stream_primitive(), "xsalsa20") == 0);
|
||||
|
@ -64,3 +64,4 @@ eea6a7251c1e72916d11c2cb214d3c252539121d8e234e652d651fa4c8cff880309e645a74e9e0a6
|
||||
eea6a7251c1e72916d11c2cb214d3c252539121d8e234e652d651fa4c8cff880309e645a74e9e0a60d8243acd9177ab51a1beb8d5a2f5d700c093c5e553d3d3d
|
||||
eea6a7251c1e72916d11c2cb214d3c252539121d8e234e652d651fa4c8cff880309e645a74e9e0a60d8243acd9177ab51a1beb8d5a2f5d700c093c5e55853e3e
|
||||
eea6a7251c1e72916d11c2cb214d3c252539121d8e234e652d651fa4c8cff880309e645a74e9e0a60d8243acd9177ab51a1beb8d5a2f5d700c093c5e5585573f
|
||||
b46af0bf761b78533e01a0dd7e07216c9710ef35f09a28d1e5fa469b602472ca5085f6dbcc6a6b51fb89986f8feca85658d05701f5677d0bb340a1f2c769547219f5420c62ffff7d1304dad82b6dec2bdc59ec12a9e18a774eed128c2c90610a9d4c75c0817d64817a76bbc12746971ae897af210a072c1bc9fb044e086b7bfe85fad95d5c2bbb28c12de5755b1ccde63e93cc892b4d2bcbd7dc0706b094c2492e329e3b9a98a9cbc7d01031cf1d5861f576e1291df6286c28146b0b4df9ad44
|
||||
|
@ -96,6 +96,7 @@ tv_stream_xchacha20(void)
|
||||
{ "9d23bd4149cb979ccf3c5c94dd217e9808cb0e50cd0f67812235eaaf601d6232", "c047548266b7c370d33566a2425cbf30d82d1eaf5294109e", "a21209096594de8c5667b1d13ad93f744106d054df210e4782cd396fec692d3515a20bf351eec011a92c367888bc464c32f0807acd6c203a247e0db854148468e9f96bee4cf718d68d5f637cbd5a376457788e6fae90fc31097cfc" },
|
||||
};
|
||||
const XChaCha20TV *tv;
|
||||
char *hex;
|
||||
unsigned char *key;
|
||||
unsigned char *nonce;
|
||||
unsigned char *out;
|
||||
@ -147,6 +148,26 @@ tv_stream_xchacha20(void)
|
||||
sodium_free(out);
|
||||
sodium_free(out2);
|
||||
|
||||
out = (unsigned char *) sodium_malloc(192);
|
||||
out2 = (unsigned char *) sodium_malloc(192);
|
||||
memset(out, 0, 192);
|
||||
memset(out2, 0, 192);
|
||||
crypto_stream_xchacha20_xor_ic(out2, out2, 192, nonce,
|
||||
(1ULL << 32) - 1ULL, key);
|
||||
crypto_stream_xchacha20_xor_ic(out, out, 64, nonce,
|
||||
(1ULL << 32) - 1ULL, key);
|
||||
crypto_stream_xchacha20_xor_ic(out + 64, out + 64, 64, nonce,
|
||||
(1ULL << 32), key);
|
||||
crypto_stream_xchacha20_xor_ic(out + 128, out + 128, 64, nonce,
|
||||
(1ULL << 32) + 1, key);
|
||||
assert(memcmp(out, out2, 192) == 0);
|
||||
hex = sodium_malloc(192 * 2 + 1);
|
||||
sodium_bin2hex(hex, 192 * 2 + 1, out, 192);
|
||||
printf("%s\n", hex);
|
||||
sodium_free(hex);
|
||||
sodium_free(out);
|
||||
sodium_free(out2);
|
||||
|
||||
sodium_free(nonce);
|
||||
sodium_free(key);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
tv_hchacha20: ok
|
||||
3e34c160a966ddfbd52d38f6a440a77256c1134ad54653db427dfdfc72f0f995768039052ec2ec4e6fe02c655d7d95681fabd417c087ad17f177510ba09d4cfe7beb8f7c9b8330d746310f9e29583e9ef240156015faafeb24a4d002d6337b7bcec8b54a64ef704e1ae3247d79625d267cbacd1c90e4a2df2f72d4090babf88c90e65a086c464ec1753c49d3b8ad02f2a3c0808e1695c5d77cec6f6f12578ae4ed077a2046e06644d14af65ae90f2869a6f1f910b83a7a3cfec8dd390621a511
|
||||
tv_stream_xchacha20: ok
|
||||
tv_secretbox_xchacha20: ok
|
||||
tv_box_xchacha20poly1305: ok
|
||||
|
Loading…
Reference in New Issue
Block a user