LCOV - code coverage report
Current view: top level - Modules/_blake2/clinic - blake2s_impl.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 116 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 4 0.0 %
Branches: 0 106 0.0 %

           Branch data     Line data    Source code
       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_blake2s_new__doc__,
      12                 :            : "blake2s(data=b\'\', /, *, digest_size=_blake2.blake2s.MAX_DIGEST_SIZE,\n"
      13                 :            : "        key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0,\n"
      14                 :            : "        node_offset=0, node_depth=0, inner_size=0, last_node=False,\n"
      15                 :            : "        usedforsecurity=True)\n"
      16                 :            : "--\n"
      17                 :            : "\n"
      18                 :            : "Return a new BLAKE2s hash object.");
      19                 :            : 
      20                 :            : static PyObject *
      21                 :            : py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
      22                 :            :                     Py_buffer *key, Py_buffer *salt, Py_buffer *person,
      23                 :            :                     int fanout, int depth, unsigned long leaf_size,
      24                 :            :                     unsigned long long node_offset, int node_depth,
      25                 :            :                     int inner_size, int last_node, int usedforsecurity);
      26                 :            : 
      27                 :            : static PyObject *
      28                 :          0 : py_blake2s_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
      29                 :            : {
      30                 :          0 :     PyObject *return_value = NULL;
      31                 :            :     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
      32                 :            : 
      33                 :            :     #define NUM_KEYWORDS 12
      34                 :            :     static struct {
      35                 :            :         PyGC_Head _this_is_not_used;
      36                 :            :         PyObject_VAR_HEAD
      37                 :            :         PyObject *ob_item[NUM_KEYWORDS];
      38                 :            :     } _kwtuple = {
      39                 :            :         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
      40                 :            :         .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), },
      41                 :            :     };
      42                 :            :     #undef NUM_KEYWORDS
      43                 :            :     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
      44                 :            : 
      45                 :            :     #else  // !Py_BUILD_CORE
      46                 :            :     #  define KWTUPLE NULL
      47                 :            :     #endif  // !Py_BUILD_CORE
      48                 :            : 
      49                 :            :     static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", "usedforsecurity", NULL};
      50                 :            :     static _PyArg_Parser _parser = {
      51                 :            :         .keywords = _keywords,
      52                 :            :         .fname = "blake2s",
      53                 :            :         .kwtuple = KWTUPLE,
      54                 :            :     };
      55                 :            :     #undef KWTUPLE
      56                 :            :     PyObject *argsbuf[13];
      57                 :            :     PyObject * const *fastargs;
      58                 :          0 :     Py_ssize_t nargs = PyTuple_GET_SIZE(args);
      59         [ #  # ]:          0 :     Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
      60                 :          0 :     PyObject *data = NULL;
      61                 :          0 :     int digest_size = BLAKE2S_OUTBYTES;
      62                 :          0 :     Py_buffer key = {NULL, NULL};
      63                 :          0 :     Py_buffer salt = {NULL, NULL};
      64                 :          0 :     Py_buffer person = {NULL, NULL};
      65                 :          0 :     int fanout = 1;
      66                 :          0 :     int depth = 1;
      67                 :          0 :     unsigned long leaf_size = 0;
      68                 :          0 :     unsigned long long node_offset = 0;
      69                 :          0 :     int node_depth = 0;
      70                 :          0 :     int inner_size = 0;
      71                 :          0 :     int last_node = 0;
      72                 :          0 :     int usedforsecurity = 1;
      73                 :            : 
      74   [ #  #  #  #  :          0 :     fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 1, 0, argsbuf);
             #  #  #  # ]
      75         [ #  # ]:          0 :     if (!fastargs) {
      76                 :          0 :         goto exit;
      77                 :            :     }
      78         [ #  # ]:          0 :     if (nargs < 1) {
      79                 :          0 :         goto skip_optional_posonly;
      80                 :            :     }
      81                 :          0 :     noptargs--;
      82                 :          0 :     data = fastargs[0];
      83                 :          0 : skip_optional_posonly:
      84         [ #  # ]:          0 :     if (!noptargs) {
      85                 :          0 :         goto skip_optional_kwonly;
      86                 :            :     }
      87         [ #  # ]:          0 :     if (fastargs[1]) {
      88                 :          0 :         digest_size = _PyLong_AsInt(fastargs[1]);
      89   [ #  #  #  # ]:          0 :         if (digest_size == -1 && PyErr_Occurred()) {
      90                 :          0 :             goto exit;
      91                 :            :         }
      92         [ #  # ]:          0 :         if (!--noptargs) {
      93                 :          0 :             goto skip_optional_kwonly;
      94                 :            :         }
      95                 :            :     }
      96         [ #  # ]:          0 :     if (fastargs[2]) {
      97         [ #  # ]:          0 :         if (PyObject_GetBuffer(fastargs[2], &key, PyBUF_SIMPLE) != 0) {
      98                 :          0 :             goto exit;
      99                 :            :         }
     100         [ #  # ]:          0 :         if (!PyBuffer_IsContiguous(&key, 'C')) {
     101                 :          0 :             _PyArg_BadArgument("blake2s", "argument 'key'", "contiguous buffer", fastargs[2]);
     102                 :          0 :             goto exit;
     103                 :            :         }
     104         [ #  # ]:          0 :         if (!--noptargs) {
     105                 :          0 :             goto skip_optional_kwonly;
     106                 :            :         }
     107                 :            :     }
     108         [ #  # ]:          0 :     if (fastargs[3]) {
     109         [ #  # ]:          0 :         if (PyObject_GetBuffer(fastargs[3], &salt, PyBUF_SIMPLE) != 0) {
     110                 :          0 :             goto exit;
     111                 :            :         }
     112         [ #  # ]:          0 :         if (!PyBuffer_IsContiguous(&salt, 'C')) {
     113                 :          0 :             _PyArg_BadArgument("blake2s", "argument 'salt'", "contiguous buffer", fastargs[3]);
     114                 :          0 :             goto exit;
     115                 :            :         }
     116         [ #  # ]:          0 :         if (!--noptargs) {
     117                 :          0 :             goto skip_optional_kwonly;
     118                 :            :         }
     119                 :            :     }
     120         [ #  # ]:          0 :     if (fastargs[4]) {
     121         [ #  # ]:          0 :         if (PyObject_GetBuffer(fastargs[4], &person, PyBUF_SIMPLE) != 0) {
     122                 :          0 :             goto exit;
     123                 :            :         }
     124         [ #  # ]:          0 :         if (!PyBuffer_IsContiguous(&person, 'C')) {
     125                 :          0 :             _PyArg_BadArgument("blake2s", "argument 'person'", "contiguous buffer", fastargs[4]);
     126                 :          0 :             goto exit;
     127                 :            :         }
     128         [ #  # ]:          0 :         if (!--noptargs) {
     129                 :          0 :             goto skip_optional_kwonly;
     130                 :            :         }
     131                 :            :     }
     132         [ #  # ]:          0 :     if (fastargs[5]) {
     133                 :          0 :         fanout = _PyLong_AsInt(fastargs[5]);
     134   [ #  #  #  # ]:          0 :         if (fanout == -1 && PyErr_Occurred()) {
     135                 :          0 :             goto exit;
     136                 :            :         }
     137         [ #  # ]:          0 :         if (!--noptargs) {
     138                 :          0 :             goto skip_optional_kwonly;
     139                 :            :         }
     140                 :            :     }
     141         [ #  # ]:          0 :     if (fastargs[6]) {
     142                 :          0 :         depth = _PyLong_AsInt(fastargs[6]);
     143   [ #  #  #  # ]:          0 :         if (depth == -1 && PyErr_Occurred()) {
     144                 :          0 :             goto exit;
     145                 :            :         }
     146         [ #  # ]:          0 :         if (!--noptargs) {
     147                 :          0 :             goto skip_optional_kwonly;
     148                 :            :         }
     149                 :            :     }
     150         [ #  # ]:          0 :     if (fastargs[7]) {
     151         [ #  # ]:          0 :         if (!_PyLong_UnsignedLong_Converter(fastargs[7], &leaf_size)) {
     152                 :          0 :             goto exit;
     153                 :            :         }
     154         [ #  # ]:          0 :         if (!--noptargs) {
     155                 :          0 :             goto skip_optional_kwonly;
     156                 :            :         }
     157                 :            :     }
     158         [ #  # ]:          0 :     if (fastargs[8]) {
     159         [ #  # ]:          0 :         if (!_PyLong_UnsignedLongLong_Converter(fastargs[8], &node_offset)) {
     160                 :          0 :             goto exit;
     161                 :            :         }
     162         [ #  # ]:          0 :         if (!--noptargs) {
     163                 :          0 :             goto skip_optional_kwonly;
     164                 :            :         }
     165                 :            :     }
     166         [ #  # ]:          0 :     if (fastargs[9]) {
     167                 :          0 :         node_depth = _PyLong_AsInt(fastargs[9]);
     168   [ #  #  #  # ]:          0 :         if (node_depth == -1 && PyErr_Occurred()) {
     169                 :          0 :             goto exit;
     170                 :            :         }
     171         [ #  # ]:          0 :         if (!--noptargs) {
     172                 :          0 :             goto skip_optional_kwonly;
     173                 :            :         }
     174                 :            :     }
     175         [ #  # ]:          0 :     if (fastargs[10]) {
     176                 :          0 :         inner_size = _PyLong_AsInt(fastargs[10]);
     177   [ #  #  #  # ]:          0 :         if (inner_size == -1 && PyErr_Occurred()) {
     178                 :          0 :             goto exit;
     179                 :            :         }
     180         [ #  # ]:          0 :         if (!--noptargs) {
     181                 :          0 :             goto skip_optional_kwonly;
     182                 :            :         }
     183                 :            :     }
     184         [ #  # ]:          0 :     if (fastargs[11]) {
     185                 :          0 :         last_node = PyObject_IsTrue(fastargs[11]);
     186         [ #  # ]:          0 :         if (last_node < 0) {
     187                 :          0 :             goto exit;
     188                 :            :         }
     189         [ #  # ]:          0 :         if (!--noptargs) {
     190                 :          0 :             goto skip_optional_kwonly;
     191                 :            :         }
     192                 :            :     }
     193                 :          0 :     usedforsecurity = PyObject_IsTrue(fastargs[12]);
     194         [ #  # ]:          0 :     if (usedforsecurity < 0) {
     195                 :          0 :         goto exit;
     196                 :            :     }
     197                 :          0 : skip_optional_kwonly:
     198                 :          0 :     return_value = py_blake2s_new_impl(type, data, digest_size, &key, &salt, &person, fanout, depth, leaf_size, node_offset, node_depth, inner_size, last_node, usedforsecurity);
     199                 :            : 
     200                 :          0 : exit:
     201                 :            :     /* Cleanup for key */
     202         [ #  # ]:          0 :     if (key.obj) {
     203                 :          0 :        PyBuffer_Release(&key);
     204                 :            :     }
     205                 :            :     /* Cleanup for salt */
     206         [ #  # ]:          0 :     if (salt.obj) {
     207                 :          0 :        PyBuffer_Release(&salt);
     208                 :            :     }
     209                 :            :     /* Cleanup for person */
     210         [ #  # ]:          0 :     if (person.obj) {
     211                 :          0 :        PyBuffer_Release(&person);
     212                 :            :     }
     213                 :            : 
     214                 :          0 :     return return_value;
     215                 :            : }
     216                 :            : 
     217                 :            : PyDoc_STRVAR(_blake2_blake2s_copy__doc__,
     218                 :            : "copy($self, /)\n"
     219                 :            : "--\n"
     220                 :            : "\n"
     221                 :            : "Return a copy of the hash object.");
     222                 :            : 
     223                 :            : #define _BLAKE2_BLAKE2S_COPY_METHODDEF    \
     224                 :            :     {"copy", (PyCFunction)_blake2_blake2s_copy, METH_NOARGS, _blake2_blake2s_copy__doc__},
     225                 :            : 
     226                 :            : static PyObject *
     227                 :            : _blake2_blake2s_copy_impl(BLAKE2sObject *self);
     228                 :            : 
     229                 :            : static PyObject *
     230                 :          0 : _blake2_blake2s_copy(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored))
     231                 :            : {
     232                 :          0 :     return _blake2_blake2s_copy_impl(self);
     233                 :            : }
     234                 :            : 
     235                 :            : PyDoc_STRVAR(_blake2_blake2s_update__doc__,
     236                 :            : "update($self, data, /)\n"
     237                 :            : "--\n"
     238                 :            : "\n"
     239                 :            : "Update this hash object\'s state with the provided bytes-like object.");
     240                 :            : 
     241                 :            : #define _BLAKE2_BLAKE2S_UPDATE_METHODDEF    \
     242                 :            :     {"update", (PyCFunction)_blake2_blake2s_update, METH_O, _blake2_blake2s_update__doc__},
     243                 :            : 
     244                 :            : PyDoc_STRVAR(_blake2_blake2s_digest__doc__,
     245                 :            : "digest($self, /)\n"
     246                 :            : "--\n"
     247                 :            : "\n"
     248                 :            : "Return the digest value as a bytes object.");
     249                 :            : 
     250                 :            : #define _BLAKE2_BLAKE2S_DIGEST_METHODDEF    \
     251                 :            :     {"digest", (PyCFunction)_blake2_blake2s_digest, METH_NOARGS, _blake2_blake2s_digest__doc__},
     252                 :            : 
     253                 :            : static PyObject *
     254                 :            : _blake2_blake2s_digest_impl(BLAKE2sObject *self);
     255                 :            : 
     256                 :            : static PyObject *
     257                 :          0 : _blake2_blake2s_digest(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored))
     258                 :            : {
     259                 :          0 :     return _blake2_blake2s_digest_impl(self);
     260                 :            : }
     261                 :            : 
     262                 :            : PyDoc_STRVAR(_blake2_blake2s_hexdigest__doc__,
     263                 :            : "hexdigest($self, /)\n"
     264                 :            : "--\n"
     265                 :            : "\n"
     266                 :            : "Return the digest value as a string of hexadecimal digits.");
     267                 :            : 
     268                 :            : #define _BLAKE2_BLAKE2S_HEXDIGEST_METHODDEF    \
     269                 :            :     {"hexdigest", (PyCFunction)_blake2_blake2s_hexdigest, METH_NOARGS, _blake2_blake2s_hexdigest__doc__},
     270                 :            : 
     271                 :            : static PyObject *
     272                 :            : _blake2_blake2s_hexdigest_impl(BLAKE2sObject *self);
     273                 :            : 
     274                 :            : static PyObject *
     275                 :          0 : _blake2_blake2s_hexdigest(BLAKE2sObject *self, PyObject *Py_UNUSED(ignored))
     276                 :            : {
     277                 :          0 :     return _blake2_blake2s_hexdigest_impl(self);
     278                 :            : }
     279                 :            : /*[clinic end generated code: output=bd0fb7639e450618 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14