Debian Codegraph @

Modules/clinic/_hashopenssl.c.h

raw
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9 #include "pycore_abstract.h" // _PyNumber_Index()
10 #include "pycore_long.h" // _PyLong_UnsignedLong_Converter()
11 #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
12
13 PyDoc_STRVAR(EVP_copy__doc__,
14 "copy($self, /)\n"
15 "--\n"
16 "\n"
17 "Return a copy of the hash object.");
18
19 #define EVP_COPY_METHODDEF \
20 {"copy", (PyCFunction)EVP_copy, METH_NOARGS, EVP_copy__doc__},
21
22 static PyObject *
23 EVP_copy_impl(EVPobject *self);
24
25 static PyObject *
26 EVP_copy(PyObject *self, PyObject *Py_UNUSED(ignored))
27 {
28 return EVP_copy_impl((EVPobject *)self);
29 }
30
31 PyDoc_STRVAR(EVP_digest__doc__,
32 "digest($self, /)\n"
33 "--\n"
34 "\n"
35 "Return the digest value as a bytes object.");
36
37 #define EVP_DIGEST_METHODDEF \
38 {"digest", (PyCFunction)EVP_digest, METH_NOARGS, EVP_digest__doc__},
39
40 static PyObject *
41 EVP_digest_impl(EVPobject *self);
42
43 static PyObject *
44 EVP_digest(PyObject *self, PyObject *Py_UNUSED(ignored))
45 {
46 return EVP_digest_impl((EVPobject *)self);
47 }
48
49 PyDoc_STRVAR(EVP_hexdigest__doc__,
50 "hexdigest($self, /)\n"
51 "--\n"
52 "\n"
53 "Return the digest value as a string of hexadecimal digits.");
54
55 #define EVP_HEXDIGEST_METHODDEF \
56 {"hexdigest", (PyCFunction)EVP_hexdigest, METH_NOARGS, EVP_hexdigest__doc__},
57
58 static PyObject *
59 EVP_hexdigest_impl(EVPobject *self);
60
61 static PyObject *
62 EVP_hexdigest(PyObject *self, PyObject *Py_UNUSED(ignored))
63 {
64 return EVP_hexdigest_impl((EVPobject *)self);
65 }
66
67 PyDoc_STRVAR(EVP_update__doc__,
68 "update($self, obj, /)\n"
69 "--\n"
70 "\n"
71 "Update this hash object\'s state with the provided string.");
72
73 #define EVP_UPDATE_METHODDEF \
74 {"update", (PyCFunction)EVP_update, METH_O, EVP_update__doc__},
75
76 static PyObject *
77 EVP_update_impl(EVPobject *self, PyObject *obj);
78
79 static PyObject *
80 EVP_update(PyObject *self, PyObject *obj)
81 {
82 PyObject *return_value = NULL;
83
84 return_value = EVP_update_impl((EVPobject *)self, obj);
85
86 return return_value;
87 }
88
89 #if defined(PY_OPENSSL_HAS_SHAKE)
90
91 PyDoc_STRVAR(EVPXOF_digest__doc__,
92 "digest($self, /, length)\n"
93 "--\n"
94 "\n"
95 "Return the digest value as a bytes object.");
96
97 #define EVPXOF_DIGEST_METHODDEF \
98 {"digest", _PyCFunction_CAST(EVPXOF_digest), METH_FASTCALL|METH_KEYWORDS, EVPXOF_digest__doc__},
99
100 static PyObject *
101 EVPXOF_digest_impl(EVPobject *self, Py_ssize_t length);
102
103 static PyObject *
104 EVPXOF_digest(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
105 {
106 PyObject *return_value = NULL;
107 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
108
109 #define NUM_KEYWORDS 1
110 static struct {
111 PyGC_Head _this_is_not_used;
112 PyObject_VAR_HEAD
113 Py_hash_t ob_hash;
114 PyObject *ob_item[NUM_KEYWORDS];
115 } _kwtuple = {
116 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
117 .ob_hash = -1,
118 .ob_item = { &_Py_ID(length), },
119 };
120 #undef NUM_KEYWORDS
121 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
122
123 #else // !Py_BUILD_CORE
124 # define KWTUPLE NULL
125 #endif // !Py_BUILD_CORE
126
127 static const char * const _keywords[] = {"length", NULL};
128 static _PyArg_Parser _parser = {
129 .keywords = _keywords,
130 .fname = "digest",
131 .kwtuple = KWTUPLE,
132 };
133 #undef KWTUPLE
134 PyObject *argsbuf[1];
135 Py_ssize_t length;
136
137 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
138 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
139 if (!args) {
140 goto exit;
141 }
142 {
143 Py_ssize_t ival = -1;
144 PyObject *iobj = _PyNumber_Index(args[0]);
145 if (iobj != NULL) {
146 ival = PyLong_AsSsize_t(iobj);
147 Py_DECREF(iobj);
148 }
149 if (ival == -1 && PyErr_Occurred()) {
150 goto exit;
151 }
152 length = ival;
153 }
154 return_value = EVPXOF_digest_impl((EVPobject *)self, length);
155
156 exit:
157 return return_value;
158 }
159
160 #endif /* defined(PY_OPENSSL_HAS_SHAKE) */
161
162 #if defined(PY_OPENSSL_HAS_SHAKE)
163
164 PyDoc_STRVAR(EVPXOF_hexdigest__doc__,
165 "hexdigest($self, /, length)\n"
166 "--\n"
167 "\n"
168 "Return the digest value as a string of hexadecimal digits.");
169
170 #define EVPXOF_HEXDIGEST_METHODDEF \
171 {"hexdigest", _PyCFunction_CAST(EVPXOF_hexdigest), METH_FASTCALL|METH_KEYWORDS, EVPXOF_hexdigest__doc__},
172
173 static PyObject *
174 EVPXOF_hexdigest_impl(EVPobject *self, Py_ssize_t length);
175
176 static PyObject *
177 EVPXOF_hexdigest(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
178 {
179 PyObject *return_value = NULL;
180 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
181
182 #define NUM_KEYWORDS 1
183 static struct {
184 PyGC_Head _this_is_not_used;
185 PyObject_VAR_HEAD
186 Py_hash_t ob_hash;
187 PyObject *ob_item[NUM_KEYWORDS];
188 } _kwtuple = {
189 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
190 .ob_hash = -1,
191 .ob_item = { &_Py_ID(length), },
192 };
193 #undef NUM_KEYWORDS
194 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
195
196 #else // !Py_BUILD_CORE
197 # define KWTUPLE NULL
198 #endif // !Py_BUILD_CORE
199
200 static const char * const _keywords[] = {"length", NULL};
201 static _PyArg_Parser _parser = {
202 .keywords = _keywords,
203 .fname = "hexdigest",
204 .kwtuple = KWTUPLE,
205 };
206 #undef KWTUPLE
207 PyObject *argsbuf[1];
208 Py_ssize_t length;
209
210 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
211 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
212 if (!args) {
213 goto exit;
214 }
215 {
216 Py_ssize_t ival = -1;
217 PyObject *iobj = _PyNumber_Index(args[0]);
218 if (iobj != NULL) {
219 ival = PyLong_AsSsize_t(iobj);
220 Py_DECREF(iobj);
221 }
222 if (ival == -1 && PyErr_Occurred()) {
223 goto exit;
224 }
225 length = ival;
226 }
227 return_value = EVPXOF_hexdigest_impl((EVPobject *)self, length);
228
229 exit:
230 return return_value;
231 }
232
233 #endif /* defined(PY_OPENSSL_HAS_SHAKE) */
234
235 PyDoc_STRVAR(_hashlib_new__doc__,
236 "new($module, /, name, data=b\'\', *, usedforsecurity=True, string=None)\n"
237 "--\n"
238 "\n"
239 "Return a new hash object using the named algorithm.\n"
240 "\n"
241 "An optional string argument may be provided and will be\n"
242 "automatically hashed.\n"
243 "\n"
244 "The MD5 and SHA1 algorithms are always supported.");
245
246 #define _HASHLIB_NEW_METHODDEF \
247 {"new", _PyCFunction_CAST(_hashlib_new), METH_FASTCALL|METH_KEYWORDS, _hashlib_new__doc__},
248
249 static PyObject *
250 _hashlib_new_impl(PyObject *module, const char *name, PyObject *data,
251 int usedforsecurity, PyObject *string);
252
253 static PyObject *
254 _hashlib_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
255 {
256 PyObject *return_value = NULL;
257 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
258
259 #define NUM_KEYWORDS 4
260 static struct {
261 PyGC_Head _this_is_not_used;
262 PyObject_VAR_HEAD
263 Py_hash_t ob_hash;
264 PyObject *ob_item[NUM_KEYWORDS];
265 } _kwtuple = {
266 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
267 .ob_hash = -1,
268 .ob_item = { &_Py_ID(name), &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
269 };
270 #undef NUM_KEYWORDS
271 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
272
273 #else // !Py_BUILD_CORE
274 # define KWTUPLE NULL
275 #endif // !Py_BUILD_CORE
276
277 static const char * const _keywords[] = {"name", "data", "usedforsecurity", "string", NULL};
278 static _PyArg_Parser _parser = {
279 .keywords = _keywords,
280 .fname = "new",
281 .kwtuple = KWTUPLE,
282 };
283 #undef KWTUPLE
284 PyObject *argsbuf[4];
285 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
286 const char *name;
287 PyObject *data = NULL;
288 int usedforsecurity = 1;
289 PyObject *string = NULL;
290
291 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
292 /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
293 if (!args) {
294 goto exit;
295 }
296 if (!PyUnicode_Check(args[0])) {
297 _PyArg_BadArgument("new", "argument 'name'", "str", args[0]);
298 goto exit;
299 }
300 Py_ssize_t name_length;
301 name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
302 if (name == NULL) {
303 goto exit;
304 }
305 if (strlen(name) != (size_t)name_length) {
306 PyErr_SetString(PyExc_ValueError, "embedded null character");
307 goto exit;
308 }
309 if (!noptargs) {
310 goto skip_optional_pos;
311 }
312 if (args[1]) {
313 data = args[1];
314 if (!--noptargs) {
315 goto skip_optional_pos;
316 }
317 }
318 skip_optional_pos:
319 if (!noptargs) {
320 goto skip_optional_kwonly;
321 }
322 if (args[2]) {
323 usedforsecurity = PyObject_IsTrue(args[2]);
324 if (usedforsecurity < 0) {
325 goto exit;
326 }
327 if (!--noptargs) {
328 goto skip_optional_kwonly;
329 }
330 }
331 string = args[3];
332 skip_optional_kwonly:
333 return_value = _hashlib_new_impl(module, name, data, usedforsecurity, string);
334
335 exit:
336 return return_value;
337 }
338
339 PyDoc_STRVAR(_hashlib_openssl_md5__doc__,
340 "openssl_md5($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n"
341 "--\n"
342 "\n"
343 "Returns a md5 hash object; optionally initialized with a string");
344
345 #define _HASHLIB_OPENSSL_MD5_METHODDEF \
346 {"openssl_md5", _PyCFunction_CAST(_hashlib_openssl_md5), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_md5__doc__},
347
348 static PyObject *
349 _hashlib_openssl_md5_impl(PyObject *module, PyObject *data,
350 int usedforsecurity, PyObject *string);
351
352 static PyObject *
353 _hashlib_openssl_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
354 {
355 PyObject *return_value = NULL;
356 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
357
358 #define NUM_KEYWORDS 3
359 static struct {
360 PyGC_Head _this_is_not_used;
361 PyObject_VAR_HEAD
362 Py_hash_t ob_hash;
363 PyObject *ob_item[NUM_KEYWORDS];
364 } _kwtuple = {
365 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
366 .ob_hash = -1,
367 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
368 };
369 #undef NUM_KEYWORDS
370 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
371
372 #else // !Py_BUILD_CORE
373 # define KWTUPLE NULL
374 #endif // !Py_BUILD_CORE
375
376 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
377 static _PyArg_Parser _parser = {
378 .keywords = _keywords,
379 .fname = "openssl_md5",
380 .kwtuple = KWTUPLE,
381 };
382 #undef KWTUPLE
383 PyObject *argsbuf[3];
384 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
385 PyObject *data = NULL;
386 int usedforsecurity = 1;
387 PyObject *string = NULL;
388
389 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
390 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
391 if (!args) {
392 goto exit;
393 }
394 if (!noptargs) {
395 goto skip_optional_pos;
396 }
397 if (args[0]) {
398 data = args[0];
399 if (!--noptargs) {
400 goto skip_optional_pos;
401 }
402 }
403 skip_optional_pos:
404 if (!noptargs) {
405 goto skip_optional_kwonly;
406 }
407 if (args[1]) {
408 usedforsecurity = PyObject_IsTrue(args[1]);
409 if (usedforsecurity < 0) {
410 goto exit;
411 }
412 if (!--noptargs) {
413 goto skip_optional_kwonly;
414 }
415 }
416 string = args[2];
417 skip_optional_kwonly:
418 return_value = _hashlib_openssl_md5_impl(module, data, usedforsecurity, string);
419
420 exit:
421 return return_value;
422 }
423
424 PyDoc_STRVAR(_hashlib_openssl_sha1__doc__,
425 "openssl_sha1($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n"
426 "--\n"
427 "\n"
428 "Returns a sha1 hash object; optionally initialized with a string");
429
430 #define _HASHLIB_OPENSSL_SHA1_METHODDEF \
431 {"openssl_sha1", _PyCFunction_CAST(_hashlib_openssl_sha1), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha1__doc__},
432
433 static PyObject *
434 _hashlib_openssl_sha1_impl(PyObject *module, PyObject *data,
435 int usedforsecurity, PyObject *string);
436
437 static PyObject *
438 _hashlib_openssl_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
439 {
440 PyObject *return_value = NULL;
441 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
442
443 #define NUM_KEYWORDS 3
444 static struct {
445 PyGC_Head _this_is_not_used;
446 PyObject_VAR_HEAD
447 Py_hash_t ob_hash;
448 PyObject *ob_item[NUM_KEYWORDS];
449 } _kwtuple = {
450 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
451 .ob_hash = -1,
452 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
453 };
454 #undef NUM_KEYWORDS
455 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
456
457 #else // !Py_BUILD_CORE
458 # define KWTUPLE NULL
459 #endif // !Py_BUILD_CORE
460
461 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
462 static _PyArg_Parser _parser = {
463 .keywords = _keywords,
464 .fname = "openssl_sha1",
465 .kwtuple = KWTUPLE,
466 };
467 #undef KWTUPLE
468 PyObject *argsbuf[3];
469 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
470 PyObject *data = NULL;
471 int usedforsecurity = 1;
472 PyObject *string = NULL;
473
474 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
475 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
476 if (!args) {
477 goto exit;
478 }
479 if (!noptargs) {
480 goto skip_optional_pos;
481 }
482 if (args[0]) {
483 data = args[0];
484 if (!--noptargs) {
485 goto skip_optional_pos;
486 }
487 }
488 skip_optional_pos:
489 if (!noptargs) {
490 goto skip_optional_kwonly;
491 }
492 if (args[1]) {
493 usedforsecurity = PyObject_IsTrue(args[1]);
494 if (usedforsecurity < 0) {
495 goto exit;
496 }
497 if (!--noptargs) {
498 goto skip_optional_kwonly;
499 }
500 }
501 string = args[2];
502 skip_optional_kwonly:
503 return_value = _hashlib_openssl_sha1_impl(module, data, usedforsecurity, string);
504
505 exit:
506 return return_value;
507 }
508
509 PyDoc_STRVAR(_hashlib_openssl_sha224__doc__,
510 "openssl_sha224($module, /, data=b\'\', *, usedforsecurity=True,\n"
511 " string=None)\n"
512 "--\n"
513 "\n"
514 "Returns a sha224 hash object; optionally initialized with a string");
515
516 #define _HASHLIB_OPENSSL_SHA224_METHODDEF \
517 {"openssl_sha224", _PyCFunction_CAST(_hashlib_openssl_sha224), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha224__doc__},
518
519 static PyObject *
520 _hashlib_openssl_sha224_impl(PyObject *module, PyObject *data,
521 int usedforsecurity, PyObject *string);
522
523 static PyObject *
524 _hashlib_openssl_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
525 {
526 PyObject *return_value = NULL;
527 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
528
529 #define NUM_KEYWORDS 3
530 static struct {
531 PyGC_Head _this_is_not_used;
532 PyObject_VAR_HEAD
533 Py_hash_t ob_hash;
534 PyObject *ob_item[NUM_KEYWORDS];
535 } _kwtuple = {
536 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
537 .ob_hash = -1,
538 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
539 };
540 #undef NUM_KEYWORDS
541 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
542
543 #else // !Py_BUILD_CORE
544 # define KWTUPLE NULL
545 #endif // !Py_BUILD_CORE
546
547 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
548 static _PyArg_Parser _parser = {
549 .keywords = _keywords,
550 .fname = "openssl_sha224",
551 .kwtuple = KWTUPLE,
552 };
553 #undef KWTUPLE
554 PyObject *argsbuf[3];
555 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
556 PyObject *data = NULL;
557 int usedforsecurity = 1;
558 PyObject *string = NULL;
559
560 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
561 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
562 if (!args) {
563 goto exit;
564 }
565 if (!noptargs) {
566 goto skip_optional_pos;
567 }
568 if (args[0]) {
569 data = args[0];
570 if (!--noptargs) {
571 goto skip_optional_pos;
572 }
573 }
574 skip_optional_pos:
575 if (!noptargs) {
576 goto skip_optional_kwonly;
577 }
578 if (args[1]) {
579 usedforsecurity = PyObject_IsTrue(args[1]);
580 if (usedforsecurity < 0) {
581 goto exit;
582 }
583 if (!--noptargs) {
584 goto skip_optional_kwonly;
585 }
586 }
587 string = args[2];
588 skip_optional_kwonly:
589 return_value = _hashlib_openssl_sha224_impl(module, data, usedforsecurity, string);
590
591 exit:
592 return return_value;
593 }
594
595 PyDoc_STRVAR(_hashlib_openssl_sha256__doc__,
596 "openssl_sha256($module, /, data=b\'\', *, usedforsecurity=True,\n"
597 " string=None)\n"
598 "--\n"
599 "\n"
600 "Returns a sha256 hash object; optionally initialized with a string");
601
602 #define _HASHLIB_OPENSSL_SHA256_METHODDEF \
603 {"openssl_sha256", _PyCFunction_CAST(_hashlib_openssl_sha256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha256__doc__},
604
605 static PyObject *
606 _hashlib_openssl_sha256_impl(PyObject *module, PyObject *data,
607 int usedforsecurity, PyObject *string);
608
609 static PyObject *
610 _hashlib_openssl_sha256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
611 {
612 PyObject *return_value = NULL;
613 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
614
615 #define NUM_KEYWORDS 3
616 static struct {
617 PyGC_Head _this_is_not_used;
618 PyObject_VAR_HEAD
619 Py_hash_t ob_hash;
620 PyObject *ob_item[NUM_KEYWORDS];
621 } _kwtuple = {
622 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
623 .ob_hash = -1,
624 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
625 };
626 #undef NUM_KEYWORDS
627 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
628
629 #else // !Py_BUILD_CORE
630 # define KWTUPLE NULL
631 #endif // !Py_BUILD_CORE
632
633 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
634 static _PyArg_Parser _parser = {
635 .keywords = _keywords,
636 .fname = "openssl_sha256",
637 .kwtuple = KWTUPLE,
638 };
639 #undef KWTUPLE
640 PyObject *argsbuf[3];
641 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
642 PyObject *data = NULL;
643 int usedforsecurity = 1;
644 PyObject *string = NULL;
645
646 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
647 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
648 if (!args) {
649 goto exit;
650 }
651 if (!noptargs) {
652 goto skip_optional_pos;
653 }
654 if (args[0]) {
655 data = args[0];
656 if (!--noptargs) {
657 goto skip_optional_pos;
658 }
659 }
660 skip_optional_pos:
661 if (!noptargs) {
662 goto skip_optional_kwonly;
663 }
664 if (args[1]) {
665 usedforsecurity = PyObject_IsTrue(args[1]);
666 if (usedforsecurity < 0) {
667 goto exit;
668 }
669 if (!--noptargs) {
670 goto skip_optional_kwonly;
671 }
672 }
673 string = args[2];
674 skip_optional_kwonly:
675 return_value = _hashlib_openssl_sha256_impl(module, data, usedforsecurity, string);
676
677 exit:
678 return return_value;
679 }
680
681 PyDoc_STRVAR(_hashlib_openssl_sha384__doc__,
682 "openssl_sha384($module, /, data=b\'\', *, usedforsecurity=True,\n"
683 " string=None)\n"
684 "--\n"
685 "\n"
686 "Returns a sha384 hash object; optionally initialized with a string");
687
688 #define _HASHLIB_OPENSSL_SHA384_METHODDEF \
689 {"openssl_sha384", _PyCFunction_CAST(_hashlib_openssl_sha384), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha384__doc__},
690
691 static PyObject *
692 _hashlib_openssl_sha384_impl(PyObject *module, PyObject *data,
693 int usedforsecurity, PyObject *string);
694
695 static PyObject *
696 _hashlib_openssl_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
697 {
698 PyObject *return_value = NULL;
699 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
700
701 #define NUM_KEYWORDS 3
702 static struct {
703 PyGC_Head _this_is_not_used;
704 PyObject_VAR_HEAD
705 Py_hash_t ob_hash;
706 PyObject *ob_item[NUM_KEYWORDS];
707 } _kwtuple = {
708 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
709 .ob_hash = -1,
710 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
711 };
712 #undef NUM_KEYWORDS
713 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
714
715 #else // !Py_BUILD_CORE
716 # define KWTUPLE NULL
717 #endif // !Py_BUILD_CORE
718
719 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
720 static _PyArg_Parser _parser = {
721 .keywords = _keywords,
722 .fname = "openssl_sha384",
723 .kwtuple = KWTUPLE,
724 };
725 #undef KWTUPLE
726 PyObject *argsbuf[3];
727 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
728 PyObject *data = NULL;
729 int usedforsecurity = 1;
730 PyObject *string = NULL;
731
732 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
733 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
734 if (!args) {
735 goto exit;
736 }
737 if (!noptargs) {
738 goto skip_optional_pos;
739 }
740 if (args[0]) {
741 data = args[0];
742 if (!--noptargs) {
743 goto skip_optional_pos;
744 }
745 }
746 skip_optional_pos:
747 if (!noptargs) {
748 goto skip_optional_kwonly;
749 }
750 if (args[1]) {
751 usedforsecurity = PyObject_IsTrue(args[1]);
752 if (usedforsecurity < 0) {
753 goto exit;
754 }
755 if (!--noptargs) {
756 goto skip_optional_kwonly;
757 }
758 }
759 string = args[2];
760 skip_optional_kwonly:
761 return_value = _hashlib_openssl_sha384_impl(module, data, usedforsecurity, string);
762
763 exit:
764 return return_value;
765 }
766
767 PyDoc_STRVAR(_hashlib_openssl_sha512__doc__,
768 "openssl_sha512($module, /, data=b\'\', *, usedforsecurity=True,\n"
769 " string=None)\n"
770 "--\n"
771 "\n"
772 "Returns a sha512 hash object; optionally initialized with a string");
773
774 #define _HASHLIB_OPENSSL_SHA512_METHODDEF \
775 {"openssl_sha512", _PyCFunction_CAST(_hashlib_openssl_sha512), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha512__doc__},
776
777 static PyObject *
778 _hashlib_openssl_sha512_impl(PyObject *module, PyObject *data,
779 int usedforsecurity, PyObject *string);
780
781 static PyObject *
782 _hashlib_openssl_sha512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
783 {
784 PyObject *return_value = NULL;
785 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
786
787 #define NUM_KEYWORDS 3
788 static struct {
789 PyGC_Head _this_is_not_used;
790 PyObject_VAR_HEAD
791 Py_hash_t ob_hash;
792 PyObject *ob_item[NUM_KEYWORDS];
793 } _kwtuple = {
794 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
795 .ob_hash = -1,
796 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
797 };
798 #undef NUM_KEYWORDS
799 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
800
801 #else // !Py_BUILD_CORE
802 # define KWTUPLE NULL
803 #endif // !Py_BUILD_CORE
804
805 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
806 static _PyArg_Parser _parser = {
807 .keywords = _keywords,
808 .fname = "openssl_sha512",
809 .kwtuple = KWTUPLE,
810 };
811 #undef KWTUPLE
812 PyObject *argsbuf[3];
813 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
814 PyObject *data = NULL;
815 int usedforsecurity = 1;
816 PyObject *string = NULL;
817
818 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
819 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
820 if (!args) {
821 goto exit;
822 }
823 if (!noptargs) {
824 goto skip_optional_pos;
825 }
826 if (args[0]) {
827 data = args[0];
828 if (!--noptargs) {
829 goto skip_optional_pos;
830 }
831 }
832 skip_optional_pos:
833 if (!noptargs) {
834 goto skip_optional_kwonly;
835 }
836 if (args[1]) {
837 usedforsecurity = PyObject_IsTrue(args[1]);
838 if (usedforsecurity < 0) {
839 goto exit;
840 }
841 if (!--noptargs) {
842 goto skip_optional_kwonly;
843 }
844 }
845 string = args[2];
846 skip_optional_kwonly:
847 return_value = _hashlib_openssl_sha512_impl(module, data, usedforsecurity, string);
848
849 exit:
850 return return_value;
851 }
852
853 #if defined(PY_OPENSSL_HAS_SHA3)
854
855 PyDoc_STRVAR(_hashlib_openssl_sha3_224__doc__,
856 "openssl_sha3_224($module, /, data=b\'\', *, usedforsecurity=True,\n"
857 " string=None)\n"
858 "--\n"
859 "\n"
860 "Returns a sha3-224 hash object; optionally initialized with a string");
861
862 #define _HASHLIB_OPENSSL_SHA3_224_METHODDEF \
863 {"openssl_sha3_224", _PyCFunction_CAST(_hashlib_openssl_sha3_224), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_224__doc__},
864
865 static PyObject *
866 _hashlib_openssl_sha3_224_impl(PyObject *module, PyObject *data,
867 int usedforsecurity, PyObject *string);
868
869 static PyObject *
870 _hashlib_openssl_sha3_224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
871 {
872 PyObject *return_value = NULL;
873 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
874
875 #define NUM_KEYWORDS 3
876 static struct {
877 PyGC_Head _this_is_not_used;
878 PyObject_VAR_HEAD
879 Py_hash_t ob_hash;
880 PyObject *ob_item[NUM_KEYWORDS];
881 } _kwtuple = {
882 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
883 .ob_hash = -1,
884 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
885 };
886 #undef NUM_KEYWORDS
887 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
888
889 #else // !Py_BUILD_CORE
890 # define KWTUPLE NULL
891 #endif // !Py_BUILD_CORE
892
893 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
894 static _PyArg_Parser _parser = {
895 .keywords = _keywords,
896 .fname = "openssl_sha3_224",
897 .kwtuple = KWTUPLE,
898 };
899 #undef KWTUPLE
900 PyObject *argsbuf[3];
901 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
902 PyObject *data = NULL;
903 int usedforsecurity = 1;
904 PyObject *string = NULL;
905
906 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
907 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
908 if (!args) {
909 goto exit;
910 }
911 if (!noptargs) {
912 goto skip_optional_pos;
913 }
914 if (args[0]) {
915 data = args[0];
916 if (!--noptargs) {
917 goto skip_optional_pos;
918 }
919 }
920 skip_optional_pos:
921 if (!noptargs) {
922 goto skip_optional_kwonly;
923 }
924 if (args[1]) {
925 usedforsecurity = PyObject_IsTrue(args[1]);
926 if (usedforsecurity < 0) {
927 goto exit;
928 }
929 if (!--noptargs) {
930 goto skip_optional_kwonly;
931 }
932 }
933 string = args[2];
934 skip_optional_kwonly:
935 return_value = _hashlib_openssl_sha3_224_impl(module, data, usedforsecurity, string);
936
937 exit:
938 return return_value;
939 }
940
941 #endif /* defined(PY_OPENSSL_HAS_SHA3) */
942
943 #if defined(PY_OPENSSL_HAS_SHA3)
944
945 PyDoc_STRVAR(_hashlib_openssl_sha3_256__doc__,
946 "openssl_sha3_256($module, /, data=b\'\', *, usedforsecurity=True,\n"
947 " string=None)\n"
948 "--\n"
949 "\n"
950 "Returns a sha3-256 hash object; optionally initialized with a string");
951
952 #define _HASHLIB_OPENSSL_SHA3_256_METHODDEF \
953 {"openssl_sha3_256", _PyCFunction_CAST(_hashlib_openssl_sha3_256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_256__doc__},
954
955 static PyObject *
956 _hashlib_openssl_sha3_256_impl(PyObject *module, PyObject *data,
957 int usedforsecurity, PyObject *string);
958
959 static PyObject *
960 _hashlib_openssl_sha3_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
961 {
962 PyObject *return_value = NULL;
963 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
964
965 #define NUM_KEYWORDS 3
966 static struct {
967 PyGC_Head _this_is_not_used;
968 PyObject_VAR_HEAD
969 Py_hash_t ob_hash;
970 PyObject *ob_item[NUM_KEYWORDS];
971 } _kwtuple = {
972 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
973 .ob_hash = -1,
974 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
975 };
976 #undef NUM_KEYWORDS
977 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
978
979 #else // !Py_BUILD_CORE
980 # define KWTUPLE NULL
981 #endif // !Py_BUILD_CORE
982
983 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
984 static _PyArg_Parser _parser = {
985 .keywords = _keywords,
986 .fname = "openssl_sha3_256",
987 .kwtuple = KWTUPLE,
988 };
989 #undef KWTUPLE
990 PyObject *argsbuf[3];
991 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
992 PyObject *data = NULL;
993 int usedforsecurity = 1;
994 PyObject *string = NULL;
995
996 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
997 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
998 if (!args) {
999 goto exit;
1000 }
1001 if (!noptargs) {
1002 goto skip_optional_pos;
1003 }
1004 if (args[0]) {
1005 data = args[0];
1006 if (!--noptargs) {
1007 goto skip_optional_pos;
1008 }
1009 }
1010 skip_optional_pos:
1011 if (!noptargs) {
1012 goto skip_optional_kwonly;
1013 }
1014 if (args[1]) {
1015 usedforsecurity = PyObject_IsTrue(args[1]);
1016 if (usedforsecurity < 0) {
1017 goto exit;
1018 }
1019 if (!--noptargs) {
1020 goto skip_optional_kwonly;
1021 }
1022 }
1023 string = args[2];
1024 skip_optional_kwonly:
1025 return_value = _hashlib_openssl_sha3_256_impl(module, data, usedforsecurity, string);
1026
1027 exit:
1028 return return_value;
1029 }
1030
1031 #endif /* defined(PY_OPENSSL_HAS_SHA3) */
1032
1033 #if defined(PY_OPENSSL_HAS_SHA3)
1034
1035 PyDoc_STRVAR(_hashlib_openssl_sha3_384__doc__,
1036 "openssl_sha3_384($module, /, data=b\'\', *, usedforsecurity=True,\n"
1037 " string=None)\n"
1038 "--\n"
1039 "\n"
1040 "Returns a sha3-384 hash object; optionally initialized with a string");
1041
1042 #define _HASHLIB_OPENSSL_SHA3_384_METHODDEF \
1043 {"openssl_sha3_384", _PyCFunction_CAST(_hashlib_openssl_sha3_384), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_384__doc__},
1044
1045 static PyObject *
1046 _hashlib_openssl_sha3_384_impl(PyObject *module, PyObject *data,
1047 int usedforsecurity, PyObject *string);
1048
1049 static PyObject *
1050 _hashlib_openssl_sha3_384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1051 {
1052 PyObject *return_value = NULL;
1053 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1054
1055 #define NUM_KEYWORDS 3
1056 static struct {
1057 PyGC_Head _this_is_not_used;
1058 PyObject_VAR_HEAD
1059 Py_hash_t ob_hash;
1060 PyObject *ob_item[NUM_KEYWORDS];
1061 } _kwtuple = {
1062 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1063 .ob_hash = -1,
1064 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
1065 };
1066 #undef NUM_KEYWORDS
1067 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1068
1069 #else // !Py_BUILD_CORE
1070 # define KWTUPLE NULL
1071 #endif // !Py_BUILD_CORE
1072
1073 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
1074 static _PyArg_Parser _parser = {
1075 .keywords = _keywords,
1076 .fname = "openssl_sha3_384",
1077 .kwtuple = KWTUPLE,
1078 };
1079 #undef KWTUPLE
1080 PyObject *argsbuf[3];
1081 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1082 PyObject *data = NULL;
1083 int usedforsecurity = 1;
1084 PyObject *string = NULL;
1085
1086 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1087 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1088 if (!args) {
1089 goto exit;
1090 }
1091 if (!noptargs) {
1092 goto skip_optional_pos;
1093 }
1094 if (args[0]) {
1095 data = args[0];
1096 if (!--noptargs) {
1097 goto skip_optional_pos;
1098 }
1099 }
1100 skip_optional_pos:
1101 if (!noptargs) {
1102 goto skip_optional_kwonly;
1103 }
1104 if (args[1]) {
1105 usedforsecurity = PyObject_IsTrue(args[1]);
1106 if (usedforsecurity < 0) {
1107 goto exit;
1108 }
1109 if (!--noptargs) {
1110 goto skip_optional_kwonly;
1111 }
1112 }
1113 string = args[2];
1114 skip_optional_kwonly:
1115 return_value = _hashlib_openssl_sha3_384_impl(module, data, usedforsecurity, string);
1116
1117 exit:
1118 return return_value;
1119 }
1120
1121 #endif /* defined(PY_OPENSSL_HAS_SHA3) */
1122
1123 #if defined(PY_OPENSSL_HAS_SHA3)
1124
1125 PyDoc_STRVAR(_hashlib_openssl_sha3_512__doc__,
1126 "openssl_sha3_512($module, /, data=b\'\', *, usedforsecurity=True,\n"
1127 " string=None)\n"
1128 "--\n"
1129 "\n"
1130 "Returns a sha3-512 hash object; optionally initialized with a string");
1131
1132 #define _HASHLIB_OPENSSL_SHA3_512_METHODDEF \
1133 {"openssl_sha3_512", _PyCFunction_CAST(_hashlib_openssl_sha3_512), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_512__doc__},
1134
1135 static PyObject *
1136 _hashlib_openssl_sha3_512_impl(PyObject *module, PyObject *data,
1137 int usedforsecurity, PyObject *string);
1138
1139 static PyObject *
1140 _hashlib_openssl_sha3_512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1141 {
1142 PyObject *return_value = NULL;
1143 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1144
1145 #define NUM_KEYWORDS 3
1146 static struct {
1147 PyGC_Head _this_is_not_used;
1148 PyObject_VAR_HEAD
1149 Py_hash_t ob_hash;
1150 PyObject *ob_item[NUM_KEYWORDS];
1151 } _kwtuple = {
1152 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1153 .ob_hash = -1,
1154 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
1155 };
1156 #undef NUM_KEYWORDS
1157 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1158
1159 #else // !Py_BUILD_CORE
1160 # define KWTUPLE NULL
1161 #endif // !Py_BUILD_CORE
1162
1163 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
1164 static _PyArg_Parser _parser = {
1165 .keywords = _keywords,
1166 .fname = "openssl_sha3_512",
1167 .kwtuple = KWTUPLE,
1168 };
1169 #undef KWTUPLE
1170 PyObject *argsbuf[3];
1171 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1172 PyObject *data = NULL;
1173 int usedforsecurity = 1;
1174 PyObject *string = NULL;
1175
1176 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1177 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1178 if (!args) {
1179 goto exit;
1180 }
1181 if (!noptargs) {
1182 goto skip_optional_pos;
1183 }
1184 if (args[0]) {
1185 data = args[0];
1186 if (!--noptargs) {
1187 goto skip_optional_pos;
1188 }
1189 }
1190 skip_optional_pos:
1191 if (!noptargs) {
1192 goto skip_optional_kwonly;
1193 }
1194 if (args[1]) {
1195 usedforsecurity = PyObject_IsTrue(args[1]);
1196 if (usedforsecurity < 0) {
1197 goto exit;
1198 }
1199 if (!--noptargs) {
1200 goto skip_optional_kwonly;
1201 }
1202 }
1203 string = args[2];
1204 skip_optional_kwonly:
1205 return_value = _hashlib_openssl_sha3_512_impl(module, data, usedforsecurity, string);
1206
1207 exit:
1208 return return_value;
1209 }
1210
1211 #endif /* defined(PY_OPENSSL_HAS_SHA3) */
1212
1213 #if defined(PY_OPENSSL_HAS_SHAKE)
1214
1215 PyDoc_STRVAR(_hashlib_openssl_shake_128__doc__,
1216 "openssl_shake_128($module, /, data=b\'\', *, usedforsecurity=True,\n"
1217 " string=None)\n"
1218 "--\n"
1219 "\n"
1220 "Returns a shake-128 variable hash object; optionally initialized with a string");
1221
1222 #define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF \
1223 {"openssl_shake_128", _PyCFunction_CAST(_hashlib_openssl_shake_128), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_128__doc__},
1224
1225 static PyObject *
1226 _hashlib_openssl_shake_128_impl(PyObject *module, PyObject *data,
1227 int usedforsecurity, PyObject *string);
1228
1229 static PyObject *
1230 _hashlib_openssl_shake_128(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1231 {
1232 PyObject *return_value = NULL;
1233 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1234
1235 #define NUM_KEYWORDS 3
1236 static struct {
1237 PyGC_Head _this_is_not_used;
1238 PyObject_VAR_HEAD
1239 Py_hash_t ob_hash;
1240 PyObject *ob_item[NUM_KEYWORDS];
1241 } _kwtuple = {
1242 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1243 .ob_hash = -1,
1244 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
1245 };
1246 #undef NUM_KEYWORDS
1247 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1248
1249 #else // !Py_BUILD_CORE
1250 # define KWTUPLE NULL
1251 #endif // !Py_BUILD_CORE
1252
1253 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
1254 static _PyArg_Parser _parser = {
1255 .keywords = _keywords,
1256 .fname = "openssl_shake_128",
1257 .kwtuple = KWTUPLE,
1258 };
1259 #undef KWTUPLE
1260 PyObject *argsbuf[3];
1261 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1262 PyObject *data = NULL;
1263 int usedforsecurity = 1;
1264 PyObject *string = NULL;
1265
1266 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1267 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1268 if (!args) {
1269 goto exit;
1270 }
1271 if (!noptargs) {
1272 goto skip_optional_pos;
1273 }
1274 if (args[0]) {
1275 data = args[0];
1276 if (!--noptargs) {
1277 goto skip_optional_pos;
1278 }
1279 }
1280 skip_optional_pos:
1281 if (!noptargs) {
1282 goto skip_optional_kwonly;
1283 }
1284 if (args[1]) {
1285 usedforsecurity = PyObject_IsTrue(args[1]);
1286 if (usedforsecurity < 0) {
1287 goto exit;
1288 }
1289 if (!--noptargs) {
1290 goto skip_optional_kwonly;
1291 }
1292 }
1293 string = args[2];
1294 skip_optional_kwonly:
1295 return_value = _hashlib_openssl_shake_128_impl(module, data, usedforsecurity, string);
1296
1297 exit:
1298 return return_value;
1299 }
1300
1301 #endif /* defined(PY_OPENSSL_HAS_SHAKE) */
1302
1303 #if defined(PY_OPENSSL_HAS_SHAKE)
1304
1305 PyDoc_STRVAR(_hashlib_openssl_shake_256__doc__,
1306 "openssl_shake_256($module, /, data=b\'\', *, usedforsecurity=True,\n"
1307 " string=None)\n"
1308 "--\n"
1309 "\n"
1310 "Returns a shake-256 variable hash object; optionally initialized with a string");
1311
1312 #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF \
1313 {"openssl_shake_256", _PyCFunction_CAST(_hashlib_openssl_shake_256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_256__doc__},
1314
1315 static PyObject *
1316 _hashlib_openssl_shake_256_impl(PyObject *module, PyObject *data,
1317 int usedforsecurity, PyObject *string);
1318
1319 static PyObject *
1320 _hashlib_openssl_shake_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1321 {
1322 PyObject *return_value = NULL;
1323 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1324
1325 #define NUM_KEYWORDS 3
1326 static struct {
1327 PyGC_Head _this_is_not_used;
1328 PyObject_VAR_HEAD
1329 Py_hash_t ob_hash;
1330 PyObject *ob_item[NUM_KEYWORDS];
1331 } _kwtuple = {
1332 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1333 .ob_hash = -1,
1334 .ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), },
1335 };
1336 #undef NUM_KEYWORDS
1337 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1338
1339 #else // !Py_BUILD_CORE
1340 # define KWTUPLE NULL
1341 #endif // !Py_BUILD_CORE
1342
1343 static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL};
1344 static _PyArg_Parser _parser = {
1345 .keywords = _keywords,
1346 .fname = "openssl_shake_256",
1347 .kwtuple = KWTUPLE,
1348 };
1349 #undef KWTUPLE
1350 PyObject *argsbuf[3];
1351 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1352 PyObject *data = NULL;
1353 int usedforsecurity = 1;
1354 PyObject *string = NULL;
1355
1356 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1357 /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1358 if (!args) {
1359 goto exit;
1360 }
1361 if (!noptargs) {
1362 goto skip_optional_pos;
1363 }
1364 if (args[0]) {
1365 data = args[0];
1366 if (!--noptargs) {
1367 goto skip_optional_pos;
1368 }
1369 }
1370 skip_optional_pos:
1371 if (!noptargs) {
1372 goto skip_optional_kwonly;
1373 }
1374 if (args[1]) {
1375 usedforsecurity = PyObject_IsTrue(args[1]);
1376 if (usedforsecurity < 0) {
1377 goto exit;
1378 }
1379 if (!--noptargs) {
1380 goto skip_optional_kwonly;
1381 }
1382 }
1383 string = args[2];
1384 skip_optional_kwonly:
1385 return_value = _hashlib_openssl_shake_256_impl(module, data, usedforsecurity, string);
1386
1387 exit:
1388 return return_value;
1389 }
1390
1391 #endif /* defined(PY_OPENSSL_HAS_SHAKE) */
1392
1393 PyDoc_STRVAR(pbkdf2_hmac__doc__,
1394 "pbkdf2_hmac($module, /, hash_name, password, salt, iterations,\n"
1395 " dklen=None)\n"
1396 "--\n"
1397 "\n"
1398 "Password based key derivation function 2 (PKCS #5 v2.0) with HMAC as pseudorandom function.");
1399
1400 #define PBKDF2_HMAC_METHODDEF \
1401 {"pbkdf2_hmac", _PyCFunction_CAST(pbkdf2_hmac), METH_FASTCALL|METH_KEYWORDS, pbkdf2_hmac__doc__},
1402
1403 static PyObject *
1404 pbkdf2_hmac_impl(PyObject *module, const char *hash_name,
1405 Py_buffer *password, Py_buffer *salt, long iterations,
1406 PyObject *dklen_obj);
1407
1408 static PyObject *
1409 pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1410 {
1411 PyObject *return_value = NULL;
1412 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1413
1414 #define NUM_KEYWORDS 5
1415 static struct {
1416 PyGC_Head _this_is_not_used;
1417 PyObject_VAR_HEAD
1418 Py_hash_t ob_hash;
1419 PyObject *ob_item[NUM_KEYWORDS];
1420 } _kwtuple = {
1421 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1422 .ob_hash = -1,
1423 .ob_item = { &_Py_ID(hash_name), &_Py_ID(password), &_Py_ID(salt), &_Py_ID(iterations), &_Py_ID(dklen), },
1424 };
1425 #undef NUM_KEYWORDS
1426 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1427
1428 #else // !Py_BUILD_CORE
1429 # define KWTUPLE NULL
1430 #endif // !Py_BUILD_CORE
1431
1432 static const char * const _keywords[] = {"hash_name", "password", "salt", "iterations", "dklen", NULL};
1433 static _PyArg_Parser _parser = {
1434 .keywords = _keywords,
1435 .fname = "pbkdf2_hmac",
1436 .kwtuple = KWTUPLE,
1437 };
1438 #undef KWTUPLE
1439 PyObject *argsbuf[5];
1440 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4;
1441 const char *hash_name;
1442 Py_buffer password = {NULL, NULL};
1443 Py_buffer salt = {NULL, NULL};
1444 long iterations;
1445 PyObject *dklen_obj = Py_None;
1446
1447 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1448 /*minpos*/ 4, /*maxpos*/ 5, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1449 if (!args) {
1450 goto exit;
1451 }
1452 if (!PyUnicode_Check(args[0])) {
1453 _PyArg_BadArgument("pbkdf2_hmac", "argument 'hash_name'", "str", args[0]);
1454 goto exit;
1455 }
1456 Py_ssize_t hash_name_length;
1457 hash_name = PyUnicode_AsUTF8AndSize(args[0], &hash_name_length);
1458 if (hash_name == NULL) {
1459 goto exit;
1460 }
1461 if (strlen(hash_name) != (size_t)hash_name_length) {
1462 PyErr_SetString(PyExc_ValueError, "embedded null character");
1463 goto exit;
1464 }
1465 if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) {
1466 goto exit;
1467 }
1468 if (PyObject_GetBuffer(args[2], &salt, PyBUF_SIMPLE) != 0) {
1469 goto exit;
1470 }
1471 iterations = PyLong_AsLong(args[3]);
1472 if (iterations == -1 && PyErr_Occurred()) {
1473 goto exit;
1474 }
1475 if (!noptargs) {
1476 goto skip_optional_pos;
1477 }
1478 dklen_obj = args[4];
1479 skip_optional_pos:
1480 return_value = pbkdf2_hmac_impl(module, hash_name, &password, &salt, iterations, dklen_obj);
1481
1482 exit:
1483 /* Cleanup for password */
1484 if (password.obj) {
1485 PyBuffer_Release(&password);
1486 }
1487 /* Cleanup for salt */
1488 if (salt.obj) {
1489 PyBuffer_Release(&salt);
1490 }
1491
1492 return return_value;
1493 }
1494
1495 #if defined(PY_OPENSSL_HAS_SCRYPT)
1496
1497 PyDoc_STRVAR(_hashlib_scrypt__doc__,
1498 "scrypt($module, /, password, *, salt, n, r, p, maxmem=0, dklen=64)\n"
1499 "--\n"
1500 "\n"
1501 "scrypt password-based key derivation function.");
1502
1503 #define _HASHLIB_SCRYPT_METHODDEF \
1504 {"scrypt", _PyCFunction_CAST(_hashlib_scrypt), METH_FASTCALL|METH_KEYWORDS, _hashlib_scrypt__doc__},
1505
1506 static PyObject *
1507 _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer *salt,
1508 unsigned long n, unsigned long r, unsigned long p,
1509 long maxmem, long dklen);
1510
1511 static PyObject *
1512 _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1513 {
1514 PyObject *return_value = NULL;
1515 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1516
1517 #define NUM_KEYWORDS 7
1518 static struct {
1519 PyGC_Head _this_is_not_used;
1520 PyObject_VAR_HEAD
1521 Py_hash_t ob_hash;
1522 PyObject *ob_item[NUM_KEYWORDS];
1523 } _kwtuple = {
1524 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1525 .ob_hash = -1,
1526 .ob_item = { &_Py_ID(password), &_Py_ID(salt), _Py_LATIN1_CHR('n'), _Py_LATIN1_CHR('r'), _Py_LATIN1_CHR('p'), &_Py_ID(maxmem), &_Py_ID(dklen), },
1527 };
1528 #undef NUM_KEYWORDS
1529 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1530
1531 #else // !Py_BUILD_CORE
1532 # define KWTUPLE NULL
1533 #endif // !Py_BUILD_CORE
1534
1535 static const char * const _keywords[] = {"password", "salt", "n", "r", "p", "maxmem", "dklen", NULL};
1536 static _PyArg_Parser _parser = {
1537 .keywords = _keywords,
1538 .fname = "scrypt",
1539 .kwtuple = KWTUPLE,
1540 };
1541 #undef KWTUPLE
1542 PyObject *argsbuf[7];
1543 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 5;
1544 Py_buffer password = {NULL, NULL};
1545 Py_buffer salt = {NULL, NULL};
1546 unsigned long n;
1547 unsigned long r;
1548 unsigned long p;
1549 long maxmem = 0;
1550 long dklen = 64;
1551
1552 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1553 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 4, /*varpos*/ 0, argsbuf);
1554 if (!args) {
1555 goto exit;
1556 }
1557 if (PyObject_GetBuffer(args[0], &password, PyBUF_SIMPLE) != 0) {
1558 goto exit;
1559 }
1560 if (PyObject_GetBuffer(args[1], &salt, PyBUF_SIMPLE) != 0) {
1561 goto exit;
1562 }
1563 if (!_PyLong_UnsignedLong_Converter(args[2], &n)) {
1564 goto exit;
1565 }
1566 if (!_PyLong_UnsignedLong_Converter(args[3], &r)) {
1567 goto exit;
1568 }
1569 if (!_PyLong_UnsignedLong_Converter(args[4], &p)) {
1570 goto exit;
1571 }
1572 if (!noptargs) {
1573 goto skip_optional_kwonly;
1574 }
1575 if (args[5]) {
1576 maxmem = PyLong_AsLong(args[5]);
1577 if (maxmem == -1 && PyErr_Occurred()) {
1578 goto exit;
1579 }
1580 if (!--noptargs) {
1581 goto skip_optional_kwonly;
1582 }
1583 }
1584 dklen = PyLong_AsLong(args[6]);
1585 if (dklen == -1 && PyErr_Occurred()) {
1586 goto exit;
1587 }
1588 skip_optional_kwonly:
1589 return_value = _hashlib_scrypt_impl(module, &password, &salt, n, r, p, maxmem, dklen);
1590
1591 exit:
1592 /* Cleanup for password */
1593 if (password.obj) {
1594 PyBuffer_Release(&password);
1595 }
1596 /* Cleanup for salt */
1597 if (salt.obj) {
1598 PyBuffer_Release(&salt);
1599 }
1600
1601 return return_value;
1602 }
1603
1604 #endif /* defined(PY_OPENSSL_HAS_SCRYPT) */
1605
1606 PyDoc_STRVAR(_hashlib_hmac_singleshot__doc__,
1607 "hmac_digest($module, /, key, msg, digest)\n"
1608 "--\n"
1609 "\n"
1610 "Single-shot HMAC.");
1611
1612 #define _HASHLIB_HMAC_SINGLESHOT_METHODDEF \
1613 {"hmac_digest", _PyCFunction_CAST(_hashlib_hmac_singleshot), METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_singleshot__doc__},
1614
1615 static PyObject *
1616 _hashlib_hmac_singleshot_impl(PyObject *module, Py_buffer *key,
1617 Py_buffer *msg, PyObject *digest);
1618
1619 static PyObject *
1620 _hashlib_hmac_singleshot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1621 {
1622 PyObject *return_value = NULL;
1623 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1624
1625 #define NUM_KEYWORDS 3
1626 static struct {
1627 PyGC_Head _this_is_not_used;
1628 PyObject_VAR_HEAD
1629 Py_hash_t ob_hash;
1630 PyObject *ob_item[NUM_KEYWORDS];
1631 } _kwtuple = {
1632 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1633 .ob_hash = -1,
1634 .ob_item = { &_Py_ID(key), &_Py_ID(msg), &_Py_ID(digest), },
1635 };
1636 #undef NUM_KEYWORDS
1637 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1638
1639 #else // !Py_BUILD_CORE
1640 # define KWTUPLE NULL
1641 #endif // !Py_BUILD_CORE
1642
1643 static const char * const _keywords[] = {"key", "msg", "digest", NULL};
1644 static _PyArg_Parser _parser = {
1645 .keywords = _keywords,
1646 .fname = "hmac_digest",
1647 .kwtuple = KWTUPLE,
1648 };
1649 #undef KWTUPLE
1650 PyObject *argsbuf[3];
1651 Py_buffer key = {NULL, NULL};
1652 Py_buffer msg = {NULL, NULL};
1653 PyObject *digest;
1654
1655 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1656 /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1657 if (!args) {
1658 goto exit;
1659 }
1660 if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) {
1661 goto exit;
1662 }
1663 if (PyObject_GetBuffer(args[1], &msg, PyBUF_SIMPLE) != 0) {
1664 goto exit;
1665 }
1666 digest = args[2];
1667 return_value = _hashlib_hmac_singleshot_impl(module, &key, &msg, digest);
1668
1669 exit:
1670 /* Cleanup for key */
1671 if (key.obj) {
1672 PyBuffer_Release(&key);
1673 }
1674 /* Cleanup for msg */
1675 if (msg.obj) {
1676 PyBuffer_Release(&msg);
1677 }
1678
1679 return return_value;
1680 }
1681
1682 PyDoc_STRVAR(_hashlib_hmac_new__doc__,
1683 "hmac_new($module, /, key, msg=b\'\', digestmod=None)\n"
1684 "--\n"
1685 "\n"
1686 "Return a new hmac object.");
1687
1688 #define _HASHLIB_HMAC_NEW_METHODDEF \
1689 {"hmac_new", _PyCFunction_CAST(_hashlib_hmac_new), METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_new__doc__},
1690
1691 static PyObject *
1692 _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
1693 PyObject *digestmod);
1694
1695 static PyObject *
1696 _hashlib_hmac_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1697 {
1698 PyObject *return_value = NULL;
1699 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1700
1701 #define NUM_KEYWORDS 3
1702 static struct {
1703 PyGC_Head _this_is_not_used;
1704 PyObject_VAR_HEAD
1705 Py_hash_t ob_hash;
1706 PyObject *ob_item[NUM_KEYWORDS];
1707 } _kwtuple = {
1708 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1709 .ob_hash = -1,
1710 .ob_item = { &_Py_ID(key), &_Py_ID(msg), &_Py_ID(digestmod), },
1711 };
1712 #undef NUM_KEYWORDS
1713 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1714
1715 #else // !Py_BUILD_CORE
1716 # define KWTUPLE NULL
1717 #endif // !Py_BUILD_CORE
1718
1719 static const char * const _keywords[] = {"key", "msg", "digestmod", NULL};
1720 static _PyArg_Parser _parser = {
1721 .keywords = _keywords,
1722 .fname = "hmac_new",
1723 .kwtuple = KWTUPLE,
1724 };
1725 #undef KWTUPLE
1726 PyObject *argsbuf[3];
1727 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
1728 Py_buffer key = {NULL, NULL};
1729 PyObject *msg_obj = NULL;
1730 PyObject *digestmod = NULL;
1731
1732 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1733 /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1734 if (!args) {
1735 goto exit;
1736 }
1737 if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) {
1738 goto exit;
1739 }
1740 if (!noptargs) {
1741 goto skip_optional_pos;
1742 }
1743 if (args[1]) {
1744 msg_obj = args[1];
1745 if (!--noptargs) {
1746 goto skip_optional_pos;
1747 }
1748 }
1749 digestmod = args[2];
1750 skip_optional_pos:
1751 return_value = _hashlib_hmac_new_impl(module, &key, msg_obj, digestmod);
1752
1753 exit:
1754 /* Cleanup for key */
1755 if (key.obj) {
1756 PyBuffer_Release(&key);
1757 }
1758
1759 return return_value;
1760 }
1761
1762 PyDoc_STRVAR(_hashlib_HMAC_copy__doc__,
1763 "copy($self, /)\n"
1764 "--\n"
1765 "\n"
1766 "Return a copy (\"clone\") of the HMAC object.");
1767
1768 #define _HASHLIB_HMAC_COPY_METHODDEF \
1769 {"copy", (PyCFunction)_hashlib_HMAC_copy, METH_NOARGS, _hashlib_HMAC_copy__doc__},
1770
1771 static PyObject *
1772 _hashlib_HMAC_copy_impl(HMACobject *self);
1773
1774 static PyObject *
1775 _hashlib_HMAC_copy(PyObject *self, PyObject *Py_UNUSED(ignored))
1776 {
1777 return _hashlib_HMAC_copy_impl((HMACobject *)self);
1778 }
1779
1780 PyDoc_STRVAR(_hashlib_HMAC_update__doc__,
1781 "update($self, /, msg)\n"
1782 "--\n"
1783 "\n"
1784 "Update the HMAC object with msg.");
1785
1786 #define _HASHLIB_HMAC_UPDATE_METHODDEF \
1787 {"update", _PyCFunction_CAST(_hashlib_HMAC_update), METH_FASTCALL|METH_KEYWORDS, _hashlib_HMAC_update__doc__},
1788
1789 static PyObject *
1790 _hashlib_HMAC_update_impl(HMACobject *self, PyObject *msg);
1791
1792 static PyObject *
1793 _hashlib_HMAC_update(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1794 {
1795 PyObject *return_value = NULL;
1796 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1797
1798 #define NUM_KEYWORDS 1
1799 static struct {
1800 PyGC_Head _this_is_not_used;
1801 PyObject_VAR_HEAD
1802 Py_hash_t ob_hash;
1803 PyObject *ob_item[NUM_KEYWORDS];
1804 } _kwtuple = {
1805 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1806 .ob_hash = -1,
1807 .ob_item = { &_Py_ID(msg), },
1808 };
1809 #undef NUM_KEYWORDS
1810 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1811
1812 #else // !Py_BUILD_CORE
1813 # define KWTUPLE NULL
1814 #endif // !Py_BUILD_CORE
1815
1816 static const char * const _keywords[] = {"msg", NULL};
1817 static _PyArg_Parser _parser = {
1818 .keywords = _keywords,
1819 .fname = "update",
1820 .kwtuple = KWTUPLE,
1821 };
1822 #undef KWTUPLE
1823 PyObject *argsbuf[1];
1824 PyObject *msg;
1825
1826 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1827 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1828 if (!args) {
1829 goto exit;
1830 }
1831 msg = args[0];
1832 return_value = _hashlib_HMAC_update_impl((HMACobject *)self, msg);
1833
1834 exit:
1835 return return_value;
1836 }
1837
1838 PyDoc_STRVAR(_hashlib_HMAC_digest__doc__,
1839 "digest($self, /)\n"
1840 "--\n"
1841 "\n"
1842 "Return the digest of the bytes passed to the update() method so far.");
1843
1844 #define _HASHLIB_HMAC_DIGEST_METHODDEF \
1845 {"digest", (PyCFunction)_hashlib_HMAC_digest, METH_NOARGS, _hashlib_HMAC_digest__doc__},
1846
1847 static PyObject *
1848 _hashlib_HMAC_digest_impl(HMACobject *self);
1849
1850 static PyObject *
1851 _hashlib_HMAC_digest(PyObject *self, PyObject *Py_UNUSED(ignored))
1852 {
1853 return _hashlib_HMAC_digest_impl((HMACobject *)self);
1854 }
1855
1856 PyDoc_STRVAR(_hashlib_HMAC_hexdigest__doc__,
1857 "hexdigest($self, /)\n"
1858 "--\n"
1859 "\n"
1860 "Return hexadecimal digest of the bytes passed to the update() method so far.\n"
1861 "\n"
1862 "This may be used to exchange the value safely in email or other\n"
1863 "non-binary environments.");
1864
1865 #define _HASHLIB_HMAC_HEXDIGEST_METHODDEF \
1866 {"hexdigest", (PyCFunction)_hashlib_HMAC_hexdigest, METH_NOARGS, _hashlib_HMAC_hexdigest__doc__},
1867
1868 static PyObject *
1869 _hashlib_HMAC_hexdigest_impl(HMACobject *self);
1870
1871 static PyObject *
1872 _hashlib_HMAC_hexdigest(PyObject *self, PyObject *Py_UNUSED(ignored))
1873 {
1874 return _hashlib_HMAC_hexdigest_impl((HMACobject *)self);
1875 }
1876
1877 PyDoc_STRVAR(_hashlib_get_fips_mode__doc__,
1878 "get_fips_mode($module, /)\n"
1879 "--\n"
1880 "\n"
1881 "Determine the OpenSSL FIPS mode of operation.\n"
1882 "\n"
1883 "For OpenSSL 3.0.0 and newer it returns the state of the default provider\n"
1884 "in the default OSSL context. It\'s not quite the same as FIPS_mode() but\n"
1885 "good enough for unittests.\n"
1886 "\n"
1887 "Effectively any non-zero return value indicates FIPS mode;\n"
1888 "values other than 1 may have additional significance.");
1889
1890 #define _HASHLIB_GET_FIPS_MODE_METHODDEF \
1891 {"get_fips_mode", (PyCFunction)_hashlib_get_fips_mode, METH_NOARGS, _hashlib_get_fips_mode__doc__},
1892
1893 static int
1894 _hashlib_get_fips_mode_impl(PyObject *module);
1895
1896 static PyObject *
1897 _hashlib_get_fips_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
1898 {
1899 PyObject *return_value = NULL;
1900 int _return_value;
1901
1902 _return_value = _hashlib_get_fips_mode_impl(module);
1903 if ((_return_value == -1) && PyErr_Occurred()) {
1904 goto exit;
1905 }
1906 return_value = PyLong_FromLong((long)_return_value);
1907
1908 exit:
1909 return return_value;
1910 }
1911
1912 PyDoc_STRVAR(_hashlib_compare_digest__doc__,
1913 "compare_digest($module, a, b, /)\n"
1914 "--\n"
1915 "\n"
1916 "Return \'a == b\'.\n"
1917 "\n"
1918 "This function uses an approach designed to prevent\n"
1919 "timing analysis, making it appropriate for cryptography.\n"
1920 "\n"
1921 "a and b must both be of the same type: either str (ASCII only),\n"
1922 "or any bytes-like object.\n"
1923 "\n"
1924 "Note: If a and b are of different lengths, or if an error occurs,\n"
1925 "a timing attack could theoretically reveal information about the\n"
1926 "types and lengths of a and b--but not their values.");
1927
1928 #define _HASHLIB_COMPARE_DIGEST_METHODDEF \
1929 {"compare_digest", _PyCFunction_CAST(_hashlib_compare_digest), METH_FASTCALL, _hashlib_compare_digest__doc__},
1930
1931 static PyObject *
1932 _hashlib_compare_digest_impl(PyObject *module, PyObject *a, PyObject *b);
1933
1934 static PyObject *
1935 _hashlib_compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1936 {
1937 PyObject *return_value = NULL;
1938 PyObject *a;
1939 PyObject *b;
1940
1941 if (!_PyArg_CheckPositional("compare_digest", nargs, 2, 2)) {
1942 goto exit;
1943 }
1944 a = args[0];
1945 b = args[1];
1946 return_value = _hashlib_compare_digest_impl(module, a, b);
1947
1948 exit:
1949 return return_value;
1950 }
1951
1952 #ifndef EVPXOF_DIGEST_METHODDEF
1953 #define EVPXOF_DIGEST_METHODDEF
1954 #endif /* !defined(EVPXOF_DIGEST_METHODDEF) */
1955
1956 #ifndef EVPXOF_HEXDIGEST_METHODDEF
1957 #define EVPXOF_HEXDIGEST_METHODDEF
1958 #endif /* !defined(EVPXOF_HEXDIGEST_METHODDEF) */
1959
1960 #ifndef _HASHLIB_OPENSSL_SHA3_224_METHODDEF
1961 #define _HASHLIB_OPENSSL_SHA3_224_METHODDEF
1962 #endif /* !defined(_HASHLIB_OPENSSL_SHA3_224_METHODDEF) */
1963
1964 #ifndef _HASHLIB_OPENSSL_SHA3_256_METHODDEF
1965 #define _HASHLIB_OPENSSL_SHA3_256_METHODDEF
1966 #endif /* !defined(_HASHLIB_OPENSSL_SHA3_256_METHODDEF) */
1967
1968 #ifndef _HASHLIB_OPENSSL_SHA3_384_METHODDEF
1969 #define _HASHLIB_OPENSSL_SHA3_384_METHODDEF
1970 #endif /* !defined(_HASHLIB_OPENSSL_SHA3_384_METHODDEF) */
1971
1972 #ifndef _HASHLIB_OPENSSL_SHA3_512_METHODDEF
1973 #define _HASHLIB_OPENSSL_SHA3_512_METHODDEF
1974 #endif /* !defined(_HASHLIB_OPENSSL_SHA3_512_METHODDEF) */
1975
1976 #ifndef _HASHLIB_OPENSSL_SHAKE_128_METHODDEF
1977 #define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF
1978 #endif /* !defined(_HASHLIB_OPENSSL_SHAKE_128_METHODDEF) */
1979
1980 #ifndef _HASHLIB_OPENSSL_SHAKE_256_METHODDEF
1981 #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF
1982 #endif /* !defined(_HASHLIB_OPENSSL_SHAKE_256_METHODDEF) */
1983
1984 #ifndef _HASHLIB_SCRYPT_METHODDEF
1985 #define _HASHLIB_SCRYPT_METHODDEF
1986 #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */
1987 /*[clinic end generated code: output=3e8d61a057978436 input=a9049054013a1b77]*/