argon2 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +6 -5
  4. data/ext/argon2_wrap/argon_wrap.c +2 -1
  5. data/ext/argon2_wrap/test.c +5 -5
  6. data/ext/phc-winner-argon2/.gitattributes +5 -0
  7. data/ext/phc-winner-argon2/.gitignore +5 -0
  8. data/ext/phc-winner-argon2/Argon2.sln +98 -0
  9. data/ext/phc-winner-argon2/CHANGELOG.md +11 -0
  10. data/ext/phc-winner-argon2/Makefile +7 -2
  11. data/ext/phc-winner-argon2/README.md +27 -15
  12. data/ext/phc-winner-argon2/appveyor.yml +25 -0
  13. data/ext/phc-winner-argon2/export.sh +7 -0
  14. data/ext/phc-winner-argon2/include/argon2.h +24 -1
  15. data/ext/phc-winner-argon2/kats/argon2d +3 -1
  16. data/ext/phc-winner-argon2/kats/argon2d.shasum +1 -1
  17. data/ext/phc-winner-argon2/kats/argon2d_v16 +12304 -0
  18. data/ext/phc-winner-argon2/kats/argon2d_v16.shasum +1 -0
  19. data/ext/phc-winner-argon2/kats/argon2i +3 -1
  20. data/ext/phc-winner-argon2/kats/argon2i.shasum +1 -1
  21. data/ext/phc-winner-argon2/kats/argon2i_v16 +12304 -0
  22. data/ext/phc-winner-argon2/kats/argon2i_v16.shasum +1 -0
  23. data/ext/phc-winner-argon2/kats/check-sums.ps1 +42 -0
  24. data/ext/phc-winner-argon2/kats/check-sums.sh +1 -1
  25. data/ext/phc-winner-argon2/kats/test.ps1 +50 -0
  26. data/ext/phc-winner-argon2/kats/test.sh +45 -43
  27. data/ext/phc-winner-argon2/man/argon2.1 +47 -0
  28. data/ext/phc-winner-argon2/src/argon2.c +29 -15
  29. data/ext/phc-winner-argon2/src/bench.c +5 -22
  30. data/ext/phc-winner-argon2/src/core.c +3 -3
  31. data/ext/phc-winner-argon2/src/core.h +1 -3
  32. data/ext/phc-winner-argon2/src/encoding.c +22 -3
  33. data/ext/phc-winner-argon2/src/encoding.h +6 -0
  34. data/ext/phc-winner-argon2/src/genkat.c +23 -5
  35. data/ext/phc-winner-argon2/src/opt.c +42 -2
  36. data/ext/phc-winner-argon2/src/opt.h +10 -0
  37. data/ext/phc-winner-argon2/src/ref.c +51 -1
  38. data/ext/phc-winner-argon2/src/ref.h +10 -0
  39. data/ext/phc-winner-argon2/src/run.c +67 -42
  40. data/ext/phc-winner-argon2/src/test.c +160 -68
  41. data/ext/phc-winner-argon2/src/thread.c +1 -1
  42. data/ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +158 -0
  43. data/ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj.filters +69 -0
  44. data/ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +158 -0
  45. data/ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj.filters +69 -0
  46. data/ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +167 -0
  47. data/ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj.filters +72 -0
  48. data/ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +159 -0
  49. data/ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj.filters +69 -0
  50. data/ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +158 -0
  51. data/ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj.filters +69 -0
  52. data/ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +158 -0
  53. data/ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj.filters +69 -0
  54. data/ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +159 -0
  55. data/ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj.filters +72 -0
  56. data/ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +158 -0
  57. data/ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj.filters +69 -0
  58. data/lib/argon2.rb +5 -1
  59. data/lib/argon2/version.rb +1 -1
  60. metadata +29 -3
@@ -9,38 +9,43 @@
9
9
  #include "argon2.h"
10
10
 
11
11
  #define OUT_LEN 32
12
- #define SALT_LEN 16
13
12
  #define ENCODED_LEN 108
14
13
 
15
- uint8_t salt[SALT_LEN];
16
-
17
14
  /* Test harness will assert:
18
- * argon_hash2() returns ARGON2_OK
15
+ * argon2_hash() returns ARGON2_OK
19
16
  * HEX output matches expected
20
17
  * encoded output matches expected
21
18
  * argon2_verify() correctly verifies value
22
19
  */
23
20
 
24
- void hashtest(uint32_t t, uint32_t m, uint32_t p, char *pwd, char *hexref,
25
- char *mcfref) {
21
+ void hashtest(uint32_t version, uint32_t t, uint32_t m, uint32_t p, char *pwd,
22
+ char *salt, char *hexref, char *mcfref) {
26
23
  unsigned char out[OUT_LEN];
27
24
  unsigned char hex_out[OUT_LEN * 2 + 4];
28
25
  char encoded[ENCODED_LEN];
29
26
  int ret, i;
30
27
 
31
- printf("Hash test: t=%d, m=%d, p=%d, pass=%s, salt=%s: ", t, m, p, pwd,
32
- salt);
33
- ret = argon2_hash(t, 1 << m, p, pwd, strlen(pwd), salt, SALT_LEN, out,
34
- OUT_LEN, encoded, ENCODED_LEN, Argon2_i);
28
+ printf("Hash test: $v=%d t=%d, m=%d, p=%d, pass=%s, salt=%s: ", version,
29
+ t, m, p, pwd, salt);
30
+
31
+ ret = argon2_hash(t, 1 << m, p, pwd, strlen(pwd), salt, strlen(salt), out,
32
+ OUT_LEN, encoded, ENCODED_LEN, Argon2_i, version);
35
33
  assert(ret == ARGON2_OK);
36
34
 
37
35
  for (i = 0; i < OUT_LEN; ++i)
38
36
  sprintf((char *)(hex_out + i * 2), "%02x", out[i]);
39
37
 
40
38
  assert(memcmp(hex_out, hexref, OUT_LEN * 2) == 0);
41
- assert(memcmp(encoded, mcfref, strlen(mcfref)) == 0);
39
+
40
+ if (ARGON2_VERSION_NUMBER == version) {
41
+ assert(memcmp(encoded, mcfref, strlen(mcfref)) == 0);
42
+ }
43
+
42
44
  ret = argon2_verify(encoded, pwd, strlen(pwd), Argon2_i);
43
45
  assert(ret == ARGON2_OK);
46
+ ret = argon2_verify(mcfref, pwd, strlen(pwd), Argon2_i);
47
+ assert(ret == ARGON2_OK);
48
+
44
49
  printf("PASS\n");
45
50
  }
46
51
 
@@ -48,84 +53,171 @@ int main() {
48
53
  int ret;
49
54
  unsigned char out[OUT_LEN];
50
55
  char const *msg;
56
+ int version;
51
57
 
52
- memset(salt, 0x00, SALT_LEN); /* pad with null bytes */
53
- memcpy(salt, "somesalt", 8);
58
+ version = ARGON2_VERSION_10;
59
+ printf("Test Argon2i version number: %02x\n", version);
54
60
 
55
61
  /* Multiple test cases for various input values */
56
- hashtest(2, 16, 1, "password",
57
- "1c7eeef9e0e969b3024722fc864a1ca9f6ca20da73f9bf3f1731881beae2039e",
58
- "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA"
59
- "$HH7u+eDpabMCRyL8hkocqfbKINpz+b8/FzGIG+riA54");
60
- hashtest(2, 20, 1, "password",
61
- "253068ce02908829f9c8a026dc7cf4bd4497fd781faa1665a0d0b10d699e0ebd",
62
- "$argon2i$m=1048576,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA"
63
- "$JTBozgKQiCn5yKAm3Hz0vUSX/XgfqhZloNCxDWmeDr0");
64
- hashtest(2, 18, 1, "password",
65
- "5c6dfd2712110cf88f1426059b01d87f8210d5368da0e7ee68586e9d4af4954b",
66
- "$argon2i$m=262144,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA"
67
- "$XG39JxIRDPiPFCYFmwHYf4IQ1TaNoOfuaFhunUr0lUs");
68
- hashtest(2, 8, 1, "password",
69
- "dfebf9d4eadd6859f4cc6a9bb20043fd9da7e1e36bdacdbb05ca569f463269f8",
70
- "$argon2i$m=256,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA"
71
- "$3+v51OrdaFn0zGqbsgBD/Z2n4eNr2s27BcpWn0Yyafg");
72
- hashtest(2, 8, 2, "password",
73
- "aea9db129d7f8c50d410a6599b0fb3d786a60ec16a3030b9ddd21ee7b6470f7f",
74
- "$argon2i$m=256,t=2,p=2$c29tZXNhbHQAAAAAAAAAAA"
75
- "$rqnbEp1/jFDUEKZZmw+z14amDsFqMDC53dIe57ZHD38");
76
- hashtest(1, 16, 1, "password",
77
- "fabd1ddbd86a101d326ac2abe79660202b10192925d2fd2483085df94df0c91a",
78
- "$argon2i$m=65536,t=1,p=1$c29tZXNhbHQAAAAAAAAAAA"
79
- "$+r0d29hqEB0yasKr55ZgICsQGSkl0v0kgwhd+U3wyRo");
80
- hashtest(4, 16, 1, "password",
81
- "b3b4cb3d6e2c1cb1e7bffdb966ab3ceafae701d6b7789c3f1e6c6b22d82d99d5",
82
- "$argon2i$m=65536,t=4,p=1$c29tZXNhbHQAAAAAAAAAAA"
83
- "$s7TLPW4sHLHnv/25Zqs86vrnAda3eJw/HmxrItgtmdU");
84
- hashtest(2, 16, 1, "differentpassword",
85
- "b2db9d7c0d1288951aec4b6e1cd3835ea29a7da2ac13e6f48554a26b127146f9",
86
- "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA"
87
- "$studfA0SiJUa7EtuHNODXqKafaKsE+b0hVSiaxJxRvk");
88
- memcpy(salt, "diffsalt", 8);
89
- hashtest(2, 16, 1, "password",
90
- "bb6686865f2c1093f70f543c9535f807d5b42d5dc6d71f14a4a7a291913e05e0",
91
- "$argon2i$m=65536,t=2,p=1$ZGlmZnNhbHQAAAAAAAAAAA"
92
- "$u2aGhl8sEJP3D1Q8lTX4B9W0LV3G1x8UpKeikZE+BeA");
62
+ hashtest(version, 2, 16, 1, "password", "somesalt",
63
+ "f6c4db4a54e2a370627aff3db6176b94a2a209a62c8e36152711802f7b30c694",
64
+ "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
65
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ");
66
+ #ifdef TEST_LARGE_RAM
67
+ hashtest(version, 2, 20, 1, "password", "somesalt",
68
+ "9690ec55d28d3ed32562f2e73ea62b02b018757643a2ae6e79528459de8106e9",
69
+ "$argon2i$m=1048576,t=2,p=1$c29tZXNhbHQ"
70
+ "$lpDsVdKNPtMlYvLnPqYrArAYdXZDoq5ueVKEWd6BBuk");
71
+ #endif
72
+ hashtest(version, 2, 18, 1, "password", "somesalt",
73
+ "3e689aaa3d28a77cf2bc72a51ac53166761751182f1ee292e3f677a7da4c2467",
74
+ "$argon2i$m=262144,t=2,p=1$c29tZXNhbHQ"
75
+ "$Pmiaqj0op3zyvHKlGsUxZnYXURgvHuKS4/Z3p9pMJGc");
76
+ hashtest(version, 2, 8, 1, "password", "somesalt",
77
+ "fd4dd83d762c49bdeaf57c47bdcd0c2f1babf863fdeb490df63ede9975fccf06",
78
+ "$argon2i$m=256,t=2,p=1$c29tZXNhbHQ"
79
+ "$/U3YPXYsSb3q9XxHvc0MLxur+GP960kN9j7emXX8zwY");
80
+ hashtest(version, 2, 8, 2, "password", "somesalt",
81
+ "b6c11560a6a9d61eac706b79a2f97d68b4463aa3ad87e00c07e2b01e90c564fb",
82
+ "$argon2i$m=256,t=2,p=2$c29tZXNhbHQ"
83
+ "$tsEVYKap1h6scGt5ovl9aLRGOqOth+AMB+KwHpDFZPs");
84
+ hashtest(version, 1, 16, 1, "password", "somesalt",
85
+ "81630552b8f3b1f48cdb1992c4c678643d490b2b5eb4ff6c4b3438b5621724b2",
86
+ "$argon2i$m=65536,t=1,p=1$c29tZXNhbHQ"
87
+ "$gWMFUrjzsfSM2xmSxMZ4ZD1JCytetP9sSzQ4tWIXJLI");
88
+ hashtest(version, 4, 16, 1, "password", "somesalt",
89
+ "f212f01615e6eb5d74734dc3ef40ade2d51d052468d8c69440a3a1f2c1c2847b",
90
+ "$argon2i$m=65536,t=4,p=1$c29tZXNhbHQ"
91
+ "$8hLwFhXm6110c03D70Ct4tUdBSRo2MaUQKOh8sHChHs");
92
+ hashtest(version, 2, 16, 1, "differentpassword", "somesalt",
93
+ "e9c902074b6754531a3a0be519e5baf404b30ce69b3f01ac3bf21229960109a3",
94
+ "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
95
+ "$6ckCB0tnVFMaOgvlGeW69ASzDOabPwGsO/ISKZYBCaM");
96
+ hashtest(version, 2, 16, 1, "password", "diffsalt",
97
+ "79a103b90fe8aef8570cb31fc8b22259778916f8336b7bdac3892569d4f1c497",
98
+ "$argon2i$m=65536,t=2,p=1$ZGlmZnNhbHQ"
99
+ "$eaEDuQ/orvhXDLMfyLIiWXeJFvgza3vaw4kladTxxJc");
93
100
 
94
101
  /* Error state tests */
95
102
 
96
- ret = argon2_hash(2, 1, 1, "password", strlen("password"), salt, SALT_LEN,
97
- out, OUT_LEN, NULL, 0, Argon2_i);
98
- assert(ret == ARGON2_MEMORY_TOO_LITTLE);
99
- printf("Fail on invalid memory: PASS\n");
103
+ /* Handle an invalid encoding correctly (it is missing a $) */
104
+ ret = argon2_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
105
+ "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
106
+ "password", strlen("password"), Argon2_i);
107
+ assert(ret == ARGON2_DECODING_FAIL);
108
+ printf("Recognise an invalid encoding: PASS\n");
100
109
 
101
- ret = argon2_hash(2, 1 << 12, 1, NULL, strlen("password"), salt, SALT_LEN,
102
- out, OUT_LEN, NULL, 0, Argon2_i);
103
- assert(ret == ARGON2_PWD_PTR_MISMATCH);
104
- printf("Fail on invalid null pointer: PASS\n");
110
+ /* Handle an invalid encoding correctly (it is missing a $) */
111
+ ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
112
+ "9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
113
+ "password", strlen("password"), Argon2_i);
114
+ assert(ret == ARGON2_OUTPUT_TOO_SHORT);
115
+ printf("Recognise an invalid encoding: PASS\n");
105
116
 
106
- ret = argon2_hash(2, 1 << 12, 1, "password", strlen("password"), salt, 1,
107
- out, OUT_LEN, NULL, 0, Argon2_i);
108
- assert(ret == ARGON2_SALT_TOO_SHORT);
109
- printf("Fail on salt too short: PASS\n");
117
+ /* Handle an mismatching hash (the encoded password is "passwore") */
118
+ ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
119
+ "$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo",
120
+ "password", strlen("password"), Argon2_i);
121
+ assert(ret == ARGON2_VERIFY_MISMATCH);
122
+ printf("Verify with mismatched password: PASS\n");
123
+
124
+ msg = argon2_error_message(ARGON2_DECODING_FAIL);
125
+ assert(strcmp(msg, "Decoding failed") == 0);
126
+ printf("Decode an error message: PASS\n");
127
+
128
+ printf("\n");
129
+
130
+ version = ARGON2_VERSION_NUMBER;
131
+ printf("Test Argon2i version number: %02x\n", version);
132
+
133
+ /* Multiple test cases for various input values */
134
+ hashtest(version, 2, 16, 1, "password", "somesalt",
135
+ "c1628832147d9720c5bd1cfd61367078729f6dfb6f8fea9ff98158e0d7816ed0",
136
+ "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
137
+ "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA");
138
+ #ifdef TEST_LARGE_RAM
139
+ hashtest(version, 2, 20, 1, "password", "somesalt",
140
+ "d1587aca0922c3b5d6a83edab31bee3c4ebaef342ed6127a55d19b2351ad1f41",
141
+ "$argon2i$v=19$m=1048576,t=2,p=1$c29tZXNhbHQ"
142
+ "$0Vh6ygkiw7XWqD7asxvuPE667zQu1hJ6VdGbI1GtH0E");
143
+ #endif
144
+ hashtest(version, 2, 18, 1, "password", "somesalt",
145
+ "296dbae80b807cdceaad44ae741b506f14db0959267b183b118f9b24229bc7cb",
146
+ "$argon2i$v=19$m=262144,t=2,p=1$c29tZXNhbHQ"
147
+ "$KW266AuAfNzqrUSudBtQbxTbCVkmexg7EY+bJCKbx8s");
148
+ hashtest(version, 2, 8, 1, "password", "somesalt",
149
+ "89e9029f4637b295beb027056a7336c414fadd43f6b208645281cb214a56452f",
150
+ "$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQ"
151
+ "$iekCn0Y3spW+sCcFanM2xBT63UP2sghkUoHLIUpWRS8");
152
+ hashtest(version, 2, 8, 2, "password", "somesalt",
153
+ "4ff5ce2769a1d7f4c8a491df09d41a9fbe90e5eb02155a13e4c01e20cd4eab61",
154
+ "$argon2i$v=19$m=256,t=2,p=2$c29tZXNhbHQ"
155
+ "$T/XOJ2mh1/TIpJHfCdQan76Q5esCFVoT5MAeIM1Oq2E");
156
+ hashtest(version, 1, 16, 1, "password", "somesalt",
157
+ "d168075c4d985e13ebeae560cf8b94c3b5d8a16c51916b6f4ac2da3ac11bbecf",
158
+ "$argon2i$v=19$m=65536,t=1,p=1$c29tZXNhbHQ"
159
+ "$0WgHXE2YXhPr6uVgz4uUw7XYoWxRkWtvSsLaOsEbvs8");
160
+ hashtest(version, 4, 16, 1, "password", "somesalt",
161
+ "aaa953d58af3706ce3df1aefd4a64a84e31d7f54175231f1285259f88174ce5b",
162
+ "$argon2i$v=19$m=65536,t=4,p=1$c29tZXNhbHQ"
163
+ "$qqlT1YrzcGzj3xrv1KZKhOMdf1QXUjHxKFJZ+IF0zls");
164
+ hashtest(version, 2, 16, 1, "differentpassword", "somesalt",
165
+ "14ae8da01afea8700c2358dcef7c5358d9021282bd88663a4562f59fb74d22ee",
166
+ "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
167
+ "$FK6NoBr+qHAMI1jc73xTWNkCEoK9iGY6RWL1n7dNIu4");
168
+ hashtest(version, 2, 16, 1, "password", "diffsalt",
169
+ "b0357cccfbef91f3860b0dba447b2348cbefecadaf990abfe9cc40726c521271",
170
+ "$argon2i$v=19$m=65536,t=2,p=1$ZGlmZnNhbHQ"
171
+ "$sDV8zPvvkfOGCw26RHsjSMvv7K2vmQq/6cxAcmxSEnE");
172
+
173
+ /* Error state tests */
110
174
 
111
175
  /* Handle an invalid encoding correctly (it is missing a $) */
112
- ret = argon2_verify("$argon2i$m=65536,t=2,p=1$"
113
- "c29tZXNhbHQAAAAAAAAAAA"
114
- "HH7u+eDpabMCRyL8hkocqfbKINpz+b8/FzGIG+riA54",
176
+ ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1c29tZXNhbHQ"
177
+ "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
115
178
  "password", strlen("password"), Argon2_i);
116
179
  assert(ret == ARGON2_DECODING_FAIL);
117
180
  printf("Recognise an invalid encoding: PASS\n");
118
181
 
182
+ /* Handle an invalid encoding correctly (it is missing a $) */
183
+ ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
184
+ "wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
185
+ "password", strlen("password"), Argon2_i);
186
+ assert(ret == ARGON2_OUTPUT_TOO_SHORT);
187
+ printf("Recognise an invalid encoding: PASS\n");
188
+
119
189
  /* Handle an mismatching hash (the encoded password is "passwore") */
120
- ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA"
121
- "$tiY53ekuxy5gUQV9pEgGgu3cfe2vKl3l+lKxTna33I4",
190
+ ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
191
+ "$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM",
122
192
  "password", strlen("password"), Argon2_i);
123
193
  assert(ret == ARGON2_VERIFY_MISMATCH);
124
194
  printf("Verify with mismatched password: PASS\n");
125
195
 
126
196
  msg = argon2_error_message(ARGON2_DECODING_FAIL);
127
- assert(strcmp(msg, "Decoding failed")==0);
197
+ assert(strcmp(msg, "Decoding failed") == 0);
128
198
  printf("Decode an error message: PASS\n");
129
199
 
200
+ /* Common error state tests */
201
+
202
+ printf("\n");
203
+ printf("Common error state tests\n");
204
+
205
+ ret = argon2_hash(2, 1, 1, "password", strlen("password"),
206
+ "diffsalt", strlen("diffsalt"),
207
+ out, OUT_LEN, NULL, 0, Argon2_i, version);
208
+ assert(ret == ARGON2_MEMORY_TOO_LITTLE);
209
+ printf("Fail on invalid memory: PASS\n");
210
+
211
+ ret = argon2_hash(2, 1 << 12, 1, NULL, strlen("password"),
212
+ "diffsalt", strlen("diffsalt"),
213
+ out, OUT_LEN, NULL, 0, Argon2_i, version);
214
+ assert(ret == ARGON2_PWD_PTR_MISMATCH);
215
+ printf("Fail on invalid null pointer: PASS\n");
216
+
217
+ ret = argon2_hash(2, 1 << 12, 1, "password", strlen("password"), "s", 1,
218
+ out, OUT_LEN, NULL, 0, Argon2_i, version);
219
+ assert(ret == ARGON2_SALT_TOO_SHORT);
220
+ printf("Fail on salt too short: PASS\n");
221
+
130
222
  return 0;
131
223
  }
@@ -1,6 +1,6 @@
1
1
  #include "thread.h"
2
2
  #if defined(_WIN32)
3
- #include <Windows.h>
3
+ #include <windows.h>
4
4
  #endif
5
5
 
6
6
  int argon2_thread_create(argon2_thread_handle_t *handle,
@@ -0,0 +1,158 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ItemGroup Label="ProjectConfigurations">
4
+ <ProjectConfiguration Include="Debug|Win32">
5
+ <Configuration>Debug</Configuration>
6
+ <Platform>Win32</Platform>
7
+ </ProjectConfiguration>
8
+ <ProjectConfiguration Include="Release|Win32">
9
+ <Configuration>Release</Configuration>
10
+ <Platform>Win32</Platform>
11
+ </ProjectConfiguration>
12
+ <ProjectConfiguration Include="Debug|x64">
13
+ <Configuration>Debug</Configuration>
14
+ <Platform>x64</Platform>
15
+ </ProjectConfiguration>
16
+ <ProjectConfiguration Include="Release|x64">
17
+ <Configuration>Release</Configuration>
18
+ <Platform>x64</Platform>
19
+ </ProjectConfiguration>
20
+ </ItemGroup>
21
+ <PropertyGroup Label="Globals">
22
+ <ProjectGuid>{CAA75C57-998C-494E-B8A5-5894EF0FC528}</ProjectGuid>
23
+ <RootNamespace>Argon2Opt</RootNamespace>
24
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
25
+ </PropertyGroup>
26
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
27
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
28
+ <ConfigurationType>Application</ConfigurationType>
29
+ <UseDebugLibraries>true</UseDebugLibraries>
30
+ <PlatformToolset>v140</PlatformToolset>
31
+ <CharacterSet>MultiByte</CharacterSet>
32
+ </PropertyGroup>
33
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
34
+ <ConfigurationType>Application</ConfigurationType>
35
+ <UseDebugLibraries>false</UseDebugLibraries>
36
+ <PlatformToolset>v140</PlatformToolset>
37
+ <WholeProgramOptimization>true</WholeProgramOptimization>
38
+ <CharacterSet>MultiByte</CharacterSet>
39
+ </PropertyGroup>
40
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
41
+ <ConfigurationType>Application</ConfigurationType>
42
+ <UseDebugLibraries>true</UseDebugLibraries>
43
+ <PlatformToolset>v140</PlatformToolset>
44
+ <CharacterSet>MultiByte</CharacterSet>
45
+ </PropertyGroup>
46
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
47
+ <ConfigurationType>Application</ConfigurationType>
48
+ <UseDebugLibraries>false</UseDebugLibraries>
49
+ <PlatformToolset>v140</PlatformToolset>
50
+ <WholeProgramOptimization>true</WholeProgramOptimization>
51
+ <CharacterSet>MultiByte</CharacterSet>
52
+ </PropertyGroup>
53
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
54
+ <ImportGroup Label="ExtensionSettings">
55
+ </ImportGroup>
56
+ <ImportGroup Label="Shared">
57
+ </ImportGroup>
58
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
59
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60
+ </ImportGroup>
61
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
62
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63
+ </ImportGroup>
64
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
65
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66
+ </ImportGroup>
67
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
68
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
69
+ </ImportGroup>
70
+ <PropertyGroup Label="UserMacros" />
71
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
72
+ <OutDir>$(SolutionDir)vs2015\build\</OutDir>
73
+ <IntDir>$(SolutionDir)vs2015\build\$(ProjectName)\</IntDir>
74
+ <IncludePath>$(SolutionDir)include;$(IncludePath)</IncludePath>
75
+ </PropertyGroup>
76
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
77
+ <OutDir>$(SolutionDir)vs2015\build\</OutDir>
78
+ <IntDir>$(SolutionDir)vs2015\build\$(ProjectName)\</IntDir>
79
+ <IncludePath>$(SolutionDir)include;$(IncludePath)</IncludePath>
80
+ </PropertyGroup>
81
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
82
+ <OutDir>$(SolutionDir)vs2015\build\</OutDir>
83
+ <IntDir>$(SolutionDir)vs2015\build\$(ProjectName)\</IntDir>
84
+ <IncludePath>$(SolutionDir)include;$(IncludePath)</IncludePath>
85
+ </PropertyGroup>
86
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
87
+ <OutDir>$(SolutionDir)vs2015\build\</OutDir>
88
+ <IntDir>$(SolutionDir)vs2015\build\$(ProjectName)\</IntDir>
89
+ <IncludePath>$(SolutionDir)include;$(IncludePath)</IncludePath>
90
+ </PropertyGroup>
91
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
92
+ <ClCompile>
93
+ <WarningLevel>Level3</WarningLevel>
94
+ <Optimization>Disabled</Optimization>
95
+ <SDLCheck>true</SDLCheck>
96
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
97
+ </ClCompile>
98
+ </ItemDefinitionGroup>
99
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
100
+ <ClCompile>
101
+ <WarningLevel>Level3</WarningLevel>
102
+ <Optimization>Disabled</Optimization>
103
+ <SDLCheck>true</SDLCheck>
104
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
105
+ </ClCompile>
106
+ </ItemDefinitionGroup>
107
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
108
+ <ClCompile>
109
+ <WarningLevel>Level3</WarningLevel>
110
+ <Optimization>MaxSpeed</Optimization>
111
+ <FunctionLevelLinking>true</FunctionLevelLinking>
112
+ <IntrinsicFunctions>true</IntrinsicFunctions>
113
+ <SDLCheck>true</SDLCheck>
114
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
115
+ </ClCompile>
116
+ <Link>
117
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
118
+ <OptimizeReferences>true</OptimizeReferences>
119
+ </Link>
120
+ </ItemDefinitionGroup>
121
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
122
+ <ClCompile>
123
+ <WarningLevel>Level3</WarningLevel>
124
+ <Optimization>MaxSpeed</Optimization>
125
+ <FunctionLevelLinking>true</FunctionLevelLinking>
126
+ <IntrinsicFunctions>true</IntrinsicFunctions>
127
+ <SDLCheck>true</SDLCheck>
128
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
129
+ </ClCompile>
130
+ <Link>
131
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
132
+ <OptimizeReferences>true</OptimizeReferences>
133
+ </Link>
134
+ </ItemDefinitionGroup>
135
+ <ItemGroup>
136
+ <ClInclude Include="..\..\include\argon2.h" />
137
+ <ClInclude Include="..\..\src\blake2\blake2-impl.h" />
138
+ <ClInclude Include="..\..\src\blake2\blake2.h" />
139
+ <ClInclude Include="..\..\src\blake2\blamka-round-opt.h" />
140
+ <ClInclude Include="..\..\src\blake2\blamka-round-ref.h" />
141
+ <ClInclude Include="..\..\src\core.h" />
142
+ <ClInclude Include="..\..\src\encoding.h" />
143
+ <ClInclude Include="..\..\src\opt.h" />
144
+ <ClInclude Include="..\..\src\thread.h" />
145
+ </ItemGroup>
146
+ <ItemGroup>
147
+ <ClCompile Include="..\..\src\argon2.c" />
148
+ <ClCompile Include="..\..\src\blake2\blake2b.c" />
149
+ <ClCompile Include="..\..\src\core.c" />
150
+ <ClCompile Include="..\..\src\encoding.c" />
151
+ <ClCompile Include="..\..\src\opt.c" />
152
+ <ClCompile Include="..\..\src\run.c" />
153
+ <ClCompile Include="..\..\src\thread.c" />
154
+ </ItemGroup>
155
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
156
+ <ImportGroup Label="ExtensionTargets">
157
+ </ImportGroup>
158
+ </Project>