From cfd597298f2dd36607ce4a4ddd8561d9c9eb9874 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 6 Jan 2016 15:36:36 +0100 Subject: [PATCH] Bring back tests vectors for argon2 strings --- test/default/pwhash_argon2i.c | 47 ++++++++++++++++++++++++--------- test/default/pwhash_argon2i.exp | 2 -- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/test/default/pwhash_argon2i.c b/test/default/pwhash_argon2i.c index 21298af3..bc3dd1e1 100644 --- a/test/default/pwhash_argon2i.c +++ b/test/default/pwhash_argon2i.c @@ -53,12 +53,6 @@ static void tv(void) 82, "39d82eef32010b8b79cc5ba88ed539fbaba741100f2edbeca7cc171ffeabf258", 190, 1, 5432947, 1 }, - { "1845e375479537e9dd4f4486d5c91ac72775d66605eeb11a787b78a7745f1fd005" - "2d526c67235dbae1b2a4d575a74cb551c8e9096c593a497aee74ba3047d911358e" - "de57bc27c9ea1829824348daaab606217cc931dcb6627787bd6e4e5854f0e8", - 97, - "3ee91a805aa62cfbe8dce29a2d9a44373a5006f4a4ce24022aca9cecb29d1473", - 212, 7, 13101817, 1 }, { "c7b09aec680e7b42fedd7fc792e78b2f6c1bea8f4a884320b648f81e8cf515e8ba" "9dcfb11d43c4aae114c1734aa69ca82d44998365db9c93744fa28b63fd16000e82" "61cbbe083e7e2da1e5f696bde0834fe53146d7e0e35e7de9920d041f5a5621aabe" @@ -67,13 +61,6 @@ static void tv(void) 156, "039c056d933b475032777edbaffac50f143f64c123329ed9cf59e3b65d3f43b6", 178, 3, 4886999, 1 }, - { "8f3a06e2fd8711350a517bb12e31f3d3423e8dc0bb14aac8240fca0995938d59bb" - "37bd0a7dfc9c9cc0705684b46612e8c8b1d6655fb0f9887562bb9899791a0250d1" - "320f945eda48cdc20c233f40a5bb0a7e3ac5ad7250ce684f68fc0b8c9633bfd75a" - "ad116525af7bdcdbbdb4e00ab163fd4df08f243f12557e", - 122, - "90631f686a8c3dbc0703ffa353bc1fdf35774568ac62406f98a13ed8f47595fd", - 55, 1, 15738350, 1 }, { "b540beb016a5366524d4605156493f9874514a5aa58818cd0c6dfffaa9e90205f1" "7b", 34, @@ -164,6 +151,39 @@ static void tv2(void) } while (++i < (sizeof tests) / (sizeof tests[0])); } +static void tv3(void) +{ + static struct { + const char *passwd; + const char *out; + } tests[] = { + { "", + "$argon2i$m=4096,t=1,p=1$ZW1wdHkAAAAAAAAAAAAAAA$iE7ExNH70nzk6SmP9k6JP4lMxhMrGbmK1MP0vAkBPtY" }, + { "^T5H$JYt39n%K*j:W]!1s?vg!:jGi]Ax?..l7[p0v:1jHTpla9;]bUN;?bWyCbtqg ", + "$argon2i$m=4096,t=3,p=2$QmF0dGVyeQAAAAAAAAAAAA$1Qe4etbL4DxBpgRbqvM9MIOhaxjP61lv0xNhegrCvlo" }, + { "K3S=KyH#)36_?]LxeR8QNKw6X=gFbxai$C%29V*", + "$argon2i$m=4096,t=3,p=1$aXRlcmF0aW9ucwAAAAAAAA$kRvT53TswrSAnVxij5BmTfgzas6PcTVh0E4/ewz6Qmk" } + }; + char *out; + char *passwd; + size_t i = 0U; + + do { + out = (char *) sodium_malloc(strlen(tests[i].out) + 1U); + assert(out != NULL); + memcpy(out, tests[i].out, strlen(tests[i].out) + 1U); + passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U); + assert(passwd != NULL); + memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U); + if (crypto_pwhash_argon2i_str_verify + (out, passwd, strlen(passwd)) != 0) { + printf("pwhash_str failure: [%u]\n", (unsigned int)i); + } + sodium_free(out); + sodium_free(passwd); + } while (++i < (sizeof tests) / (sizeof tests[0])); +} + int main(void) { char *str_out; @@ -173,6 +193,7 @@ int main(void) tv(); tv2(); + tv3(); salt = (char *) sodium_malloc(crypto_pwhash_SALTBYTES); str_out = (char *) sodium_malloc(crypto_pwhash_STRBYTES); str_out2 = (char *) sodium_malloc(crypto_pwhash_STRBYTES); diff --git a/test/default/pwhash_argon2i.exp b/test/default/pwhash_argon2i.exp index ebc8afe3..abeb6e17 100644 --- a/test/default/pwhash_argon2i.exp +++ b/test/default/pwhash_argon2i.exp @@ -3,9 +3,7 @@ c4b37dfcd2b6d8ff0e15edeea57ca1f94730965cf05859191aeb8e1631f6308b9883b49b3b5a0e0f32d48a5d4e9b6e7b18c0b068eaaade5d127f01cdaa00d404ec2c0c92453418fd93881c5d0abdae49f072f4b3bff61553bd557bc90276693a800ef290c8b71d8c294c7f51132279ff71707b0f3f107a0060cd7e329dfbb48112e1df14ad076f5526a9bfc1473aae12ab412b15beec92a828d7d32deeea38079f3b4ceb28d1b26bb19d5ef3830ad2344f893dd79a2d5e69f61c51d352f6aea739925a3ee0d9c67aea25dac41431b950e29d3ea3e4752b416ea2e7d205d240b562b4bba2add71eaf0210f34af28d92cc98a3ae8f21199fd0bd 2fe419bf3e 65b641d6551934cbeea2d54b034116212eecf8ff55848deb168f80686d5ba184a2d24f8428aff0af72a4e0af4e71110b5efc03a4246d9adef1697897a47bca086570bd1d26620ab39834288ec787bb9da713b5298f2e3c327982e1d2744fead69062054d0d160d0bf669273f8b0803645aa54b6eb997a45f05b00d3af9caf3a26db953cd8de5e37eefc7ae969781021664f327dd42839bd10e0d0bd76440f9114bf060584c41fc922233839cf09cc50a96691c58ffb899feddb3ea1b5e11 -85119e31650ac4d7151466a80e828139bf1adf2cde6ca8ec8eef5bb32035b9893f8206f05a3f41ccd6ae5cd6cbc9476aca2dbb67b9c965d9090c61af87c1d9bcd9648456900efb61c20a9144db6eb9820a01c660a18f373d1cade66ca9c95cf0c82d83ef7069e7c3136e1b3a89133122a122f46cc2e01535bffdc35aa36536f7d9828ac7add79f1771b523fe0d1c3de3edd577b42afed582479a87e3993128415222307cf040e76412a4d13aec01cd7d24738a7edcaa7df31808e15dea6c7f39b9410fd9df91caf73a8974a445b8780dcf149e31 7cf0e31e4e9c42e4a02d07e4414dd70d05f9be5c21d44062fedbf482bcfea4a08319b8d3a68de95335202f76b93fa80d2ae0e4b4ef442d937ca57528024cf1aa2429c569b0d514da1b8a6e79c18aeba6894fa2d6635cd1b17d7dabf275cca07b1d11fdbe1a1677a7e76716a818f22c8770db878431ae41611703c4e995477cb70efeb938d61c35152f3287bd008b302d6615d807a0a1c8774c1027ec5857438c91816a9c92f6502a1be5aa77bbc5e6736e04 -805a4928f5657d41de0c98e6b91228da883a09ef0e6ffdd1888e2398be57bfc2aab65b5d5ead780d4decb947ff4f196230b789bffa0462 038360c1c425840e1aa65bb936e1b5ef666ca4884c47361983fff75df8eb425826d2064bfc56c414bb80167db10ac7871d114e8177e23a994274cafbf244f85dbb2dfffbc39fe47df5c7790c8f26bc1d90f2f99afc989cc4b44d415a4e836737be708e5972e423149c82c8a1bf7532677287e2928012fdc48bcffd23123e4f38d6aecddb907ca7bcdc0db300a466d6938a240ffa09019c4bf515f562fe56b6ed3404c83a92f86b7235c5f477a090ac8455535e5edf755e9e7a58f0568d53bfd66ca29b42d4c397f9a7223c0604493ce3d4f739bf6497ac9a0ad96e48297ef24ad9ef072e6f6912 a36a18573037f735e9153487cf9e30dbfca32e11bfa9b85986ac1b628bbc1449eaed76280a0ba2791e23d630dcd94830fdd582bc3c8f4a4c105add9b15a251dc16d9fbf83bd0bf0b0f696b62b7f1d61299638973f5fe30568d269ae5f78d96f16fe4e7de0c6b3ba69abbd94ddfe42be8d5d7bbee5cb3943c3c1aab916a4b76a325401a0ad659f4d53edc75d402968d330420693af7d65d72571de31c12106837231b270671feed ed97978efee7bec536f7657e7c8758d320b7ea91a3e37fe83cc50468f6aedfcc1c4784f38252d8d59ce0c43d917d69c87a7e301f267c55074fe21d2a1447e1eb31ea80e1b5154266952b35784370658551349bfcbfcd35ba93d02fe2ec13d3a5d83b0a1d421fb7bb0eda1abe1ac3c863f85069eac02b15ec0cee94802ad8382cd8a44594432f5d3dbbfa5f99862827e8a28f8f4904ab05bd4a2735