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