| 1 |
/*[clinic input] |
| 2 |
preserve |
| 3 |
[clinic start generated code]*/ |
| 4 |
|
| 5 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6 |
# include "pycore_gc.h" // PyGC_Head |
| 7 |
# include "pycore_runtime.h" // _Py_ID() |
| 8 |
#endif |
| 9 |
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
| 10 |
|
| 11 |
PyDoc_STRVAR(SHA1Type_copy__doc__, |
| 12 |
"copy($self, /)\n" |
| 13 |
"--\n" |
| 14 |
"\n" |
| 15 |
"Return a copy of the hash object."); |
| 16 |
|
| 17 |
#define SHA1TYPE_COPY_METHODDEF \ |
| 18 |
{"copy", _PyCFunction_CAST(SHA1Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, SHA1Type_copy__doc__}, |
| 19 |
|
| 20 |
static PyObject * |
| 21 |
SHA1Type_copy_impl(SHA1object *self, PyTypeObject *cls); |
| 22 |
|
| 23 |
static PyObject * |
| 24 |
SHA1Type_copy(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 25 |
{ |
| 26 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 27 |
PyErr_SetString(PyExc_TypeError, "copy() takes no arguments"); |
| 28 |
return NULL; |
| 29 |
} |
| 30 |
return SHA1Type_copy_impl((SHA1object *)self, cls); |
| 31 |
} |
| 32 |
|
| 33 |
PyDoc_STRVAR(SHA1Type_digest__doc__, |
| 34 |
"digest($self, /)\n" |
| 35 |
"--\n" |
| 36 |
"\n" |
| 37 |
"Return the digest value as a bytes object."); |
| 38 |
|
| 39 |
#define SHA1TYPE_DIGEST_METHODDEF \ |
| 40 |
{"digest", (PyCFunction)SHA1Type_digest, METH_NOARGS, SHA1Type_digest__doc__}, |
| 41 |
|
| 42 |
static PyObject * |
| 43 |
SHA1Type_digest_impl(SHA1object *self); |
| 44 |
|
| 45 |
static PyObject * |
| 46 |
SHA1Type_digest(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 47 |
{ |
| 48 |
return SHA1Type_digest_impl((SHA1object *)self); |
| 49 |
} |
| 50 |
|
| 51 |
PyDoc_STRVAR(SHA1Type_hexdigest__doc__, |
| 52 |
"hexdigest($self, /)\n" |
| 53 |
"--\n" |
| 54 |
"\n" |
| 55 |
"Return the digest value as a string of hexadecimal digits."); |
| 56 |
|
| 57 |
#define SHA1TYPE_HEXDIGEST_METHODDEF \ |
| 58 |
{"hexdigest", (PyCFunction)SHA1Type_hexdigest, METH_NOARGS, SHA1Type_hexdigest__doc__}, |
| 59 |
|
| 60 |
static PyObject * |
| 61 |
SHA1Type_hexdigest_impl(SHA1object *self); |
| 62 |
|
| 63 |
static PyObject * |
| 64 |
SHA1Type_hexdigest(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 65 |
{ |
| 66 |
return SHA1Type_hexdigest_impl((SHA1object *)self); |
| 67 |
} |
| 68 |
|
| 69 |
PyDoc_STRVAR(SHA1Type_update__doc__, |
| 70 |
"update($self, obj, /)\n" |
| 71 |
"--\n" |
| 72 |
"\n" |
| 73 |
"Update this hash object\'s state with the provided string."); |
| 74 |
|
| 75 |
#define SHA1TYPE_UPDATE_METHODDEF \ |
| 76 |
{"update", (PyCFunction)SHA1Type_update, METH_O, SHA1Type_update__doc__}, |
| 77 |
|
| 78 |
static PyObject * |
| 79 |
SHA1Type_update_impl(SHA1object *self, PyObject *obj); |
| 80 |
|
| 81 |
static PyObject * |
| 82 |
SHA1Type_update(PyObject *self, PyObject *obj) |
| 83 |
{ |
| 84 |
PyObject *return_value = NULL; |
| 85 |
|
| 86 |
return_value = SHA1Type_update_impl((SHA1object *)self, obj); |
| 87 |
|
| 88 |
return return_value; |
| 89 |
} |
| 90 |
|
| 91 |
PyDoc_STRVAR(_sha1_sha1__doc__, |
| 92 |
"sha1($module, /, data=b\'\', *, usedforsecurity=True, string=None)\n" |
| 93 |
"--\n" |
| 94 |
"\n" |
| 95 |
"Return a new SHA1 hash object; optionally initialized with a string."); |
| 96 |
|
| 97 |
#define _SHA1_SHA1_METHODDEF \ |
| 98 |
{"sha1", _PyCFunction_CAST(_sha1_sha1), METH_FASTCALL|METH_KEYWORDS, _sha1_sha1__doc__}, |
| 99 |
|
| 100 |
static PyObject * |
| 101 |
_sha1_sha1_impl(PyObject *module, PyObject *data, int usedforsecurity, |
| 102 |
PyObject *string_obj); |
| 103 |
|
| 104 |
static PyObject * |
| 105 |
_sha1_sha1(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 106 |
{ |
| 107 |
PyObject *return_value = NULL; |
| 108 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 109 |
|
| 110 |
#define NUM_KEYWORDS 3 |
| 111 |
static struct { |
| 112 |
PyGC_Head _this_is_not_used; |
| 113 |
PyObject_VAR_HEAD |
| 114 |
Py_hash_t ob_hash; |
| 115 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 116 |
} _kwtuple = { |
| 117 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 118 |
.ob_hash = -1, |
| 119 |
.ob_item = { &_Py_ID(data), &_Py_ID(usedforsecurity), &_Py_ID(string), }, |
| 120 |
}; |
| 121 |
#undef NUM_KEYWORDS |
| 122 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 123 |
|
| 124 |
#else // !Py_BUILD_CORE |
| 125 |
# define KWTUPLE NULL |
| 126 |
#endif // !Py_BUILD_CORE |
| 127 |
|
| 128 |
static const char * const _keywords[] = {"data", "usedforsecurity", "string", NULL}; |
| 129 |
static _PyArg_Parser _parser = { |
| 130 |
.keywords = _keywords, |
| 131 |
.fname = "sha1", |
| 132 |
.kwtuple = KWTUPLE, |
| 133 |
}; |
| 134 |
#undef KWTUPLE |
| 135 |
PyObject *argsbuf[3]; |
| 136 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 137 |
PyObject *data = NULL; |
| 138 |
int usedforsecurity = 1; |
| 139 |
PyObject *string_obj = NULL; |
| 140 |
|
| 141 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 142 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 143 |
if (!args) { |
| 144 |
goto exit; |
| 145 |
} |
| 146 |
if (!noptargs) { |
| 147 |
goto skip_optional_pos; |
| 148 |
} |
| 149 |
if (args[0]) { |
| 150 |
data = args[0]; |
| 151 |
if (!--noptargs) { |
| 152 |
goto skip_optional_pos; |
| 153 |
} |
| 154 |
} |
| 155 |
skip_optional_pos: |
| 156 |
if (!noptargs) { |
| 157 |
goto skip_optional_kwonly; |
| 158 |
} |
| 159 |
if (args[1]) { |
| 160 |
usedforsecurity = PyObject_IsTrue(args[1]); |
| 161 |
if (usedforsecurity < 0) { |
| 162 |
goto exit; |
| 163 |
} |
| 164 |
if (!--noptargs) { |
| 165 |
goto skip_optional_kwonly; |
| 166 |
} |
| 167 |
} |
| 168 |
string_obj = args[2]; |
| 169 |
skip_optional_kwonly: |
| 170 |
return_value = _sha1_sha1_impl(module, data, usedforsecurity, string_obj); |
| 171 |
|
| 172 |
exit: |
| 173 |
return return_value; |
| 174 |
} |
| 175 |
/*[clinic end generated code: output=fd5a917404b68c4f input=a9049054013a1b77]*/ |