diff --git a/test/default/pwhash_scrypt_ll.c b/test/default/pwhash_scrypt_ll.c index 54a4cdf0..1adaa0e2 100644 --- a/test/default/pwhash_scrypt_ll.c +++ b/test/default/pwhash_scrypt_ll.c @@ -5,52 +5,56 @@ #include "cmptest.h" /* Tarsnap test vectors, see: https://www.tarsnap.com/scrypt/scrypt.pdf */ -unsigned long olenGlobal = 64ul; -uint8_t password1[] = "\0"; -uint8_t salt1[] = "\0"; +uint8_t password1[] = ""; +uint8_t salt1[] = ""; uint64_t N1 = 16ul; uint32_t r1 = 1ul; uint32_t p1 = 1ul; -uint8_t password2[] = "password\0"; -uint8_t salt2[] = "NaCl\0"; +uint8_t password2[] = "password"; +uint8_t salt2[] = "NaCl"; uint64_t N2 = 1024ul; uint32_t r2 = 8ul; uint32_t p2 = 16ul; -uint8_t password3[] = "pleaseletmein\0"; -uint8_t salt3[] = "SodiumChloride\0"; +uint8_t password3[] = "pleaseletmein"; +uint8_t salt3[] = "SodiumChloride"; uint64_t N3 = 16384ul; uint32_t r3 = 8ul; uint32_t p3 = 1ul; -uint8_t password4[] = "pleaseletmein\0"; -uint8_t salt4[] = "SodiumChloride\0"; +uint8_t password4[] = "pleaseletmein"; +uint8_t salt4[] = "SodiumChloride"; size_t N4 = 1048576ul; size_t r4 = 8ul; size_t p4 = 1ul; -void test_vector(uint8_t * password, size_t passwordLength, uint8_t * salt, size_t saltLenght, uint64_t N, uint32_t r, uint32_t p, size_t olen) +void test_vector(uint8_t * password, uint8_t * salt, uint64_t N, uint32_t r, uint32_t p) { - uint8_t data[olen]; - int ret = crypto_pwhash_scryptsalsa208sha256_ll(password, passwordLength, salt, saltLenght, N, r, p, data, olen); - if(ret != 0) - { - printf("crypto_scrypt_compat failed!"); - } - - // Print header - printf("scrypt(“"); - printf("%s", password); - printf("”, “"); - printf("%s", salt); - printf("”, %lu, %lu, %lu, %lu) =\n", N, r, p, olen); - - // Print test result + const size_t olen = 64; + uint8_t data[64]; + size_t passwordLength = strlen((const char*) password); + size_t saltLenght = strlen((const char*) salt); int lineitems = 0; const int lineitemsLimit = 15; - for(int i = 0; i < olen; ++i) + + int i = crypto_pwhash_scryptsalsa208sha256_ll(password, passwordLength, salt, saltLenght, N, r, p, data, olen); + if(i != 0) + { + printf("crypto_scrypt_compat failed!"); + } + + // Print header + printf("scrypt('"); + printf("%s", password); + printf("', '"); + printf("%s", salt); + printf("', %llu, %lu, %lu, %lu) =", N, r, p, olen); + printf("\n"); + + // Print test result + for(i = 0; i < olen; ++i) { printf("%02x", data[i]); printf((lineitems < lineitemsLimit)? " " : "\n"); @@ -60,22 +64,10 @@ void test_vector(uint8_t * password, size_t passwordLength, uint8_t * salt, size int main(void) { - test_vector( - password1, strlen((const char*)password1), - salt1, strlen((const char*)salt1), - N1, r1, p1, olenGlobal); - test_vector( - password2, strlen((const char*)password2), - salt2, strlen((const char*)salt2), - N2, r2, p2, olenGlobal); - test_vector( - password3, strlen((const char*)password3), - salt3, strlen((const char*)salt3), - N3, r3, p3, olenGlobal); - test_vector( - password4, strlen((const char*)password4), - salt4, strlen((const char*)salt4), - N4, r4, p4, olenGlobal); + test_vector(password1, salt1, N1, r1, p1); + test_vector(password2, salt2, N2, r2, p2); + test_vector(password3, salt3, N3, r3, p3); + test_vector(password4, salt4, N4, r4, p4); return 0; } diff --git a/test/default/pwhash_scrypt_ll.exp b/test/default/pwhash_scrypt_ll.exp index cf4c0d3e..44fe199e 100644 --- a/test/default/pwhash_scrypt_ll.exp +++ b/test/default/pwhash_scrypt_ll.exp @@ -1,19 +1,19 @@ -scrypt(“”, “”, 16, 1, 1, 64) = +scrypt('', '', 16, 1, 1, 64) = 77 d6 57 62 38 65 7b 20 3b 19 ca 42 c1 8a 04 97 f1 6b 48 44 e3 07 4a e8 df df fa 3f ed e2 14 42 fc d0 06 9d ed 09 48 f8 32 6a 75 3a 0f c8 1f 17 e8 d3 e0 fb 2e 0d 36 28 cf 35 e2 0c 38 d1 89 06 -scrypt(“password”, “NaCl”, 1024, 8, 16, 64) = +scrypt('password', 'NaCl', 1024, 8, 16, 64) = fd ba be 1c 9d 34 72 00 78 56 e7 19 0d 01 e9 fe 7c 6a d7 cb c8 23 78 30 e7 73 76 63 4b 37 31 62 2e af 30 d9 2e 22 a3 88 6f f1 09 27 9d 98 30 da c7 27 af b9 4a 83 ee 6d 83 60 cb df a2 cc 06 40 -scrypt(“pleaseletmein”, “SodiumChloride”, 16384, 8, 1, 64) = +scrypt('pleaseletmein', 'SodiumChloride', 16384, 8, 1, 64) = 70 23 bd cb 3a fd 73 48 46 1c 06 cd 81 fd 38 eb fd a8 fb ba 90 4f 8e 3e a9 b5 43 f6 54 5d a1 f2 d5 43 29 55 61 3f 0f cf 62 d4 97 05 24 2a 9a f9 e6 1e 85 dc 0d 65 1e 40 df cf 01 7b 45 57 58 87 -scrypt(“pleaseletmein”, “SodiumChloride”, 1048576, 8, 1, 64) = +scrypt('pleaseletmein', 'SodiumChloride', 1048576, 8, 1, 64) = 21 01 cb 9b 6a 51 1a ae ad db be 09 cf 70 f8 81 ec 56 8d 57 4a 2f fd 4d ab e5 ee 98 20 ad aa 47 8e 56 fd 8f 4b a5 d0 9f fa 1c 6d 92 7c 40 f4 c3