Path: blob/main/Modules/_blake2/clinic/blake2b_impl.c.h
12 views
/*[clinic input]1preserve2[clinic start generated code]*/34#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)5# include "pycore_gc.h" // PyGC_Head6# include "pycore_runtime.h" // _Py_ID()7#endif8910PyDoc_STRVAR(py_blake2b_new__doc__,11"blake2b(data=b\'\', /, *, digest_size=_blake2.blake2b.MAX_DIGEST_SIZE,\n"12" key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0,\n"13" node_offset=0, node_depth=0, inner_size=0, last_node=False,\n"14" usedforsecurity=True)\n"15"--\n"16"\n"17"Return a new BLAKE2b hash object.");1819static PyObject *20py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,21Py_buffer *key, Py_buffer *salt, Py_buffer *person,22int fanout, int depth, unsigned long leaf_size,23unsigned long long node_offset, int node_depth,24int inner_size, int last_node, int usedforsecurity);2526static PyObject *27py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)28{29PyObject *return_value = NULL;30#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)3132#define NUM_KEYWORDS 1233static struct {34PyGC_Head _this_is_not_used;35PyObject_VAR_HEAD36PyObject *ob_item[NUM_KEYWORDS];37} _kwtuple = {38.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)39.ob_item = { &_Py_ID(digest_size), &_Py_ID(key), &_Py_ID(salt), &_Py_ID(person), &_Py_ID(fanout), &_Py_ID(depth), &_Py_ID(leaf_size), &_Py_ID(node_offset), &_Py_ID(node_depth), &_Py_ID(inner_size), &_Py_ID(last_node), &_Py_ID(usedforsecurity), },40};41#undef NUM_KEYWORDS42#define KWTUPLE (&_kwtuple.ob_base.ob_base)4344#else // !Py_BUILD_CORE45# define KWTUPLE NULL46#endif // !Py_BUILD_CORE4748static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", "usedforsecurity", NULL};49static _PyArg_Parser _parser = {50.keywords = _keywords,51.fname = "blake2b",52.kwtuple = KWTUPLE,53};54#undef KWTUPLE55PyObject *argsbuf[13];56PyObject * const *fastargs;57Py_ssize_t nargs = PyTuple_GET_SIZE(args);58Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;59PyObject *data = NULL;60int digest_size = BLAKE2B_OUTBYTES;61Py_buffer key = {NULL, NULL};62Py_buffer salt = {NULL, NULL};63Py_buffer person = {NULL, NULL};64int fanout = 1;65int depth = 1;66unsigned long leaf_size = 0;67unsigned long long node_offset = 0;68int node_depth = 0;69int inner_size = 0;70int last_node = 0;71int usedforsecurity = 1;7273fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf);74if (!fastargs) {75goto exit;76}77if (nargs < 1) {78goto skip_optional_posonly;79}80noptargs--;81data = fastargs[0];82skip_optional_posonly:83if (!noptargs) {84goto skip_optional_kwonly;85}86if (fastargs[1]) {87digest_size = _PyLong_AsInt(fastargs[1]);88if (digest_size == -1 && PyErr_Occurred()) {89goto exit;90}91if (!--noptargs) {92goto skip_optional_kwonly;93}94}95if (fastargs[2]) {96if (PyObject_GetBuffer(fastargs[2], &key, PyBUF_SIMPLE) != 0) {97goto exit;98}99if (!PyBuffer_IsContiguous(&key, 'C')) {100_PyArg_BadArgument("blake2b", "argument 'key'", "contiguous buffer", fastargs[2]);101goto exit;102}103if (!--noptargs) {104goto skip_optional_kwonly;105}106}107if (fastargs[3]) {108if (PyObject_GetBuffer(fastargs[3], &salt, PyBUF_SIMPLE) != 0) {109goto exit;110}111if (!PyBuffer_IsContiguous(&salt, 'C')) {112_PyArg_BadArgument("blake2b", "argument 'salt'", "contiguous buffer", fastargs[3]);113goto exit;114}115if (!--noptargs) {116goto skip_optional_kwonly;117}118}119if (fastargs[4]) {120if (PyObject_GetBuffer(fastargs[4], &person, PyBUF_SIMPLE) != 0) {121goto exit;122}123if (!PyBuffer_IsContiguous(&person, 'C')) {124_PyArg_BadArgument("blake2b", "argument 'person'", "contiguous buffer", fastargs[4]);125goto exit;126}127if (!--noptargs) {128goto skip_optional_kwonly;129}130}131if (fastargs[5]) {132fanout = _PyLong_AsInt(fastargs[5]);133if (fanout == -1 && PyErr_Occurred()) {134goto exit;135}136if (!--noptargs) {137goto skip_optional_kwonly;138}139}140if (fastargs[6]) {141depth = _PyLong_AsInt(fastargs[6]);142if (depth == -1 && PyErr_Occurred()) {143goto exit;144}145if (!--noptargs) {146goto skip_optional_kwonly;147}148}149if (fastargs[7]) {150if (!_PyLong_UnsignedLong_Converter(fastargs[7], &leaf_size)) {151goto exit;152}153if (!--noptargs) {154goto skip_optional_kwonly;155}156}157if (fastargs[8]) {158if (!_PyLong_UnsignedLongLong_Converter(fastargs[8], &node_offset)) {159goto exit;160}161if (!--noptargs) {162goto skip_optional_kwonly;163}164}165if (fastargs[9]) {166node_depth = _PyLong_AsInt(fastargs[9]);167if (node_depth == -1 && PyErr_Occurred()) {168goto exit;169}170if (!--noptargs) {171goto skip_optional_kwonly;172}173}174if (fastargs[10]) {175inner_size = _PyLong_AsInt(fastargs[10]);176if (inner_size == -1 && PyErr_Occurred()) {177goto exit;178}179if (!--noptargs) {180goto skip_optional_kwonly;181}182}183if (fastargs[11]) {184last_node = PyObject_IsTrue(fastargs[11]);185if (last_node < 0) {186goto exit;187}188if (!--noptargs) {189goto skip_optional_kwonly;190}191}192usedforsecurity = PyObject_IsTrue(fastargs[12]);193if (usedforsecurity < 0) {194goto exit;195}196skip_optional_kwonly:197return_value = py_blake2b_new_impl(type, data, digest_size, &key, &salt, &person, fanout, depth, leaf_size, node_offset, node_depth, inner_size, last_node, usedforsecurity);198199exit:200/* Cleanup for key */201if (key.obj) {202PyBuffer_Release(&key);203}204/* Cleanup for salt */205if (salt.obj) {206PyBuffer_Release(&salt);207}208/* Cleanup for person */209if (person.obj) {210PyBuffer_Release(&person);211}212213return return_value;214}215216PyDoc_STRVAR(_blake2_blake2b_copy__doc__,217"copy($self, /)\n"218"--\n"219"\n"220"Return a copy of the hash object.");221222#define _BLAKE2_BLAKE2B_COPY_METHODDEF \223{"copy", (PyCFunction)_blake2_blake2b_copy, METH_NOARGS, _blake2_blake2b_copy__doc__},224225static PyObject *226_blake2_blake2b_copy_impl(BLAKE2bObject *self);227228static PyObject *229_blake2_blake2b_copy(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))230{231return _blake2_blake2b_copy_impl(self);232}233234PyDoc_STRVAR(_blake2_blake2b_update__doc__,235"update($self, data, /)\n"236"--\n"237"\n"238"Update this hash object\'s state with the provided bytes-like object.");239240#define _BLAKE2_BLAKE2B_UPDATE_METHODDEF \241{"update", (PyCFunction)_blake2_blake2b_update, METH_O, _blake2_blake2b_update__doc__},242243PyDoc_STRVAR(_blake2_blake2b_digest__doc__,244"digest($self, /)\n"245"--\n"246"\n"247"Return the digest value as a bytes object.");248249#define _BLAKE2_BLAKE2B_DIGEST_METHODDEF \250{"digest", (PyCFunction)_blake2_blake2b_digest, METH_NOARGS, _blake2_blake2b_digest__doc__},251252static PyObject *253_blake2_blake2b_digest_impl(BLAKE2bObject *self);254255static PyObject *256_blake2_blake2b_digest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))257{258return _blake2_blake2b_digest_impl(self);259}260261PyDoc_STRVAR(_blake2_blake2b_hexdigest__doc__,262"hexdigest($self, /)\n"263"--\n"264"\n"265"Return the digest value as a string of hexadecimal digits.");266267#define _BLAKE2_BLAKE2B_HEXDIGEST_METHODDEF \268{"hexdigest", (PyCFunction)_blake2_blake2b_hexdigest, METH_NOARGS, _blake2_blake2b_hexdigest__doc__},269270static PyObject *271_blake2_blake2b_hexdigest_impl(BLAKE2bObject *self);272273static PyObject *274_blake2_blake2b_hexdigest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))275{276return _blake2_blake2b_hexdigest_impl(self);277}278/*[clinic end generated code: output=996b4fe396824797 input=a9049054013a1b77]*/279280281