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,39 @@
1
+ module Enzoic
2
+ class ArgonHashFail < StandardError; end
3
+ ERRORS = %w(
4
+ ARGON2_OK
5
+ ARGON2_OUTPUT_PTR_NULL
6
+ ARGON2_OUTPUT_TOO_SHORT
7
+ ARGON2_OUTPUT_TOO_LONG
8
+ ARGON2_PWD_TOO_SHORT
9
+ ARGON2_PWD_TOO_LONG
10
+ ARGON2_SALT_TOO_SHORT
11
+ ARGON2_SALT_TOO_LONG
12
+ ARGON2_AD_TOO_SHORT
13
+ ARGON2_AD_TOO_LONG
14
+ ARGON2_SECRET_TOO_SHORT
15
+ ARGON2_SECRET_TOO_LONG
16
+ ARGON2_TIME_TOO_SMALL
17
+ ARGON2_TIME_TOO_LARGE
18
+ ARGON2_MEMORY_TOO_LITTLE
19
+ ARGON2_MEMORY_TOO_MUCH
20
+ ARGON2_LANES_TOO_FEW
21
+ ARGON2_LANES_TOO_MANY
22
+ ARGON2_PWD_PTR_MISMATCH
23
+ ARGON2_SALT_PTR_MISMATCH
24
+ ARGON2_SECRET_PTR_MISMATCH
25
+ ARGON2_AD_PTR_MISMATCH
26
+ ARGON2_MEMORY_ALLOCATION_ERROR
27
+ ARGON2_FREE_MEMORY_CBK_NULL
28
+ ARGON2_ALLOCATE_MEMORY_CBK_NULL
29
+ ARGON2_INCORRECT_PARAMETER
30
+ ARGON2_INCORRECT_TYPE
31
+ ARGON2_OUT_PTR_MISMATCH
32
+ ARGON2_THREADS_TOO_FEW
33
+ ARGON2_THREADS_TOO_MANY
34
+ ARGON2_MISSING_ARGS
35
+ ARGON2_ENCODING_FAIL
36
+ ARGON2_DECODING_FAIL
37
+ ARGON2_THREAD_FAIL
38
+ ).freeze
39
+ end
@@ -0,0 +1,89 @@
1
+ require 'ffi'
2
+ require 'ffi-compiler/loader'
3
+
4
+ module Enzoic
5
+
6
+ # Import of argon2 wrapper library
7
+ module Ext
8
+ extend FFI::Library
9
+ ffi_lib FFI::Compiler::Loader.find('argon2-wrapper')
10
+
11
+ # int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
12
+ # const uint32_t parallelism, const void *pwd,
13
+ # const size_t pwdlen, const void *salt,
14
+ # const size_t saltlen, void *hash, const size_t hashlen);
15
+
16
+ attach_function :argon2i_hash_raw, [
17
+ :uint, :uint, :uint, :pointer,
18
+ :size_t, :pointer, :size_t, :pointer, :size_t], :int, :blocking => true
19
+
20
+ attach_function :argon2i_hash_encoded, [
21
+ :uint, :uint, :uint, :pointer,
22
+ :size_t, :pointer, :size_t, :size_t, :pointer, :size_t], :int, :blocking => true
23
+
24
+ # int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
25
+ # const uint32_t parallelism, const void *pwd,
26
+ # const size_t pwdlen, const void *salt,
27
+ # const size_t saltlen, void *hash, const size_t hashlen);
28
+
29
+ attach_function :argon2d_hash_raw, [
30
+ :uint, :uint, :uint, :pointer,
31
+ :size_t, :pointer, :size_t, :pointer, :size_t], :int, :blocking => true
32
+
33
+ attach_function :argon2d_hash_encoded, [
34
+ :uint, :uint, :uint, :pointer,
35
+ :size_t, :pointer, :size_t, :size_t, :pointer, :size_t], :int, :blocking => true
36
+ end
37
+
38
+ # The engine class shields users from the FFI interface.
39
+ # It is generally not advised to directly use this class.
40
+ class Argon2Wrapper
41
+ def self.hash_argon2i(password, salt, t_cost, m_cost, lanes, hash_length)
42
+ result = ''
43
+ FFI::MemoryPointer.new(:char, hash_length) do |buffer|
44
+ ret = Ext.argon2i_hash_raw(t_cost, 1 << m_cost, lanes, password,
45
+ password.length, salt, salt.length,
46
+ buffer, hash_length)
47
+ raise ArgonHashFail, ERRORS[ret.abs] unless ret.zero?
48
+ result = buffer.read_string(hash_length)
49
+ end
50
+ result.unpack('H*').join
51
+ end
52
+
53
+ def self.hash_argon2i_encode(password, salt, t_cost, m_cost, lanes, hash_length)
54
+ result = ''
55
+ FFI::MemoryPointer.new(:char, 96 + salt.length) do |buffer|
56
+ ret = Ext.argon2i_hash_encoded(t_cost, 1 << m_cost, lanes, password,
57
+ password.length, salt, salt.length,
58
+ hash_length, buffer, 96 + salt.length)
59
+ raise ArgonHashFail, ERRORS[ret.abs] unless ret.zero?
60
+ result = buffer.read_string(96 + salt.length)
61
+ end
62
+ result.delete "\0"
63
+ end
64
+
65
+ def self.hash_argon2d(password, salt, t_cost, m_cost, lanes, hash_length)
66
+ result = ''
67
+ FFI::MemoryPointer.new(:char, hash_length) do |buffer|
68
+ ret = Ext.argon2d_hash_raw(t_cost, 1 << m_cost, lanes, password,
69
+ password.length, salt, salt.length,
70
+ buffer, hash_length)
71
+ raise ArgonHashFail, ERRORS[ret.abs] unless ret.zero?
72
+ result = buffer.read_string(hash_length)
73
+ end
74
+ result.unpack('H*').join
75
+ end
76
+
77
+ def self.hash_argon2d_encode(password, salt, t_cost, m_cost, lanes, hash_length)
78
+ result = ''
79
+ FFI::MemoryPointer.new(:char, 96 + salt.length) do |buffer|
80
+ ret = Ext.argon2d_hash_encoded(t_cost, 1 << m_cost, lanes, password,
81
+ password.length, salt, salt.length,
82
+ hash_length, buffer, 96 + salt.length)
83
+ raise ArgonHashFail, ERRORS[ret.abs] unless ret.zero?
84
+ result = buffer.read_string(96 + salt.length)
85
+ end
86
+ result.delete "\0"
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,10 @@
1
+ module Enzoic
2
+ # Constants utilized by the Enzoic module
3
+ module Constants
4
+ CREDENTIALS_API_PATH = "/credentials"
5
+ PASSWORDS_API_PATH = "/passwords"
6
+ EXPOSURES_API_PATH = "/exposures"
7
+ ACCOUNTS_API_PATH = "/accounts"
8
+ ALERTS_SERVICE_PATH = "/alert-subscriptions"
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Enzoic
2
+ class EnzoicFail < StandardError; end
3
+ end
@@ -0,0 +1,258 @@
1
+ require 'enzoic/argon2_wrapper_ffi'
2
+ require 'digest'
3
+ require 'bcrypt'
4
+ require 'unix_crypt'
5
+ require 'zlib'
6
+ require 'digest/whirlpool'
7
+ require 'base64url'
8
+
9
+ module Enzoic
10
+ class Hashing
11
+ def self.md5(to_hash)
12
+ return Digest::MD5.hexdigest to_hash
13
+ end
14
+
15
+ def self.md5_binary(to_hash)
16
+ return Digest::MD5.digest(to_hash).bytes
17
+ end
18
+
19
+ def self.md5_binary_array(to_hash_bytes)
20
+ return Digest::MD5.digest(to_hash_bytes.pack('c*')).bytes
21
+ end
22
+
23
+ def self.sha1(to_hash)
24
+ return Digest::SHA1.hexdigest to_hash
25
+ end
26
+
27
+ def self.sha256(to_hash)
28
+ return Digest::SHA256.hexdigest to_hash
29
+ end
30
+
31
+ def self.sha512(to_hash)
32
+ return Digest::SHA512.hexdigest to_hash
33
+ end
34
+
35
+ def self.sha512_binary(to_hash)
36
+ return Digest::SHA512.digest to_hash
37
+ end
38
+
39
+ def self.sha512_binary_array(to_hash)
40
+ return Digest::SHA512.digest(to_hash).bytes
41
+ end
42
+
43
+ def self.whirlpool(to_hash)
44
+ return Digest::Whirlpool.hexdigest(to_hash)
45
+ end
46
+
47
+ def self.whirlpool_binary(to_hash)
48
+ return Digest::Whirlpool.digest(to_hash)
49
+ end
50
+
51
+ def self.whirlpool_binary_array(to_hash)
52
+ return Digest::Whirlpool.digest(to_hash).bytes
53
+ end
54
+
55
+ def self.crc32(to_hash)
56
+ return Zlib.crc32(to_hash, 0).to_s(16)
57
+ end
58
+
59
+ def self.mybb(to_hash, salt)
60
+ return self.md5(self.md5(salt) + self.md5(to_hash))
61
+ end
62
+
63
+ def self.vbulletin(to_hash, salt)
64
+ return self.md5(self.md5(to_hash) + salt)
65
+ end
66
+
67
+ def self.bcrypt(to_hash, salt)
68
+ # if salt starts with $2y$, first replace with $2a$
69
+ if salt[0..3] == "$2y$"
70
+ y_variant = true
71
+ checked_salt = "$2a$" + salt[4..-1]
72
+ else
73
+ y_variant = false
74
+ checked_salt = salt
75
+ end
76
+
77
+ result = BCrypt::Engine.hash_secret(to_hash, checked_salt)
78
+
79
+ if y_variant
80
+ # replace with $2y$
81
+ result = "$2y$" + result[4..-1]
82
+ end
83
+
84
+ return result
85
+ end
86
+
87
+ def self.phpbb3(to_hash, salt)
88
+ if !salt.start_with?("$H$")
89
+ return ""
90
+ end
91
+
92
+ itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
93
+ to_hash_bytes = to_hash.bytes
94
+ count = 2**itoa64.index(salt[3])
95
+ justsalt = salt[4..12]
96
+
97
+ hash = self.md5_binary(justsalt + to_hash)
98
+ loop do
99
+ hash = self.md5_binary_array(hash.push(to_hash_bytes).flatten!)
100
+ count = count - 1;
101
+ break if count == 0
102
+ end
103
+
104
+ hashout = ""
105
+ i = 0
106
+ count = 16
107
+ value = 0
108
+
109
+ loop do
110
+ value = hash[i] + (hash[i] < 0 ? 256 : 0)
111
+ i = i + 1
112
+ hashout = hashout + itoa64[value & 63]
113
+ if i < count
114
+ value = value | (hash[i] + (hash[i] < 0 ? 256 : 0)) << 8;
115
+ end
116
+
117
+ hashout = hashout + itoa64[(value >> 6) & 63]
118
+ i = i + 1
119
+ if (i >= count)
120
+ break
121
+ end
122
+
123
+ if (i < count)
124
+ value = value | (hash[i] + (hash[i] < 0 ? 256 : 0)) << 16
125
+ end
126
+
127
+ hashout = hashout + itoa64[(value >> 12) & 63]
128
+
129
+ i = i + 1
130
+ if (i >= count)
131
+ break
132
+ end
133
+
134
+ hashout = hashout + itoa64[(value >> 18) & 63]
135
+
136
+ break if i == count
137
+ end
138
+
139
+ return salt + hashout
140
+ end
141
+
142
+ def self.custom_algorithm1(to_hash, salt)
143
+ return self.bytes_to_hex(self.xor(self.sha512_binary_array(to_hash + salt), self.whirlpool_binary_array(salt + to_hash)))
144
+ end
145
+
146
+ def self.custom_algorithm2(to_hash, salt)
147
+ return self.md5(to_hash + salt)
148
+ end
149
+
150
+ def self.md5crypt(to_hash, salt)
151
+ return UnixCrypt::MD5.build(to_hash, salt.start_with?("$1$") ? salt[3..salt.length] : salt);
152
+ end
153
+
154
+ def self.custom_algorithm4(to_hash, salt)
155
+ return self.bcrypt(self.md5(to_hash), salt)
156
+ end
157
+
158
+ def self.argon2_raw(to_hash, salt)
159
+ time_cost = 3
160
+ mem_cost = 10
161
+ threads = 2
162
+ hash_length = 20
163
+ just_salt = salt
164
+
165
+ #$argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$RdescudvJCsgt3ub+b+dWRWJTmaaJObG
166
+ if (salt[0..6] == "$argon2")
167
+ # looks like we specified algo info for argon2 in the salt
168
+ salt_values = salt.split("$")
169
+ just_salt = Base64URL.decode(salt_values[4])
170
+ cost_params = salt_values[3].split(",")
171
+
172
+ for param in cost_params
173
+ begin
174
+ param_parts = param.split("=")
175
+ if (param_parts[0] == "t")
176
+ time_cost = Integer(param_parts[1])
177
+ elsif (param_parts[0] == "m")
178
+ mem_cost = Math.log2(Integer(param_parts[1])).round
179
+ elsif (param_parts[0] == "p")
180
+ threads = Integer(param_parts[1])
181
+ elsif (param_parts[0] == "l")
182
+ hash_length = Integer(param_parts[1])
183
+ end
184
+ rescue ArgumentError
185
+ # ignore invalid params and just use default
186
+ end
187
+ end
188
+
189
+ if (salt_values[1] == "argon2i")
190
+ return Argon2Wrapper.hash_argon2i(to_hash, just_salt, time_cost, mem_cost, threads, hash_length)
191
+ else
192
+ return Argon2Wrapper.hash_argon2d(to_hash, just_salt, time_cost, mem_cost, threads, hash_length)
193
+ end
194
+ else
195
+ return Argon2Wrapper.hash_argon2d(to_hash, just_salt, time_cost, mem_cost, threads, hash_length)
196
+ end
197
+ end
198
+
199
+ def self.argon2(to_hash, salt)
200
+ time_cost = 3
201
+ mem_cost = 10
202
+ threads = 2
203
+ hash_length = 20
204
+ just_salt = salt
205
+
206
+ #$argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$RdescudvJCsgt3ub+b+dWRWJTmaaJObG
207
+ if (salt[0..6] == "$argon2")
208
+ # looks like we specified algo info for argon2 in the salt
209
+ salt_values = salt.split("$")
210
+ just_salt = Base64URL.decode(salt_values[4])
211
+ cost_params = salt_values[3].split(",")
212
+
213
+ for param in cost_params
214
+ begin
215
+ param_parts = param.split("=")
216
+ if (param_parts[0] == "t")
217
+ time_cost = Integer(param_parts[1])
218
+ elsif (param_parts[0] == "m")
219
+ mem_cost = Math.log2(Integer(param_parts[1])).round
220
+ elsif (param_parts[0] == "p")
221
+ threads = Integer(param_parts[1])
222
+ elsif (param_parts[0] == "l")
223
+ hash_length = Integer(param_parts[1])
224
+ end
225
+ rescue ArgumentError
226
+ # ignore invalid params and just use default
227
+ end
228
+ end
229
+
230
+ if (salt_values[1] == "argon2i")
231
+ return Argon2Wrapper.hash_argon2i_encode(to_hash, just_salt, time_cost, mem_cost, threads, hash_length)
232
+ else
233
+ return Argon2Wrapper.hash_argon2d_encode(to_hash, just_salt, time_cost, mem_cost, threads, hash_length)
234
+ end
235
+ else
236
+ return Argon2Wrapper.hash_argon2d_encode(to_hash, just_salt, time_cost, mem_cost, threads, hash_length)
237
+ end
238
+ end
239
+
240
+ def self.xor(byte_array1, byte_array2)
241
+ result = Array.new(byte_array1.length);
242
+
243
+ for i in 0..byte_array1.length - 1 do
244
+ result[i] = byte_array1[i] ^ byte_array2[i];
245
+ end
246
+
247
+ return result;
248
+ end
249
+
250
+ def self.bytes_to_hex(bytes)
251
+ return bytes.pack('c*').unpack('H*')[0]
252
+ end
253
+
254
+ def self.hex_to_bytes(hex)
255
+ hex.scan(/../).map { |x| x.hex }.pack('c*')
256
+ end
257
+ end
258
+ end
@@ -0,0 +1,25 @@
1
+ module Enzoic
2
+ # Constants utilized by the Enzoic module
3
+ module PasswordType
4
+ Plaintext = 0
5
+ MD5 = 1
6
+ SHA1 = 2
7
+ SHA256 = 3
8
+ TripleDES = 4
9
+ IPBoard_MyBB = 5
10
+ VBulletinPre3_8_5 = 6
11
+ VBulletinPost3_8_5 = 7
12
+ BCrypt = 8
13
+ CRC32 = 9
14
+ PHPBB3 = 10
15
+ CustomAlgorithm1 = 11
16
+ SCrypt = 12
17
+ CustomAlgorithm2 = 13
18
+ SHA512 = 14
19
+ MD5Crypt = 16
20
+ CustomAlgorithm4 = 17
21
+ Unknown = 97
22
+ UnusablePassword = 98
23
+ None = 99
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # Standard Gem version constant.
3
+ module Enzoic
4
+ VERSION = "1.0.3".freeze
5
+ end
metadata ADDED
@@ -0,0 +1,354 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: enzoic
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Enzoic
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.11.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.11.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: ffi-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.0.2
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '2.0'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.0.2
61
+ - !ruby/object:Gem::Dependency
62
+ name: bcrypt
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.1'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.1.11
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '3.1'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 3.1.11
81
+ - !ruby/object:Gem::Dependency
82
+ name: unix-crypt
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.3'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '1.3'
95
+ - !ruby/object:Gem::Dependency
96
+ name: base64url
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '1.0'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 1.0.1
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '1.0'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 1.0.1
115
+ - !ruby/object:Gem::Dependency
116
+ name: bundler
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: 2.0.2
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 2.0.2
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 2.0.2
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 2.0.2
135
+ - !ruby/object:Gem::Dependency
136
+ name: rake
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '10.4'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 10.4.2
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '10.4'
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 10.4.2
155
+ - !ruby/object:Gem::Dependency
156
+ name: test-unit
157
+ requirement: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - "~>"
160
+ - !ruby/object:Gem::Version
161
+ version: '3.2'
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: 3.2.4
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: '3.2'
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: 3.2.4
175
+ - !ruby/object:Gem::Dependency
176
+ name: rake-compiler
177
+ requirement: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '1.0'
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: 1.0.4
185
+ type: :development
186
+ prerelease: false
187
+ version_requirements: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - "~>"
190
+ - !ruby/object:Gem::Version
191
+ version: '1.0'
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 1.0.4
195
+ - !ruby/object:Gem::Dependency
196
+ name: io-console
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '0.4'
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: 0.4.6
205
+ type: :development
206
+ prerelease: false
207
+ version_requirements: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - "~>"
210
+ - !ruby/object:Gem::Version
211
+ version: '0.4'
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: 0.4.6
215
+ description: Ruby library for Enzoic API
216
+ email:
217
+ - support@enzoic.com
218
+ executables: []
219
+ extensions:
220
+ - ext/argon2-wrapper/extconf.rb
221
+ - ext/digest/whirlpool/extconf.rb
222
+ extra_rdoc_files: []
223
+ files:
224
+ - ".gitignore"
225
+ - ".gitmodules"
226
+ - ".travis.yml"
227
+ - Gemfile
228
+ - LICENSE
229
+ - README.md
230
+ - Rakefile
231
+ - enzoic.gemspec
232
+ - ext/.DS_Store
233
+ - ext/argon2-wrapper/Makefile
234
+ - ext/argon2-wrapper/argon2-wrapper.c
235
+ - ext/argon2-wrapper/extconf.rb
236
+ - ext/argon2_import/.DS_Store
237
+ - ext/digest/whirlpool/extconf.rb
238
+ - ext/digest/whirlpool/whirlpool-algorithm.c
239
+ - ext/digest/whirlpool/whirlpool-algorithm.h
240
+ - ext/digest/whirlpool/whirlpool-constants.h
241
+ - ext/digest/whirlpool/whirlpool-portability.h
242
+ - ext/digest/whirlpool/whirlpool.c
243
+ - ext/phc-winner-argon2/.DS_Store
244
+ - ext/phc-winner-argon2/.git
245
+ - ext/phc-winner-argon2/.gitattributes
246
+ - ext/phc-winner-argon2/.gitignore
247
+ - ext/phc-winner-argon2/.travis.yml
248
+ - ext/phc-winner-argon2/Argon2.sln
249
+ - ext/phc-winner-argon2/CHANGELOG.md
250
+ - ext/phc-winner-argon2/LICENSE
251
+ - ext/phc-winner-argon2/Makefile
252
+ - ext/phc-winner-argon2/README.md
253
+ - ext/phc-winner-argon2/appveyor.yml
254
+ - ext/phc-winner-argon2/argon2-specs.pdf
255
+ - ext/phc-winner-argon2/export.sh
256
+ - ext/phc-winner-argon2/include/argon2.h
257
+ - ext/phc-winner-argon2/kats/argon2d
258
+ - ext/phc-winner-argon2/kats/argon2d.shasum
259
+ - ext/phc-winner-argon2/kats/argon2d_v16
260
+ - ext/phc-winner-argon2/kats/argon2d_v16.shasum
261
+ - ext/phc-winner-argon2/kats/argon2i
262
+ - ext/phc-winner-argon2/kats/argon2i.shasum
263
+ - ext/phc-winner-argon2/kats/argon2i_v16
264
+ - ext/phc-winner-argon2/kats/argon2i_v16.shasum
265
+ - ext/phc-winner-argon2/kats/argon2id
266
+ - ext/phc-winner-argon2/kats/argon2id.shasum
267
+ - ext/phc-winner-argon2/kats/argon2id_v16
268
+ - ext/phc-winner-argon2/kats/argon2id_v16.shasum
269
+ - ext/phc-winner-argon2/kats/check-sums.ps1
270
+ - ext/phc-winner-argon2/kats/check-sums.sh
271
+ - ext/phc-winner-argon2/kats/test.ps1
272
+ - ext/phc-winner-argon2/kats/test.sh
273
+ - ext/phc-winner-argon2/latex/IEEEtran.cls
274
+ - ext/phc-winner-argon2/latex/Makefile
275
+ - ext/phc-winner-argon2/latex/argon2-specs.tex
276
+ - ext/phc-winner-argon2/latex/pics/argon2-par.pdf
277
+ - ext/phc-winner-argon2/latex/pics/compression.pdf
278
+ - ext/phc-winner-argon2/latex/pics/generic.pdf
279
+ - ext/phc-winner-argon2/latex/pics/power-distribution.jpg
280
+ - ext/phc-winner-argon2/latex/tradeoff.bib
281
+ - ext/phc-winner-argon2/libargon2.pc
282
+ - ext/phc-winner-argon2/man/argon2.1
283
+ - ext/phc-winner-argon2/src/argon2.c
284
+ - ext/phc-winner-argon2/src/bench.c
285
+ - ext/phc-winner-argon2/src/blake2/blake2-impl.h
286
+ - ext/phc-winner-argon2/src/blake2/blake2.h
287
+ - ext/phc-winner-argon2/src/blake2/blake2b.c
288
+ - ext/phc-winner-argon2/src/blake2/blamka-round-opt.h
289
+ - ext/phc-winner-argon2/src/blake2/blamka-round-ref.h
290
+ - ext/phc-winner-argon2/src/core.c
291
+ - ext/phc-winner-argon2/src/core.h
292
+ - ext/phc-winner-argon2/src/encoding.c
293
+ - ext/phc-winner-argon2/src/encoding.h
294
+ - ext/phc-winner-argon2/src/genkat.c
295
+ - ext/phc-winner-argon2/src/genkat.h
296
+ - ext/phc-winner-argon2/src/opt.c
297
+ - ext/phc-winner-argon2/src/ref.c
298
+ - ext/phc-winner-argon2/src/run.c
299
+ - ext/phc-winner-argon2/src/test.c
300
+ - ext/phc-winner-argon2/src/thread.c
301
+ - ext/phc-winner-argon2/src/thread.h
302
+ - ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj
303
+ - ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj.filters
304
+ - ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj
305
+ - ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj.filters
306
+ - ext/phc-winner-argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj
307
+ - ext/phc-winner-argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj.filters
308
+ - ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj
309
+ - ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj.filters
310
+ - ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj
311
+ - ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj.filters
312
+ - ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj
313
+ - ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj.filters
314
+ - ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj
315
+ - ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj.filters
316
+ - ext/phc-winner-argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj
317
+ - ext/phc-winner-argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj.filters
318
+ - ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj
319
+ - ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj.filters
320
+ - ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj
321
+ - ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj.filters
322
+ - lib/enzoic.rb
323
+ - lib/enzoic/argon2_errors.rb
324
+ - lib/enzoic/argon2_wrapper_ffi.rb
325
+ - lib/enzoic/constants.rb
326
+ - lib/enzoic/errors.rb
327
+ - lib/enzoic/hashing.rb
328
+ - lib/enzoic/password_type.rb
329
+ - lib/enzoic/version.rb
330
+ homepage: https://github.com/enzoic/enzoic-ruby-client
331
+ licenses:
332
+ - MIT
333
+ metadata: {}
334
+ post_install_message:
335
+ rdoc_options: []
336
+ require_paths:
337
+ - lib
338
+ required_ruby_version: !ruby/object:Gem::Requirement
339
+ requirements:
340
+ - - ">="
341
+ - !ruby/object:Gem::Version
342
+ version: '0'
343
+ required_rubygems_version: !ruby/object:Gem::Requirement
344
+ requirements:
345
+ - - ">="
346
+ - !ruby/object:Gem::Version
347
+ version: '0'
348
+ requirements: []
349
+ rubyforge_project:
350
+ rubygems_version: 2.5.2.3
351
+ signing_key:
352
+ specification_version: 4
353
+ summary: Ruby library for Enzoic API
354
+ test_files: []