(root)/
Python-3.12.0/
Modules/
clinic/
sha3module.c.h
       1  /*[clinic input]
       2  preserve
       3  [clinic start generated code]*/
       4  
       5  #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6  #  include "pycore_gc.h"            // PyGC_Head
       7  #  include "pycore_runtime.h"       // _Py_ID()
       8  #endif
       9  
      10  
      11  PyDoc_STRVAR(py_sha3_new__doc__,
      12  "sha3_224(data=b\'\', /, *, usedforsecurity=True)\n"
      13  "--\n"
      14  "\n"
      15  "Return a new SHA3 hash object.");
      16  
      17  static PyObject *
      18  py_sha3_new_impl(PyTypeObject *type, PyObject *data, int usedforsecurity);
      19  
      20  static PyObject *
      21  py_sha3_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
      22  {
      23      PyObject *return_value = NULL;
      24      #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      25  
      26      #define NUM_KEYWORDS 1
      27      static struct {
      28          PyGC_Head _this_is_not_used;
      29          PyObject_VAR_HEAD
      30          PyObject *ob_item[NUM_KEYWORDS];
      31      } _kwtuple = {
      32          .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
      33          .ob_item = { &_Py_ID(usedforsecurity), },
      34      };
      35      #undef NUM_KEYWORDS
      36      #define KWTUPLE (&_kwtuple.ob_base.ob_base)
      37  
      38      #else  // !Py_BUILD_CORE
      39      #  define KWTUPLE NULL
      40      #endif  // !Py_BUILD_CORE
      41  
      42      static const char * const _keywords[] = {"", "usedforsecurity", NULL};
      43      static _PyArg_Parser _parser = {
      44          .keywords = _keywords,
      45          .fname = "sha3_224",
      46          .kwtuple = KWTUPLE,
      47      };
      48      #undef KWTUPLE
      49      PyObject *argsbuf[2];
      50      PyObject * const *fastargs;
      51      Py_ssize_t nargs = PyTuple_GET_SIZE(args);
      52      Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
      53      PyObject *data = NULL;
      54      int usedforsecurity = 1;
      55  
      56      fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf);
      57      if (!fastargs) {
      58          goto exit;
      59      }
      60      if (nargs < 1) {
      61          goto skip_optional_posonly;
      62      }
      63      noptargs--;
      64      data = fastargs[0];
      65  skip_optional_posonly:
      66      if (!noptargs) {
      67          goto skip_optional_kwonly;
      68      }
      69      usedforsecurity = PyObject_IsTrue(fastargs[1]);
      70      if (usedforsecurity < 0) {
      71          goto exit;
      72      }
      73  skip_optional_kwonly:
      74      return_value = py_sha3_new_impl(type, data, usedforsecurity);
      75  
      76  exit:
      77      return return_value;
      78  }
      79  
      80  PyDoc_STRVAR(_sha3_sha3_224_copy__doc__,
      81  "copy($self, /)\n"
      82  "--\n"
      83  "\n"
      84  "Return a copy of the hash object.");
      85  
      86  #define _SHA3_SHA3_224_COPY_METHODDEF    \
      87      {"copy", (PyCFunction)_sha3_sha3_224_copy, METH_NOARGS, _sha3_sha3_224_copy__doc__},
      88  
      89  static PyObject *
      90  _sha3_sha3_224_copy_impl(SHA3object *self);
      91  
      92  static PyObject *
      93  _sha3_sha3_224_copy(SHA3object *self, PyObject *Py_UNUSED(ignored))
      94  {
      95      return _sha3_sha3_224_copy_impl(self);
      96  }
      97  
      98  PyDoc_STRVAR(_sha3_sha3_224_digest__doc__,
      99  "digest($self, /)\n"
     100  "--\n"
     101  "\n"
     102  "Return the digest value as a bytes object.");
     103  
     104  #define _SHA3_SHA3_224_DIGEST_METHODDEF    \
     105      {"digest", (PyCFunction)_sha3_sha3_224_digest, METH_NOARGS, _sha3_sha3_224_digest__doc__},
     106  
     107  static PyObject *
     108  _sha3_sha3_224_digest_impl(SHA3object *self);
     109  
     110  static PyObject *
     111  _sha3_sha3_224_digest(SHA3object *self, PyObject *Py_UNUSED(ignored))
     112  {
     113      return _sha3_sha3_224_digest_impl(self);
     114  }
     115  
     116  PyDoc_STRVAR(_sha3_sha3_224_hexdigest__doc__,
     117  "hexdigest($self, /)\n"
     118  "--\n"
     119  "\n"
     120  "Return the digest value as a string of hexadecimal digits.");
     121  
     122  #define _SHA3_SHA3_224_HEXDIGEST_METHODDEF    \
     123      {"hexdigest", (PyCFunction)_sha3_sha3_224_hexdigest, METH_NOARGS, _sha3_sha3_224_hexdigest__doc__},
     124  
     125  static PyObject *
     126  _sha3_sha3_224_hexdigest_impl(SHA3object *self);
     127  
     128  static PyObject *
     129  _sha3_sha3_224_hexdigest(SHA3object *self, PyObject *Py_UNUSED(ignored))
     130  {
     131      return _sha3_sha3_224_hexdigest_impl(self);
     132  }
     133  
     134  PyDoc_STRVAR(_sha3_sha3_224_update__doc__,
     135  "update($self, data, /)\n"
     136  "--\n"
     137  "\n"
     138  "Update this hash object\'s state with the provided bytes-like object.");
     139  
     140  #define _SHA3_SHA3_224_UPDATE_METHODDEF    \
     141      {"update", (PyCFunction)_sha3_sha3_224_update, METH_O, _sha3_sha3_224_update__doc__},
     142  
     143  PyDoc_STRVAR(_sha3_shake_128_digest__doc__,
     144  "digest($self, length, /)\n"
     145  "--\n"
     146  "\n"
     147  "Return the digest value as a bytes object.");
     148  
     149  #define _SHA3_SHAKE_128_DIGEST_METHODDEF    \
     150      {"digest", (PyCFunction)_sha3_shake_128_digest, METH_O, _sha3_shake_128_digest__doc__},
     151  
     152  static PyObject *
     153  _sha3_shake_128_digest_impl(SHA3object *self, unsigned long length);
     154  
     155  static PyObject *
     156  _sha3_shake_128_digest(SHA3object *self, PyObject *arg)
     157  {
     158      PyObject *return_value = NULL;
     159      unsigned long length;
     160  
     161      if (!_PyLong_UnsignedLong_Converter(arg, &length)) {
     162          goto exit;
     163      }
     164      return_value = _sha3_shake_128_digest_impl(self, length);
     165  
     166  exit:
     167      return return_value;
     168  }
     169  
     170  PyDoc_STRVAR(_sha3_shake_128_hexdigest__doc__,
     171  "hexdigest($self, length, /)\n"
     172  "--\n"
     173  "\n"
     174  "Return the digest value as a string of hexadecimal digits.");
     175  
     176  #define _SHA3_SHAKE_128_HEXDIGEST_METHODDEF    \
     177      {"hexdigest", (PyCFunction)_sha3_shake_128_hexdigest, METH_O, _sha3_shake_128_hexdigest__doc__},
     178  
     179  static PyObject *
     180  _sha3_shake_128_hexdigest_impl(SHA3object *self, unsigned long length);
     181  
     182  static PyObject *
     183  _sha3_shake_128_hexdigest(SHA3object *self, PyObject *arg)
     184  {
     185      PyObject *return_value = NULL;
     186      unsigned long length;
     187  
     188      if (!_PyLong_UnsignedLong_Converter(arg, &length)) {
     189          goto exit;
     190      }
     191      return_value = _sha3_shake_128_hexdigest_impl(self, length);
     192  
     193  exit:
     194      return return_value;
     195  }
     196  /*[clinic end generated code: output=907cb475f3dc9ee0 input=a9049054013a1b77]*/