argon2 2.0.0 → 2.1.0

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +70 -0
  3. data/.rubocop.yml +178 -5
  4. data/Changelog.md +10 -0
  5. data/Gemfile +2 -0
  6. data/README.md +29 -17
  7. data/Rakefile +2 -0
  8. data/Steepfile +16 -0
  9. data/argon2.gemspec +13 -7
  10. data/bin/console +5 -4
  11. data/bin/setup +6 -2
  12. data/bin/test +10 -0
  13. data/ext/argon2_wrap/argon_wrap.c +6 -0
  14. data/ext/argon2_wrap/extconf.rb +1 -0
  15. data/ext/argon2_wrap/libargon2_wrap.so +0 -0
  16. data/ext/argon2_wrap/test.c +0 -1
  17. data/ext/phc-winner-argon2/.gitignore +1 -0
  18. data/ext/phc-winner-argon2/Argon2.sln +2 -4
  19. data/ext/phc-winner-argon2/LICENSE +2 -2
  20. data/ext/phc-winner-argon2/Makefile +86 -18
  21. data/ext/phc-winner-argon2/README.md +3 -1
  22. data/ext/phc-winner-argon2/include/argon2.h +3 -3
  23. data/ext/phc-winner-argon2/libargon2.pc.in +18 -0
  24. data/ext/phc-winner-argon2/src/argon2.c +2 -2
  25. data/ext/phc-winner-argon2/src/bench.c +4 -4
  26. data/ext/phc-winner-argon2/src/blake2/blake2-impl.h +3 -3
  27. data/ext/phc-winner-argon2/src/blake2/blake2.h +2 -2
  28. data/ext/phc-winner-argon2/src/blake2/blake2b.c +2 -2
  29. data/ext/phc-winner-argon2/src/blake2/blamka-round-opt.h +2 -2
  30. data/ext/phc-winner-argon2/src/blake2/blamka-round-ref.h +2 -2
  31. data/ext/phc-winner-argon2/src/core.c +20 -6
  32. data/ext/phc-winner-argon2/src/core.h +2 -2
  33. data/ext/phc-winner-argon2/src/encoding.c +2 -2
  34. data/ext/phc-winner-argon2/src/encoding.h +2 -2
  35. data/ext/phc-winner-argon2/src/genkat.c +9 -3
  36. data/ext/phc-winner-argon2/src/genkat.h +2 -2
  37. data/ext/phc-winner-argon2/src/opt.c +2 -2
  38. data/ext/phc-winner-argon2/src/ref.c +2 -2
  39. data/ext/phc-winner-argon2/src/run.c +2 -2
  40. data/ext/phc-winner-argon2/src/test.c +2 -2
  41. data/ext/phc-winner-argon2/src/thread.c +2 -2
  42. data/ext/phc-winner-argon2/src/thread.h +2 -2
  43. data/ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +11 -6
  44. data/ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +11 -6
  45. data/ext/phc-winner-argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj +11 -6
  46. data/ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +11 -6
  47. data/ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +16 -8
  48. data/ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +25 -8
  49. data/ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +11 -6
  50. data/ext/phc-winner-argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj +11 -6
  51. data/ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +11 -6
  52. data/ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +11 -6
  53. data/lib/argon2/ffi_engine.rb +49 -17
  54. data/lib/argon2/hash_format.rb +49 -0
  55. data/lib/argon2/version.rb +1 -1
  56. data/lib/argon2.rb +19 -8
  57. data/sig/argon2.rbs +16 -0
  58. data/sig/constants.rbs +8 -0
  59. data/sig/version.rbs +4 -0
  60. metadata +59 -39
  61. data/.travis.yml +0 -14
  62. data/ext/argon2_wrap/tests +0 -0
  63. data/ext/phc-winner-argon2/libargon2.pc +0 -16
@@ -8,8 +8,8 @@
8
8
  # License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  # these licenses can be found at:
10
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
11
+ # - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ # - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  #
14
14
  # You should have received a copy of both of these licenses along with this
15
15
  # software. If not, they may be obtained at the above URLs.
@@ -18,6 +18,13 @@
18
18
  RUN = argon2
19
19
  BENCH = bench
20
20
  GENKAT = genkat
21
+ ARGON2_VERSION ?= ZERO
22
+
23
+ # installation parameters for staging area and final installation path
24
+ # Note; if Linux and not Debian/Ubuntu version also add lib override to make command-line
25
+ # for RedHat/Fedora, add: LIBRARY_REL=lib64
26
+ DESTDIR ?=
27
+ PREFIX ?= /usr
21
28
 
22
29
  # Increment on an ABI breaking change
23
30
  ABI_VERSION = 1
@@ -56,40 +63,51 @@ endif
56
63
 
57
64
  BUILD_PATH := $(shell pwd)
58
65
  KERNEL_NAME := $(shell uname -s)
66
+ MACHINE_NAME := $(shell uname -m)
67
+
68
+ LIB_NAME = argon2
69
+ PC_NAME = lib$(LIB_NAME).pc
70
+ PC_SRC = $(PC_NAME).in
59
71
 
60
- LIB_NAME=argon2
61
72
  ifeq ($(KERNEL_NAME), Linux)
62
73
  LIB_EXT := so.$(ABI_VERSION)
63
74
  LIB_CFLAGS := -shared -fPIC -fvisibility=hidden -DA2_VISCTL=1
64
75
  SO_LDFLAGS := -Wl,-soname,lib$(LIB_NAME).$(LIB_EXT)
65
76
  LINKED_LIB_EXT := so
77
+ PC_EXTRA_LIBS ?= -lrt -ldl
66
78
  endif
67
- ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),FreeBSD NetBSD OpenBSD))
79
+ ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),DragonFly FreeBSD NetBSD OpenBSD))
68
80
  LIB_EXT := so
69
81
  LIB_CFLAGS := -shared -fPIC
82
+ PC_EXTRA_LIBS ?=
70
83
  endif
71
84
  ifeq ($(KERNEL_NAME), Darwin)
72
85
  LIB_EXT := $(ABI_VERSION).dylib
73
86
  LIB_CFLAGS := -dynamiclib -install_name @rpath/lib$(LIB_NAME).$(LIB_EXT)
74
87
  LINKED_LIB_EXT := dylib
88
+ PC_EXTRA_LIBS ?=
75
89
  endif
76
90
  ifeq ($(findstring CYGWIN, $(KERNEL_NAME)), CYGWIN)
77
91
  LIB_EXT := dll
78
92
  LIB_CFLAGS := -shared -Wl,--out-implib,lib$(LIB_NAME).$(LIB_EXT).a
93
+ PC_EXTRA_LIBS ?=
79
94
  endif
80
95
  ifeq ($(findstring MINGW, $(KERNEL_NAME)), MINGW)
81
96
  LIB_EXT := dll
82
97
  LIB_CFLAGS := -shared -Wl,--out-implib,lib$(LIB_NAME).$(LIB_EXT).a
98
+ PC_EXTRA_LIBS ?=
83
99
  endif
84
100
  ifeq ($(findstring MSYS, $(KERNEL_NAME)), MSYS)
85
101
  LIB_EXT := dll
86
102
  LIB_CFLAGS := -shared -Wl,--out-implib,lib$(LIB_NAME).$(LIB_EXT).a
103
+ PC_EXTRA_LIBS ?=
87
104
  endif
88
105
  ifeq ($(KERNEL_NAME), SunOS)
89
106
  CC := gcc
90
107
  CFLAGS += -D_REENTRANT
91
108
  LIB_EXT := so
92
109
  LIB_CFLAGS := -shared -fPIC
110
+ PC_EXTRA_LIBS ?=
93
111
  endif
94
112
 
95
113
  ifeq ($(KERNEL_NAME), Linux)
@@ -105,26 +123,53 @@ ifdef LINKED_LIB_EXT
105
123
  LINKED_LIB_SH := lib$(LIB_NAME).$(LINKED_LIB_EXT)
106
124
  endif
107
125
 
126
+ # Some systems don't provide an unprefixed ar when cross-compiling.
127
+ AR=ar
108
128
 
109
129
  LIBRARIES = $(LIB_SH) $(LIB_ST)
110
130
  HEADERS = include/argon2.h
111
131
 
112
132
  INSTALL = install
113
133
 
114
- DESTDIR =
115
- PREFIX = /usr
116
- INCLUDE_REL = include
117
- LIBRARY_REL = lib
118
- BINARY_REL = bin
134
+ # relative paths for different OS
135
+ ifeq ($(KERNEL_NAME), $(filter $(KERNEL_NAME),DragonFly FreeBSD))
136
+
137
+ # default for FreeBSD
138
+ BINARY_REL ?= bin
139
+ INCLUDE_REL ?= include
140
+ LIBRARY_REL ?= lib
141
+ PKGCONFIG_REL ?= libdata
142
+
143
+ else ifeq ($(KERNEL_NAME)-$(MACHINE_NAME), Linux-x86_64)
144
+
145
+ # default for Debian/Ubuntu x86_64
146
+ BINARY_REL ?= bin
147
+ INCLUDE_REL ?= include
148
+ LIBRARY_REL ?= lib/x86_64-linux-gnu
149
+ PKGCONFIG_REL ?= $(LIBRARY_REL)
150
+
151
+ else
152
+
153
+ # NetBSD, ... and Linux64/Linux32 variants that use plain lib directory
154
+ BINARY_REL ?= bin
155
+ INCLUDE_REL ?= include
156
+ LIBRARY_REL ?= lib
157
+ PKGCONFIG_REL ?= $(LIBRARY_REL)
158
+
159
+ endif
119
160
 
161
+ # absolute paths to staging area
120
162
  INST_INCLUDE = $(DESTDIR)$(PREFIX)/$(INCLUDE_REL)
121
163
  INST_LIBRARY = $(DESTDIR)$(PREFIX)/$(LIBRARY_REL)
122
164
  INST_BINARY = $(DESTDIR)$(PREFIX)/$(BINARY_REL)
165
+ INST_PKGCONFIG = $(DESTDIR)$(PREFIX)/$(PKGCONFIG_REL)/pkgconfig
123
166
 
124
- .PHONY: clean dist format $(GENKAT) all install
125
-
167
+ # main target
168
+ .PHONY: all
126
169
  all: $(RUN) libs
127
- libs: $(LIBRARIES)
170
+
171
+ .PHONY: libs
172
+ libs: $(LIBRARIES) $(PC_NAME)
128
173
 
129
174
  $(RUN): $(SRC) $(SRC_RUN)
130
175
  $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
@@ -139,49 +184,72 @@ $(LIB_SH): $(SRC)
139
184
  $(CC) $(CFLAGS) $(LIB_CFLAGS) $(LDFLAGS) $(SO_LDFLAGS) $^ -o $@
140
185
 
141
186
  $(LIB_ST): $(OBJ)
142
- ar rcs $@ $^
187
+ $(AR) rcs $@ $^
143
188
 
189
+ .PHONY: clean
144
190
  clean:
145
- rm -f $(RUN) $(BENCH) $(GENKAT)
146
- rm -f $(LIB_SH) $(LIB_ST) kat-argon2*
191
+ rm -f '$(RUN)' '$(BENCH)' '$(GENKAT)'
192
+ rm -f '$(LIB_SH)' '$(LIB_ST)' kat-argon2* '$(PC_NAME)'
147
193
  rm -f testcase
148
194
  rm -rf *.dSYM
149
195
  cd src/ && rm -f *.o
150
196
  cd src/blake2/ && rm -f *.o
151
197
  cd kats/ && rm -f kat-* diff* run_* make_*
152
198
 
199
+
200
+ # all substitutions to pc template
201
+ SED_COMMANDS = /^\#\#.*$$/d;
202
+ SED_COMMANDS += s\#@PREFIX@\#$(PREFIX)\#g;
203
+ SED_COMMANDS += s\#@EXTRA_LIBS@\#$(PC_EXTRA_LIBS)\#g;
204
+ SED_COMMANDS += s\#@UPSTREAM_VER@\#$(ARGON2_VERSION)\#g;
205
+ SED_COMMANDS += s\#@HOST_MULTIARCH@\#$(LIBRARY_REL)\#g;
206
+ SED_COMMANDS += s\#@INCLUDE@\#$(INCLUDE_REL)\#g;
207
+
208
+ # substitute PREFIX and PC_EXTRA_LIBS into pkgconfig pc file
209
+ $(PC_NAME): $(PC_SRC)
210
+ sed '$(SED_COMMANDS)' < '$(PC_SRC)' > '$@'
211
+
212
+
213
+ .PHONY: dist
153
214
  dist:
154
215
  cd ..; \
155
216
  tar -c --exclude='.??*' -z -f $(DIST)-`date "+%Y%m%d"`.tgz $(DIST)/*
156
217
 
218
+ .PHONY: test
157
219
  test: $(SRC) src/test.c
158
220
  $(CC) $(CFLAGS) -Wextra -Wno-type-limits $^ -o testcase
159
221
  @sh kats/test.sh
160
222
  ./testcase
161
223
 
224
+ .PHONY: testci
162
225
  testci: $(SRC) src/test.c
163
226
  $(CC) $(CI_CFLAGS) $^ -o testcase
164
227
  @sh kats/test.sh
165
228
  ./testcase
166
229
 
167
- .PHONY: test
168
230
 
231
+ .PHONY: format
169
232
  format:
170
233
  clang-format -style="{BasedOnStyle: llvm, IndentWidth: 4}" \
171
234
  -i include/*.h src/*.c src/*.h src/blake2/*.c src/blake2/*.h
172
235
 
236
+ .PHONY: install
173
237
  install: $(RUN) libs
174
238
  $(INSTALL) -d $(INST_INCLUDE)
175
239
  $(INSTALL) -m 0644 $(HEADERS) $(INST_INCLUDE)
176
240
  $(INSTALL) -d $(INST_LIBRARY)
177
- $(INSTALL) $(LIBRARIES) $(INST_LIBRARY)
241
+ $(INSTALL) -m 0644 $(LIBRARIES) $(INST_LIBRARY)
178
242
  ifdef LINKED_LIB_SH
179
- cd $(INST_LIBRARY) && ln -s $(notdir $(LIB_SH) $(LINKED_LIB_SH))
243
+ cd $(INST_LIBRARY) && ln -sf $(notdir $(LIB_SH) $(LINKED_LIB_SH))
180
244
  endif
181
245
  $(INSTALL) -d $(INST_BINARY)
182
246
  $(INSTALL) $(RUN) $(INST_BINARY)
247
+ $(INSTALL) -d $(INST_PKGCONFIG)
248
+ $(INSTALL) -m 0644 $(PC_NAME) $(INST_PKGCONFIG)
183
249
 
250
+ .PHONY: uninstall
184
251
  uninstall:
185
252
  cd $(INST_INCLUDE) && rm -f $(notdir $(HEADERS))
186
253
  cd $(INST_LIBRARY) && rm -f $(notdir $(LIBRARIES) $(LINKED_LIB_SH))
187
254
  cd $(INST_BINARY) && rm -f $(notdir $(RUN))
255
+ cd $(INST_PKG_CONFIG) && rm -f $(notdir $(PC_NAME))
@@ -243,6 +243,7 @@ Argon2i 1 iterations 4096 MiB 4 threads: 2.72 cpb 11124.86 Mcycles
243
243
  Bindings are available for the following languages (make sure to read
244
244
  their documentation):
245
245
 
246
+ * [Android (Java/Kotlin)](https://github.com/lambdapioneer/argon2kt) by [@lambdapioneer](https://github.com/lambdapioneer)
246
247
  * [Elixir](https://github.com/riverrun/argon2_elixir) by [@riverrun](https://github.com/riverrun)
247
248
  * [Erlang](https://github.com/ergenius/eargon2) by [@ergenius](https://github.com/ergenius)
248
249
  * [Go](https://github.com/tvdburgt/go-argon2) by [@tvdburgt](https://github.com/tvdburgt)
@@ -259,6 +260,7 @@ their documentation):
259
260
  * [Python (native)](https://pypi.python.org/pypi/argon2), by [@flamewow](https://github.com/flamewow)
260
261
  * [Python (ffi)](https://pypi.python.org/pypi/argon2_cffi), by [@hynek](https://github.com/hynek)
261
262
  * [Python (ffi, with keyed hashing)](https://github.com/thusoy/porridge), by [@thusoy](https://github.com/thusoy)
263
+ * [Python (ffi, with keyed hashing)](https://github.com/ultrahorizon/pyargon2), by [@ultrahorizon](https://github.com/ultrahorizon)
262
264
  * [R](https://cran.r-project.org/package=argon2) by [@wrathematics](https://github.com/wrathematics)
263
265
  * [Ruby](https://github.com/technion/ruby-argon2) by [@technion](https://github.com/technion)
264
266
  * [Rust](https://github.com/quininer/argon2-rs) by [@quininer](https://github.com/quininer)
@@ -283,7 +285,7 @@ Except for the components listed below, the Argon2 code in this
283
285
  repository is copyright (c) 2015 Daniel Dinu, Dmitry Khovratovich (main
284
286
  authors), Jean-Philippe Aumasson and Samuel Neves, and dual licensed under the
285
287
  [CC0 License](https://creativecommons.org/about/cc0) and the
286
- [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0). For more info
288
+ [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For more info
287
289
  see the LICENSE file.
288
290
 
289
291
  The string encoding routines in [`src/encoding.c`](src/encoding.c) are
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -30,7 +30,7 @@ extern "C" {
30
30
  #ifdef A2_VISCTL
31
31
  #define ARGON2_PUBLIC __attribute__((visibility("default")))
32
32
  #define ARGON2_LOCAL __attribute__ ((visibility ("hidden")))
33
- #elif _MSC_VER
33
+ #elif defined(_MSC_VER)
34
34
  #define ARGON2_PUBLIC __declspec(dllexport)
35
35
  #define ARGON2_LOCAL
36
36
  #else
@@ -0,0 +1,18 @@
1
+ # libargon2 info for pkg-config
2
+ ## Template for downstream installers:
3
+ ## - replace @UPSTREAM_VER@ with current version, e.g. '20160406'
4
+ ## - replace @HOST_MULTIARCH@ with target arch lib, e.g. 'lib', 'lib/x86_64-linux-gnu' or 'lib64'
5
+ ## - replace @PREFIX@ with install path, e.g. '/usr', '/usr/local', '/usr/pkg'
6
+ ## - replace @INCLUDE@ with incluse path, e.g. 'include' or 'include/argon2'
7
+
8
+ prefix=@PREFIX@
9
+ exec_prefix=${prefix}
10
+ libdir=${prefix}/@HOST_MULTIARCH@
11
+ includedir=${prefix}/@INCLUDE@
12
+
13
+ Name: libargon2
14
+ Description: Development libraries for libargon2
15
+ Version: @UPSTREAM_VER@
16
+ Libs: -L${libdir} -largon2 @EXTRA_LIBS@
17
+ Cflags: -I${includedir}
18
+ URL: https://github.com/P-H-C/phc-winner-argon2
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -20,14 +20,14 @@
20
20
  #include <stdlib.h>
21
21
  #include <string.h>
22
22
  #include <time.h>
23
- #ifdef _MSC_VER
23
+ #ifdef _WIN32
24
24
  #include <intrin.h>
25
25
  #endif
26
26
 
27
27
  #include "argon2.h"
28
28
 
29
29
  static uint64_t rdtsc(void) {
30
- #ifdef _MSC_VER
30
+ #ifdef _WIN32
31
31
  return __rdtsc();
32
32
  #else
33
33
  #if defined(__amd64__) || defined(__x86_64__)
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -21,7 +21,7 @@
21
21
  #include <stdint.h>
22
22
  #include <string.h>
23
23
 
24
- #if defined(_MSC_VER)
24
+ #ifdef _WIN32
25
25
  #define BLAKE2_INLINE __inline
26
26
  #elif defined(__GNUC__) || defined(__clang__)
27
27
  #define BLAKE2_INLINE __inline__
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,15 +8,15 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
16
16
  */
17
17
 
18
18
  /*For memory wiping*/
19
- #ifdef _MSC_VER
19
+ #ifdef _WIN32
20
20
  #include <windows.h>
21
21
  #include <winbase.h> /* For SecureZeroMemory */
22
22
  #endif
@@ -25,6 +25,9 @@
25
25
  #endif
26
26
  #define VC_GE_2005(version) (version >= 1400)
27
27
 
28
+ /* for explicit_bzero() on glibc */
29
+ #define _DEFAULT_SOURCE
30
+
28
31
  #include <stdio.h>
29
32
  #include <stdlib.h>
30
33
  #include <string.h>
@@ -120,12 +123,20 @@ void free_memory(const argon2_context *context, uint8_t *memory,
120
123
  }
121
124
  }
122
125
 
126
+ #if defined(__OpenBSD__)
127
+ #define HAVE_EXPLICIT_BZERO 1
128
+ #elif defined(__GLIBC__) && defined(__GLIBC_PREREQ)
129
+ #if __GLIBC_PREREQ(2,25)
130
+ #define HAVE_EXPLICIT_BZERO 1
131
+ #endif
132
+ #endif
133
+
123
134
  void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) {
124
- #if defined(_MSC_VER) && VC_GE_2005(_MSC_VER)
135
+ #if defined(_MSC_VER) && VC_GE_2005(_MSC_VER) || defined(__MINGW32__)
125
136
  SecureZeroMemory(v, n);
126
137
  #elif defined memset_s
127
138
  memset_s(v, n, 0, n);
128
- #elif defined(__OpenBSD__)
139
+ #elif defined(HAVE_EXPLICIT_BZERO)
129
140
  explicit_bzero(v, n);
130
141
  #else
131
142
  static void *(*const volatile memset_sec)(void *, int, size_t) = &memset;
@@ -299,7 +310,7 @@ static int fill_memory_blocks_mt(argon2_instance_t *instance) {
299
310
 
300
311
  for (r = 0; r < instance->passes; ++r) {
301
312
  for (s = 0; s < ARGON2_SYNC_POINTS; ++s) {
302
- uint32_t l;
313
+ uint32_t l, ll;
303
314
 
304
315
  /* 2. Calling threads */
305
316
  for (l = 0; l < instance->lanes; ++l) {
@@ -324,6 +335,9 @@ static int fill_memory_blocks_mt(argon2_instance_t *instance) {
324
335
  sizeof(argon2_position_t));
325
336
  if (argon2_thread_create(&thread[l], &fill_segment_thr,
326
337
  (void *)&thr_data[l])) {
338
+ /* Wait for already running threads */
339
+ for (ll = 0; ll < l; ++ll)
340
+ argon2_thread_join(thread[ll]);
327
341
  rc = ARGON2_THREAD_FAIL;
328
342
  goto fail;
329
343
  }
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -20,6 +20,12 @@
20
20
  #include <string.h>
21
21
  #include "argon2.h"
22
22
  #include "core.h"
23
+ #ifdef __MINGW32__
24
+ #include <inttypes.h>
25
+ #else
26
+ /* Don't use <inttypes.h> (it's not C89) */
27
+ #define PRIx64 "llx"
28
+ #endif
23
29
 
24
30
  void initial_kat(const uint8_t *blockhash, const argon2_context *context,
25
31
  argon2_type type) {
@@ -115,7 +121,7 @@ void internal_kat(const argon2_instance_t *instance, uint32_t pass) {
115
121
  : ARGON2_QWORDS_IN_BLOCK;
116
122
 
117
123
  for (j = 0; j < how_many_words; ++j)
118
- printf("Block %.4u [%3u]: %016llx\n", i, j,
124
+ printf("Block %.4u [%3u]: %016" PRIx64 "\n", i, j,
119
125
  (unsigned long long)instance->memory[i].v[j]);
120
126
  }
121
127
  }
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.
@@ -8,8 +8,8 @@
8
8
  * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9
9
  * these licenses can be found at:
10
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
11
+ * - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
12
+ * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
13
13
  *
14
14
  * You should have received a copy of both of these licenses along with this
15
15
  * software. If not, they may be obtained at the above URLs.