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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ce063f0a857005f2e3c1e33d0313cf6c2dbe7a4
4
- data.tar.gz: c080ce2b9067066a59dac49655d6e43582efcc1d
3
+ metadata.gz: 4db0f3233c1faa582f56da4f70611158490822e6
4
+ data.tar.gz: 7261aba06880156bf240786b4b12016f7834d2fa
5
5
  SHA512:
6
- metadata.gz: 7742082e8db62329c94941512676a40536145ce52b7e2b4d3ba9f7a2cd25fe06eadb35811bb2eb9493aae67f4ae4f663a49f1158fdbea42f34ad7420d9b94321
7
- data.tar.gz: b2ef7db8cbcbd54f411481995fb53ba76c15810b3c816cae5dfd664ab832279609f2a194951d5c882ab8b2a44755a63bc14b902e1c6b6f20d77dcb6d87c4490a
6
+ metadata.gz: f55caacf26f22e15c4a1ab91deca56b65556bc52e0203b78110f48afd9fa94bc398c7b116adbad916309fddd00fe237d16647b162f4b4d3db0cdea44501d93b4
7
+ data.tar.gz: 27e7638366fc322d518c7ffaeb48b35b10426c1253794c67cf0e32dcc9ef01ffeaafdfe32f8c2b0ef53ab998319eb94d08d0c7d29012862c63fbdab1e944d2df
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.4
4
- - 2.3.0
4
+ - 2.3.1
5
5
  - jruby-9000
6
6
  before_install: gem install bundler -v 1.10.5
7
7
  install: bin/setup
data/README.md CHANGED
@@ -11,7 +11,7 @@ This Ruby Gem provides FFI bindings, and a simplified interface, to the Argon2 a
11
11
 
12
12
  This project has several key tenants to its design:
13
13
 
14
- * The reference Argon2 implementation is to be used "unaltered". To ensure compliance wit this goal, and encourage regular updates from upstream, this is implemented as a git submodule, and is intended to stay that way.
14
+ * The reference Argon2 implementation is to be used "unaltered". To ensure compliance with this goal, and encourage regular updates from upstream, the upstrema library is implemented as a git submodule, and is intended to stay that way.
15
15
  * The FFI interface is kept as slim as possible, with wrapper classes preferred to implementing context structs in FFI
16
16
  * Security and maintainability take top priority. This can have an impact on platform support. A PR that contains platform specific code paths is unlikely to be accepted.
17
17
  * Tested platforms are MRI Ruby 2.2, 2.3 and JRuby 9000. No assertions are made on other platforms.
@@ -34,7 +34,7 @@ To generate a hash using specific time and memory cost:
34
34
  ```ruby
35
35
  hasher = Argon2::Password.new(t_cost: 2, m_cost: 16)
36
36
  hasher.create("password")
37
- => "$argon2i$m=65536,t=2,p=1$6ua7khmHLZwIHnjV2A6nSw$Kak8CTBN/yUYAESSxJKO/jfWH+40c0JQtc7EXhLm0SU"
37
+ => "$argon2i$v=19$m=65536,t=2,p=1$jL7lLEAjDN+pY2cG1N8D2g$iwj1ueduCvm6B9YVjBSnAHu+6mKzqGmDW745ALR38Uo"
38
38
  ```
39
39
 
40
40
  To utilise default costs:
@@ -48,7 +48,7 @@ Alternatively, use this shotcut:
48
48
 
49
49
  ```ruby
50
50
  Argon2::Password.create("password")
51
- => "$argon2i$m=65536,t=2,p=1$VYXqHZe+5OpNzhbU0LvMZA$XGmkk9tzjYtjatmS5VvuovLvUCfijevwgDzvIkOF+bs"
51
+ => "$argon2i$v=19$m=65536,t=2,p=1$61qkSyYNbUgf3kZH3GtHRw$4CQff9AZ0lWd7uF24RKMzqEiGpzhte1Hp8SO7X8bAew"
52
52
  ```
53
53
 
54
54
  You can then use this function to verify a password against a given hash. Will return either true or false.
@@ -69,9 +69,10 @@ Argon2::Password.verify_password("A password", myhash, KEY)
69
69
  ## Important notes regarding version 1.0 upgrade
70
70
  Version 1.0.0 included a major version bump over 0.1.4 due to several breaking changes. The first of these was an API change, which you can read the background on [here](https://github.com/technion/ruby-argon2/issues/9).
71
71
 
72
- The second of these is that the reference Argon2 implementation introduced an algorithm change, which produces a hash which is not backwards compatible. This is documented on [this PR on the C library](https://github.com/P-H-C/phc-winner-argon2/pull/115). This was a regrettable requirement to address a security concern in the algorithm itself.
72
+ The second of these is that the reference Argon2 implementation introduced an algorithm change, which produces a hash which is not backwards compatible. This is documented on [this PR on the C library](https://github.com/P-H-C/phc-winner-argon2/pull/115). This was a regrettable requirement to address a security concern in the algorithm itself. The two versions of the Argon2 algorithm are numbered 1.0 and 1.3 respectively.
73
+
74
+ Shortly after this, version 1.0.0 of this gem was released with this breaking change, supporting only Argon2 v1.3. Further time later, the official encoding format was updated, with a spec that included the version number, and the library introduced backward compatibility. This should remove the likelyhood of such breaking changes in future. Version 1.1.0 will silently introduce the current version number in hashes, in order to avoid a further compatibility break.
73
75
 
74
- As the crypt format did not change, there is no simple way to identify an original, or improved hash. To support existing users, I'll be maintaining the 0.1.x branch with patches and bugfixes for the immediate future.
75
76
 
76
77
  ## Platform Issues
77
78
 
@@ -20,7 +20,7 @@
20
20
  #define THREADS_DEF 1
21
21
  #define OUT_LEN 32
22
22
  #define SALT_LEN 16
23
- #define ENCODE_LEN 108
23
+ #define ENCODE_LEN 112
24
24
 
25
25
  /* Workaround for https://github.com/technion/ruby-argon2/issues/8. Hopefully temporary */
26
26
  static int wrap_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
@@ -65,6 +65,7 @@ unsigned int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
65
65
  context.allocate_cbk = NULL;
66
66
  context.free_cbk = NULL;
67
67
  context.flags = 0;
68
+ context.version = ARGON2_VERSION_13;
68
69
 
69
70
  int result = argon2i_ctx(&context);
70
71
  if (result != ARGON2_OK)
@@ -88,20 +88,20 @@ int main()
88
88
 
89
89
  memcpy(salt, "somesalt", 8);
90
90
  WRAP_TEST(2, 16, "password",
91
- "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$HH7u+eDpabMCRyL8hkocqfbKINpz+b8/FzGIG+riA54");
91
+ "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$HH7u+eDpabMCRyL8hkocqfbKINpz+b8/FzGIG+riA54");
92
92
 
93
93
  WRAP_TEST(2, 8, "password",
94
- "$argon2i$m=256,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$3+v51OrdaFn0zGqbsgBD/Z2n4eNr2s27BcpWn0Yyafg");
94
+ "$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$3+v51OrdaFn0zGqbsgBD/Z2n4eNr2s27BcpWn0Yyafg");
95
95
 
96
96
  WRAP_TEST(2, 16, "differentpassword",
97
- "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$studfA0SiJUa7EtuHNODXqKafaKsE+b0hVSiaxJxRvk");
97
+ "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$studfA0SiJUa7EtuHNODXqKafaKsE+b0hVSiaxJxRvk");
98
98
 
99
- ret = wrap_argon2_verify("$argon2i$m=256,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$3+v51OrdaFn0zGqbsgBD/Z2n4eNr2s27BcpWn0Yyafg", "password",
99
+ ret = wrap_argon2_verify("$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$3+v51OrdaFn0zGqbsgBD/Z2n4eNr2s27BcpWn0Yyafg", "password",
100
100
  strlen("password"), NULL, 0);
101
101
  assert(ret == ARGON2_OK);
102
102
  printf("Verify OK test: PASS\n");
103
103
 
104
- ret = wrap_argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$iUr0/y4tJvPOFfd6fhwl20W04gQ56ZYXcroZnK3bAB4", "notpassword",
104
+ ret = wrap_argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$iUr0/y4tJvPOFfd6fhwl20W04gQ56ZYXcroZnK3bAB4", "notpassword",
105
105
  strlen("notpassword"), NULL, 0);
106
106
  assert(ret == ARGON2_DECODING_FAIL);
107
107
  printf("Verify FAIL test: PASS\n");
@@ -0,0 +1,5 @@
1
+ .gitattributes export-ignore
2
+ .gitignore export-ignore
3
+ .travis.yml export-ignore
4
+ appveyor.yml export-ignore
5
+ export.sh export-ignore
@@ -13,3 +13,8 @@ testcase
13
13
  *.gcno
14
14
  *.gcov
15
15
  bench
16
+ vs2015/build
17
+ Argon2.sdf
18
+ Argon2.VC.opendb
19
+ *.zip
20
+ *.tar.gz
@@ -0,0 +1,98 @@
1
+ 
2
+ Microsoft Visual Studio Solution File, Format Version 12.00
3
+ # Visual Studio Express 14 for Windows Desktop
4
+ VisualStudioVersion = 14.0.24720.0
5
+ MinimumVisualStudioVersion = 10.0.40219.1
6
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2OptTestCI", "vs2015\Argon2OptTestCI\Argon2OptTestCI.vcxproj", "{12956597-5E42-433A-93F3-D4EFF50AA207}"
7
+ EndProject
8
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2RefTestCI", "vs2015\Argon2RefTestCI\Argon2RefTestCI.vcxproj", "{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}"
9
+ EndProject
10
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2OptGenKAT", "vs2015\Argon2OptGenKAT\Argon2OptGenKAT.vcxproj", "{DBBAAAE6-4560-4D11-8280-30A6650A82EF}"
11
+ EndProject
12
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2RefGenKAT", "vs2015\Argon2RefGenKAT\Argon2RefGenKAT.vcxproj", "{71921B4C-A795-4A37-95A3-99D600E01211}"
13
+ EndProject
14
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2Opt", "vs2015\Argon2Opt\Argon2Opt.vcxproj", "{CAA75C57-998C-494E-B8A5-5894EF0FC528}"
15
+ EndProject
16
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2Ref", "vs2015\Argon2Ref\Argon2Ref.vcxproj", "{B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}"
17
+ EndProject
18
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2OptBench", "vs2015\Argon2OptBench\Argon2OptBench.vcxproj", "{B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}"
19
+ EndProject
20
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2RefBench", "vs2015\Argon2RefBench\Argon2RefBench.vcxproj", "{99203F6A-6E8C-42FC-8C7C-C07E8913D539}"
21
+ EndProject
22
+ Global
23
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
24
+ Debug|x64 = Debug|x64
25
+ Debug|x86 = Debug|x86
26
+ Release|x64 = Release|x64
27
+ Release|x86 = Release|x86
28
+ EndGlobalSection
29
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
30
+ {12956597-5E42-433A-93F3-D4EFF50AA207}.Debug|x64.ActiveCfg = Debug|x64
31
+ {12956597-5E42-433A-93F3-D4EFF50AA207}.Debug|x64.Build.0 = Debug|x64
32
+ {12956597-5E42-433A-93F3-D4EFF50AA207}.Debug|x86.ActiveCfg = Debug|Win32
33
+ {12956597-5E42-433A-93F3-D4EFF50AA207}.Debug|x86.Build.0 = Debug|Win32
34
+ {12956597-5E42-433A-93F3-D4EFF50AA207}.Release|x64.ActiveCfg = Release|x64
35
+ {12956597-5E42-433A-93F3-D4EFF50AA207}.Release|x64.Build.0 = Release|x64
36
+ {12956597-5E42-433A-93F3-D4EFF50AA207}.Release|x86.ActiveCfg = Release|Win32
37
+ {12956597-5E42-433A-93F3-D4EFF50AA207}.Release|x86.Build.0 = Release|Win32
38
+ {8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Debug|x64.ActiveCfg = Debug|x64
39
+ {8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Debug|x64.Build.0 = Debug|x64
40
+ {8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Debug|x86.ActiveCfg = Debug|Win32
41
+ {8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Debug|x86.Build.0 = Debug|Win32
42
+ {8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Release|x64.ActiveCfg = Release|x64
43
+ {8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Release|x64.Build.0 = Release|x64
44
+ {8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Release|x86.ActiveCfg = Release|Win32
45
+ {8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}.Release|x86.Build.0 = Release|Win32
46
+ {DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Debug|x64.ActiveCfg = Debug|x64
47
+ {DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Debug|x64.Build.0 = Debug|x64
48
+ {DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Debug|x86.ActiveCfg = Debug|Win32
49
+ {DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Debug|x86.Build.0 = Debug|Win32
50
+ {DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Release|x64.ActiveCfg = Release|x64
51
+ {DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Release|x64.Build.0 = Release|x64
52
+ {DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Release|x86.ActiveCfg = Release|Win32
53
+ {DBBAAAE6-4560-4D11-8280-30A6650A82EF}.Release|x86.Build.0 = Release|Win32
54
+ {71921B4C-A795-4A37-95A3-99D600E01211}.Debug|x64.ActiveCfg = Debug|x64
55
+ {71921B4C-A795-4A37-95A3-99D600E01211}.Debug|x64.Build.0 = Debug|x64
56
+ {71921B4C-A795-4A37-95A3-99D600E01211}.Debug|x86.ActiveCfg = Debug|Win32
57
+ {71921B4C-A795-4A37-95A3-99D600E01211}.Debug|x86.Build.0 = Debug|Win32
58
+ {71921B4C-A795-4A37-95A3-99D600E01211}.Release|x64.ActiveCfg = Release|x64
59
+ {71921B4C-A795-4A37-95A3-99D600E01211}.Release|x64.Build.0 = Release|x64
60
+ {71921B4C-A795-4A37-95A3-99D600E01211}.Release|x86.ActiveCfg = Release|Win32
61
+ {71921B4C-A795-4A37-95A3-99D600E01211}.Release|x86.Build.0 = Release|Win32
62
+ {CAA75C57-998C-494E-B8A5-5894EF0FC528}.Debug|x64.ActiveCfg = Debug|x64
63
+ {CAA75C57-998C-494E-B8A5-5894EF0FC528}.Debug|x64.Build.0 = Debug|x64
64
+ {CAA75C57-998C-494E-B8A5-5894EF0FC528}.Debug|x86.ActiveCfg = Debug|Win32
65
+ {CAA75C57-998C-494E-B8A5-5894EF0FC528}.Debug|x86.Build.0 = Debug|Win32
66
+ {CAA75C57-998C-494E-B8A5-5894EF0FC528}.Release|x64.ActiveCfg = Release|x64
67
+ {CAA75C57-998C-494E-B8A5-5894EF0FC528}.Release|x64.Build.0 = Release|x64
68
+ {CAA75C57-998C-494E-B8A5-5894EF0FC528}.Release|x86.ActiveCfg = Release|Win32
69
+ {CAA75C57-998C-494E-B8A5-5894EF0FC528}.Release|x86.Build.0 = Release|Win32
70
+ {B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Debug|x64.ActiveCfg = Debug|x64
71
+ {B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Debug|x64.Build.0 = Debug|x64
72
+ {B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Debug|x86.ActiveCfg = Debug|Win32
73
+ {B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Debug|x86.Build.0 = Debug|Win32
74
+ {B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Release|x64.ActiveCfg = Release|x64
75
+ {B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Release|x64.Build.0 = Release|x64
76
+ {B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Release|x86.ActiveCfg = Release|Win32
77
+ {B9CAC9CE-9F0D-4F52-8D67-FDBBAFCD0DE2}.Release|x86.Build.0 = Release|Win32
78
+ {B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Debug|x64.ActiveCfg = Debug|x64
79
+ {B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Debug|x64.Build.0 = Debug|x64
80
+ {B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Debug|x86.ActiveCfg = Debug|Win32
81
+ {B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Debug|x86.Build.0 = Debug|Win32
82
+ {B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Release|x64.ActiveCfg = Release|x64
83
+ {B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Release|x64.Build.0 = Release|x64
84
+ {B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Release|x86.ActiveCfg = Release|Win32
85
+ {B3A0FB44-0C1C-4EC3-B155-8B39371F8EE4}.Release|x86.Build.0 = Release|Win32
86
+ {99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Debug|x64.ActiveCfg = Debug|x64
87
+ {99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Debug|x64.Build.0 = Debug|x64
88
+ {99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Debug|x86.ActiveCfg = Debug|Win32
89
+ {99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Debug|x86.Build.0 = Debug|Win32
90
+ {99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Release|x64.ActiveCfg = Release|x64
91
+ {99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Release|x64.Build.0 = Release|x64
92
+ {99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Release|x86.ActiveCfg = Release|Win32
93
+ {99203F6A-6E8C-42FC-8C7C-C07E8913D539}.Release|x86.Build.0 = Release|Win32
94
+ EndGlobalSection
95
+ GlobalSection(SolutionProperties) = preSolution
96
+ HideSolutionNode = FALSE
97
+ EndGlobalSection
98
+ EndGlobal
@@ -1,3 +1,14 @@
1
+ # 20160406
2
+
3
+ * Version 1.3 of Argon2
4
+ * Version number in encoded hash
5
+ * Refactored low-level API
6
+ * Visibility control for library symbols
7
+ * Microsft Visual Studio solution
8
+ * New bindings
9
+ * Minor bug and warning fixes (no security issue)
10
+
11
+
1
12
  # 20151206
2
13
 
3
14
  * Python bindings
@@ -21,9 +21,10 @@ OBJ = $(SRC:.c=.o)
21
21
 
22
22
  CFLAGS += -std=c89 -pthread -O3 -Wall -g -Iinclude -Isrc
23
23
  CI_CFLAGS := $(CFLAGS) -Werror=declaration-after-statement -D_FORTIFY_SOURCE=2 \
24
- -Wextra -Wno-type-limits -Werror -coverage
24
+ -Wextra -Wno-type-limits -Werror -coverage -DTEST_LARGE_RAM
25
25
 
26
- OPTTEST := $(shell $(CC) -Iinclude -Isrc -march=native src/opt.c -c 2>/dev/null; echo $$?)
26
+ OPTTEST := $(shell $(CC) -Iinclude -Isrc -march=native src/opt.c -c \
27
+ -o /dev/null 2>/dev/null; echo $$?)
27
28
  # Detect compatible platform
28
29
  ifneq ($(OPTTEST), 0)
29
30
  SRC += src/ref.c
@@ -53,6 +54,10 @@ ifeq ($(findstring MINGW, $(KERNEL_NAME)), MINGW)
53
54
  LIB_EXT := dll
54
55
  LIB_CFLAGS := -shared -Wl,--out-implib,lib$(LIB_NAME).$(LIB_EXT).a
55
56
  endif
57
+ ifeq ($(findstring MSYS, $(KERNEL_NAME)), MSYS)
58
+ LIB_EXT := dll
59
+ LIB_CFLAGS := -shared -Wl,--out-implib,lib$(LIB_NAME).$(LIB_EXT).a
60
+ endif
56
61
  ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),OpenBSD FreeBSD))
57
62
  LIB_EXT := so
58
63
  LIB_CFLAGS := -shared -fPIC
@@ -1,6 +1,7 @@
1
1
  # Argon2
2
2
 
3
3
  [![Build Status](https://travis-ci.org/P-H-C/phc-winner-argon2.svg?branch=master)](https://travis-ci.org/P-H-C/phc-winner-argon2)
4
+ [![Build status](https://ci.appveyor.com/api/projects/status/8nfwuwq55sgfkele?svg=true)](https://ci.appveyor.com/project/P-H-C/phc-winner-argon2)
4
5
  [![codecov.io](https://codecov.io/github/P-H-C/phc-winner-argon2/coverage.svg?branch=master)](https://codecov.io/github/P-H-C/phc-winner-argon2?branch=master)
5
6
 
6
7
  This is the reference C implementation of Argon2, the password-hashing
@@ -49,7 +50,7 @@ results.
49
50
  on your system. To show usage instructions, run
50
51
  `./argon2` without arguments as
51
52
  ```
52
- Usage: ./argon2 salt [-d] [-t iterations] [-m memory] [-p parallelism]
53
+ Usage: ./argon2 salt [-d] [-t iterations] [-m memory] [-p parallelism] [-h hash length] [-e|-r]
53
54
  Password is read from stdin
54
55
  Parameters:
55
56
  salt The salt to use, at least 8 characters
@@ -58,6 +59,8 @@ Parameters:
58
59
  -m N Sets the memory usage of 2^N KiB (default 12)
59
60
  -p N Sets parallelism to N threads (default 1)
60
61
  -h N Sets hash output length to N bytes (default 32)
62
+ -e Output only encoded hash
63
+ -r Output only the raw bytes of the hash
61
64
  ```
62
65
  For example, to hash "password" using "somesalt" as a salt and doing 2
63
66
  iterations, consuming 64 MiB, using four parallel threads and an output hash
@@ -68,8 +71,8 @@ Type: Argon2i
68
71
  Iterations: 2
69
72
  Memory: 65536 KiB
70
73
  Parallelism: 4
71
- Hash: 5a028f1a99c9eae671ee448ab80057b78510430865abe57f
72
- Encoded: $argon2i$m=65536,t=2,p=4$c29tZXNhbHQ$WgKPGpnJ6uZx7kSKuABXt4UQQwhlq+V/
74
+ Hash: 45d7ac72e76f242b20b77b9bf9bf9d5915894e669a24e6c6
75
+ Encoded: $argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$RdescudvJCsgt3ub+b+dWRWJTmaaJObG
73
76
  0.188 seconds
74
77
  Verification ok
75
78
  ```
@@ -122,28 +125,36 @@ int main(void)
122
125
  argon2i_hash_raw(t_cost, m_cost, parallelism, pwd, pwdlen, salt, SALTLEN, hash1, HASHLEN);
123
126
 
124
127
  // low-level API
125
- uint32_t lanes = parallelism;
126
- uint32_t threads = parallelism;
127
128
  argon2_context context = {
128
- hash2, HASHLEN,
129
- pwd, pwdlen,
130
- salt, SALTLEN,
131
- NULL, 0, /* secret data */
132
- NULL, 0, /* associated data */
129
+ hash2, /* output array, at least HASHLEN in size */
130
+ HASHLEN, /* digest length */
131
+ pwd, /* password array */
132
+ pwdlen, /* password length */
133
+ salt, /* salt array */
134
+ SALTLEN, /* salt length */
135
+ NULL, 0, /* optional secret data */
136
+ NULL, 0, /* optional associated data */
133
137
  t_cost, m_cost, parallelism, parallelism,
138
+ ARGON2_VERSION_13, /* algorithm version */
134
139
  NULL, NULL, /* custom memory allocation / deallocation functions */
135
140
  ARGON2_DEFAULT_FLAGS /* by default the password is zeroed on exit */
136
141
  };
137
- argon2i( &context );
142
+
143
+ int rc = argon2i_ctx( &context );
144
+ if(ARGON2_OK != rc) {
145
+ printf("Error: %s\n", argon2_error_message(rc));
146
+ exit(1);
147
+ }
138
148
  free(pwd);
139
149
 
140
150
  for( int i=0; i<HASHLEN; ++i ) printf( "%02x", hash1[i] ); printf( "\n" );
141
151
  if (memcmp(hash1, hash2, HASHLEN)) {
142
- for( int i=0; i<HASHLEN; ++i ) printf( "%02x", hash2[i] ); printf( "\n" );
143
- printf("fail\n");
152
+ for( int i=0; i<HASHLEN; ++i ) {
153
+ printf( "%02x", hash2[i] );
154
+ }
155
+ printf("\nfail\n");
144
156
  }
145
157
  else printf("ok\n");
146
-
147
158
  return 0;
148
159
  }
149
160
  ```
@@ -200,7 +211,8 @@ their documentation):
200
211
 
201
212
  * [Go](https://github.com/tvdburgt/go-argon2) by [@tvdburgt](https://github.com/tvdburgt)
202
213
  * [Haskell](https://hackage.haskell.org/package/argon2-1.0.0/docs/Crypto-Argon2.html) by [@ocharles](https://github.com/ocharles)
203
- * [Javascript](https://github.com/ranisalt/node-argon2), by [@ranisalt](https://github.com/ranisalt)
214
+ * [JavaScript](https://github.com/ranisalt/node-argon2), by [@ranisalt](https://github.com/ranisalt)
215
+ * [JavaScript](https://github.com/cjlarose/argon2-ffi), by [@cjlarose](https://github.com/cjlarose)
204
216
  * [JVM](https://github.com/phxql/argon2-jvm) by [@phXql](https://github.com/phxql)
205
217
  * [Lua](https://github.com/thibaultCha/lua-argon2) by [@thibaultCha](https://github.com/thibaultCha)
206
218
  * [OCaml](https://github.com/Khady/ocaml-argon2) by [@Khady](https://github.com/Khady)
@@ -0,0 +1,25 @@
1
+ os: Visual Studio 2015
2
+
3
+ environment:
4
+ matrix:
5
+ - platform: x86
6
+ configuration: Debug
7
+ - platform: x86
8
+ configuration: Release
9
+ - platform: x64
10
+ configuration: Debug
11
+ - platform: x64
12
+ configuration: Release
13
+
14
+ matrix:
15
+ fast_finish: false
16
+
17
+ build:
18
+ parallel: true
19
+ project: Argon2.sln
20
+ verbosity: minimal
21
+
22
+ test_script:
23
+ - ps: kats\test.ps1
24
+ - ps: if ("Release" -eq $env:configuration) { vs2015\build\Argon2OptTestCI.exe }
25
+ - ps: if ("Release" -eq $env:configuration) { vs2015\build\Argon2RefTestCI.exe }
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ FILE=`date "+%Y%m%d"`
4
+ BRANCH=master
5
+
6
+ git archive --format zip --output $FILE.zip $BRANCH
7
+ git archive --format tar.gz --output $FILE.tar.gz $BRANCH
@@ -195,6 +195,8 @@ typedef struct Argon2_Context {
195
195
  uint32_t lanes; /* number of lanes */
196
196
  uint32_t threads; /* maximum number of threads */
197
197
 
198
+ uint32_t version; /* version number */
199
+
198
200
  allocate_fptr allocate_cbk; /* pointer to memory allocator */
199
201
  deallocate_fptr free_cbk; /* pointer to memory deallocator */
200
202
 
@@ -204,6 +206,13 @@ typedef struct Argon2_Context {
204
206
  /* Argon2 primitive type */
205
207
  typedef enum Argon2_type { Argon2_d = 0, Argon2_i = 1 } argon2_type;
206
208
 
209
+ /* Version of the algorithm */
210
+ typedef enum Argon2_version {
211
+ ARGON2_VERSION_10 = 0x10,
212
+ ARGON2_VERSION_13 = 0x13,
213
+ ARGON2_VERSION_NUMBER = ARGON2_VERSION_13
214
+ } argon2_version;
215
+
207
216
  /*
208
217
  * Function that performs memory-hard hashing with certain degree of parallelism
209
218
  * @param context Pointer to the Argon2 internal structure
@@ -275,7 +284,8 @@ ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
275
284
  const size_t pwdlen, const void *salt,
276
285
  const size_t saltlen, void *hash,
277
286
  const size_t hashlen, char *encoded,
278
- const size_t encodedlen, argon2_type type);
287
+ const size_t encodedlen, argon2_type type,
288
+ const uint32_t version);
279
289
 
280
290
  /**
281
291
  * Verifies a password against an encoded string
@@ -342,6 +352,19 @@ ARGON2_PUBLIC int argon2_verify_ctx(argon2_context *context, const char *hash,
342
352
  */
343
353
  ARGON2_PUBLIC const char *argon2_error_message(int error_code);
344
354
 
355
+ /**
356
+ * Returns the encoded hash length for the given input parameters
357
+ * @param t_cost Number of iterations
358
+ * @param m_cost Memory usage in kibibytes
359
+ * @param parallelism Number of threads; used to compute lanes
360
+ * @param saltlen Salt size in bytes
361
+ * @param hashlen Hash size in bytes
362
+ * @return The encoded hash length in bytes
363
+ */
364
+ ARGON2_PUBLIC size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost,
365
+ uint32_t parallelism, uint32_t saltlen,
366
+ uint32_t hashlen);
367
+
345
368
  #if defined(__cplusplus)
346
369
  }
347
370
  #endif
@@ -1,4 +1,6 @@
1
- =======================================Argon2d
1
+ =======================================
2
+ Argon2d version number 19
3
+ =======================================
2
4
  Memory: 32 KiB, Iterations: 3, Parallelism: 4 lanes, Tag length: 32 bytes
3
5
  Password[32]: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
4
6
  Salt[16]: 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02