@@ -35,13 +35,15 @@ class hash_base : public object_base {
35
35
C_SHA3_256 = 9 ,
36
36
C_SHA3_384 = 10 ,
37
37
C_SHA3_512 = 11 ,
38
- C_KECCAK256 = 12 ,
39
- C_KECCAK384 = 13 ,
40
- C_KECCAK512 = 14 ,
41
- C_BLAKE2S = 15 ,
42
- C_BLAKE2B = 16 ,
43
- C_BLAKE2SP = 17 ,
44
- C_BLAKE2BP = 18
38
+ C_SHAKE128 = 12 ,
39
+ C_SHAKE256 = 13 ,
40
+ C_KECCAK256 = 14 ,
41
+ C_KECCAK384 = 15 ,
42
+ C_KECCAK512 = 16 ,
43
+ C_BLAKE2S = 17 ,
44
+ C_BLAKE2B = 18 ,
45
+ C_BLAKE2SP = 19 ,
46
+ C_BLAKE2BP = 20
45
47
};
46
48
47
49
public:
@@ -59,6 +61,8 @@ class hash_base : public object_base {
59
61
static result_t sha3_256 (Buffer_base* data, obj_ptr<Digest_base>& retVal);
60
62
static result_t sha3_384 (Buffer_base* data, obj_ptr<Digest_base>& retVal);
61
63
static result_t sha3_512 (Buffer_base* data, obj_ptr<Digest_base>& retVal);
64
+ static result_t shake128 (Buffer_base* data, obj_ptr<Digest_base>& retVal);
65
+ static result_t shake256 (Buffer_base* data, obj_ptr<Digest_base>& retV
8000
al);
62
66
static result_t keccak256 (Buffer_base* data, obj_ptr<Digest_base>& retVal);
63
67
static result_t keccak384 (Buffer_base* data, obj_ptr<Digest_base>& retVal);
64
68
static result_t keccak512 (Buffer_base* data, obj_ptr<Digest_base>& retVal);
@@ -78,6 +82,8 @@ class hash_base : public object_base {
78
82
static result_t hmac_sm3 (PKey_base* pubKey, exlib::string id, Buffer_base* key, Buffer_base* data, obj_ptr<Digest_base>& retVal);
79
83
static result_t hmac_sha3_256 (Buffer_base* key, Buffer_base* data, obj_ptr<Digest_base>& retVal);
80
84
static result_t hmac_sha3_384 (Buffer_base* key, Buffer_base* data, obj_ptr<Digest_base>& retVal);
85
+ static result_t hmac_shake128 (Buffer_base* key, Buffer_base* data, obj_ptr<Digest_base>& retVal);
86
+ static result_t hmac_shake256 (Buffer_base* key, Buffer_base* data, obj_ptr<Digest_base>& retVal);
81
87
static result_t hmac_sha3_512 (Buffer_base* key, Buffer_base* data, obj_ptr<Digest_base>& retVal);
82
88
static result_t hmac_keccak256 (Buffer_base* key, Buffer_base* data, obj_ptr<Digest_base>& retVal);
83
89
static result_t hmac_keccak384 (Buffer_base* key, Buffer_base* data, obj_ptr<Digest_base>& retVal);
@@ -109,6 +115,8 @@ class hash_base : public object_base {
109
115
static void s_static_sha3_256 (const v8::FunctionCallbackInfo<v8::Value>& args);
110
116
static void s_static_sha3_384 (const v8::FunctionCallbackInfo<v8::Value>& args);
111
117
static void s_static_sha3_512 (const v8::FunctionCallbackInfo<v8::Value>& args);
118
+ static void s_static_shake128 (const v8::FunctionCallbackInfo<v8::Value>& args);
119
+ static void s_static_shake256 (const v8::FunctionCallbackInfo<v8::Value>& args);
112
120
static void s_static_keccak256 (const v8::FunctionCallbackInfo<v8::Value>& args);
113
121
static void s_static_keccak384 (const v8::FunctionCallbackInfo<v8::Value>& args);
114
122
static void s_static_keccak512 (const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -127,6 +135,8 @@ class hash_base : public object_base {
127
135
static void s_static_hmac_sm3 (const v8::FunctionCallbackInfo<v8::Value>& args);
128
136
static void s_static_hmac_sha3_256 (const v8::FunctionCallbackInfo<v8::Value>& args);
129
137
static void s_static_hmac_sha3_384 (const v8::FunctionCallbackInfo<v8::Value>& args);
138
+ static void s_static_hmac_shake128 (const v8::FunctionCallbackInfo<v8::Value>& args);
139
+ static void s_static_hmac_shake256 (const v8::FunctionCallbackInfo<v8::Value>& args);
130
140
static void s_static_hmac_sha3_512 (const v8::FunctionCallbackInfo<v8::Value>& args);
131
141
static void s_static_hmac_keccak256 (const v8::FunctionCallbackInfo<v8::Value>& args);
132
142
static void s_static_hmac_keccak384 (const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -158,6 +168,8 @@ inline ClassInfo& hash_base::class_info()
158
168
{ " sha3_256" , s_static_sha3_256, true , false },
159
169
{ " sha3_384" , s_static_sha3_384, true , false },
160
170
{ " sha3_512" , s_static_sha3_512, true , false },
171
+ { " shake128" , s_static_shake128, true , false },
172
+ { " shake256" , s_static_shake256, true , false },
161
173
{ " keccak256" , s_static_keccak256, true , false },
162
174
{ " keccak384" , s_static_keccak384, true , false },
163
175
{ " keccak512" , s_static_keccak512, true , false },
@@ -176,6 +188,8 @@ inline ClassInfo& hash_base::class_info()
176
188
{ " hmac_sm3" , s_static_hmac_sm3, true , false },
177
189
{ " hmac_sha3_256" , s_static_hmac_sha3_256, true , false },
178
190
{ " hmac_sha3_384" , s_static_hmac_sha3_384, true , false },
191
+ { " hmac_shake128" , s_static_hmac_shake128, true , false },
192
+ { " hmac_shake256" , s_static_hmac_shake256, true , false },
179
193
{ " hmac_sha3_512" , s_static_hmac_sha3_512, true , false },
180
194
{ " hmac_keccak256" , s_static_hmac_keccak256, true , false },
181
195
{ " hmac_keccak384" , s_static_hmac_keccak384, true , false },
@@ -198,6 +212,8 @@ inline ClassInfo& hash_base::class_info()
198
212
{ " SHA3_256" , C_SHA3_256 },
199
213
{ " SHA3_384" , C_SHA3_384 },
200
214
{ " SHA3_512" , C_SHA3_512 },
215
+ { " SHAKE128" , C_SHAKE128 },
216
+ { " SHAKE256" , C_SHAKE256 },
201
217
{ " KECCAK256" , C_KECCAK256 },
202
218
{ " KECCAK384" , C_KECCAK384 },
203
219
{ " KECCAK512" , C_KECCAK512 },
@@ -406,6 +422,36 @@ inline void hash_base::s_static_sha3_512(const v8::FunctionCallbackInfo<v8::Valu
406
422
METHOD_RETURN ();
407
423
}
408
424
425
+ inline void hash_base::s_static_shake128 (const v8::FunctionCallbackInfo<v8::Value>& args)
426
+ {
427
+ obj_ptr<Digest_base> vr;
428
+
429
+ METHOD_ENTER ();
430
+
431
+ METHOD_OVER (1 , 0 );
432
+
433
+ OPT_ARG (obj_ptr<Buffer_base>, 0 , NULL );
434
+
435
+ hr = shake128 (v0, vr);
436
+
437
+ METHOD_RETURN ();
438
+ }
439
+
440
+ inline void hash_base::s_static_shake256 (const v8::FunctionCallbackInfo<v8::Value>& args)
441
+ {
442
+ obj_ptr<Digest_base> vr;
443
+
444
+ METHOD_ENTER ();
445
+
446
+ METHOD_OVER (1 , 0 );
447
+
448
+ OPT_ARG (obj_ptr<Buffer_base>, 0 , NULL );
449
+
450
+ hr = shake256 (v0, vr);
451
+
452
+ METHOD_RETURN ();
453
+ }
454
+
409
455
inline void hash_base::s_static_keccak256 (const v8::FunctionCallbackInfo<v8::Value>& args)
410
456
{
411
457
obj_ptr<Digest_base> vr;
@@ -697,6 +743,38 @@ inline void hash_base::s_static_hmac_sha3_384(const v8::FunctionCallbackInfo<v8:
697
743
METHOD_RETURN ();
698
744
}
699
745
746
+ inline void hash_base::s_static_hmac_shake128 (const v8::FunctionCallbackInfo<v8::Value>& args)
747
+ {
748
+ obj_ptr<Digest_base> vr;
749
+
750
+ METHOD_ENTER ();
751
+
752
+ METHOD_OVER (2 , 1 );
753
+
754
+ ARG (obj_ptr<Buffer_base>, 0 );
755
+ OPT_ARG (obj_ptr<Buffer_base>, 1 , NULL );
756
+
757
+ hr = hmac_shake128 (v0, v1, vr);
758
+
759
+ METHOD_RETURN ();
760
+ }
761
+
762
+ inline void hash_base::s_static_hmac_shake256 (const v8::FunctionCallbackInfo<v8::Value>& args)
763
+ {
764
+ obj_ptr<Digest_base> vr;
765
+
766
+ METHOD_ENTER ();
767
+
768
+ METHOD_OVER (2 , 1 );
769
+
770
+ ARG (obj_ptr<Buffer_base>, 0 );
771
+ OPT_ARG (obj_ptr<Buffer_base>, 1 , NULL );
772
+
773
+ hr = hmac_shake256 (v0, v1, vr);
774
+
775
+ METHOD_RETURN ();
776
+ }
777
+
700
778
inline void hash_base::s_static_hmac_sha3_512 (const v8::FunctionCallbackInfo<v8::Value>& args)
701
779
{
702
780
obj_ptr<Digest_base> vr;
0 commit comments