• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(py_blake2b_new__doc__,
6 "blake2b(data=b\'\', /, *, digest_size=_blake2.blake2b.MAX_DIGEST_SIZE,\n"
7 "        key=b\'\', salt=b\'\', person=b\'\', fanout=1, depth=1, leaf_size=0,\n"
8 "        node_offset=0, node_depth=0, inner_size=0, last_node=False)\n"
9 "--\n"
10 "\n"
11 "Return a new BLAKE2b hash object.");
12 
13 static PyObject *
14 py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
15                     Py_buffer *key, Py_buffer *salt, Py_buffer *person,
16                     int fanout, int depth, PyObject *leaf_size_obj,
17                     PyObject *node_offset_obj, int node_depth,
18                     int inner_size, int last_node);
19 
20 static PyObject *
py_blake2b_new(PyTypeObject * type,PyObject * args,PyObject * kwargs)21 py_blake2b_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
22 {
23     PyObject *return_value = NULL;
24     static const char * const _keywords[] = {"", "digest_size", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node", NULL};
25     static _PyArg_Parser _parser = {"|O$iy*y*y*iiOOiip:blake2b", _keywords, 0};
26     PyObject *data = NULL;
27     int digest_size = BLAKE2B_OUTBYTES;
28     Py_buffer key = {NULL, NULL};
29     Py_buffer salt = {NULL, NULL};
30     Py_buffer person = {NULL, NULL};
31     int fanout = 1;
32     int depth = 1;
33     PyObject *leaf_size_obj = NULL;
34     PyObject *node_offset_obj = NULL;
35     int node_depth = 0;
36     int inner_size = 0;
37     int last_node = 0;
38 
39     if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
40         &data, &digest_size, &key, &salt, &person, &fanout, &depth, &leaf_size_obj, &node_offset_obj, &node_depth, &inner_size, &last_node)) {
41         goto exit;
42     }
43     return_value = py_blake2b_new_impl(type, data, digest_size, &key, &salt, &person, fanout, depth, leaf_size_obj, node_offset_obj, node_depth, inner_size, last_node);
44 
45 exit:
46     /* Cleanup for key */
47     if (key.obj) {
48        PyBuffer_Release(&key);
49     }
50     /* Cleanup for salt */
51     if (salt.obj) {
52        PyBuffer_Release(&salt);
53     }
54     /* Cleanup for person */
55     if (person.obj) {
56        PyBuffer_Release(&person);
57     }
58 
59     return return_value;
60 }
61 
62 PyDoc_STRVAR(_blake2_blake2b_copy__doc__,
63 "copy($self, /)\n"
64 "--\n"
65 "\n"
66 "Return a copy of the hash object.");
67 
68 #define _BLAKE2_BLAKE2B_COPY_METHODDEF    \
69     {"copy", (PyCFunction)_blake2_blake2b_copy, METH_NOARGS, _blake2_blake2b_copy__doc__},
70 
71 static PyObject *
72 _blake2_blake2b_copy_impl(BLAKE2bObject *self);
73 
74 static PyObject *
_blake2_blake2b_copy(BLAKE2bObject * self,PyObject * Py_UNUSED (ignored))75 _blake2_blake2b_copy(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))
76 {
77     return _blake2_blake2b_copy_impl(self);
78 }
79 
80 PyDoc_STRVAR(_blake2_blake2b_update__doc__,
81 "update($self, data, /)\n"
82 "--\n"
83 "\n"
84 "Update this hash object\'s state with the provided bytes-like object.");
85 
86 #define _BLAKE2_BLAKE2B_UPDATE_METHODDEF    \
87     {"update", (PyCFunction)_blake2_blake2b_update, METH_O, _blake2_blake2b_update__doc__},
88 
89 PyDoc_STRVAR(_blake2_blake2b_digest__doc__,
90 "digest($self, /)\n"
91 "--\n"
92 "\n"
93 "Return the digest value as a bytes object.");
94 
95 #define _BLAKE2_BLAKE2B_DIGEST_METHODDEF    \
96     {"digest", (PyCFunction)_blake2_blake2b_digest, METH_NOARGS, _blake2_blake2b_digest__doc__},
97 
98 static PyObject *
99 _blake2_blake2b_digest_impl(BLAKE2bObject *self);
100 
101 static PyObject *
_blake2_blake2b_digest(BLAKE2bObject * self,PyObject * Py_UNUSED (ignored))102 _blake2_blake2b_digest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))
103 {
104     return _blake2_blake2b_digest_impl(self);
105 }
106 
107 PyDoc_STRVAR(_blake2_blake2b_hexdigest__doc__,
108 "hexdigest($self, /)\n"
109 "--\n"
110 "\n"
111 "Return the digest value as a string of hexadecimal digits.");
112 
113 #define _BLAKE2_BLAKE2B_HEXDIGEST_METHODDEF    \
114     {"hexdigest", (PyCFunction)_blake2_blake2b_hexdigest, METH_NOARGS, _blake2_blake2b_hexdigest__doc__},
115 
116 static PyObject *
117 _blake2_blake2b_hexdigest_impl(BLAKE2bObject *self);
118 
119 static PyObject *
_blake2_blake2b_hexdigest(BLAKE2bObject * self,PyObject * Py_UNUSED (ignored))120 _blake2_blake2b_hexdigest(BLAKE2bObject *self, PyObject *Py_UNUSED(ignored))
121 {
122     return _blake2_blake2b_hexdigest_impl(self);
123 }
124 /*[clinic end generated code: output=0eb559f418fc0a21 input=a9049054013a1b77]*/
125