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