diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Modules/_cryptmodule.c | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Modules/_cryptmodule.c')
-rw-r--r-- | contrib/tools/python3/src/Modules/_cryptmodule.c | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/contrib/tools/python3/src/Modules/_cryptmodule.c b/contrib/tools/python3/src/Modules/_cryptmodule.c index 72a4f44600..73bb2277db 100644 --- a/contrib/tools/python3/src/Modules/_cryptmodule.c +++ b/contrib/tools/python3/src/Modules/_cryptmodule.c @@ -1,80 +1,80 @@ -/* cryptmodule.c - by Steve Majewski - */ - -#include "Python.h" - -#include <sys/types.h> -#ifdef HAVE_CRYPT_H -#include <crypt.h> -#endif - -/* Module crypt */ - -/*[clinic input] -module crypt -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c6252cf4f2f2ae81]*/ - -#include "clinic/_cryptmodule.c.h" - -/*[clinic input] -crypt.crypt - - word: str - salt: str - / - -Hash a *word* with the given *salt* and return the hashed password. - -*word* will usually be a user's password. *salt* (either a random 2 or 16 -character string, possibly prefixed with $digit$ to indicate the method) -will be used to perturb the encryption algorithm and produce distinct -results for a given *word*. - -[clinic start generated code]*/ - -static PyObject * -crypt_crypt_impl(PyObject *module, const char *word, const char *salt) -/*[clinic end generated code: output=0512284a03d2803c input=0e8edec9c364352b]*/ -{ - char *crypt_result; -#ifdef HAVE_CRYPT_R - struct crypt_data data; - memset(&data, 0, sizeof(data)); - crypt_result = crypt_r(word, salt, &data); -#else - crypt_result = crypt(word, salt); -#endif - if (crypt_result == NULL) { - return PyErr_SetFromErrno(PyExc_OSError); - } - return Py_BuildValue("s", crypt_result); -} - - -static PyMethodDef crypt_methods[] = { - CRYPT_CRYPT_METHODDEF - {NULL, NULL} /* sentinel */ -}; - -static PyModuleDef_Slot _crypt_slots[] = { - {0, NULL} -}; - -static struct PyModuleDef cryptmodule = { - PyModuleDef_HEAD_INIT, - "_crypt", - NULL, - 0, - crypt_methods, - _crypt_slots, - NULL, - NULL, - NULL -}; - -PyMODINIT_FUNC -PyInit__crypt(void) -{ - return PyModuleDef_Init(&cryptmodule); -} +/* cryptmodule.c - by Steve Majewski + */ + +#include "Python.h" + +#include <sys/types.h> +#ifdef HAVE_CRYPT_H +#include <crypt.h> +#endif + +/* Module crypt */ + +/*[clinic input] +module crypt +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c6252cf4f2f2ae81]*/ + +#include "clinic/_cryptmodule.c.h" + +/*[clinic input] +crypt.crypt + + word: str + salt: str + / + +Hash a *word* with the given *salt* and return the hashed password. + +*word* will usually be a user's password. *salt* (either a random 2 or 16 +character string, possibly prefixed with $digit$ to indicate the method) +will be used to perturb the encryption algorithm and produce distinct +results for a given *word*. + +[clinic start generated code]*/ + +static PyObject * +crypt_crypt_impl(PyObject *module, const char *word, const char *salt) +/*[clinic end generated code: output=0512284a03d2803c input=0e8edec9c364352b]*/ +{ + char *crypt_result; +#ifdef HAVE_CRYPT_R + struct crypt_data data; + memset(&data, 0, sizeof(data)); + crypt_result = crypt_r(word, salt, &data); +#else + crypt_result = crypt(word, salt); +#endif + if (crypt_result == NULL) { + return PyErr_SetFromErrno(PyExc_OSError); + } + return Py_BuildValue("s", crypt_result); +} + + +static PyMethodDef crypt_methods[] = { + CRYPT_CRYPT_METHODDEF + {NULL, NULL} /* sentinel */ +}; + +static PyModuleDef_Slot _crypt_slots[] = { + {0, NULL} +}; + +static struct PyModuleDef cryptmodule = { + PyModuleDef_HEAD_INIT, + "_crypt", + NULL, + 0, + crypt_methods, + _crypt_slots, + NULL, + NULL, + NULL +}; + +PyMODINIT_FUNC +PyInit__crypt(void) +{ + return PyModuleDef_Init(&cryptmodule); +} |