enzoic 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +5 -0
  7. data/README.md +90 -0
  8. data/Rakefile +28 -0
  9. data/enzoic.gemspec +36 -0
  10. data/ext/.DS_Store +0 -0
  11. data/ext/argon2-wrapper/Makefile +74 -0
  12. data/ext/argon2-wrapper/argon2-wrapper.c +165 -0
  13. data/ext/argon2-wrapper/extconf.rb +1 -0
  14. data/ext/argon2_import/.DS_Store +0 -0
  15. data/ext/digest/whirlpool/extconf.rb +10 -0
  16. data/ext/digest/whirlpool/whirlpool-algorithm.c +476 -0
  17. data/ext/digest/whirlpool/whirlpool-algorithm.h +86 -0
  18. data/ext/digest/whirlpool/whirlpool-constants.h +1116 -0
  19. data/ext/digest/whirlpool/whirlpool-portability.h +142 -0
  20. data/ext/digest/whirlpool/whirlpool.c +51 -0
  21. data/ext/phc-winner-argon2/.gitattributes +10 -0
  22. data/ext/phc-winner-argon2/.gitignore +21 -0
  23. data/ext/phc-winner-argon2/.travis.yml +14 -0
  24. data/ext/phc-winner-argon2/Argon2.sln +160 -0
  25. data/ext/phc-winner-argon2/CHANGELOG.md +25 -0
  26. data/ext/phc-winner-argon2/LICENSE +314 -0
  27. data/ext/phc-winner-argon2/Makefile +187 -0
  28. data/ext/phc-winner-argon2/README.md +290 -0
  29. data/ext/phc-winner-argon2/appveyor.yml +25 -0
  30. data/ext/phc-winner-argon2/argon2-specs.pdf +0 -0
  31. data/ext/phc-winner-argon2/export.sh +7 -0
  32. data/ext/phc-winner-argon2/include/argon2.h +435 -0
  33. data/ext/phc-winner-argon2/kats/argon2d +12304 -0
  34. data/ext/phc-winner-argon2/kats/argon2d.shasum +1 -0
  35. data/ext/phc-winner-argon2/kats/argon2d_v16 +12304 -0
  36. data/ext/phc-winner-argon2/kats/argon2d_v16.shasum +1 -0
  37. data/ext/phc-winner-argon2/kats/argon2i +12304 -0
  38. data/ext/phc-winner-argon2/kats/argon2i.shasum +1 -0
  39. data/ext/phc-winner-argon2/kats/argon2i_v16 +12304 -0
  40. data/ext/phc-winner-argon2/kats/argon2i_v16.shasum +1 -0
  41. data/ext/phc-winner-argon2/kats/argon2id +12304 -0
  42. data/ext/phc-winner-argon2/kats/argon2id.shasum +1 -0
  43. data/ext/phc-winner-argon2/kats/argon2id_v16 +12304 -0
  44. data/ext/phc-winner-argon2/kats/argon2id_v16.shasum +1 -0
  45. data/ext/phc-winner-argon2/kats/check-sums.ps1 +42 -0
  46. data/ext/phc-winner-argon2/kats/check-sums.sh +13 -0
  47. data/ext/phc-winner-argon2/kats/test.ps1 +50 -0
  48. data/ext/phc-winner-argon2/kats/test.sh +49 -0
  49. data/ext/phc-winner-argon2/latex/IEEEtran.cls +6347 -0
  50. data/ext/phc-winner-argon2/latex/Makefile +18 -0
  51. data/ext/phc-winner-argon2/latex/argon2-specs.tex +920 -0
  52. data/ext/phc-winner-argon2/latex/pics/argon2-par.pdf +0 -0
  53. data/ext/phc-winner-argon2/latex/pics/compression.pdf +0 -0
  54. data/ext/phc-winner-argon2/latex/pics/generic.pdf +0 -0
  55. data/ext/phc-winner-argon2/latex/pics/power-distribution.jpg +0 -0
  56. data/ext/phc-winner-argon2/latex/tradeoff.bib +822 -0
  57. data/ext/phc-winner-argon2/libargon2.pc +16 -0
  58. data/ext/phc-winner-argon2/man/argon2.1 +57 -0
  59. data/ext/phc-winner-argon2/src/argon2.c +452 -0
  60. data/ext/phc-winner-argon2/src/bench.c +111 -0
  61. data/ext/phc-winner-argon2/src/blake2/blake2-impl.h +156 -0
  62. data/ext/phc-winner-argon2/src/blake2/blake2.h +91 -0
  63. data/ext/phc-winner-argon2/src/blake2/blake2b.c +390 -0
  64. data/ext/phc-winner-argon2/src/blake2/blamka-round-opt.h +328 -0
  65. data/ext/phc-winner-argon2/src/blake2/blamka-round-ref.h +56 -0
  66. data/ext/phc-winner-argon2/src/core.c +635 -0
  67. data/ext/phc-winner-argon2/src/core.h +227 -0
  68. data/ext/phc-winner-argon2/src/encoding.c +463 -0
  69. data/ext/phc-winner-argon2/src/encoding.h +57 -0
  70. data/ext/phc-winner-argon2/src/genkat.c +208 -0
  71. data/ext/phc-winner-argon2/src/genkat.h +49 -0
  72. data/ext/phc-winner-argon2/src/opt.c +241 -0
  73. data/ext/phc-winner-argon2/src/ref.c +194 -0
  74. data/ext/phc-winner-argon2/src/run.c +317 -0
  75. data/ext/phc-winner-argon2/src/test.c +254 -0
  76. data/ext/phc-winner-argon2/src/thread.c +57 -0
  77. data/ext/phc-winner-argon2/src/thread.h +67 -0
  78. data/ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +226 -0
  79. data/ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj.filters +69 -0
  80. data/ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +226 -0
  81. data/ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj.filters +69 -0
  82. data/ext/phc-winner-argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj +225 -0
  83. data/ext/phc-winner-argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj.filters +66 -0
  84. data/ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +239 -0
  85. data/ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj.filters +72 -0
  86. data/ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +227 -0
  87. data/ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj.filters +69 -0
  88. data/ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +226 -0
  89. data/ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj.filters +69 -0
  90. data/ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +226 -0
  91. data/ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj.filters +69 -0
  92. data/ext/phc-winner-argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj +225 -0
  93. data/ext/phc-winner-argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj.filters +66 -0
  94. data/ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +227 -0
  95. data/ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj.filters +72 -0
  96. data/ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +226 -0
  97. data/ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj.filters +69 -0
  98. data/lib/enzoic.rb +189 -0
  99. data/lib/enzoic/argon2_errors.rb +39 -0
  100. data/lib/enzoic/argon2_wrapper_ffi.rb +89 -0
  101. data/lib/enzoic/constants.rb +10 -0
  102. data/lib/enzoic/errors.rb +3 -0
  103. data/lib/enzoic/hashing.rb +258 -0
  104. data/lib/enzoic/password_type.rb +25 -0
  105. data/lib/enzoic/version.rb +5 -0
  106. metadata +354 -0
@@ -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
@@ -0,0 +1,435 @@
1
+ /*
2
+ * Argon2 reference source code package - reference C implementations
3
+ *
4
+ * Copyright 2015
5
+ * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
6
+ *
7
+ * You may use this work under the terms of a Creative Commons CC0 1.0
8
+ * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
+ * these licenses can be found at:
10
+ *
11
+ * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * You should have received a copy of both of these licenses along with this
15
+ * software. If not, they may be obtained at the above URLs.
16
+ */
17
+
18
+ #ifndef ARGON2_H
19
+ #define ARGON2_H
20
+
21
+ #include <stdint.h>
22
+ #include <stddef.h>
23
+ #include <limits.h>
24
+
25
+ #if defined(__cplusplus)
26
+ extern "C" {
27
+ #endif
28
+
29
+ /* Symbols visibility control */
30
+ #ifdef A2_VISCTL
31
+ #define ARGON2_PUBLIC __attribute__((visibility("default")))
32
+ #elif _MSC_VER
33
+ #define ARGON2_PUBLIC __declspec(dllexport)
34
+ #else
35
+ #define ARGON2_PUBLIC
36
+ #endif
37
+
38
+ /*
39
+ * Argon2 input parameter restrictions
40
+ */
41
+
42
+ /* Minimum and maximum number of lanes (degree of parallelism) */
43
+ #define ARGON2_MIN_LANES UINT32_C(1)
44
+ #define ARGON2_MAX_LANES UINT32_C(0xFFFFFF)
45
+
46
+ /* Minimum and maximum number of threads */
47
+ #define ARGON2_MIN_THREADS UINT32_C(1)
48
+ #define ARGON2_MAX_THREADS UINT32_C(0xFFFFFF)
49
+
50
+ /* Number of synchronization points between lanes per pass */
51
+ #define ARGON2_SYNC_POINTS UINT32_C(4)
52
+
53
+ /* Minimum and maximum digest size in bytes */
54
+ #define ARGON2_MIN_OUTLEN UINT32_C(4)
55
+ #define ARGON2_MAX_OUTLEN UINT32_C(0xFFFFFFFF)
56
+
57
+ /* Minimum and maximum number of memory blocks (each of BLOCK_SIZE bytes) */
58
+ #define ARGON2_MIN_MEMORY (2 * ARGON2_SYNC_POINTS) /* 2 blocks per slice */
59
+
60
+ #define ARGON2_MIN(a, b) ((a) < (b) ? (a) : (b))
61
+ /* Max memory size is addressing-space/2, topping at 2^32 blocks (4 TB) */
62
+ #define ARGON2_MAX_MEMORY_BITS \
63
+ ARGON2_MIN(UINT32_C(32), (sizeof(void *) * CHAR_BIT - 10 - 1))
64
+ #define ARGON2_MAX_MEMORY \
65
+ ARGON2_MIN(UINT32_C(0xFFFFFFFF), UINT64_C(1) << ARGON2_MAX_MEMORY_BITS)
66
+
67
+ /* Minimum and maximum number of passes */
68
+ #define ARGON2_MIN_TIME UINT32_C(1)
69
+ #define ARGON2_MAX_TIME UINT32_C(0xFFFFFFFF)
70
+
71
+ /* Minimum and maximum password length in bytes */
72
+ #define ARGON2_MIN_PWD_LENGTH UINT32_C(0)
73
+ #define ARGON2_MAX_PWD_LENGTH UINT32_C(0xFFFFFFFF)
74
+
75
+ /* Minimum and maximum associated data length in bytes */
76
+ #define ARGON2_MIN_AD_LENGTH UINT32_C(0)
77
+ #define ARGON2_MAX_AD_LENGTH UINT32_C(0xFFFFFFFF)
78
+
79
+ /* Minimum and maximum salt length in bytes */
80
+ #define ARGON2_MIN_SALT_LENGTH UINT32_C(8)
81
+ #define ARGON2_MAX_SALT_LENGTH UINT32_C(0xFFFFFFFF)
82
+
83
+ /* Minimum and maximum key length in bytes */
84
+ #define ARGON2_MIN_SECRET UINT32_C(0)
85
+ #define ARGON2_MAX_SECRET UINT32_C(0xFFFFFFFF)
86
+
87
+ /* Flags to determine which fields are securely wiped (default = no wipe). */
88
+ #define ARGON2_DEFAULT_FLAGS UINT32_C(0)
89
+ #define ARGON2_FLAG_CLEAR_PASSWORD (UINT32_C(1) << 0)
90
+ #define ARGON2_FLAG_CLEAR_SECRET (UINT32_C(1) << 1)
91
+
92
+ /* Global flag to determine if we are wiping internal memory buffers. This flag
93
+ * is defined in core.c and deafults to 1 (wipe internal memory). */
94
+ extern int FLAG_clear_internal_memory;
95
+
96
+ /* Error codes */
97
+ typedef enum Argon2_ErrorCodes {
98
+ ARGON2_OK = 0,
99
+
100
+ ARGON2_OUTPUT_PTR_NULL = -1,
101
+
102
+ ARGON2_OUTPUT_TOO_SHORT = -2,
103
+ ARGON2_OUTPUT_TOO_LONG = -3,
104
+
105
+ ARGON2_PWD_TOO_SHORT = -4,
106
+ ARGON2_PWD_TOO_LONG = -5,
107
+
108
+ ARGON2_SALT_TOO_SHORT = -6,
109
+ ARGON2_SALT_TOO_LONG = -7,
110
+
111
+ ARGON2_AD_TOO_SHORT = -8,
112
+ ARGON2_AD_TOO_LONG = -9,
113
+
114
+ ARGON2_SECRET_TOO_SHORT = -10,
115
+ ARGON2_SECRET_TOO_LONG = -11,
116
+
117
+ ARGON2_TIME_TOO_SMALL = -12,
118
+ ARGON2_TIME_TOO_LARGE = -13,
119
+
120
+ ARGON2_MEMORY_TOO_LITTLE = -14,
121
+ ARGON2_MEMORY_TOO_MUCH = -15,
122
+
123
+ ARGON2_LANES_TOO_FEW = -16,
124
+ ARGON2_LANES_TOO_MANY = -17,
125
+
126
+ ARGON2_PWD_PTR_MISMATCH = -18, /* NULL ptr with non-zero length */
127
+ ARGON2_SALT_PTR_MISMATCH = -19, /* NULL ptr with non-zero length */
128
+ ARGON2_SECRET_PTR_MISMATCH = -20, /* NULL ptr with non-zero length */
129
+ ARGON2_AD_PTR_MISMATCH = -21, /* NULL ptr with non-zero length */
130
+
131
+ ARGON2_MEMORY_ALLOCATION_ERROR = -22,
132
+
133
+ ARGON2_FREE_MEMORY_CBK_NULL = -23,
134
+ ARGON2_ALLOCATE_MEMORY_CBK_NULL = -24,
135
+
136
+ ARGON2_INCORRECT_PARAMETER = -25,
137
+ ARGON2_INCORRECT_TYPE = -26,
138
+
139
+ ARGON2_OUT_PTR_MISMATCH = -27,
140
+
141
+ ARGON2_THREADS_TOO_FEW = -28,
142
+ ARGON2_THREADS_TOO_MANY = -29,
143
+
144
+ ARGON2_MISSING_ARGS = -30,
145
+
146
+ ARGON2_ENCODING_FAIL = -31,
147
+
148
+ ARGON2_DECODING_FAIL = -32,
149
+
150
+ ARGON2_THREAD_FAIL = -33,
151
+
152
+ ARGON2_DECODING_LENGTH_FAIL = -34,
153
+
154
+ ARGON2_VERIFY_MISMATCH = -35
155
+ } argon2_error_codes;
156
+
157
+ /* Memory allocator types --- for external allocation */
158
+ typedef int (*allocate_fptr)(uint8_t **memory, size_t bytes_to_allocate);
159
+ typedef void (*deallocate_fptr)(uint8_t *memory, size_t bytes_to_allocate);
160
+
161
+ /* Argon2 external data structures */
162
+
163
+ /*
164
+ *****
165
+ * Context: structure to hold Argon2 inputs:
166
+ * output array and its length,
167
+ * password and its length,
168
+ * salt and its length,
169
+ * secret and its length,
170
+ * associated data and its length,
171
+ * number of passes, amount of used memory (in KBytes, can be rounded up a bit)
172
+ * number of parallel threads that will be run.
173
+ * All the parameters above affect the output hash value.
174
+ * Additionally, two function pointers can be provided to allocate and
175
+ * deallocate the memory (if NULL, memory will be allocated internally).
176
+ * Also, three flags indicate whether to erase password, secret as soon as they
177
+ * are pre-hashed (and thus not needed anymore), and the entire memory
178
+ *****
179
+ * Simplest situation: you have output array out[8], password is stored in
180
+ * pwd[32], salt is stored in salt[16], you do not have keys nor associated
181
+ * data. You need to spend 1 GB of RAM and you run 5 passes of Argon2d with
182
+ * 4 parallel lanes.
183
+ * You want to erase the password, but you're OK with last pass not being
184
+ * erased. You want to use the default memory allocator.
185
+ * Then you initialize:
186
+ Argon2_Context(out,8,pwd,32,salt,16,NULL,0,NULL,0,5,1<<20,4,4,NULL,NULL,true,false,false,false)
187
+ */
188
+ typedef struct Argon2_Context {
189
+ uint8_t *out; /* output array */
190
+ uint32_t outlen; /* digest length */
191
+
192
+ uint8_t *pwd; /* password array */
193
+ uint32_t pwdlen; /* password length */
194
+
195
+ uint8_t *salt; /* salt array */
196
+ uint32_t saltlen; /* salt length */
197
+
198
+ uint8_t *secret; /* key array */
199
+ uint32_t secretlen; /* key length */
200
+
201
+ uint8_t *ad; /* associated data array */
202
+ uint32_t adlen; /* associated data length */
203
+
204
+ uint32_t t_cost; /* number of passes */
205
+ uint32_t m_cost; /* amount of memory requested (KB) */
206
+ uint32_t lanes; /* number of lanes */
207
+ uint32_t threads; /* maximum number of threads */
208
+
209
+ uint32_t version; /* version number */
210
+
211
+ allocate_fptr allocate_cbk; /* pointer to memory allocator */
212
+ deallocate_fptr free_cbk; /* pointer to memory deallocator */
213
+
214
+ uint32_t flags; /* array of bool options */
215
+ } argon2_context;
216
+
217
+ /* Argon2 primitive type */
218
+ typedef enum Argon2_type {
219
+ Argon2_d = 0,
220
+ Argon2_i = 1,
221
+ Argon2_id = 2
222
+ } argon2_type;
223
+
224
+ /* Version of the algorithm */
225
+ typedef enum Argon2_version {
226
+ ARGON2_VERSION_10 = 0x10,
227
+ ARGON2_VERSION_13 = 0x13,
228
+ ARGON2_VERSION_NUMBER = ARGON2_VERSION_13
229
+ } argon2_version;
230
+
231
+ /*
232
+ * Function that gives the string representation of an argon2_type.
233
+ * @param type The argon2_type that we want the string for
234
+ * @param uppercase Whether the string should have the first letter uppercase
235
+ * @return NULL if invalid type, otherwise the string representation.
236
+ */
237
+ ARGON2_PUBLIC const char *argon2_type2string(argon2_type type, int uppercase);
238
+
239
+ /*
240
+ * Function that performs memory-hard hashing with certain degree of parallelism
241
+ * @param context Pointer to the Argon2 internal structure
242
+ * @return Error code if smth is wrong, ARGON2_OK otherwise
243
+ */
244
+ ARGON2_PUBLIC int argon2_ctx(argon2_context *context, argon2_type type);
245
+
246
+ /**
247
+ * Hashes a password with Argon2i, producing an encoded hash
248
+ * @param t_cost Number of iterations
249
+ * @param m_cost Sets memory usage to m_cost kibibytes
250
+ * @param parallelism Number of threads and compute lanes
251
+ * @param pwd Pointer to password
252
+ * @param pwdlen Password size in bytes
253
+ * @param salt Pointer to salt
254
+ * @param saltlen Salt size in bytes
255
+ * @param hashlen Desired length of the hash in bytes
256
+ * @param encoded Buffer where to write the encoded hash
257
+ * @param encodedlen Size of the buffer (thus max size of the encoded hash)
258
+ * @pre Different parallelism levels will give different results
259
+ * @pre Returns ARGON2_OK if successful
260
+ */
261
+ ARGON2_PUBLIC int argon2i_hash_encoded(const uint32_t t_cost,
262
+ const uint32_t m_cost,
263
+ const uint32_t parallelism,
264
+ const void *pwd, const size_t pwdlen,
265
+ const void *salt, const size_t saltlen,
266
+ const size_t hashlen, char *encoded,
267
+ const size_t encodedlen);
268
+
269
+ /**
270
+ * Hashes a password with Argon2i, producing a raw hash by allocating memory at
271
+ * @hash
272
+ * @param t_cost Number of iterations
273
+ * @param m_cost Sets memory usage to m_cost kibibytes
274
+ * @param parallelism Number of threads and compute lanes
275
+ * @param pwd Pointer to password
276
+ * @param pwdlen Password size in bytes
277
+ * @param salt Pointer to salt
278
+ * @param saltlen Salt size in bytes
279
+ * @param hash Buffer where to write the raw hash - updated by the function
280
+ * @param hashlen Desired length of the hash in bytes
281
+ * @pre Different parallelism levels will give different results
282
+ * @pre Returns ARGON2_OK if successful
283
+ */
284
+ ARGON2_PUBLIC int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
285
+ const uint32_t parallelism, const void *pwd,
286
+ const size_t pwdlen, const void *salt,
287
+ const size_t saltlen, void *hash,
288
+ const size_t hashlen);
289
+
290
+ ARGON2_PUBLIC int argon2d_hash_encoded(const uint32_t t_cost,
291
+ const uint32_t m_cost,
292
+ const uint32_t parallelism,
293
+ const void *pwd, const size_t pwdlen,
294
+ const void *salt, const size_t saltlen,
295
+ const size_t hashlen, char *encoded,
296
+ const size_t encodedlen);
297
+
298
+ ARGON2_PUBLIC int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
299
+ const uint32_t parallelism, const void *pwd,
300
+ const size_t pwdlen, const void *salt,
301
+ const size_t saltlen, void *hash,
302
+ const size_t hashlen);
303
+
304
+ ARGON2_PUBLIC int argon2id_hash_encoded(const uint32_t t_cost,
305
+ const uint32_t m_cost,
306
+ const uint32_t parallelism,
307
+ const void *pwd, const size_t pwdlen,
308
+ const void *salt, const size_t saltlen,
309
+ const size_t hashlen, char *encoded,
310
+ const size_t encodedlen);
311
+
312
+ ARGON2_PUBLIC int argon2id_hash_raw(const uint32_t t_cost,
313
+ const uint32_t m_cost,
314
+ const uint32_t parallelism, const void *pwd,
315
+ const size_t pwdlen, const void *salt,
316
+ const size_t saltlen, void *hash,
317
+ const size_t hashlen);
318
+
319
+ /* generic function underlying the above ones */
320
+ ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
321
+ const uint32_t parallelism, const void *pwd,
322
+ const size_t pwdlen, const void *salt,
323
+ const size_t saltlen, void *hash,
324
+ const size_t hashlen, char *encoded,
325
+ const size_t encodedlen, argon2_type type,
326
+ const uint32_t version);
327
+
328
+ /**
329
+ * Verifies a password against an encoded string
330
+ * Encoded string is restricted as in validate_inputs()
331
+ * @param encoded String encoding parameters, salt, hash
332
+ * @param pwd Pointer to password
333
+ * @pre Returns ARGON2_OK if successful
334
+ */
335
+ ARGON2_PUBLIC int argon2i_verify(const char *encoded, const void *pwd,
336
+ const size_t pwdlen);
337
+
338
+ ARGON2_PUBLIC int argon2d_verify(const char *encoded, const void *pwd,
339
+ const size_t pwdlen);
340
+
341
+ ARGON2_PUBLIC int argon2id_verify(const char *encoded, const void *pwd,
342
+ const size_t pwdlen);
343
+
344
+ /* generic function underlying the above ones */
345
+ ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd,
346
+ const size_t pwdlen, argon2_type type);
347
+
348
+ /**
349
+ * Argon2d: Version of Argon2 that picks memory blocks depending
350
+ * on the password and salt. Only for side-channel-free
351
+ * environment!!
352
+ *****
353
+ * @param context Pointer to current Argon2 context
354
+ * @return Zero if successful, a non zero error code otherwise
355
+ */
356
+ ARGON2_PUBLIC int argon2d_ctx(argon2_context *context);
357
+
358
+ /**
359
+ * Argon2i: Version of Argon2 that picks memory blocks
360
+ * independent on the password and salt. Good for side-channels,
361
+ * but worse w.r.t. tradeoff attacks if only one pass is used.
362
+ *****
363
+ * @param context Pointer to current Argon2 context
364
+ * @return Zero if successful, a non zero error code otherwise
365
+ */
366
+ ARGON2_PUBLIC int argon2i_ctx(argon2_context *context);
367
+
368
+ /**
369
+ * Argon2id: Version of Argon2 where the first half-pass over memory is
370
+ * password-independent, the rest are password-dependent (on the password and
371
+ * salt). OK against side channels (they reduce to 1/2-pass Argon2i), and
372
+ * better with w.r.t. tradeoff attacks (similar to Argon2d).
373
+ *****
374
+ * @param context Pointer to current Argon2 context
375
+ * @return Zero if successful, a non zero error code otherwise
376
+ */
377
+ ARGON2_PUBLIC int argon2id_ctx(argon2_context *context);
378
+
379
+ /**
380
+ * Verify if a given password is correct for Argon2d hashing
381
+ * @param context Pointer to current Argon2 context
382
+ * @param hash The password hash to verify. The length of the hash is
383
+ * specified by the context outlen member
384
+ * @return Zero if successful, a non zero error code otherwise
385
+ */
386
+ ARGON2_PUBLIC int argon2d_verify_ctx(argon2_context *context, const char *hash);
387
+
388
+ /**
389
+ * Verify if a given password is correct for Argon2i hashing
390
+ * @param context Pointer to current Argon2 context
391
+ * @param hash The password hash to verify. The length of the hash is
392
+ * specified by the context outlen member
393
+ * @return Zero if successful, a non zero error code otherwise
394
+ */
395
+ ARGON2_PUBLIC int argon2i_verify_ctx(argon2_context *context, const char *hash);
396
+
397
+ /**
398
+ * Verify if a given password is correct for Argon2id hashing
399
+ * @param context Pointer to current Argon2 context
400
+ * @param hash The password hash to verify. The length of the hash is
401
+ * specified by the context outlen member
402
+ * @return Zero if successful, a non zero error code otherwise
403
+ */
404
+ ARGON2_PUBLIC int argon2id_verify_ctx(argon2_context *context,
405
+ const char *hash);
406
+
407
+ /* generic function underlying the above ones */
408
+ ARGON2_PUBLIC int argon2_verify_ctx(argon2_context *context, const char *hash,
409
+ argon2_type type);
410
+
411
+ /**
412
+ * Get the associated error message for given error code
413
+ * @return The error message associated with the given error code
414
+ */
415
+ ARGON2_PUBLIC const char *argon2_error_message(int error_code);
416
+
417
+ /**
418
+ * Returns the encoded hash length for the given input parameters
419
+ * @param t_cost Number of iterations
420
+ * @param m_cost Memory usage in kibibytes
421
+ * @param parallelism Number of threads; used to compute lanes
422
+ * @param saltlen Salt size in bytes
423
+ * @param hashlen Hash size in bytes
424
+ * @param type The argon2_type that we want the encoded length for
425
+ * @return The encoded hash length in bytes
426
+ */
427
+ ARGON2_PUBLIC size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost,
428
+ uint32_t parallelism, uint32_t saltlen,
429
+ uint32_t hashlen, argon2_type type);
430
+
431
+ #if defined(__cplusplus)
432
+ }
433
+ #endif
434
+
435
+ #endif