(root)/
Python-3.11.7/
Modules/
clinic/
_hashopenssl.c.h
       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  EVP_copy(EVPobject *self, PyObject *Py_UNUSED(ignored))
      19  {
      20      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  EVP_digest(EVPobject *self, PyObject *Py_UNUSED(ignored))
      37  {
      38      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  EVP_hexdigest(EVPobject *self, PyObject *Py_UNUSED(ignored))
      55  {
      56      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  EVPXOF_digest(EVPobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      84  {
      85      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      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
      92      if (!args) {
      93          goto exit;
      94      }
      95      {
      96          Py_ssize_t ival = -1;
      97          PyObject *iobj = _PyNumber_Index(args[0]);
      98          if (iobj != NULL) {
      99              ival = PyLong_AsSsize_t(iobj);
     100              Py_DECREF(iobj);
     101          }
     102          if (ival == -1 && PyErr_Occurred()) {
     103              goto exit;
     104          }
     105          length = ival;
     106      }
     107      return_value = EVPXOF_digest_impl(self, length);
     108  
     109  exit:
     110      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  EVPXOF_hexdigest(EVPobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     131  {
     132      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      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
     139      if (!args) {
     140          goto exit;
     141      }
     142      {
     143          Py_ssize_t ival = -1;
     144          PyObject *iobj = _PyNumber_Index(args[0]);
     145          if (iobj != NULL) {
     146              ival = PyLong_AsSsize_t(iobj);
     147              Py_DECREF(iobj);
     148          }
     149          if (ival == -1 && PyErr_Occurred()) {
     150              goto exit;
     151          }
     152          length = ival;
     153      }
     154      return_value = EVPXOF_hexdigest_impl(self, length);
     155  
     156  exit:
     157      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  EVP_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     182  {
     183      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     188      PyObject *name_obj;
     189      PyObject *data_obj = NULL;
     190      int usedforsecurity = 1;
     191  
     192      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
     193      if (!args) {
     194          goto exit;
     195      }
     196      name_obj = args[0];
     197      if (!noptargs) {
     198          goto skip_optional_pos;
     199      }
     200      if (args[1]) {
     201          data_obj = args[1];
     202          if (!--noptargs) {
     203              goto skip_optional_pos;
     204          }
     205      }
     206  skip_optional_pos:
     207      if (!noptargs) {
     208          goto skip_optional_kwonly;
     209      }
     210      usedforsecurity = PyObject_IsTrue(args[2]);
     211      if (usedforsecurity < 0) {
     212          goto exit;
     213      }
     214  skip_optional_kwonly:
     215      return_value = EVP_new_impl(module, name_obj, data_obj, usedforsecurity);
     216  
     217  exit:
     218      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  _hashlib_openssl_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     236  {
     237      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     242      PyObject *data_obj = NULL;
     243      int usedforsecurity = 1;
     244  
     245      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     246      if (!args) {
     247          goto exit;
     248      }
     249      if (!noptargs) {
     250          goto skip_optional_pos;
     251      }
     252      if (args[0]) {
     253          data_obj = args[0];
     254          if (!--noptargs) {
     255              goto skip_optional_pos;
     256          }
     257      }
     258  skip_optional_pos:
     259      if (!noptargs) {
     260          goto skip_optional_kwonly;
     261      }
     262      usedforsecurity = PyObject_IsTrue(args[1]);
     263      if (usedforsecurity < 0) {
     264          goto exit;
     265      }
     266  skip_optional_kwonly:
     267      return_value = _hashlib_openssl_md5_impl(module, data_obj, usedforsecurity);
     268  
     269  exit:
     270      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  _hashlib_openssl_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     288  {
     289      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     294      PyObject *data_obj = NULL;
     295      int usedforsecurity = 1;
     296  
     297      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     298      if (!args) {
     299          goto exit;
     300      }
     301      if (!noptargs) {
     302          goto skip_optional_pos;
     303      }
     304      if (args[0]) {
     305          data_obj = args[0];
     306          if (!--noptargs) {
     307              goto skip_optional_pos;
     308          }
     309      }
     310  skip_optional_pos:
     311      if (!noptargs) {
     312          goto skip_optional_kwonly;
     313      }
     314      usedforsecurity = PyObject_IsTrue(args[1]);
     315      if (usedforsecurity < 0) {
     316          goto exit;
     317      }
     318  skip_optional_kwonly:
     319      return_value = _hashlib_openssl_sha1_impl(module, data_obj, usedforsecurity);
     320  
     321  exit:
     322      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  _hashlib_openssl_sha224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     340  {
     341      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     346      PyObject *data_obj = NULL;
     347      int usedforsecurity = 1;
     348  
     349      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     350      if (!args) {
     351          goto exit;
     352      }
     353      if (!noptargs) {
     354          goto skip_optional_pos;
     355      }
     356      if (args[0]) {
     357          data_obj = args[0];
     358          if (!--noptargs) {
     359              goto skip_optional_pos;
     360          }
     361      }
     362  skip_optional_pos:
     363      if (!noptargs) {
     364          goto skip_optional_kwonly;
     365      }
     366      usedforsecurity = PyObject_IsTrue(args[1]);
     367      if (usedforsecurity < 0) {
     368          goto exit;
     369      }
     370  skip_optional_kwonly:
     371      return_value = _hashlib_openssl_sha224_impl(module, data_obj, usedforsecurity);
     372  
     373  exit:
     374      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  _hashlib_openssl_sha256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     392  {
     393      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     398      PyObject *data_obj = NULL;
     399      int usedforsecurity = 1;
     400  
     401      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     402      if (!args) {
     403          goto exit;
     404      }
     405      if (!noptargs) {
     406          goto skip_optional_pos;
     407      }
     408      if (args[0]) {
     409          data_obj = args[0];
     410          if (!--noptargs) {
     411              goto skip_optional_pos;
     412          }
     413      }
     414  skip_optional_pos:
     415      if (!noptargs) {
     416          goto skip_optional_kwonly;
     417      }
     418      usedforsecurity = PyObject_IsTrue(args[1]);
     419      if (usedforsecurity < 0) {
     420          goto exit;
     421      }
     422  skip_optional_kwonly:
     423      return_value = _hashlib_openssl_sha256_impl(module, data_obj, usedforsecurity);
     424  
     425  exit:
     426      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  _hashlib_openssl_sha384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     444  {
     445      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     450      PyObject *data_obj = NULL;
     451      int usedforsecurity = 1;
     452  
     453      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     454      if (!args) {
     455          goto exit;
     456      }
     457      if (!noptargs) {
     458          goto skip_optional_pos;
     459      }
     460      if (args[0]) {
     461          data_obj = args[0];
     462          if (!--noptargs) {
     463              goto skip_optional_pos;
     464          }
     465      }
     466  skip_optional_pos:
     467      if (!noptargs) {
     468          goto skip_optional_kwonly;
     469      }
     470      usedforsecurity = PyObject_IsTrue(args[1]);
     471      if (usedforsecurity < 0) {
     472          goto exit;
     473      }
     474  skip_optional_kwonly:
     475      return_value = _hashlib_openssl_sha384_impl(module, data_obj, usedforsecurity);
     476  
     477  exit:
     478      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  _hashlib_openssl_sha512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     496  {
     497      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     502      PyObject *data_obj = NULL;
     503      int usedforsecurity = 1;
     504  
     505      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     506      if (!args) {
     507          goto exit;
     508      }
     509      if (!noptargs) {
     510          goto skip_optional_pos;
     511      }
     512      if (args[0]) {
     513          data_obj = args[0];
     514          if (!--noptargs) {
     515              goto skip_optional_pos;
     516          }
     517      }
     518  skip_optional_pos:
     519      if (!noptargs) {
     520          goto skip_optional_kwonly;
     521      }
     522      usedforsecurity = PyObject_IsTrue(args[1]);
     523      if (usedforsecurity < 0) {
     524          goto exit;
     525      }
     526  skip_optional_kwonly:
     527      return_value = _hashlib_openssl_sha512_impl(module, data_obj, usedforsecurity);
     528  
     529  exit:
     530      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  _hashlib_openssl_sha3_224(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     550  {
     551      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     556      PyObject *data_obj = NULL;
     557      int usedforsecurity = 1;
     558  
     559      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     560      if (!args) {
     561          goto exit;
     562      }
     563      if (!noptargs) {
     564          goto skip_optional_pos;
     565      }
     566      if (args[0]) {
     567          data_obj = args[0];
     568          if (!--noptargs) {
     569              goto skip_optional_pos;
     570          }
     571      }
     572  skip_optional_pos:
     573      if (!noptargs) {
     574          goto skip_optional_kwonly;
     575      }
     576      usedforsecurity = PyObject_IsTrue(args[1]);
     577      if (usedforsecurity < 0) {
     578          goto exit;
     579      }
     580  skip_optional_kwonly:
     581      return_value = _hashlib_openssl_sha3_224_impl(module, data_obj, usedforsecurity);
     582  
     583  exit:
     584      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  _hashlib_openssl_sha3_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     606  {
     607      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     612      PyObject *data_obj = NULL;
     613      int usedforsecurity = 1;
     614  
     615      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     616      if (!args) {
     617          goto exit;
     618      }
     619      if (!noptargs) {
     620          goto skip_optional_pos;
     621      }
     622      if (args[0]) {
     623          data_obj = args[0];
     624          if (!--noptargs) {
     625              goto skip_optional_pos;
     626          }
     627      }
     628  skip_optional_pos:
     629      if (!noptargs) {
     630          goto skip_optional_kwonly;
     631      }
     632      usedforsecurity = PyObject_IsTrue(args[1]);
     633      if (usedforsecurity < 0) {
     634          goto exit;
     635      }
     636  skip_optional_kwonly:
     637      return_value = _hashlib_openssl_sha3_256_impl(module, data_obj, usedforsecurity);
     638  
     639  exit:
     640      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  _hashlib_openssl_sha3_384(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     662  {
     663      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     668      PyObject *data_obj = NULL;
     669      int usedforsecurity = 1;
     670  
     671      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     672      if (!args) {
     673          goto exit;
     674      }
     675      if (!noptargs) {
     676          goto skip_optional_pos;
     677      }
     678      if (args[0]) {
     679          data_obj = args[0];
     680          if (!--noptargs) {
     681              goto skip_optional_pos;
     682          }
     683      }
     684  skip_optional_pos:
     685      if (!noptargs) {
     686          goto skip_optional_kwonly;
     687      }
     688      usedforsecurity = PyObject_IsTrue(args[1]);
     689      if (usedforsecurity < 0) {
     690          goto exit;
     691      }
     692  skip_optional_kwonly:
     693      return_value = _hashlib_openssl_sha3_384_impl(module, data_obj, usedforsecurity);
     694  
     695  exit:
     696      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  _hashlib_openssl_sha3_512(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     718  {
     719      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     724      PyObject *data_obj = NULL;
     725      int usedforsecurity = 1;
     726  
     727      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     728      if (!args) {
     729          goto exit;
     730      }
     731      if (!noptargs) {
     732          goto skip_optional_pos;
     733      }
     734      if (args[0]) {
     735          data_obj = args[0];
     736          if (!--noptargs) {
     737              goto skip_optional_pos;
     738          }
     739      }
     740  skip_optional_pos:
     741      if (!noptargs) {
     742          goto skip_optional_kwonly;
     743      }
     744      usedforsecurity = PyObject_IsTrue(args[1]);
     745      if (usedforsecurity < 0) {
     746          goto exit;
     747      }
     748  skip_optional_kwonly:
     749      return_value = _hashlib_openssl_sha3_512_impl(module, data_obj, usedforsecurity);
     750  
     751  exit:
     752      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  _hashlib_openssl_shake_128(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     774  {
     775      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     780      PyObject *data_obj = NULL;
     781      int usedforsecurity = 1;
     782  
     783      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     784      if (!args) {
     785          goto exit;
     786      }
     787      if (!noptargs) {
     788          goto skip_optional_pos;
     789      }
     790      if (args[0]) {
     791          data_obj = args[0];
     792          if (!--noptargs) {
     793              goto skip_optional_pos;
     794          }
     795      }
     796  skip_optional_pos:
     797      if (!noptargs) {
     798          goto skip_optional_kwonly;
     799      }
     800      usedforsecurity = PyObject_IsTrue(args[1]);
     801      if (usedforsecurity < 0) {
     802          goto exit;
     803      }
     804  skip_optional_kwonly:
     805      return_value = _hashlib_openssl_shake_128_impl(module, data_obj, usedforsecurity);
     806  
     807  exit:
     808      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  _hashlib_openssl_shake_256(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     830  {
     831      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     836      PyObject *data_obj = NULL;
     837      int usedforsecurity = 1;
     838  
     839      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     840      if (!args) {
     841          goto exit;
     842      }
     843      if (!noptargs) {
     844          goto skip_optional_pos;
     845      }
     846      if (args[0]) {
     847          data_obj = args[0];
     848          if (!--noptargs) {
     849              goto skip_optional_pos;
     850          }
     851      }
     852  skip_optional_pos:
     853      if (!noptargs) {
     854          goto skip_optional_kwonly;
     855      }
     856      usedforsecurity = PyObject_IsTrue(args[1]);
     857      if (usedforsecurity < 0) {
     858          goto exit;
     859      }
     860  skip_optional_kwonly:
     861      return_value = _hashlib_openssl_shake_256_impl(module, data_obj, usedforsecurity);
     862  
     863  exit:
     864      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  pbkdf2_hmac(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     886  {
     887      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4;
     892      const char *hash_name;
     893      Py_buffer password = {NULL, NULL};
     894      Py_buffer salt = {NULL, NULL};
     895      long iterations;
     896      PyObject *dklen_obj = Py_None;
     897  
     898      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 5, 0, argsbuf);
     899      if (!args) {
     900          goto exit;
     901      }
     902      if (!PyUnicode_Check(args[0])) {
     903          _PyArg_BadArgument("pbkdf2_hmac", "argument 'hash_name'", "str", args[0]);
     904          goto exit;
     905      }
     906      Py_ssize_t hash_name_length;
     907      hash_name = PyUnicode_AsUTF8AndSize(args[0], &hash_name_length);
     908      if (hash_name == NULL) {
     909          goto exit;
     910      }
     911      if (strlen(hash_name) != (size_t)hash_name_length) {
     912          PyErr_SetString(PyExc_ValueError, "embedded null character");
     913          goto exit;
     914      }
     915      if (PyObject_GetBuffer(args[1], &password, PyBUF_SIMPLE) != 0) {
     916          goto exit;
     917      }
     918      if (!PyBuffer_IsContiguous(&password, 'C')) {
     919          _PyArg_BadArgument("pbkdf2_hmac", "argument 'password'", "contiguous buffer", args[1]);
     920          goto exit;
     921      }
     922      if (PyObject_GetBuffer(args[2], &salt, PyBUF_SIMPLE) != 0) {
     923          goto exit;
     924      }
     925      if (!PyBuffer_IsContiguous(&salt, 'C')) {
     926          _PyArg_BadArgument("pbkdf2_hmac", "argument 'salt'", "contiguous buffer", args[2]);
     927          goto exit;
     928      }
     929      iterations = PyLong_AsLong(args[3]);
     930      if (iterations == -1 && PyErr_Occurred()) {
     931          goto exit;
     932      }
     933      if (!noptargs) {
     934          goto skip_optional_pos;
     935      }
     936      dklen_obj = args[4];
     937  skip_optional_pos:
     938      return_value = pbkdf2_hmac_impl(module, hash_name, &password, &salt, iterations, dklen_obj);
     939  
     940  exit:
     941      /* Cleanup for password */
     942      if (password.obj) {
     943         PyBuffer_Release(&password);
     944      }
     945      /* Cleanup for salt */
     946      if (salt.obj) {
     947         PyBuffer_Release(&salt);
     948      }
     949  
     950      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  _hashlib_scrypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     972  {
     973      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     978      Py_buffer password = {NULL, NULL};
     979      Py_buffer salt = {NULL, NULL};
     980      PyObject *n_obj = Py_None;
     981      PyObject *r_obj = Py_None;
     982      PyObject *p_obj = Py_None;
     983      long maxmem = 0;
     984      long dklen = 64;
     985  
     986      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
     987      if (!args) {
     988          goto exit;
     989      }
     990      if (PyObject_GetBuffer(args[0], &password, PyBUF_SIMPLE) != 0) {
     991          goto exit;
     992      }
     993      if (!PyBuffer_IsContiguous(&password, 'C')) {
     994          _PyArg_BadArgument("scrypt", "argument 'password'", "contiguous buffer", args[0]);
     995          goto exit;
     996      }
     997      if (!noptargs) {
     998          goto skip_optional_kwonly;
     999      }
    1000      if (args[1]) {
    1001          if (PyObject_GetBuffer(args[1], &salt, PyBUF_SIMPLE) != 0) {
    1002              goto exit;
    1003          }
    1004          if (!PyBuffer_IsContiguous(&salt, 'C')) {
    1005              _PyArg_BadArgument("scrypt", "argument 'salt'", "contiguous buffer", args[1]);
    1006              goto exit;
    1007          }
    1008          if (!--noptargs) {
    1009              goto skip_optional_kwonly;
    1010          }
    1011      }
    1012      if (args[2]) {
    1013          if (!PyLong_Check(args[2])) {
    1014              _PyArg_BadArgument("scrypt", "argument 'n'", "int", args[2]);
    1015              goto exit;
    1016          }
    1017          n_obj = args[2];
    1018          if (!--noptargs) {
    1019              goto skip_optional_kwonly;
    1020          }
    1021      }
    1022      if (args[3]) {
    1023          if (!PyLong_Check(args[3])) {
    1024              _PyArg_BadArgument("scrypt", "argument 'r'", "int", args[3]);
    1025              goto exit;
    1026          }
    1027          r_obj = args[3];
    1028          if (!--noptargs) {
    1029              goto skip_optional_kwonly;
    1030          }
    1031      }
    1032      if (args[4]) {
    1033          if (!PyLong_Check(args[4])) {
    1034              _PyArg_BadArgument("scrypt", "argument 'p'", "int", args[4]);
    1035              goto exit;
    1036          }
    1037          p_obj = args[4];
    1038          if (!--noptargs) {
    1039              goto skip_optional_kwonly;
    1040          }
    1041      }
    1042      if (args[5]) {
    1043          maxmem = PyLong_AsLong(args[5]);
    1044          if (maxmem == -1 && PyErr_Occurred()) {
    1045              goto exit;
    1046          }
    1047          if (!--noptargs) {
    1048              goto skip_optional_kwonly;
    1049          }
    1050      }
    1051      dklen = PyLong_AsLong(args[6]);
    1052      if (dklen == -1 && PyErr_Occurred()) {
    1053          goto exit;
    1054      }
    1055  skip_optional_kwonly:
    1056      return_value = _hashlib_scrypt_impl(module, &password, &salt, n_obj, r_obj, p_obj, maxmem, dklen);
    1057  
    1058  exit:
    1059      /* Cleanup for password */
    1060      if (password.obj) {
    1061         PyBuffer_Release(&password);
    1062      }
    1063      /* Cleanup for salt */
    1064      if (salt.obj) {
    1065         PyBuffer_Release(&salt);
    1066      }
    1067  
    1068      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  _hashlib_hmac_singleshot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1088  {
    1089      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      Py_buffer key = {NULL, NULL};
    1094      Py_buffer msg = {NULL, NULL};
    1095      PyObject *digest;
    1096  
    1097      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
    1098      if (!args) {
    1099          goto exit;
    1100      }
    1101      if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) {
    1102          goto exit;
    1103      }
    1104      if (!PyBuffer_IsContiguous(&key, 'C')) {
    1105          _PyArg_BadArgument("hmac_digest", "argument 'key'", "contiguous buffer", args[0]);
    1106          goto exit;
    1107      }
    1108      if (PyObject_GetBuffer(args[1], &msg, PyBUF_SIMPLE) != 0) {
    1109          goto exit;
    1110      }
    1111      if (!PyBuffer_IsContiguous(&msg, 'C')) {
    1112          _PyArg_BadArgument("hmac_digest", "argument 'msg'", "contiguous buffer", args[1]);
    1113          goto exit;
    1114      }
    1115      digest = args[2];
    1116      return_value = _hashlib_hmac_singleshot_impl(module, &key, &msg, digest);
    1117  
    1118  exit:
    1119      /* Cleanup for key */
    1120      if (key.obj) {
    1121         PyBuffer_Release(&key);
    1122      }
    1123      /* Cleanup for msg */
    1124      if (msg.obj) {
    1125         PyBuffer_Release(&msg);
    1126      }
    1127  
    1128      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  _hashlib_hmac_new(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1146  {
    1147      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      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
    1152      Py_buffer key = {NULL, NULL};
    1153      PyObject *msg_obj = NULL;
    1154      PyObject *digestmod = NULL;
    1155  
    1156      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
    1157      if (!args) {
    1158          goto exit;
    1159      }
    1160      if (PyObject_GetBuffer(args[0], &key, PyBUF_SIMPLE) != 0) {
    1161          goto exit;
    1162      }
    1163      if (!PyBuffer_IsContiguous(&key, 'C')) {
    1164          _PyArg_BadArgument("hmac_new", "argument 'key'", "contiguous buffer", args[0]);
    1165          goto exit;
    1166      }
    1167      if (!noptargs) {
    1168          goto skip_optional_pos;
    1169      }
    1170      if (args[1]) {
    1171          msg_obj = args[1];
    1172          if (!--noptargs) {
    1173              goto skip_optional_pos;
    1174          }
    1175      }
    1176      digestmod = args[2];
    1177  skip_optional_pos:
    1178      return_value = _hashlib_hmac_new_impl(module, &key, msg_obj, digestmod);
    1179  
    1180  exit:
    1181      /* Cleanup for key */
    1182      if (key.obj) {
    1183         PyBuffer_Release(&key);
    1184      }
    1185  
    1186      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  _hashlib_HMAC_copy(HMACobject *self, PyObject *Py_UNUSED(ignored))
    1203  {
    1204      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  _hashlib_HMAC_update(HMACobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1221  {
    1222      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      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
    1229      if (!args) {
    1230          goto exit;
    1231      }
    1232      msg = args[0];
    1233      return_value = _hashlib_HMAC_update_impl(self, msg);
    1234  
    1235  exit:
    1236      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  _hashlib_HMAC_digest(HMACobject *self, PyObject *Py_UNUSED(ignored))
    1253  {
    1254      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  _hashlib_HMAC_hexdigest(HMACobject *self, PyObject *Py_UNUSED(ignored))
    1274  {
    1275      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  _hashlib_get_fips_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
    1299  {
    1300      PyObject *return_value = NULL;
    1301      int _return_value;
    1302  
    1303      _return_value = _hashlib_get_fips_mode_impl(module);
    1304      if ((_return_value == -1) && PyErr_Occurred()) {
    1305          goto exit;
    1306      }
    1307      return_value = PyLong_FromLong((long)_return_value);
    1308  
    1309  exit:
    1310      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  _hashlib_compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1337  {
    1338      PyObject *return_value = NULL;
    1339      PyObject *a;
    1340      PyObject *b;
    1341  
    1342      if (!_PyArg_CheckPositional("compare_digest", nargs, 2, 2)) {
    1343          goto exit;
    1344      }
    1345      a = args[0];
    1346      b = args[1];
    1347      return_value = _hashlib_compare_digest_impl(module, a, b);
    1348  
    1349  exit:
    1350      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]*/