LCOV - code coverage report
Current view: top level - Modules/clinic - _hashopenssl.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit acb105a7c1f] Lines: 479 543 88.2 %
Date: 2022-07-20 13:12:14 Functions: 28 28 100.0 %
Branches: 335 480 69.8 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : PyDoc_STRVAR(EVP_copy__doc__,
       6                 :            : "copy($self, /)\n"
       7                 :            : "--\n"
       8                 :            : "\n"
       9                 :            : "Return a copy of the hash object.");
      10                 :            : 
      11                 :            : #define EVP_COPY_METHODDEF    \
      12                 :            :     {"copy", (PyCFunction)EVP_copy, METH_NOARGS, EVP_copy__doc__},
      13                 :            : 
      14                 :            : static PyObject *
      15                 :            : EVP_copy_impl(EVPobject *self);
      16                 :            : 
      17                 :            : static PyObject *
      18                 :        104 : EVP_copy(EVPobject *self, PyObject *Py_UNUSED(ignored))
      19                 :            : {
      20                 :        104 :     return EVP_copy_impl(self);
      21                 :            : }
      22                 :            : 
      23                 :            : PyDoc_STRVAR(EVP_digest__doc__,
      24                 :            : "digest($self, /)\n"
      25                 :            : "--\n"
      26                 :            : "\n"
      27                 :            : "Return the digest value as a bytes object.");
      28                 :            : 
      29                 :            : #define EVP_DIGEST_METHODDEF    \
      30                 :            :     {"digest", (PyCFunction)EVP_digest, METH_NOARGS, EVP_digest__doc__},
      31                 :            : 
      32                 :            : static PyObject *
      33                 :            : EVP_digest_impl(EVPobject *self);
      34                 :            : 
      35                 :            : static PyObject *
      36                 :       2492 : EVP_digest(EVPobject *self, PyObject *Py_UNUSED(ignored))
      37                 :            : {
      38                 :       2492 :     return EVP_digest_impl(self);
      39                 :            : }
      40                 :            : 
      41                 :            : PyDoc_STRVAR(EVP_hexdigest__doc__,
      42                 :            : "hexdigest($self, /)\n"
      43                 :            : "--\n"
      44                 :            : "\n"
      45                 :            : "Return the digest value as a string of hexadecimal digits.");
      46                 :            : 
      47                 :            : #define EVP_HEXDIGEST_METHODDEF    \
      48                 :            :     {"hexdigest", (PyCFunction)EVP_hexdigest, METH_NOARGS, EVP_hexdigest__doc__},
      49                 :            : 
      50                 :            : static PyObject *
      51                 :            : EVP_hexdigest_impl(EVPobject *self);
      52                 :            : 
      53                 :            : static PyObject *
      54                 :       8852 : EVP_hexdigest(EVPobject *self, PyObject *Py_UNUSED(ignored))
      55                 :            : {
      56                 :       8852 :     return EVP_hexdigest_impl(self);
      57                 :            : }
      58                 :            : 
      59                 :            : PyDoc_STRVAR(EVP_update__doc__,
      60                 :            : "update($self, obj, /)\n"
      61                 :            : "--\n"
      62                 :            : "\n"
      63                 :            : "Update this hash object\'s state with the provided string.");
      64                 :            : 
      65                 :            : #define EVP_UPDATE_METHODDEF    \
      66                 :            :     {"update", (PyCFunction)EVP_update, METH_O, EVP_update__doc__},
      67                 :            : 
      68                 :            : #if defined(PY_OPENSSL_HAS_SHAKE)
      69                 :            : 
      70                 :            : PyDoc_STRVAR(EVPXOF_digest__doc__,
      71                 :            : "digest($self, /, length)\n"
      72                 :            : "--\n"
      73                 :            : "\n"
      74                 :            : "Return the digest value as a bytes object.");
      75                 :            : 
      76                 :            : #define EVPXOF_DIGEST_METHODDEF    \
      77                 :            :     {"digest", _PyCFunction_CAST(EVPXOF_digest), METH_FASTCALL|METH_KEYWORDS, EVPXOF_digest__doc__},
      78                 :            : 
      79                 :            : static PyObject *
      80                 :            : EVPXOF_digest_impl(EVPobject *self, Py_ssize_t length);
      81                 :            : 
      82                 :            : static PyObject *
      83                 :       1076 : EVPXOF_digest(EVPobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      84                 :            : {
      85                 :       1076 :     PyObject *return_value = NULL;
      86                 :            :     static const char * const _keywords[] = {"length", NULL};
      87                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "digest", 0};
      88                 :            :     PyObject *argsbuf[1];
      89                 :            :     Py_ssize_t length;
      90                 :            : 
      91   [ +  -  +  -  :       1076 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             +  -  -  + ]
      92         [ -  + ]:       1076 :     if (!args) {
      93                 :          0 :         goto exit;
      94                 :            :     }
      95                 :            :     {
      96                 :       1076 :         Py_ssize_t ival = -1;
      97                 :       1076 :         PyObject *iobj = _PyNumber_Index(args[0]);
      98         [ +  - ]:       1076 :         if (iobj != NULL) {
      99                 :       1076 :             ival = PyLong_AsSsize_t(iobj);
     100                 :       1076 :             Py_DECREF(iobj);
     101                 :            :         }
     102   [ -  +  -  - ]:       1076 :         if (ival == -1 && PyErr_Occurred()) {
     103                 :          0 :             goto exit;
     104                 :            :         }
     105                 :       1076 :         length = ival;
     106                 :            :     }
     107                 :       1076 :     return_value = EVPXOF_digest_impl(self, length);
     108                 :            : 
     109                 :       1076 : exit:
     110                 :       1076 :     return return_value;
     111                 :            : }
     112                 :            : 
     113                 :            : #endif /* defined(PY_OPENSSL_HAS_SHAKE) */
     114                 :            : 
     115                 :            : #if defined(PY_OPENSSL_HAS_SHAKE)
     116                 :            : 
     117                 :            : PyDoc_STRVAR(EVPXOF_hexdigest__doc__,
     118                 :            : "hexdigest($self, /, length)\n"
     119                 :            : "--\n"
     120                 :            : "\n"
     121                 :            : "Return the digest value as a string of hexadecimal digits.");
     122                 :            : 
     123                 :            : #define EVPXOF_HEXDIGEST_METHODDEF    \
     124                 :            :     {"hexdigest", _PyCFunction_CAST(EVPXOF_hexdigest), METH_FASTCALL|METH_KEYWORDS, EVPXOF_hexdigest__doc__},
     125                 :            : 
     126                 :            : static PyObject *
     127                 :            : EVPXOF_hexdigest_impl(EVPobject *self, Py_ssize_t length);
     128                 :            : 
     129                 :            : static PyObject *
     130                 :       1044 : EVPXOF_hexdigest(EVPobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     131                 :            : {
     132                 :       1044 :     PyObject *return_value = NULL;
     133                 :            :     static const char * const _keywords[] = {"length", NULL};
     134                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "hexdigest", 0};
     135                 :            :     PyObject *argsbuf[1];
     136                 :            :     Py_ssize_t length;
     137                 :            : 
     138   [ +  -  +  -  :       1044 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             +  -  -  + ]
     139         [ -  + ]:       1044 :     if (!args) {
     140                 :          0 :         goto exit;
     141                 :            :     }
     142                 :            :     {
     143                 :       1044 :         Py_ssize_t ival = -1;
     144                 :       1044 :         PyObject *iobj = _PyNumber_Index(args[0]);
     145         [ +  - ]:       1044 :         if (iobj != NULL) {
     146                 :       1044 :             ival = PyLong_AsSsize_t(iobj);
     147                 :       1044 :             Py_DECREF(iobj);
     148                 :            :         }
     149   [ -  +  -  - ]:       1044 :         if (ival == -1 && PyErr_Occurred()) {
     150                 :          0 :             goto exit;
     151                 :            :         }
     152                 :       1044 :         length = ival;
     153                 :            :     }
     154                 :       1044 :     return_value = EVPXOF_hexdigest_impl(self, length);
     155                 :            : 
     156                 :       1044 : exit:
     157                 :       1044 :     return return_value;
     158                 :            : }
     159                 :            : 
     160                 :            : #endif /* defined(PY_OPENSSL_HAS_SHAKE) */
     161                 :            : 
     162                 :            : PyDoc_STRVAR(EVP_new__doc__,
     163                 :            : "new($module, /, name, string=b\'\', *, usedforsecurity=True)\n"
     164                 :            : "--\n"
     165                 :            : "\n"
     166                 :            : "Return a new hash object using the named algorithm.\n"
     167                 :            : "\n"
     168                 :            : "An optional string argument may be provided and will be\n"
     169                 :            : "automatically hashed.\n"
     170                 :            : "\n"
     171                 :            : "The MD5 and SHA1 algorithms are always supported.");
     172                 :            : 
     173                 :            : #define EVP_NEW_METHODDEF    \
     174                 :            :     {"new", _PyCFunction_CAST(EVP_new), METH_FASTCALL|METH_KEYWORDS, EVP_new__doc__},
     175                 :            : 
     176                 :            : static PyObject *
     177                 :            : EVP_new_impl(PyObject *module, PyObject *name_obj, PyObject *data_obj,
     178                 :            :              int usedforsecurity);
     179                 :            : 
     180                 :            : static PyObject *
     181                 :       7290 : EVP_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     182                 :            : {
     183                 :       7290 :     PyObject *return_value = NULL;
     184                 :            :     static const char * const _keywords[] = {"name", "string", "usedforsecurity", NULL};
     185                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "new", 0};
     186                 :            :     PyObject *argsbuf[3];
     187         [ +  + ]:       7290 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     188                 :            :     PyObject *name_obj;
     189                 :       7290 :     PyObject *data_obj = NULL;
     190                 :       7290 :     int usedforsecurity = 1;
     191                 :            : 
     192   [ +  +  +  -  :       7290 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
             +  -  -  + ]
     193         [ -  + ]:       7290 :     if (!args) {
     194                 :          0 :         goto exit;
     195                 :            :     }
     196                 :       7290 :     name_obj = args[0];
     197         [ -  + ]:       7290 :     if (!noptargs) {
     198                 :          0 :         goto skip_optional_pos;
     199                 :            :     }
     200         [ +  + ]:       7290 :     if (args[1]) {
     201                 :       7266 :         data_obj = args[1];
     202         [ +  + ]:       7266 :         if (!--noptargs) {
     203                 :       6953 :             goto skip_optional_pos;
     204                 :            :         }
     205                 :            :     }
     206                 :        337 : skip_optional_pos:
     207         [ +  + ]:       7290 :     if (!noptargs) {
     208                 :       6953 :         goto skip_optional_kwonly;
     209                 :            :     }
     210                 :        337 :     usedforsecurity = PyObject_IsTrue(args[2]);
     211         [ -  + ]:        337 :     if (usedforsecurity < 0) {
     212                 :          0 :         goto exit;
     213                 :            :     }
     214                 :        337 : skip_optional_kwonly:
     215                 :       7290 :     return_value = EVP_new_impl(module, name_obj, data_obj, usedforsecurity);
     216                 :            : 
     217                 :       7290 : exit:
     218                 :       7290 :     return return_value;
     219                 :            : }
     220                 :            : 
     221                 :            : PyDoc_STRVAR(_hashlib_openssl_md5__doc__,
     222                 :            : "openssl_md5($module, /, string=b\'\', *, usedforsecurity=True)\n"
     223                 :            : "--\n"
     224                 :            : "\n"
     225                 :            : "Returns a md5 hash object; optionally initialized with a string");
     226                 :            : 
     227                 :            : #define _HASHLIB_OPENSSL_MD5_METHODDEF    \
     228                 :            :     {"openssl_md5", _PyCFunction_CAST(_hashlib_openssl_md5), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_md5__doc__},
     229                 :            : 
     230                 :            : static PyObject *
     231                 :            : _hashlib_openssl_md5_impl(PyObject *module, PyObject *data_obj,
     232                 :            :                           int usedforsecurity);
     233                 :            : 
     234                 :            : static PyObject *
     235                 :        621 : _hashlib_openssl_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     236                 :            : {
     237                 :        621 :     PyObject *return_value = NULL;
     238                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     239                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_md5", 0};
     240                 :            :     PyObject *argsbuf[2];
     241         [ +  + ]:        621 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     242                 :        621 :     PyObject *data_obj = NULL;
     243                 :        621 :     int usedforsecurity = 1;
     244                 :            : 
     245   [ +  +  +  -  :        621 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     246         [ -  + ]:        621 :     if (!args) {
     247                 :          0 :         goto exit;
     248                 :            :     }
     249         [ +  + ]:        621 :     if (!noptargs) {
     250                 :         88 :         goto skip_optional_pos;
     251                 :            :     }
     252         [ +  + ]:        533 :     if (args[0]) {
     253                 :         99 :         data_obj = args[0];
     254         [ +  + ]:         99 :         if (!--noptargs) {
     255                 :         82 :             goto skip_optional_pos;
     256                 :            :         }
     257                 :            :     }
     258                 :        451 : skip_optional_pos:
     259         [ +  + ]:        621 :     if (!noptargs) {
     260                 :        170 :         goto skip_optional_kwonly;
     261                 :            :     }
     262                 :        451 :     usedforsecurity = PyObject_IsTrue(args[1]);
     263         [ -  + ]:        451 :     if (usedforsecurity < 0) {
     264                 :          0 :         goto exit;
     265                 :            :     }
     266                 :        451 : skip_optional_kwonly:
     267                 :        621 :     return_value = _hashlib_openssl_md5_impl(module, data_obj, usedforsecurity);
     268                 :            : 
     269                 :        621 : exit:
     270                 :        621 :     return return_value;
     271                 :            : }
     272                 :            : 
     273                 :            : PyDoc_STRVAR(_hashlib_openssl_sha1__doc__,
     274                 :            : "openssl_sha1($module, /, string=b\'\', *, usedforsecurity=True)\n"
     275                 :            : "--\n"
     276                 :            : "\n"
     277                 :            : "Returns a sha1 hash object; optionally initialized with a string");
     278                 :            : 
     279                 :            : #define _HASHLIB_OPENSSL_SHA1_METHODDEF    \
     280                 :            :     {"openssl_sha1", _PyCFunction_CAST(_hashlib_openssl_sha1), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha1__doc__},
     281                 :            : 
     282                 :            : static PyObject *
     283                 :            : _hashlib_openssl_sha1_impl(PyObject *module, PyObject *data_obj,
     284                 :            :                            int usedforsecurity);
     285                 :            : 
     286                 :            : static PyObject *
     287                 :        722 : _hashlib_openssl_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     288                 :            : {
     289                 :        722 :     PyObject *return_value = NULL;
     290                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     291                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha1", 0};
     292                 :            :     PyObject *argsbuf[2];
     293         [ +  + ]:        722 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     294                 :        722 :     PyObject *data_obj = NULL;
     295                 :        722 :     int usedforsecurity = 1;
     296                 :            : 
     297   [ +  +  +  -  :        722 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     298         [ -  + ]:        722 :     if (!args) {
     299                 :          0 :         goto exit;
     300                 :            :     }
     301         [ +  + ]:        722 :     if (!noptargs) {
     302                 :         85 :         goto skip_optional_pos;
     303                 :            :     }
     304         [ +  + ]:        637 :     if (args[0]) {
     305                 :        207 :         data_obj = args[0];
     306         [ +  + ]:        207 :         if (!--noptargs) {
     307                 :        201 :             goto skip_optional_pos;
     308                 :            :         }
     309                 :            :     }
     310                 :        436 : skip_optional_pos:
     311         [ +  + ]:        722 :     if (!noptargs) {
     312                 :        286 :         goto skip_optional_kwonly;
     313                 :            :     }
     314                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     315         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     316                 :          0 :         goto exit;
     317                 :            :     }
     318                 :        436 : skip_optional_kwonly:
     319                 :        722 :     return_value = _hashlib_openssl_sha1_impl(module, data_obj, usedforsecurity);
     320                 :            : 
     321                 :        722 : exit:
     322                 :        722 :     return return_value;
     323                 :            : }
     324                 :            : 
     325                 :            : PyDoc_STRVAR(_hashlib_openssl_sha224__doc__,
     326                 :            : "openssl_sha224($module, /, string=b\'\', *, usedforsecurity=True)\n"
     327                 :            : "--\n"
     328                 :            : "\n"
     329                 :            : "Returns a sha224 hash object; optionally initialized with a string");
     330                 :            : 
     331                 :            : #define _HASHLIB_OPENSSL_SHA224_METHODDEF    \
     332                 :            :     {"openssl_sha224", _PyCFunction_CAST(_hashlib_openssl_sha224), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha224__doc__},
     333                 :            : 
     334                 :            : static PyObject *
     335                 :            : _hashlib_openssl_sha224_impl(PyObject *module, PyObject *data_obj,
     336                 :            :                              int usedforsecurity);
     337                 :            : 
     338                 :            : static PyObject *
     339                 :        547 : _hashlib_openssl_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     340                 :            : {
     341                 :        547 :     PyObject *return_value = NULL;
     342                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     343                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha224", 0};
     344                 :            :     PyObject *argsbuf[2];
     345         [ +  + ]:        547 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     346                 :        547 :     PyObject *data_obj = NULL;
     347                 :        547 :     int usedforsecurity = 1;
     348                 :            : 
     349   [ +  +  +  -  :        547 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     350         [ -  + ]:        547 :     if (!args) {
     351                 :          0 :         goto exit;
     352                 :            :     }
     353         [ +  + ]:        547 :     if (!noptargs) {
     354                 :         82 :         goto skip_optional_pos;
     355                 :            :     }
     356         [ +  + ]:        465 :     if (args[0]) {
     357                 :         35 :         data_obj = args[0];
     358         [ +  + ]:         35 :         if (!--noptargs) {
     359                 :         29 :             goto skip_optional_pos;
     360                 :            :         }
     361                 :            :     }
     362                 :        436 : skip_optional_pos:
     363         [ +  + ]:        547 :     if (!noptargs) {
     364                 :        111 :         goto skip_optional_kwonly;
     365                 :            :     }
     366                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     367         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     368                 :          0 :         goto exit;
     369                 :            :     }
     370                 :        436 : skip_optional_kwonly:
     371                 :        547 :     return_value = _hashlib_openssl_sha224_impl(module, data_obj, usedforsecurity);
     372                 :            : 
     373                 :        547 : exit:
     374                 :        547 :     return return_value;
     375                 :            : }
     376                 :            : 
     377                 :            : PyDoc_STRVAR(_hashlib_openssl_sha256__doc__,
     378                 :            : "openssl_sha256($module, /, string=b\'\', *, usedforsecurity=True)\n"
     379                 :            : "--\n"
     380                 :            : "\n"
     381                 :            : "Returns a sha256 hash object; optionally initialized with a string");
     382                 :            : 
     383                 :            : #define _HASHLIB_OPENSSL_SHA256_METHODDEF    \
     384                 :            :     {"openssl_sha256", _PyCFunction_CAST(_hashlib_openssl_sha256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha256__doc__},
     385                 :            : 
     386                 :            : static PyObject *
     387                 :            : _hashlib_openssl_sha256_impl(PyObject *module, PyObject *data_obj,
     388                 :            :                              int usedforsecurity);
     389                 :            : 
     390                 :            : static PyObject *
     391                 :        598 : _hashlib_openssl_sha256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     392                 :            : {
     393                 :        598 :     PyObject *return_value = NULL;
     394                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     395                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha256", 0};
     396                 :            :     PyObject *argsbuf[2];
     397         [ +  + ]:        598 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     398                 :        598 :     PyObject *data_obj = NULL;
     399                 :        598 :     int usedforsecurity = 1;
     400                 :            : 
     401   [ +  +  +  -  :        598 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     402         [ -  + ]:        598 :     if (!args) {
     403                 :          0 :         goto exit;
     404                 :            :     }
     405         [ +  + ]:        598 :     if (!noptargs) {
     406                 :        117 :         goto skip_optional_pos;
     407                 :            :     }
     408         [ +  + ]:        481 :     if (args[0]) {
     409                 :         51 :         data_obj = args[0];
     410         [ +  + ]:         51 :         if (!--noptargs) {
     411                 :         45 :             goto skip_optional_pos;
     412                 :            :         }
     413                 :            :     }
     414                 :        436 : skip_optional_pos:
     415         [ +  + ]:        598 :     if (!noptargs) {
     416                 :        162 :         goto skip_optional_kwonly;
     417                 :            :     }
     418                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     419         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     420                 :          0 :         goto exit;
     421                 :            :     }
     422                 :        436 : skip_optional_kwonly:
     423                 :        598 :     return_value = _hashlib_openssl_sha256_impl(module, data_obj, usedforsecurity);
     424                 :            : 
     425                 :        598 : exit:
     426                 :        598 :     return return_value;
     427                 :            : }
     428                 :            : 
     429                 :            : PyDoc_STRVAR(_hashlib_openssl_sha384__doc__,
     430                 :            : "openssl_sha384($module, /, string=b\'\', *, usedforsecurity=True)\n"
     431                 :            : "--\n"
     432                 :            : "\n"
     433                 :            : "Returns a sha384 hash object; optionally initialized with a string");
     434                 :            : 
     435                 :            : #define _HASHLIB_OPENSSL_SHA384_METHODDEF    \
     436                 :            :     {"openssl_sha384", _PyCFunction_CAST(_hashlib_openssl_sha384), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha384__doc__},
     437                 :            : 
     438                 :            : static PyObject *
     439                 :            : _hashlib_openssl_sha384_impl(PyObject *module, PyObject *data_obj,
     440                 :            :                              int usedforsecurity);
     441                 :            : 
     442                 :            : static PyObject *
     443                 :        523 : _hashlib_openssl_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     444                 :            : {
     445                 :        523 :     PyObject *return_value = NULL;
     446                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     447                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha384", 0};
     448                 :            :     PyObject *argsbuf[2];
     449         [ +  + ]:        523 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     450                 :        523 :     PyObject *data_obj = NULL;
     451                 :        523 :     int usedforsecurity = 1;
     452                 :            : 
     453   [ +  +  +  -  :        523 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     454         [ -  + ]:        523 :     if (!args) {
     455                 :          0 :         goto exit;
     456                 :            :     }
     457         [ +  + ]:        523 :     if (!noptargs) {
     458                 :         82 :         goto skip_optional_pos;
     459                 :            :     }
     460         [ +  + ]:        441 :     if (args[0]) {
     461                 :         11 :         data_obj = args[0];
     462         [ +  + ]:         11 :         if (!--noptargs) {
     463                 :          5 :             goto skip_optional_pos;
     464                 :            :         }
     465                 :            :     }
     466                 :        436 : skip_optional_pos:
     467         [ +  + ]:        523 :     if (!noptargs) {
     468                 :         87 :         goto skip_optional_kwonly;
     469                 :            :     }
     470                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     471         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     472                 :          0 :         goto exit;
     473                 :            :     }
     474                 :        436 : skip_optional_kwonly:
     475                 :        523 :     return_value = _hashlib_openssl_sha384_impl(module, data_obj, usedforsecurity);
     476                 :            : 
     477                 :        523 : exit:
     478                 :        523 :     return return_value;
     479                 :            : }
     480                 :            : 
     481                 :            : PyDoc_STRVAR(_hashlib_openssl_sha512__doc__,
     482                 :            : "openssl_sha512($module, /, string=b\'\', *, usedforsecurity=True)\n"
     483                 :            : "--\n"
     484                 :            : "\n"
     485                 :            : "Returns a sha512 hash object; optionally initialized with a string");
     486                 :            : 
     487                 :            : #define _HASHLIB_OPENSSL_SHA512_METHODDEF    \
     488                 :            :     {"openssl_sha512", _PyCFunction_CAST(_hashlib_openssl_sha512), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha512__doc__},
     489                 :            : 
     490                 :            : static PyObject *
     491                 :            : _hashlib_openssl_sha512_impl(PyObject *module, PyObject *data_obj,
     492                 :            :                              int usedforsecurity);
     493                 :            : 
     494                 :            : static PyObject *
     495                 :        523 : _hashlib_openssl_sha512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     496                 :            : {
     497                 :        523 :     PyObject *return_value = NULL;
     498                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     499                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha512", 0};
     500                 :            :     PyObject *argsbuf[2];
     501         [ +  + ]:        523 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     502                 :        523 :     PyObject *data_obj = NULL;
     503                 :        523 :     int usedforsecurity = 1;
     504                 :            : 
     505   [ +  +  +  -  :        523 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     506         [ -  + ]:        523 :     if (!args) {
     507                 :          0 :         goto exit;
     508                 :            :     }
     509         [ +  + ]:        523 :     if (!noptargs) {
     510                 :         82 :         goto skip_optional_pos;
     511                 :            :     }
     512         [ +  + ]:        441 :     if (args[0]) {
     513                 :         11 :         data_obj = args[0];
     514         [ +  + ]:         11 :         if (!--noptargs) {
     515                 :          5 :             goto skip_optional_pos;
     516                 :            :         }
     517                 :            :     }
     518                 :        436 : skip_optional_pos:
     519         [ +  + ]:        523 :     if (!noptargs) {
     520                 :         87 :         goto skip_optional_kwonly;
     521                 :            :     }
     522                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     523         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     524                 :          0 :         goto exit;
     525                 :            :     }
     526                 :        436 : skip_optional_kwonly:
     527                 :        523 :     return_value = _hashlib_openssl_sha512_impl(module, data_obj, usedforsecurity);
     528                 :            : 
     529                 :        523 : exit:
     530                 :        523 :     return return_value;
     531                 :            : }
     532                 :            : 
     533                 :            : #if defined(PY_OPENSSL_HAS_SHA3)
     534                 :            : 
     535                 :            : PyDoc_STRVAR(_hashlib_openssl_sha3_224__doc__,
     536                 :            : "openssl_sha3_224($module, /, string=b\'\', *, usedforsecurity=True)\n"
     537                 :            : "--\n"
     538                 :            : "\n"
     539                 :            : "Returns a sha3-224 hash object; optionally initialized with a string");
     540                 :            : 
     541                 :            : #define _HASHLIB_OPENSSL_SHA3_224_METHODDEF    \
     542                 :            :     {"openssl_sha3_224", _PyCFunction_CAST(_hashlib_openssl_sha3_224), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_224__doc__},
     543                 :            : 
     544                 :            : static PyObject *
     545                 :            : _hashlib_openssl_sha3_224_impl(PyObject *module, PyObject *data_obj,
     546                 :            :                                int usedforsecurity);
     547                 :            : 
     548                 :            : static PyObject *
     549                 :       1282 : _hashlib_openssl_sha3_224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     550                 :            : {
     551                 :       1282 :     PyObject *return_value = NULL;
     552                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     553                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_224", 0};
     554                 :            :     PyObject *argsbuf[2];
     555         [ +  + ]:       1282 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     556                 :       1282 :     PyObject *data_obj = NULL;
     557                 :       1282 :     int usedforsecurity = 1;
     558                 :            : 
     559   [ +  +  +  -  :       1282 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     560         [ -  + ]:       1282 :     if (!args) {
     561                 :          0 :         goto exit;
     562                 :            :     }
     563         [ +  + ]:       1282 :     if (!noptargs) {
     564                 :        588 :         goto skip_optional_pos;
     565                 :            :     }
     566         [ +  + ]:        694 :     if (args[0]) {
     567                 :        264 :         data_obj = args[0];
     568         [ +  + ]:        264 :         if (!--noptargs) {
     569                 :        258 :             goto skip_optional_pos;
     570                 :            :         }
     571                 :            :     }
     572                 :        436 : skip_optional_pos:
     573         [ +  + ]:       1282 :     if (!noptargs) {
     574                 :        846 :         goto skip_optional_kwonly;
     575                 :            :     }
     576                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     577         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     578                 :          0 :         goto exit;
     579                 :            :     }
     580                 :        436 : skip_optional_kwonly:
     581                 :       1282 :     return_value = _hashlib_openssl_sha3_224_impl(module, data_obj, usedforsecurity);
     582                 :            : 
     583                 :       1282 : exit:
     584                 :       1282 :     return return_value;
     585                 :            : }
     586                 :            : 
     587                 :            : #endif /* defined(PY_OPENSSL_HAS_SHA3) */
     588                 :            : 
     589                 :            : #if defined(PY_OPENSSL_HAS_SHA3)
     590                 :            : 
     591                 :            : PyDoc_STRVAR(_hashlib_openssl_sha3_256__doc__,
     592                 :            : "openssl_sha3_256($module, /, string=b\'\', *, usedforsecurity=True)\n"
     593                 :            : "--\n"
     594                 :            : "\n"
     595                 :            : "Returns a sha3-256 hash object; optionally initialized with a string");
     596                 :            : 
     597                 :            : #define _HASHLIB_OPENSSL_SHA3_256_METHODDEF    \
     598                 :            :     {"openssl_sha3_256", _PyCFunction_CAST(_hashlib_openssl_sha3_256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_256__doc__},
     599                 :            : 
     600                 :            : static PyObject *
     601                 :            : _hashlib_openssl_sha3_256_impl(PyObject *module, PyObject *data_obj,
     602                 :            :                                int usedforsecurity);
     603                 :            : 
     604                 :            : static PyObject *
     605                 :       1282 : _hashlib_openssl_sha3_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     606                 :            : {
     607                 :       1282 :     PyObject *return_value = NULL;
     608                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     609                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_256", 0};
     610                 :            :     PyObject *argsbuf[2];
     611         [ +  + ]:       1282 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     612                 :       1282 :     PyObject *data_obj = NULL;
     613                 :       1282 :     int usedforsecurity = 1;
     614                 :            : 
     615   [ +  +  +  -  :       1282 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     616         [ -  + ]:       1282 :     if (!args) {
     617                 :          0 :         goto exit;
     618                 :            :     }
     619         [ +  + ]:       1282 :     if (!noptargs) {
     620                 :        588 :         goto skip_optional_pos;
     621                 :            :     }
     622         [ +  + ]:        694 :     if (args[0]) {
     623                 :        264 :         data_obj = args[0];
     624         [ +  + ]:        264 :         if (!--noptargs) {
     625                 :        258 :             goto skip_optional_pos;
     626                 :            :         }
     627                 :            :     }
     628                 :        436 : skip_optional_pos:
     629         [ +  + ]:       1282 :     if (!noptargs) {
     630                 :        846 :         goto skip_optional_kwonly;
     631                 :            :     }
     632                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     633         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     634                 :          0 :         goto exit;
     635                 :            :     }
     636                 :        436 : skip_optional_kwonly:
     637                 :       1282 :     return_value = _hashlib_openssl_sha3_256_impl(module, data_obj, usedforsecurity);
     638                 :            : 
     639                 :       1282 : exit:
     640                 :       1282 :     return return_value;
     641                 :            : }
     642                 :            : 
     643                 :            : #endif /* defined(PY_OPENSSL_HAS_SHA3) */
     644                 :            : 
     645                 :            : #if defined(PY_OPENSSL_HAS_SHA3)
     646                 :            : 
     647                 :            : PyDoc_STRVAR(_hashlib_openssl_sha3_384__doc__,
     648                 :            : "openssl_sha3_384($module, /, string=b\'\', *, usedforsecurity=True)\n"
     649                 :            : "--\n"
     650                 :            : "\n"
     651                 :            : "Returns a sha3-384 hash object; optionally initialized with a string");
     652                 :            : 
     653                 :            : #define _HASHLIB_OPENSSL_SHA3_384_METHODDEF    \
     654                 :            :     {"openssl_sha3_384", _PyCFunction_CAST(_hashlib_openssl_sha3_384), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_384__doc__},
     655                 :            : 
     656                 :            : static PyObject *
     657                 :            : _hashlib_openssl_sha3_384_impl(PyObject *module, PyObject *data_obj,
     658                 :            :                                int usedforsecurity);
     659                 :            : 
     660                 :            : static PyObject *
     661                 :       1282 : _hashlib_openssl_sha3_384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     662                 :            : {
     663                 :       1282 :     PyObject *return_value = NULL;
     664                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     665                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_384", 0};
     666                 :            :     PyObject *argsbuf[2];
     667         [ +  + ]:       1282 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     668                 :       1282 :     PyObject *data_obj = NULL;
     669                 :       1282 :     int usedforsecurity = 1;
     670                 :            : 
     671   [ +  +  +  -  :       1282 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     672         [ -  + ]:       1282 :     if (!args) {
     673                 :          0 :         goto exit;
     674                 :            :     }
     675         [ +  + ]:       1282 :     if (!noptargs) {
     676                 :        588 :         goto skip_optional_pos;
     677                 :            :     }
     678         [ +  + ]:        694 :     if (args[0]) {
     679                 :        264 :         data_obj = args[0];
     680         [ +  + ]:        264 :         if (!--noptargs) {
     681                 :        258 :             goto skip_optional_pos;
     682                 :            :         }
     683                 :            :     }
     684                 :        436 : skip_optional_pos:
     685         [ +  + ]:       1282 :     if (!noptargs) {
     686                 :        846 :         goto skip_optional_kwonly;
     687                 :            :     }
     688                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     689         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     690                 :          0 :         goto exit;
     691                 :            :     }
     692                 :        436 : skip_optional_kwonly:
     693                 :       1282 :     return_value = _hashlib_openssl_sha3_384_impl(module, data_obj, usedforsecurity);
     694                 :            : 
     695                 :       1282 : exit:
     696                 :       1282 :     return return_value;
     697                 :            : }
     698                 :            : 
     699                 :            : #endif /* defined(PY_OPENSSL_HAS_SHA3) */
     700                 :            : 
     701                 :            : #if defined(PY_OPENSSL_HAS_SHA3)
     702                 :            : 
     703                 :            : PyDoc_STRVAR(_hashlib_openssl_sha3_512__doc__,
     704                 :            : "openssl_sha3_512($module, /, string=b\'\', *, usedforsecurity=True)\n"
     705                 :            : "--\n"
     706                 :            : "\n"
     707                 :            : "Returns a sha3-512 hash object; optionally initialized with a string");
     708                 :            : 
     709                 :            : #define _HASHLIB_OPENSSL_SHA3_512_METHODDEF    \
     710                 :            :     {"openssl_sha3_512", _PyCFunction_CAST(_hashlib_openssl_sha3_512), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_sha3_512__doc__},
     711                 :            : 
     712                 :            : static PyObject *
     713                 :            : _hashlib_openssl_sha3_512_impl(PyObject *module, PyObject *data_obj,
     714                 :            :                                int usedforsecurity);
     715                 :            : 
     716                 :            : static PyObject *
     717                 :       1282 : _hashlib_openssl_sha3_512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     718                 :            : {
     719                 :       1282 :     PyObject *return_value = NULL;
     720                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     721                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_sha3_512", 0};
     722                 :            :     PyObject *argsbuf[2];
     723         [ +  + ]:       1282 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     724                 :       1282 :     PyObject *data_obj = NULL;
     725                 :       1282 :     int usedforsecurity = 1;
     726                 :            : 
     727   [ +  +  +  -  :       1282 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     728         [ -  + ]:       1282 :     if (!args) {
     729                 :          0 :         goto exit;
     730                 :            :     }
     731         [ +  + ]:       1282 :     if (!noptargs) {
     732                 :        588 :         goto skip_optional_pos;
     733                 :            :     }
     734         [ +  + ]:        694 :     if (args[0]) {
     735                 :        264 :         data_obj = args[0];
     736         [ +  + ]:        264 :         if (!--noptargs) {
     737                 :        258 :             goto skip_optional_pos;
     738                 :            :         }
     739                 :            :     }
     740                 :        436 : skip_optional_pos:
     741         [ +  + ]:       1282 :     if (!noptargs) {
     742                 :        846 :         goto skip_optional_kwonly;
     743                 :            :     }
     744                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     745         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     746                 :          0 :         goto exit;
     747                 :            :     }
     748                 :        436 : skip_optional_kwonly:
     749                 :       1282 :     return_value = _hashlib_openssl_sha3_512_impl(module, data_obj, usedforsecurity);
     750                 :            : 
     751                 :       1282 : exit:
     752                 :       1282 :     return return_value;
     753                 :            : }
     754                 :            : 
     755                 :            : #endif /* defined(PY_OPENSSL_HAS_SHA3) */
     756                 :            : 
     757                 :            : #if defined(PY_OPENSSL_HAS_SHAKE)
     758                 :            : 
     759                 :            : PyDoc_STRVAR(_hashlib_openssl_shake_128__doc__,
     760                 :            : "openssl_shake_128($module, /, string=b\'\', *, usedforsecurity=True)\n"
     761                 :            : "--\n"
     762                 :            : "\n"
     763                 :            : "Returns a shake-128 variable hash object; optionally initialized with a string");
     764                 :            : 
     765                 :            : #define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF    \
     766                 :            :     {"openssl_shake_128", _PyCFunction_CAST(_hashlib_openssl_shake_128), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_128__doc__},
     767                 :            : 
     768                 :            : static PyObject *
     769                 :            : _hashlib_openssl_shake_128_impl(PyObject *module, PyObject *data_obj,
     770                 :            :                                 int usedforsecurity);
     771                 :            : 
     772                 :            : static PyObject *
     773                 :        769 : _hashlib_openssl_shake_128(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     774                 :            : {
     775                 :        769 :     PyObject *return_value = NULL;
     776                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     777                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_shake_128", 0};
     778                 :            :     PyObject *argsbuf[2];
     779         [ +  + ]:        769 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     780                 :        769 :     PyObject *data_obj = NULL;
     781                 :        769 :     int usedforsecurity = 1;
     782                 :            : 
     783   [ +  +  +  -  :        769 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     784         [ -  + ]:        769 :     if (!args) {
     785                 :          0 :         goto exit;
     786                 :            :     }
     787         [ +  + ]:        769 :     if (!noptargs) {
     788                 :         74 :         goto skip_optional_pos;
     789                 :            :     }
     790         [ +  + ]:        695 :     if (args[0]) {
     791                 :        265 :         data_obj = args[0];
     792         [ +  + ]:        265 :         if (!--noptargs) {
     793                 :        259 :             goto skip_optional_pos;
     794                 :            :         }
     795                 :            :     }
     796                 :        436 : skip_optional_pos:
     797         [ +  + ]:        769 :     if (!noptargs) {
     798                 :        333 :         goto skip_optional_kwonly;
     799                 :            :     }
     800                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     801         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     802                 :          0 :         goto exit;
     803                 :            :     }
     804                 :        436 : skip_optional_kwonly:
     805                 :        769 :     return_value = _hashlib_openssl_shake_128_impl(module, data_obj, usedforsecurity);
     806                 :            : 
     807                 :        769 : exit:
     808                 :        769 :     return return_value;
     809                 :            : }
     810                 :            : 
     811                 :            : #endif /* defined(PY_OPENSSL_HAS_SHAKE) */
     812                 :            : 
     813                 :            : #if defined(PY_OPENSSL_HAS_SHAKE)
     814                 :            : 
     815                 :            : PyDoc_STRVAR(_hashlib_openssl_shake_256__doc__,
     816                 :            : "openssl_shake_256($module, /, string=b\'\', *, usedforsecurity=True)\n"
     817                 :            : "--\n"
     818                 :            : "\n"
     819                 :            : "Returns a shake-256 variable hash object; optionally initialized with a string");
     820                 :            : 
     821                 :            : #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF    \
     822                 :            :     {"openssl_shake_256", _PyCFunction_CAST(_hashlib_openssl_shake_256), METH_FASTCALL|METH_KEYWORDS, _hashlib_openssl_shake_256__doc__},
     823                 :            : 
     824                 :            : static PyObject *
     825                 :            : _hashlib_openssl_shake_256_impl(PyObject *module, PyObject *data_obj,
     826                 :            :                                 int usedforsecurity);
     827                 :            : 
     828                 :            : static PyObject *
     829                 :        769 : _hashlib_openssl_shake_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     830                 :            : {
     831                 :        769 :     PyObject *return_value = NULL;
     832                 :            :     static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
     833                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "openssl_shake_256", 0};
     834                 :            :     PyObject *argsbuf[2];
     835         [ +  + ]:        769 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     836                 :        769 :     PyObject *data_obj = NULL;
     837                 :        769 :     int usedforsecurity = 1;
     838                 :            : 
     839   [ +  +  +  -  :        769 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  -  -  + ]
     840         [ -  + ]:        769 :     if (!args) {
     841                 :          0 :         goto exit;
     842                 :            :     }
     843         [ +  + ]:        769 :     if (!noptargs) {
     844                 :         74 :         goto skip_optional_pos;
     845                 :            :     }
     846         [ +  + ]:        695 :     if (args[0]) {
     847                 :        265 :         data_obj = args[0];
     848         [ +  + ]:        265 :         if (!--noptargs) {
     849                 :        259 :             goto skip_optional_pos;
     850                 :            :         }
     851                 :            :     }
     852                 :        436 : skip_optional_pos:
     853         [ +  + ]:        769 :     if (!noptargs) {
     854                 :        333 :         goto skip_optional_kwonly;
     855                 :            :     }
     856                 :        436 :     usedforsecurity = PyObject_IsTrue(args[1]);
     857         [ -  + ]:        436 :     if (usedforsecurity < 0) {
     858                 :          0 :         goto exit;
     859                 :            :     }
     860                 :        436 : skip_optional_kwonly:
     861                 :        769 :     return_value = _hashlib_openssl_shake_256_impl(module, data_obj, usedforsecurity);
     862                 :            : 
     863                 :        769 : exit:
     864                 :        769 :     return return_value;
     865                 :            : }
     866                 :            : 
     867                 :            : #endif /* defined(PY_OPENSSL_HAS_SHAKE) */
     868                 :            : 
     869                 :            : PyDoc_STRVAR(pbkdf2_hmac__doc__,
     870                 :            : "pbkdf2_hmac($module, /, hash_name, password, salt, iterations,\n"
     871                 :            : "            dklen=None)\n"
     872                 :            : "--\n"
     873                 :            : "\n"
     874                 :            : "Password based key derivation function 2 (PKCS #5 v2.0) with HMAC as pseudorandom function.");
     875                 :            : 
     876                 :            : #define PBKDF2_HMAC_METHODDEF    \
     877                 :            :     {"pbkdf2_hmac", _PyCFunction_CAST(pbkdf2_hmac), METH_FASTCALL|METH_KEYWORDS, pbkdf2_hmac__doc__},
     878                 :            : 
     879                 :            : static PyObject *
     880                 :            : pbkdf2_hmac_impl(PyObject *module, const char *hash_name,
     881                 :            :                  Py_buffer *password, Py_buffer *salt, long iterations,
     882                 :            :                  PyObject *dklen_obj);
     883                 :            : 
     884                 :            : static PyObject *
     885                 :         62 : pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     886                 :            : {
     887                 :         62 :     PyObject *return_value = NULL;
     888                 :            :     static const char * const _keywords[] = {"hash_name", "password", "salt", "iterations", "dklen", NULL};
     889                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "pbkdf2_hmac", 0};
     890                 :            :     PyObject *argsbuf[5];
     891         [ +  + ]:         62 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4;
     892                 :            :     const char *hash_name;
     893                 :         62 :     Py_buffer password = {NULL, NULL};
     894                 :         62 :     Py_buffer salt = {NULL, NULL};
     895                 :            :     long iterations;
     896                 :         62 :     PyObject *dklen_obj = Py_None;
     897                 :            : 
     898   [ +  +  +  -  :         62 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 5, 0, argsbuf);
             +  -  -  + ]
     899         [ -  + ]:         62 :     if (!args) {
     900                 :          0 :         goto exit;
     901                 :            :     }
     902         [ +  + ]:         62 :     if (!PyUnicode_Check(args[0])) {
     903                 :          1 :         _PyArg_BadArgument("pbkdf2_hmac", "argument 'hash_name'", "str", args[0]);
     904                 :          1 :         goto exit;
     905                 :            :     }
     906                 :            :     Py_ssize_t hash_name_length;
     907                 :         61 :     hash_name = PyUnicode_AsUTF8AndSize(args[0], &hash_name_length);
     908         [ -  + ]:         61 :     if (hash_name == NULL) {
     909                 :          0 :         goto exit;
     910                 :            :     }
     911         [ -  + ]:         61 :     if (strlen(hash_name) != (size_t)hash_name_length) {
     912                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
     913                 :          0 :         goto exit;
     914                 :            :     }
     915         [ +  + ]:         61 :     if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) {
     916                 :          1 :         goto exit;
     917                 :            :     }
     918         [ -  + ]:         60 :     if (!PyBuffer_IsContiguous(&password, 'C')) {
     919                 :          0 :         _PyArg_BadArgument("pbkdf2_hmac", "argument 'password'", "contiguous buffer", args[1]);
     920                 :          0 :         goto exit;
     921                 :            :     }
     922         [ -  + ]:         60 :     if (PyObject_GetBuffer(args[2], &salt, PyBUF_SIMPLE) != 0) {
     923                 :          0 :         goto exit;
     924                 :            :     }
     925         [ -  + ]:         60 :     if (!PyBuffer_IsContiguous(&salt, 'C')) {
     926                 :          0 :         _PyArg_BadArgument("pbkdf2_hmac", "argument 'salt'", "contiguous buffer", args[2]);
     927                 :          0 :         goto exit;
     928                 :            :     }
     929                 :         60 :     iterations = PyLong_AsLong(args[3]);
     930   [ +  +  -  + ]:         60 :     if (iterations == -1 && PyErr_Occurred()) {
     931                 :          0 :         goto exit;
     932                 :            :     }
     933         [ +  + ]:         60 :     if (!noptargs) {
     934                 :         12 :         goto skip_optional_pos;
     935                 :            :     }
     936                 :         48 :     dklen_obj = args[4];
     937                 :         60 : skip_optional_pos:
     938                 :         60 :     return_value = pbkdf2_hmac_impl(module, hash_name, &password, &salt, iterations, dklen_obj);
     939                 :            : 
     940                 :         62 : exit:
     941                 :            :     /* Cleanup for password */
     942         [ +  + ]:         62 :     if (password.obj) {
     943                 :         60 :        PyBuffer_Release(&password);
     944                 :            :     }
     945                 :            :     /* Cleanup for salt */
     946         [ +  + ]:         62 :     if (salt.obj) {
     947                 :         60 :        PyBuffer_Release(&salt);
     948                 :            :     }
     949                 :            : 
     950                 :         62 :     return return_value;
     951                 :            : }
     952                 :            : 
     953                 :            : #if defined(PY_OPENSSL_HAS_SCRYPT)
     954                 :            : 
     955                 :            : PyDoc_STRVAR(_hashlib_scrypt__doc__,
     956                 :            : "scrypt($module, /, password, *, salt=None, n=None, r=None, p=None,\n"
     957                 :            : "       maxmem=0, dklen=64)\n"
     958                 :            : "--\n"
     959                 :            : "\n"
     960                 :            : "scrypt password-based key derivation function.");
     961                 :            : 
     962                 :            : #define _HASHLIB_SCRYPT_METHODDEF    \
     963                 :            :     {"scrypt", _PyCFunction_CAST(_hashlib_scrypt), METH_FASTCALL|METH_KEYWORDS, _hashlib_scrypt__doc__},
     964                 :            : 
     965                 :            : static PyObject *
     966                 :            : _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer *salt,
     967                 :            :                      PyObject *n_obj, PyObject *r_obj, PyObject *p_obj,
     968                 :            :                      long maxmem, long dklen);
     969                 :            : 
     970                 :            : static PyObject *
     971                 :         23 : _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     972                 :            : {
     973                 :         23 :     PyObject *return_value = NULL;
     974                 :            :     static const char * const _keywords[] = {"password", "salt", "n", "r", "p", "maxmem", "dklen", NULL};
     975                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "scrypt", 0};
     976                 :            :     PyObject *argsbuf[7];
     977         [ +  + ]:         23 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     978                 :         23 :     Py_buffer password = {NULL, NULL};
     979                 :         23 :     Py_buffer salt = {NULL, NULL};
     980                 :         23 :     PyObject *n_obj = Py_None;
     981                 :         23 :     PyObject *r_obj = Py_None;
     982                 :         23 :     PyObject *p_obj = Py_None;
     983                 :         23 :     long maxmem = 0;
     984                 :         23 :     long dklen = 64;
     985                 :            : 
     986   [ +  +  +  -  :         23 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             +  +  -  + ]
     987         [ +  + ]:         23 :     if (!args) {
     988                 :          2 :         goto exit;
     989                 :            :     }
     990         [ +  + ]:         21 :     if (PyObject_GetBuffer(args[0], &password, PyBUF_SIMPLE) != 0) {
     991                 :          1 :         goto exit;
     992                 :            :     }
     993         [ -  + ]:         20 :     if (!PyBuffer_IsContiguous(&password, 'C')) {
     994                 :          0 :         _PyArg_BadArgument("scrypt", "argument 'password'", "contiguous buffer", args[0]);
     995                 :          0 :         goto exit;
     996                 :            :     }
     997         [ +  + ]:         20 :     if (!noptargs) {
     998                 :          1 :         goto skip_optional_kwonly;
     999                 :            :     }
    1000         [ +  - ]:         19 :     if (args[1]) {
    1001         [ +  + ]:         19 :         if (PyObject_GetBuffer(args[1], &salt, PyBUF_SIMPLE) != 0) {
    1002                 :          1 :             goto exit;
    1003                 :            :         }
    1004         [ -  + ]:         18 :         if (!PyBuffer_IsContiguous(&salt, 'C')) {
    1005                 :          0 :             _PyArg_BadArgument("scrypt", "argument 'salt'", "contiguous buffer", args[1]);
    1006                 :          0 :             goto exit;
    1007                 :            :         }
    1008         [ -  + ]:         18 :         if (!--noptargs) {
    1009                 :          0 :             goto skip_optional_kwonly;
    1010                 :            :         }
    1011                 :            :     }
    1012         [ +  - ]:         18 :     if (args[2]) {
    1013         [ +  + ]:         18 :         if (!PyLong_Check(args[2])) {
    1014                 :          1 :             _PyArg_BadArgument("scrypt", "argument 'n'", "int", args[2]);
    1015                 :          1 :             goto exit;
    1016                 :            :         }
    1017                 :         17 :         n_obj = args[2];
    1018         [ -  + ]:         17 :         if (!--noptargs) {
    1019                 :          0 :             goto skip_optional_kwonly;
    1020                 :            :         }
    1021                 :            :     }
    1022         [ +  - ]:         17 :     if (args[3]) {
    1023         [ +  + ]:         17 :         if (!PyLong_Check(args[3])) {
    1024                 :          1 :             _PyArg_BadArgument("scrypt", "argument 'r'", "int", args[3]);
    1025                 :          1 :             goto exit;
    1026                 :            :         }
    1027                 :         16 :         r_obj = args[3];
    1028         [ -  + ]:         16 :         if (!--noptargs) {
    1029                 :          0 :             goto skip_optional_kwonly;
    1030                 :            :         }
    1031                 :            :     }
    1032         [ +  - ]:         16 :     if (args[4]) {
    1033         [ +  + ]:         16 :         if (!PyLong_Check(args[4])) {
    1034                 :          1 :             _PyArg_BadArgument("scrypt", "argument 'p'", "int", args[4]);
    1035                 :          1 :             goto exit;
    1036                 :            :         }
    1037                 :         15 :         p_obj = args[4];
    1038         [ +  + ]:         15 :         if (!--noptargs) {
    1039                 :         11 :             goto skip_optional_kwonly;
    1040                 :            :         }
    1041                 :            :     }
    1042         [ +  + ]:          4 :     if (args[5]) {
    1043                 :          2 :         maxmem = PyLong_AsLong(args[5]);
    1044   [ +  -  +  + ]:          2 :         if (maxmem == -1 && PyErr_Occurred()) {
    1045                 :          1 :             goto exit;
    1046                 :            :         }
    1047         [ +  - ]:          1 :         if (!--noptargs) {
    1048                 :          1 :             goto skip_optional_kwonly;
    1049                 :            :         }
    1050                 :            :     }
    1051                 :          2 :     dklen = PyLong_AsLong(args[6]);
    1052   [ +  -  +  + ]:          2 :     if (dklen == -1 && PyErr_Occurred()) {
    1053                 :          1 :         goto exit;
    1054                 :            :     }
    1055                 :          1 : skip_optional_kwonly:
    1056                 :         14 :     return_value = _hashlib_scrypt_impl(module, &password, &salt, n_obj, r_obj, p_obj, maxmem, dklen);
    1057                 :            : 
    1058                 :         23 : exit:
    1059                 :            :     /* Cleanup for password */
    1060         [ +  + ]:         23 :     if (password.obj) {
    1061                 :         20 :        PyBuffer_Release(&password);
    1062                 :            :     }
    1063                 :            :     /* Cleanup for salt */
    1064         [ +  + ]:         23 :     if (salt.obj) {
    1065                 :         18 :        PyBuffer_Release(&salt);
    1066                 :            :     }
    1067                 :            : 
    1068                 :         23 :     return return_value;
    1069                 :            : }
    1070                 :            : 
    1071                 :            : #endif /* defined(PY_OPENSSL_HAS_SCRYPT) */
    1072                 :            : 
    1073                 :            : PyDoc_STRVAR(_hashlib_hmac_singleshot__doc__,
    1074                 :            : "hmac_digest($module, /, key, msg, digest)\n"
    1075                 :            : "--\n"
    1076                 :            : "\n"
    1077                 :            : "Single-shot HMAC.");
    1078                 :            : 
    1079                 :            : #define _HASHLIB_HMAC_SINGLESHOT_METHODDEF    \
    1080                 :            :     {"hmac_digest", _PyCFunction_CAST(_hashlib_hmac_singleshot), METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_singleshot__doc__},
    1081                 :            : 
    1082                 :            : static PyObject *
    1083                 :            : _hashlib_hmac_singleshot_impl(PyObject *module, Py_buffer *key,
    1084                 :            :                               Py_buffer *msg, PyObject *digest);
    1085                 :            : 
    1086                 :            : static PyObject *
    1087                 :         77 : _hashlib_hmac_singleshot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1088                 :            : {
    1089                 :         77 :     PyObject *return_value = NULL;
    1090                 :            :     static const char * const _keywords[] = {"key", "msg", "digest", NULL};
    1091                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "hmac_digest", 0};
    1092                 :            :     PyObject *argsbuf[3];
    1093                 :         77 :     Py_buffer key = {NULL, NULL};
    1094                 :         77 :     Py_buffer msg = {NULL, NULL};
    1095                 :            :     PyObject *digest;
    1096                 :            : 
    1097   [ +  -  +  -  :         77 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
             +  -  -  + ]
    1098         [ -  + ]:         77 :     if (!args) {
    1099                 :          0 :         goto exit;
    1100                 :            :     }
    1101         [ -  + ]:         77 :     if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) {
    1102                 :          0 :         goto exit;
    1103                 :            :     }
    1104         [ -  + ]:         77 :     if (!PyBuffer_IsContiguous(&key, 'C')) {
    1105                 :          0 :         _PyArg_BadArgument("hmac_digest", "argument 'key'", "contiguous buffer", args[0]);
    1106                 :          0 :         goto exit;
    1107                 :            :     }
    1108         [ -  + ]:         77 :     if (PyObject_GetBuffer(args[1], &msg, PyBUF_SIMPLE) != 0) {
    1109                 :          0 :         goto exit;
    1110                 :            :     }
    1111         [ -  + ]:         77 :     if (!PyBuffer_IsContiguous(&msg, 'C')) {
    1112                 :          0 :         _PyArg_BadArgument("hmac_digest", "argument 'msg'", "contiguous buffer", args[1]);
    1113                 :          0 :         goto exit;
    1114                 :            :     }
    1115                 :         77 :     digest = args[2];
    1116                 :         77 :     return_value = _hashlib_hmac_singleshot_impl(module, &key, &msg, digest);
    1117                 :            : 
    1118                 :         77 : exit:
    1119                 :            :     /* Cleanup for key */
    1120         [ +  - ]:         77 :     if (key.obj) {
    1121                 :         77 :        PyBuffer_Release(&key);
    1122                 :            :     }
    1123                 :            :     /* Cleanup for msg */
    1124         [ +  - ]:         77 :     if (msg.obj) {
    1125                 :         77 :        PyBuffer_Release(&msg);
    1126                 :            :     }
    1127                 :            : 
    1128                 :         77 :     return return_value;
    1129                 :            : }
    1130                 :            : 
    1131                 :            : PyDoc_STRVAR(_hashlib_hmac_new__doc__,
    1132                 :            : "hmac_new($module, /, key, msg=b\'\', digestmod=None)\n"
    1133                 :            : "--\n"
    1134                 :            : "\n"
    1135                 :            : "Return a new hmac object.");
    1136                 :            : 
    1137                 :            : #define _HASHLIB_HMAC_NEW_METHODDEF    \
    1138                 :            :     {"hmac_new", _PyCFunction_CAST(_hashlib_hmac_new), METH_FASTCALL|METH_KEYWORDS, _hashlib_hmac_new__doc__},
    1139                 :            : 
    1140                 :            : static PyObject *
    1141                 :            : _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
    1142                 :            :                        PyObject *digestmod);
    1143                 :            : 
    1144                 :            : static PyObject *
    1145                 :       7744 : _hashlib_hmac_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1146                 :            : {
    1147                 :       7744 :     PyObject *return_value = NULL;
    1148                 :            :     static const char * const _keywords[] = {"key", "msg", "digestmod", NULL};
    1149                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "hmac_new", 0};
    1150                 :            :     PyObject *argsbuf[3];
    1151         [ +  - ]:       7744 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
    1152                 :       7744 :     Py_buffer key = {NULL, NULL};
    1153                 :       7744 :     PyObject *msg_obj = NULL;
    1154                 :       7744 :     PyObject *digestmod = NULL;
    1155                 :            : 
    1156   [ -  +  -  -  :       7744 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
             -  -  -  - ]
    1157         [ -  + ]:       7744 :     if (!args) {
    1158                 :          0 :         goto exit;
    1159                 :            :     }
    1160         [ -  + ]:       7744 :     if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) {
    1161                 :          0 :         goto exit;
    1162                 :            :     }
    1163         [ -  + ]:       7744 :     if (!PyBuffer_IsContiguous(&key, 'C')) {
    1164                 :          0 :         _PyArg_BadArgument("hmac_new", "argument 'key'", "contiguous buffer", args[0]);
    1165                 :          0 :         goto exit;
    1166                 :            :     }
    1167         [ -  + ]:       7744 :     if (!noptargs) {
    1168                 :          0 :         goto skip_optional_pos;
    1169                 :            :     }
    1170         [ +  + ]:       7744 :     if (args[1]) {
    1171                 :       7706 :         msg_obj = args[1];
    1172         [ -  + ]:       7706 :         if (!--noptargs) {
    1173                 :          0 :             goto skip_optional_pos;
    1174                 :            :         }
    1175                 :            :     }
    1176                 :       7744 :     digestmod = args[2];
    1177                 :       7744 : skip_optional_pos:
    1178                 :       7744 :     return_value = _hashlib_hmac_new_impl(module, &key, msg_obj, digestmod);
    1179                 :            : 
    1180                 :       7744 : exit:
    1181                 :            :     /* Cleanup for key */
    1182         [ +  - ]:       7744 :     if (key.obj) {
    1183                 :       7744 :        PyBuffer_Release(&key);
    1184                 :            :     }
    1185                 :            : 
    1186                 :       7744 :     return return_value;
    1187                 :            : }
    1188                 :            : 
    1189                 :            : PyDoc_STRVAR(_hashlib_HMAC_copy__doc__,
    1190                 :            : "copy($self, /)\n"
    1191                 :            : "--\n"
    1192                 :            : "\n"
    1193                 :            : "Return a copy (\"clone\") of the HMAC object.");
    1194                 :            : 
    1195                 :            : #define _HASHLIB_HMAC_COPY_METHODDEF    \
    1196                 :            :     {"copy", (PyCFunction)_hashlib_HMAC_copy, METH_NOARGS, _hashlib_HMAC_copy__doc__},
    1197                 :            : 
    1198                 :            : static PyObject *
    1199                 :            : _hashlib_HMAC_copy_impl(HMACobject *self);
    1200                 :            : 
    1201                 :            : static PyObject *
    1202                 :         80 : _hashlib_HMAC_copy(HMACobject *self, PyObject *Py_UNUSED(ignored))
    1203                 :            : {
    1204                 :         80 :     return _hashlib_HMAC_copy_impl(self);
    1205                 :            : }
    1206                 :            : 
    1207                 :            : PyDoc_STRVAR(_hashlib_HMAC_update__doc__,
    1208                 :            : "update($self, /, msg)\n"
    1209                 :            : "--\n"
    1210                 :            : "\n"
    1211                 :            : "Update the HMAC object with msg.");
    1212                 :            : 
    1213                 :            : #define _HASHLIB_HMAC_UPDATE_METHODDEF    \
    1214                 :            :     {"update", _PyCFunction_CAST(_hashlib_HMAC_update), METH_FASTCALL|METH_KEYWORDS, _hashlib_HMAC_update__doc__},
    1215                 :            : 
    1216                 :            : static PyObject *
    1217                 :            : _hashlib_HMAC_update_impl(HMACobject *self, PyObject *msg);
    1218                 :            : 
    1219                 :            : static PyObject *
    1220                 :        231 : _hashlib_HMAC_update(HMACobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1221                 :            : {
    1222                 :        231 :     PyObject *return_value = NULL;
    1223                 :            :     static const char * const _keywords[] = {"msg", NULL};
    1224                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "update", 0};
    1225                 :            :     PyObject *argsbuf[1];
    1226                 :            :     PyObject *msg;
    1227                 :            : 
    1228   [ +  -  +  -  :        231 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
             +  -  -  + ]
    1229         [ -  + ]:        231 :     if (!args) {
    1230                 :          0 :         goto exit;
    1231                 :            :     }
    1232                 :        231 :     msg = args[0];
    1233                 :        231 :     return_value = _hashlib_HMAC_update_impl(self, msg);
    1234                 :            : 
    1235                 :        231 : exit:
    1236                 :        231 :     return return_value;
    1237                 :            : }
    1238                 :            : 
    1239                 :            : PyDoc_STRVAR(_hashlib_HMAC_digest__doc__,
    1240                 :            : "digest($self, /)\n"
    1241                 :            : "--\n"
    1242                 :            : "\n"
    1243                 :            : "Return the digest of the bytes passed to the update() method so far.");
    1244                 :            : 
    1245                 :            : #define _HASHLIB_HMAC_DIGEST_METHODDEF    \
    1246                 :            :     {"digest", (PyCFunction)_hashlib_HMAC_digest, METH_NOARGS, _hashlib_HMAC_digest__doc__},
    1247                 :            : 
    1248                 :            : static PyObject *
    1249                 :            : _hashlib_HMAC_digest_impl(HMACobject *self);
    1250                 :            : 
    1251                 :            : static PyObject *
    1252                 :       7535 : _hashlib_HMAC_digest(HMACobject *self, PyObject *Py_UNUSED(ignored))
    1253                 :            : {
    1254                 :       7535 :     return _hashlib_HMAC_digest_impl(self);
    1255                 :            : }
    1256                 :            : 
    1257                 :            : PyDoc_STRVAR(_hashlib_HMAC_hexdigest__doc__,
    1258                 :            : "hexdigest($self, /)\n"
    1259                 :            : "--\n"
    1260                 :            : "\n"
    1261                 :            : "Return hexadecimal digest of the bytes passed to the update() method so far.\n"
    1262                 :            : "\n"
    1263                 :            : "This may be used to exchange the value safely in email or other non-binary\n"
    1264                 :            : "environments.");
    1265                 :            : 
    1266                 :            : #define _HASHLIB_HMAC_HEXDIGEST_METHODDEF    \
    1267                 :            :     {"hexdigest", (PyCFunction)_hashlib_HMAC_hexdigest, METH_NOARGS, _hashlib_HMAC_hexdigest__doc__},
    1268                 :            : 
    1269                 :            : static PyObject *
    1270                 :            : _hashlib_HMAC_hexdigest_impl(HMACobject *self);
    1271                 :            : 
    1272                 :            : static PyObject *
    1273                 :        440 : _hashlib_HMAC_hexdigest(HMACobject *self, PyObject *Py_UNUSED(ignored))
    1274                 :            : {
    1275                 :        440 :     return _hashlib_HMAC_hexdigest_impl(self);
    1276                 :            : }
    1277                 :            : 
    1278                 :            : PyDoc_STRVAR(_hashlib_get_fips_mode__doc__,
    1279                 :            : "get_fips_mode($module, /)\n"
    1280                 :            : "--\n"
    1281                 :            : "\n"
    1282                 :            : "Determine the OpenSSL FIPS mode of operation.\n"
    1283                 :            : "\n"
    1284                 :            : "For OpenSSL 3.0.0 and newer it returns the state of the default provider\n"
    1285                 :            : "in the default OSSL context. It\'s not quite the same as FIPS_mode() but good\n"
    1286                 :            : "enough for unittests.\n"
    1287                 :            : "\n"
    1288                 :            : "Effectively any non-zero return value indicates FIPS mode;\n"
    1289                 :            : "values other than 1 may have additional significance.");
    1290                 :            : 
    1291                 :            : #define _HASHLIB_GET_FIPS_MODE_METHODDEF    \
    1292                 :            :     {"get_fips_mode", (PyCFunction)_hashlib_get_fips_mode, METH_NOARGS, _hashlib_get_fips_mode__doc__},
    1293                 :            : 
    1294                 :            : static int
    1295                 :            : _hashlib_get_fips_mode_impl(PyObject *module);
    1296                 :            : 
    1297                 :            : static PyObject *
    1298                 :          3 : _hashlib_get_fips_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
    1299                 :            : {
    1300                 :          3 :     PyObject *return_value = NULL;
    1301                 :            :     int _return_value;
    1302                 :            : 
    1303                 :          3 :     _return_value = _hashlib_get_fips_mode_impl(module);
    1304   [ -  +  -  - ]:          3 :     if ((_return_value == -1) && PyErr_Occurred()) {
    1305                 :          0 :         goto exit;
    1306                 :            :     }
    1307                 :          3 :     return_value = PyLong_FromLong((long)_return_value);
    1308                 :            : 
    1309                 :          3 : exit:
    1310                 :          3 :     return return_value;
    1311                 :            : }
    1312                 :            : 
    1313                 :            : PyDoc_STRVAR(_hashlib_compare_digest__doc__,
    1314                 :            : "compare_digest($module, a, b, /)\n"
    1315                 :            : "--\n"
    1316                 :            : "\n"
    1317                 :            : "Return \'a == b\'.\n"
    1318                 :            : "\n"
    1319                 :            : "This function uses an approach designed to prevent\n"
    1320                 :            : "timing analysis, making it appropriate for cryptography.\n"
    1321                 :            : "\n"
    1322                 :            : "a and b must both be of the same type: either str (ASCII only),\n"
    1323                 :            : "or any bytes-like object.\n"
    1324                 :            : "\n"
    1325                 :            : "Note: If a and b are of different lengths, or if an error occurs,\n"
    1326                 :            : "a timing attack could theoretically reveal information about the\n"
    1327                 :            : "types and lengths of a and b--but not their values.");
    1328                 :            : 
    1329                 :            : #define _HASHLIB_COMPARE_DIGEST_METHODDEF    \
    1330                 :            :     {"compare_digest", _PyCFunction_CAST(_hashlib_compare_digest), METH_FASTCALL, _hashlib_compare_digest__doc__},
    1331                 :            : 
    1332                 :            : static PyObject *
    1333                 :            : _hashlib_compare_digest_impl(PyObject *module, PyObject *a, PyObject *b);
    1334                 :            : 
    1335                 :            : static PyObject *
    1336                 :         86 : _hashlib_compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1337                 :            : {
    1338                 :         86 :     PyObject *return_value = NULL;
    1339                 :            :     PyObject *a;
    1340                 :            :     PyObject *b;
    1341                 :            : 
    1342   [ +  -  -  +  :         86 :     if (!_PyArg_CheckPositional("compare_digest", nargs, 2, 2)) {
                   -  - ]
    1343                 :          0 :         goto exit;
    1344                 :            :     }
    1345                 :         86 :     a = args[0];
    1346                 :         86 :     b = args[1];
    1347                 :         86 :     return_value = _hashlib_compare_digest_impl(module, a, b);
    1348                 :            : 
    1349                 :         86 : exit:
    1350                 :         86 :     return return_value;
    1351                 :            : }
    1352                 :            : 
    1353                 :            : #ifndef EVPXOF_DIGEST_METHODDEF
    1354                 :            :     #define EVPXOF_DIGEST_METHODDEF
    1355                 :            : #endif /* !defined(EVPXOF_DIGEST_METHODDEF) */
    1356                 :            : 
    1357                 :            : #ifndef EVPXOF_HEXDIGEST_METHODDEF
    1358                 :            :     #define EVPXOF_HEXDIGEST_METHODDEF
    1359                 :            : #endif /* !defined(EVPXOF_HEXDIGEST_METHODDEF) */
    1360                 :            : 
    1361                 :            : #ifndef _HASHLIB_OPENSSL_SHA3_224_METHODDEF
    1362                 :            :     #define _HASHLIB_OPENSSL_SHA3_224_METHODDEF
    1363                 :            : #endif /* !defined(_HASHLIB_OPENSSL_SHA3_224_METHODDEF) */
    1364                 :            : 
    1365                 :            : #ifndef _HASHLIB_OPENSSL_SHA3_256_METHODDEF
    1366                 :            :     #define _HASHLIB_OPENSSL_SHA3_256_METHODDEF
    1367                 :            : #endif /* !defined(_HASHLIB_OPENSSL_SHA3_256_METHODDEF) */
    1368                 :            : 
    1369                 :            : #ifndef _HASHLIB_OPENSSL_SHA3_384_METHODDEF
    1370                 :            :     #define _HASHLIB_OPENSSL_SHA3_384_METHODDEF
    1371                 :            : #endif /* !defined(_HASHLIB_OPENSSL_SHA3_384_METHODDEF) */
    1372                 :            : 
    1373                 :            : #ifndef _HASHLIB_OPENSSL_SHA3_512_METHODDEF
    1374                 :            :     #define _HASHLIB_OPENSSL_SHA3_512_METHODDEF
    1375                 :            : #endif /* !defined(_HASHLIB_OPENSSL_SHA3_512_METHODDEF) */
    1376                 :            : 
    1377                 :            : #ifndef _HASHLIB_OPENSSL_SHAKE_128_METHODDEF
    1378                 :            :     #define _HASHLIB_OPENSSL_SHAKE_128_METHODDEF
    1379                 :            : #endif /* !defined(_HASHLIB_OPENSSL_SHAKE_128_METHODDEF) */
    1380                 :            : 
    1381                 :            : #ifndef _HASHLIB_OPENSSL_SHAKE_256_METHODDEF
    1382                 :            :     #define _HASHLIB_OPENSSL_SHAKE_256_METHODDEF
    1383                 :            : #endif /* !defined(_HASHLIB_OPENSSL_SHAKE_256_METHODDEF) */
    1384                 :            : 
    1385                 :            : #ifndef _HASHLIB_SCRYPT_METHODDEF
    1386                 :            :     #define _HASHLIB_SCRYPT_METHODDEF
    1387                 :            : #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */
    1388                 :            : /*[clinic end generated code: output=69f2374071bff707 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14