LCOV - code coverage report
Current view: top level - Modules/clinic - _cryptmodule.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 25 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 1 0.0 %
Branches: 0 18 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(crypt_crypt__doc__,
      12                 :            : "crypt($module, word, salt, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Hash a *word* with the given *salt* and return the hashed password.\n"
      16                 :            : "\n"
      17                 :            : "*word* will usually be a user\'s password.  *salt* (either a random 2 or 16\n"
      18                 :            : "character string, possibly prefixed with $digit$ to indicate the method)\n"
      19                 :            : "will be used to perturb the encryption algorithm and produce distinct\n"
      20                 :            : "results for a given *word*.");
      21                 :            : 
      22                 :            : #define CRYPT_CRYPT_METHODDEF    \
      23                 :            :     {"crypt", _PyCFunction_CAST(crypt_crypt), METH_FASTCALL, crypt_crypt__doc__},
      24                 :            : 
      25                 :            : static PyObject *
      26                 :            : crypt_crypt_impl(PyObject *module, const char *word, const char *salt);
      27                 :            : 
      28                 :            : static PyObject *
      29                 :          0 : crypt_crypt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      30                 :            : {
      31                 :          0 :     PyObject *return_value = NULL;
      32                 :            :     const char *word;
      33                 :            :     const char *salt;
      34                 :            : 
      35   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("crypt", nargs, 2, 2)) {
                   #  # ]
      36                 :          0 :         goto exit;
      37                 :            :     }
      38         [ #  # ]:          0 :     if (!PyUnicode_Check(args[0])) {
      39                 :          0 :         _PyArg_BadArgument("crypt", "argument 1", "str", args[0]);
      40                 :          0 :         goto exit;
      41                 :            :     }
      42                 :            :     Py_ssize_t word_length;
      43                 :          0 :     word = PyUnicode_AsUTF8AndSize(args[0], &word_length);
      44         [ #  # ]:          0 :     if (word == NULL) {
      45                 :          0 :         goto exit;
      46                 :            :     }
      47         [ #  # ]:          0 :     if (strlen(word) != (size_t)word_length) {
      48                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
      49                 :          0 :         goto exit;
      50                 :            :     }
      51         [ #  # ]:          0 :     if (!PyUnicode_Check(args[1])) {
      52                 :          0 :         _PyArg_BadArgument("crypt", "argument 2", "str", args[1]);
      53                 :          0 :         goto exit;
      54                 :            :     }
      55                 :            :     Py_ssize_t salt_length;
      56                 :          0 :     salt = PyUnicode_AsUTF8AndSize(args[1], &salt_length);
      57         [ #  # ]:          0 :     if (salt == NULL) {
      58                 :          0 :         goto exit;
      59                 :            :     }
      60         [ #  # ]:          0 :     if (strlen(salt) != (size_t)salt_length) {
      61                 :          0 :         PyErr_SetString(PyExc_ValueError, "embedded null character");
      62                 :          0 :         goto exit;
      63                 :            :     }
      64                 :          0 :     return_value = crypt_crypt_impl(module, word, salt);
      65                 :            : 
      66                 :          0 : exit:
      67                 :          0 :     return return_value;
      68                 :            : }
      69                 :            : /*[clinic end generated code: output=235ccef9211184f4 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14