(root)/
Python-3.11.7/
Modules/
clinic/
_ssl.c.h
       1  /*[clinic input]
       2  preserve
       3  [clinic start generated code]*/
       4  
       5  PyDoc_STRVAR(_ssl__SSLSocket_do_handshake__doc__,
       6  "do_handshake($self, /)\n"
       7  "--\n"
       8  "\n");
       9  
      10  #define _SSL__SSLSOCKET_DO_HANDSHAKE_METHODDEF    \
      11      {"do_handshake", (PyCFunction)_ssl__SSLSocket_do_handshake, METH_NOARGS, _ssl__SSLSocket_do_handshake__doc__},
      12  
      13  static PyObject *
      14  _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self);
      15  
      16  static PyObject *
      17  _ssl__SSLSocket_do_handshake(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
      18  {
      19      return _ssl__SSLSocket_do_handshake_impl(self);
      20  }
      21  
      22  PyDoc_STRVAR(_ssl__test_decode_cert__doc__,
      23  "_test_decode_cert($module, path, /)\n"
      24  "--\n"
      25  "\n");
      26  
      27  #define _SSL__TEST_DECODE_CERT_METHODDEF    \
      28      {"_test_decode_cert", (PyCFunction)_ssl__test_decode_cert, METH_O, _ssl__test_decode_cert__doc__},
      29  
      30  static PyObject *
      31  _ssl__test_decode_cert_impl(PyObject *module, PyObject *path);
      32  
      33  static PyObject *
      34  _ssl__test_decode_cert(PyObject *module, PyObject *arg)
      35  {
      36      PyObject *return_value = NULL;
      37      PyObject *path;
      38  
      39      if (!PyUnicode_FSConverter(arg, &path)) {
      40          goto exit;
      41      }
      42      return_value = _ssl__test_decode_cert_impl(module, path);
      43  
      44  exit:
      45      return return_value;
      46  }
      47  
      48  PyDoc_STRVAR(_ssl__SSLSocket_getpeercert__doc__,
      49  "getpeercert($self, der=False, /)\n"
      50  "--\n"
      51  "\n"
      52  "Returns the certificate for the peer.\n"
      53  "\n"
      54  "If no certificate was provided, returns None.  If a certificate was\n"
      55  "provided, but not validated, returns an empty dictionary.  Otherwise\n"
      56  "returns a dict containing information about the peer certificate.\n"
      57  "\n"
      58  "If the optional argument is True, returns a DER-encoded copy of the\n"
      59  "peer certificate, or None if no certificate was provided.  This will\n"
      60  "return the certificate even if it wasn\'t validated.");
      61  
      62  #define _SSL__SSLSOCKET_GETPEERCERT_METHODDEF    \
      63      {"getpeercert", _PyCFunction_CAST(_ssl__SSLSocket_getpeercert), METH_FASTCALL, _ssl__SSLSocket_getpeercert__doc__},
      64  
      65  static PyObject *
      66  _ssl__SSLSocket_getpeercert_impl(PySSLSocket *self, int binary_mode);
      67  
      68  static PyObject *
      69  _ssl__SSLSocket_getpeercert(PySSLSocket *self, PyObject *const *args, Py_ssize_t nargs)
      70  {
      71      PyObject *return_value = NULL;
      72      int binary_mode = 0;
      73  
      74      if (!_PyArg_CheckPositional("getpeercert", nargs, 0, 1)) {
      75          goto exit;
      76      }
      77      if (nargs < 1) {
      78          goto skip_optional;
      79      }
      80      binary_mode = PyObject_IsTrue(args[0]);
      81      if (binary_mode < 0) {
      82          goto exit;
      83      }
      84  skip_optional:
      85      return_value = _ssl__SSLSocket_getpeercert_impl(self, binary_mode);
      86  
      87  exit:
      88      return return_value;
      89  }
      90  
      91  PyDoc_STRVAR(_ssl__SSLSocket_get_verified_chain__doc__,
      92  "get_verified_chain($self, /)\n"
      93  "--\n"
      94  "\n");
      95  
      96  #define _SSL__SSLSOCKET_GET_VERIFIED_CHAIN_METHODDEF    \
      97      {"get_verified_chain", (PyCFunction)_ssl__SSLSocket_get_verified_chain, METH_NOARGS, _ssl__SSLSocket_get_verified_chain__doc__},
      98  
      99  static PyObject *
     100  _ssl__SSLSocket_get_verified_chain_impl(PySSLSocket *self);
     101  
     102  static PyObject *
     103  _ssl__SSLSocket_get_verified_chain(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     104  {
     105      return _ssl__SSLSocket_get_verified_chain_impl(self);
     106  }
     107  
     108  PyDoc_STRVAR(_ssl__SSLSocket_get_unverified_chain__doc__,
     109  "get_unverified_chain($self, /)\n"
     110  "--\n"
     111  "\n");
     112  
     113  #define _SSL__SSLSOCKET_GET_UNVERIFIED_CHAIN_METHODDEF    \
     114      {"get_unverified_chain", (PyCFunction)_ssl__SSLSocket_get_unverified_chain, METH_NOARGS, _ssl__SSLSocket_get_unverified_chain__doc__},
     115  
     116  static PyObject *
     117  _ssl__SSLSocket_get_unverified_chain_impl(PySSLSocket *self);
     118  
     119  static PyObject *
     120  _ssl__SSLSocket_get_unverified_chain(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     121  {
     122      return _ssl__SSLSocket_get_unverified_chain_impl(self);
     123  }
     124  
     125  PyDoc_STRVAR(_ssl__SSLSocket_shared_ciphers__doc__,
     126  "shared_ciphers($self, /)\n"
     127  "--\n"
     128  "\n");
     129  
     130  #define _SSL__SSLSOCKET_SHARED_CIPHERS_METHODDEF    \
     131      {"shared_ciphers", (PyCFunction)_ssl__SSLSocket_shared_ciphers, METH_NOARGS, _ssl__SSLSocket_shared_ciphers__doc__},
     132  
     133  static PyObject *
     134  _ssl__SSLSocket_shared_ciphers_impl(PySSLSocket *self);
     135  
     136  static PyObject *
     137  _ssl__SSLSocket_shared_ciphers(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     138  {
     139      return _ssl__SSLSocket_shared_ciphers_impl(self);
     140  }
     141  
     142  PyDoc_STRVAR(_ssl__SSLSocket_cipher__doc__,
     143  "cipher($self, /)\n"
     144  "--\n"
     145  "\n");
     146  
     147  #define _SSL__SSLSOCKET_CIPHER_METHODDEF    \
     148      {"cipher", (PyCFunction)_ssl__SSLSocket_cipher, METH_NOARGS, _ssl__SSLSocket_cipher__doc__},
     149  
     150  static PyObject *
     151  _ssl__SSLSocket_cipher_impl(PySSLSocket *self);
     152  
     153  static PyObject *
     154  _ssl__SSLSocket_cipher(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     155  {
     156      return _ssl__SSLSocket_cipher_impl(self);
     157  }
     158  
     159  PyDoc_STRVAR(_ssl__SSLSocket_version__doc__,
     160  "version($self, /)\n"
     161  "--\n"
     162  "\n");
     163  
     164  #define _SSL__SSLSOCKET_VERSION_METHODDEF    \
     165      {"version", (PyCFunction)_ssl__SSLSocket_version, METH_NOARGS, _ssl__SSLSocket_version__doc__},
     166  
     167  static PyObject *
     168  _ssl__SSLSocket_version_impl(PySSLSocket *self);
     169  
     170  static PyObject *
     171  _ssl__SSLSocket_version(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     172  {
     173      return _ssl__SSLSocket_version_impl(self);
     174  }
     175  
     176  PyDoc_STRVAR(_ssl__SSLSocket_selected_alpn_protocol__doc__,
     177  "selected_alpn_protocol($self, /)\n"
     178  "--\n"
     179  "\n");
     180  
     181  #define _SSL__SSLSOCKET_SELECTED_ALPN_PROTOCOL_METHODDEF    \
     182      {"selected_alpn_protocol", (PyCFunction)_ssl__SSLSocket_selected_alpn_protocol, METH_NOARGS, _ssl__SSLSocket_selected_alpn_protocol__doc__},
     183  
     184  static PyObject *
     185  _ssl__SSLSocket_selected_alpn_protocol_impl(PySSLSocket *self);
     186  
     187  static PyObject *
     188  _ssl__SSLSocket_selected_alpn_protocol(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     189  {
     190      return _ssl__SSLSocket_selected_alpn_protocol_impl(self);
     191  }
     192  
     193  PyDoc_STRVAR(_ssl__SSLSocket_compression__doc__,
     194  "compression($self, /)\n"
     195  "--\n"
     196  "\n");
     197  
     198  #define _SSL__SSLSOCKET_COMPRESSION_METHODDEF    \
     199      {"compression", (PyCFunction)_ssl__SSLSocket_compression, METH_NOARGS, _ssl__SSLSocket_compression__doc__},
     200  
     201  static PyObject *
     202  _ssl__SSLSocket_compression_impl(PySSLSocket *self);
     203  
     204  static PyObject *
     205  _ssl__SSLSocket_compression(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     206  {
     207      return _ssl__SSLSocket_compression_impl(self);
     208  }
     209  
     210  PyDoc_STRVAR(_ssl__SSLSocket_write__doc__,
     211  "write($self, b, /)\n"
     212  "--\n"
     213  "\n"
     214  "Writes the bytes-like object b into the SSL object.\n"
     215  "\n"
     216  "Returns the number of bytes written.");
     217  
     218  #define _SSL__SSLSOCKET_WRITE_METHODDEF    \
     219      {"write", (PyCFunction)_ssl__SSLSocket_write, METH_O, _ssl__SSLSocket_write__doc__},
     220  
     221  static PyObject *
     222  _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b);
     223  
     224  static PyObject *
     225  _ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg)
     226  {
     227      PyObject *return_value = NULL;
     228      Py_buffer b = {NULL, NULL};
     229  
     230      if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
     231          goto exit;
     232      }
     233      if (!PyBuffer_IsContiguous(&b, 'C')) {
     234          _PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
     235          goto exit;
     236      }
     237      return_value = _ssl__SSLSocket_write_impl(self, &b);
     238  
     239  exit:
     240      /* Cleanup for b */
     241      if (b.obj) {
     242         PyBuffer_Release(&b);
     243      }
     244  
     245      return return_value;
     246  }
     247  
     248  PyDoc_STRVAR(_ssl__SSLSocket_pending__doc__,
     249  "pending($self, /)\n"
     250  "--\n"
     251  "\n"
     252  "Returns the number of already decrypted bytes available for read, pending on the connection.");
     253  
     254  #define _SSL__SSLSOCKET_PENDING_METHODDEF    \
     255      {"pending", (PyCFunction)_ssl__SSLSocket_pending, METH_NOARGS, _ssl__SSLSocket_pending__doc__},
     256  
     257  static PyObject *
     258  _ssl__SSLSocket_pending_impl(PySSLSocket *self);
     259  
     260  static PyObject *
     261  _ssl__SSLSocket_pending(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     262  {
     263      return _ssl__SSLSocket_pending_impl(self);
     264  }
     265  
     266  PyDoc_STRVAR(_ssl__SSLSocket_read__doc__,
     267  "read(size, [buffer])\n"
     268  "Read up to size bytes from the SSL socket.");
     269  
     270  #define _SSL__SSLSOCKET_READ_METHODDEF    \
     271      {"read", (PyCFunction)_ssl__SSLSocket_read, METH_VARARGS, _ssl__SSLSocket_read__doc__},
     272  
     273  static PyObject *
     274  _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
     275                            int group_right_1, Py_buffer *buffer);
     276  
     277  static PyObject *
     278  _ssl__SSLSocket_read(PySSLSocket *self, PyObject *args)
     279  {
     280      PyObject *return_value = NULL;
     281      Py_ssize_t len;
     282      int group_right_1 = 0;
     283      Py_buffer buffer = {NULL, NULL};
     284  
     285      switch (PyTuple_GET_SIZE(args)) {
     286          case 1:
     287              if (!PyArg_ParseTuple(args, "n:read", &len)) {
     288                  goto exit;
     289              }
     290              break;
     291          case 2:
     292              if (!PyArg_ParseTuple(args, "nw*:read", &len, &buffer)) {
     293                  goto exit;
     294              }
     295              group_right_1 = 1;
     296              break;
     297          default:
     298              PyErr_SetString(PyExc_TypeError, "_ssl._SSLSocket.read requires 1 to 2 arguments");
     299              goto exit;
     300      }
     301      return_value = _ssl__SSLSocket_read_impl(self, len, group_right_1, &buffer);
     302  
     303  exit:
     304      /* Cleanup for buffer */
     305      if (buffer.obj) {
     306         PyBuffer_Release(&buffer);
     307      }
     308  
     309      return return_value;
     310  }
     311  
     312  PyDoc_STRVAR(_ssl__SSLSocket_shutdown__doc__,
     313  "shutdown($self, /)\n"
     314  "--\n"
     315  "\n"
     316  "Does the SSL shutdown handshake with the remote end.");
     317  
     318  #define _SSL__SSLSOCKET_SHUTDOWN_METHODDEF    \
     319      {"shutdown", (PyCFunction)_ssl__SSLSocket_shutdown, METH_NOARGS, _ssl__SSLSocket_shutdown__doc__},
     320  
     321  static PyObject *
     322  _ssl__SSLSocket_shutdown_impl(PySSLSocket *self);
     323  
     324  static PyObject *
     325  _ssl__SSLSocket_shutdown(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     326  {
     327      return _ssl__SSLSocket_shutdown_impl(self);
     328  }
     329  
     330  PyDoc_STRVAR(_ssl__SSLSocket_get_channel_binding__doc__,
     331  "get_channel_binding($self, /, cb_type=\'tls-unique\')\n"
     332  "--\n"
     333  "\n"
     334  "Get channel binding data for current connection.\n"
     335  "\n"
     336  "Raise ValueError if the requested `cb_type` is not supported.  Return bytes\n"
     337  "of the data or None if the data is not available (e.g. before the handshake).\n"
     338  "Only \'tls-unique\' channel binding data from RFC 5929 is supported.");
     339  
     340  #define _SSL__SSLSOCKET_GET_CHANNEL_BINDING_METHODDEF    \
     341      {"get_channel_binding", _PyCFunction_CAST(_ssl__SSLSocket_get_channel_binding), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLSocket_get_channel_binding__doc__},
     342  
     343  static PyObject *
     344  _ssl__SSLSocket_get_channel_binding_impl(PySSLSocket *self,
     345                                           const char *cb_type);
     346  
     347  static PyObject *
     348  _ssl__SSLSocket_get_channel_binding(PySSLSocket *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     349  {
     350      PyObject *return_value = NULL;
     351      static const char * const _keywords[] = {"cb_type", NULL};
     352      static _PyArg_Parser _parser = {NULL, _keywords, "get_channel_binding", 0};
     353      PyObject *argsbuf[1];
     354      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     355      const char *cb_type = "tls-unique";
     356  
     357      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     358      if (!args) {
     359          goto exit;
     360      }
     361      if (!noptargs) {
     362          goto skip_optional_pos;
     363      }
     364      if (!PyUnicode_Check(args[0])) {
     365          _PyArg_BadArgument("get_channel_binding", "argument 'cb_type'", "str", args[0]);
     366          goto exit;
     367      }
     368      Py_ssize_t cb_type_length;
     369      cb_type = PyUnicode_AsUTF8AndSize(args[0], &cb_type_length);
     370      if (cb_type == NULL) {
     371          goto exit;
     372      }
     373      if (strlen(cb_type) != (size_t)cb_type_length) {
     374          PyErr_SetString(PyExc_ValueError, "embedded null character");
     375          goto exit;
     376      }
     377  skip_optional_pos:
     378      return_value = _ssl__SSLSocket_get_channel_binding_impl(self, cb_type);
     379  
     380  exit:
     381      return return_value;
     382  }
     383  
     384  PyDoc_STRVAR(_ssl__SSLSocket_verify_client_post_handshake__doc__,
     385  "verify_client_post_handshake($self, /)\n"
     386  "--\n"
     387  "\n"
     388  "Initiate TLS 1.3 post-handshake authentication");
     389  
     390  #define _SSL__SSLSOCKET_VERIFY_CLIENT_POST_HANDSHAKE_METHODDEF    \
     391      {"verify_client_post_handshake", (PyCFunction)_ssl__SSLSocket_verify_client_post_handshake, METH_NOARGS, _ssl__SSLSocket_verify_client_post_handshake__doc__},
     392  
     393  static PyObject *
     394  _ssl__SSLSocket_verify_client_post_handshake_impl(PySSLSocket *self);
     395  
     396  static PyObject *
     397  _ssl__SSLSocket_verify_client_post_handshake(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
     398  {
     399      return _ssl__SSLSocket_verify_client_post_handshake_impl(self);
     400  }
     401  
     402  static PyObject *
     403  _ssl__SSLContext_impl(PyTypeObject *type, int proto_version);
     404  
     405  static PyObject *
     406  _ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     407  {
     408      PyObject *return_value = NULL;
     409      int proto_version;
     410  
     411      if ((type == get_state_type(type)->PySSLContext_Type ||
     412           type->tp_init == get_state_type(type)->PySSLContext_Type->tp_init) &&
     413          !_PyArg_NoKeywords("_SSLContext", kwargs)) {
     414          goto exit;
     415      }
     416      if (!_PyArg_CheckPositional("_SSLContext", PyTuple_GET_SIZE(args), 1, 1)) {
     417          goto exit;
     418      }
     419      proto_version = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0));
     420      if (proto_version == -1 && PyErr_Occurred()) {
     421          goto exit;
     422      }
     423      return_value = _ssl__SSLContext_impl(type, proto_version);
     424  
     425  exit:
     426      return return_value;
     427  }
     428  
     429  PyDoc_STRVAR(_ssl__SSLContext_set_ciphers__doc__,
     430  "set_ciphers($self, cipherlist, /)\n"
     431  "--\n"
     432  "\n");
     433  
     434  #define _SSL__SSLCONTEXT_SET_CIPHERS_METHODDEF    \
     435      {"set_ciphers", (PyCFunction)_ssl__SSLContext_set_ciphers, METH_O, _ssl__SSLContext_set_ciphers__doc__},
     436  
     437  static PyObject *
     438  _ssl__SSLContext_set_ciphers_impl(PySSLContext *self, const char *cipherlist);
     439  
     440  static PyObject *
     441  _ssl__SSLContext_set_ciphers(PySSLContext *self, PyObject *arg)
     442  {
     443      PyObject *return_value = NULL;
     444      const char *cipherlist;
     445  
     446      if (!PyUnicode_Check(arg)) {
     447          _PyArg_BadArgument("set_ciphers", "argument", "str", arg);
     448          goto exit;
     449      }
     450      Py_ssize_t cipherlist_length;
     451      cipherlist = PyUnicode_AsUTF8AndSize(arg, &cipherlist_length);
     452      if (cipherlist == NULL) {
     453          goto exit;
     454      }
     455      if (strlen(cipherlist) != (size_t)cipherlist_length) {
     456          PyErr_SetString(PyExc_ValueError, "embedded null character");
     457          goto exit;
     458      }
     459      return_value = _ssl__SSLContext_set_ciphers_impl(self, cipherlist);
     460  
     461  exit:
     462      return return_value;
     463  }
     464  
     465  PyDoc_STRVAR(_ssl__SSLContext_get_ciphers__doc__,
     466  "get_ciphers($self, /)\n"
     467  "--\n"
     468  "\n");
     469  
     470  #define _SSL__SSLCONTEXT_GET_CIPHERS_METHODDEF    \
     471      {"get_ciphers", (PyCFunction)_ssl__SSLContext_get_ciphers, METH_NOARGS, _ssl__SSLContext_get_ciphers__doc__},
     472  
     473  static PyObject *
     474  _ssl__SSLContext_get_ciphers_impl(PySSLContext *self);
     475  
     476  static PyObject *
     477  _ssl__SSLContext_get_ciphers(PySSLContext *self, PyObject *Py_UNUSED(ignored))
     478  {
     479      return _ssl__SSLContext_get_ciphers_impl(self);
     480  }
     481  
     482  PyDoc_STRVAR(_ssl__SSLContext__set_alpn_protocols__doc__,
     483  "_set_alpn_protocols($self, protos, /)\n"
     484  "--\n"
     485  "\n");
     486  
     487  #define _SSL__SSLCONTEXT__SET_ALPN_PROTOCOLS_METHODDEF    \
     488      {"_set_alpn_protocols", (PyCFunction)_ssl__SSLContext__set_alpn_protocols, METH_O, _ssl__SSLContext__set_alpn_protocols__doc__},
     489  
     490  static PyObject *
     491  _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
     492                                            Py_buffer *protos);
     493  
     494  static PyObject *
     495  _ssl__SSLContext__set_alpn_protocols(PySSLContext *self, PyObject *arg)
     496  {
     497      PyObject *return_value = NULL;
     498      Py_buffer protos = {NULL, NULL};
     499  
     500      if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) {
     501          goto exit;
     502      }
     503      if (!PyBuffer_IsContiguous(&protos, 'C')) {
     504          _PyArg_BadArgument("_set_alpn_protocols", "argument", "contiguous buffer", arg);
     505          goto exit;
     506      }
     507      return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos);
     508  
     509  exit:
     510      /* Cleanup for protos */
     511      if (protos.obj) {
     512         PyBuffer_Release(&protos);
     513      }
     514  
     515      return return_value;
     516  }
     517  
     518  PyDoc_STRVAR(_ssl__SSLContext_load_cert_chain__doc__,
     519  "load_cert_chain($self, /, certfile, keyfile=None, password=None)\n"
     520  "--\n"
     521  "\n");
     522  
     523  #define _SSL__SSLCONTEXT_LOAD_CERT_CHAIN_METHODDEF    \
     524      {"load_cert_chain", _PyCFunction_CAST(_ssl__SSLContext_load_cert_chain), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_cert_chain__doc__},
     525  
     526  static PyObject *
     527  _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile,
     528                                        PyObject *keyfile, PyObject *password);
     529  
     530  static PyObject *
     531  _ssl__SSLContext_load_cert_chain(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     532  {
     533      PyObject *return_value = NULL;
     534      static const char * const _keywords[] = {"certfile", "keyfile", "password", NULL};
     535      static _PyArg_Parser _parser = {NULL, _keywords, "load_cert_chain", 0};
     536      PyObject *argsbuf[3];
     537      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     538      PyObject *certfile;
     539      PyObject *keyfile = Py_None;
     540      PyObject *password = Py_None;
     541  
     542      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
     543      if (!args) {
     544          goto exit;
     545      }
     546      certfile = args[0];
     547      if (!noptargs) {
     548          goto skip_optional_pos;
     549      }
     550      if (args[1]) {
     551          keyfile = args[1];
     552          if (!--noptargs) {
     553              goto skip_optional_pos;
     554          }
     555      }
     556      password = args[2];
     557  skip_optional_pos:
     558      return_value = _ssl__SSLContext_load_cert_chain_impl(self, certfile, keyfile, password);
     559  
     560  exit:
     561      return return_value;
     562  }
     563  
     564  PyDoc_STRVAR(_ssl__SSLContext_load_verify_locations__doc__,
     565  "load_verify_locations($self, /, cafile=None, capath=None, cadata=None)\n"
     566  "--\n"
     567  "\n");
     568  
     569  #define _SSL__SSLCONTEXT_LOAD_VERIFY_LOCATIONS_METHODDEF    \
     570      {"load_verify_locations", _PyCFunction_CAST(_ssl__SSLContext_load_verify_locations), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_verify_locations__doc__},
     571  
     572  static PyObject *
     573  _ssl__SSLContext_load_verify_locations_impl(PySSLContext *self,
     574                                              PyObject *cafile,
     575                                              PyObject *capath,
     576                                              PyObject *cadata);
     577  
     578  static PyObject *
     579  _ssl__SSLContext_load_verify_locations(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     580  {
     581      PyObject *return_value = NULL;
     582      static const char * const _keywords[] = {"cafile", "capath", "cadata", NULL};
     583      static _PyArg_Parser _parser = {NULL, _keywords, "load_verify_locations", 0};
     584      PyObject *argsbuf[3];
     585      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     586      PyObject *cafile = Py_None;
     587      PyObject *capath = Py_None;
     588      PyObject *cadata = Py_None;
     589  
     590      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf);
     591      if (!args) {
     592          goto exit;
     593      }
     594      if (!noptargs) {
     595          goto skip_optional_pos;
     596      }
     597      if (args[0]) {
     598          cafile = args[0];
     599          if (!--noptargs) {
     600              goto skip_optional_pos;
     601          }
     602      }
     603      if (args[1]) {
     604          capath = args[1];
     605          if (!--noptargs) {
     606              goto skip_optional_pos;
     607          }
     608      }
     609      cadata = args[2];
     610  skip_optional_pos:
     611      return_value = _ssl__SSLContext_load_verify_locations_impl(self, cafile, capath, cadata);
     612  
     613  exit:
     614      return return_value;
     615  }
     616  
     617  PyDoc_STRVAR(_ssl__SSLContext_load_dh_params__doc__,
     618  "load_dh_params($self, path, /)\n"
     619  "--\n"
     620  "\n");
     621  
     622  #define _SSL__SSLCONTEXT_LOAD_DH_PARAMS_METHODDEF    \
     623      {"load_dh_params", (PyCFunction)_ssl__SSLContext_load_dh_params, METH_O, _ssl__SSLContext_load_dh_params__doc__},
     624  
     625  PyDoc_STRVAR(_ssl__SSLContext__wrap_socket__doc__,
     626  "_wrap_socket($self, /, sock, server_side, server_hostname=None, *,\n"
     627  "             owner=None, session=None)\n"
     628  "--\n"
     629  "\n");
     630  
     631  #define _SSL__SSLCONTEXT__WRAP_SOCKET_METHODDEF    \
     632      {"_wrap_socket", _PyCFunction_CAST(_ssl__SSLContext__wrap_socket), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_socket__doc__},
     633  
     634  static PyObject *
     635  _ssl__SSLContext__wrap_socket_impl(PySSLContext *self, PyObject *sock,
     636                                     int server_side, PyObject *hostname_obj,
     637                                     PyObject *owner, PyObject *session);
     638  
     639  static PyObject *
     640  _ssl__SSLContext__wrap_socket(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     641  {
     642      PyObject *return_value = NULL;
     643      static const char * const _keywords[] = {"sock", "server_side", "server_hostname", "owner", "session", NULL};
     644      static _PyArg_Parser _parser = {NULL, _keywords, "_wrap_socket", 0};
     645      PyObject *argsbuf[5];
     646      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
     647      PyObject *sock;
     648      int server_side;
     649      PyObject *hostname_obj = Py_None;
     650      PyObject *owner = Py_None;
     651      PyObject *session = Py_None;
     652  
     653      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
     654      if (!args) {
     655          goto exit;
     656      }
     657      if (!PyObject_TypeCheck(args[0], get_state_ctx(self)->Sock_Type)) {
     658          _PyArg_BadArgument("_wrap_socket", "argument 'sock'", (get_state_ctx(self)->Sock_Type)->tp_name, args[0]);
     659          goto exit;
     660      }
     661      sock = args[0];
     662      server_side = _PyLong_AsInt(args[1]);
     663      if (server_side == -1 && PyErr_Occurred()) {
     664          goto exit;
     665      }
     666      if (!noptargs) {
     667          goto skip_optional_pos;
     668      }
     669      if (args[2]) {
     670          hostname_obj = args[2];
     671          if (!--noptargs) {
     672              goto skip_optional_pos;
     673          }
     674      }
     675  skip_optional_pos:
     676      if (!noptargs) {
     677          goto skip_optional_kwonly;
     678      }
     679      if (args[3]) {
     680          owner = args[3];
     681          if (!--noptargs) {
     682              goto skip_optional_kwonly;
     683          }
     684      }
     685      session = args[4];
     686  skip_optional_kwonly:
     687      return_value = _ssl__SSLContext__wrap_socket_impl(self, sock, server_side, hostname_obj, owner, session);
     688  
     689  exit:
     690      return return_value;
     691  }
     692  
     693  PyDoc_STRVAR(_ssl__SSLContext__wrap_bio__doc__,
     694  "_wrap_bio($self, /, incoming, outgoing, server_side,\n"
     695  "          server_hostname=None, *, owner=None, session=None)\n"
     696  "--\n"
     697  "\n");
     698  
     699  #define _SSL__SSLCONTEXT__WRAP_BIO_METHODDEF    \
     700      {"_wrap_bio", _PyCFunction_CAST(_ssl__SSLContext__wrap_bio), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_bio__doc__},
     701  
     702  static PyObject *
     703  _ssl__SSLContext__wrap_bio_impl(PySSLContext *self, PySSLMemoryBIO *incoming,
     704                                  PySSLMemoryBIO *outgoing, int server_side,
     705                                  PyObject *hostname_obj, PyObject *owner,
     706                                  PyObject *session);
     707  
     708  static PyObject *
     709  _ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     710  {
     711      PyObject *return_value = NULL;
     712      static const char * const _keywords[] = {"incoming", "outgoing", "server_side", "server_hostname", "owner", "session", NULL};
     713      static _PyArg_Parser _parser = {NULL, _keywords, "_wrap_bio", 0};
     714      PyObject *argsbuf[6];
     715      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
     716      PySSLMemoryBIO *incoming;
     717      PySSLMemoryBIO *outgoing;
     718      int server_side;
     719      PyObject *hostname_obj = Py_None;
     720      PyObject *owner = Py_None;
     721      PyObject *session = Py_None;
     722  
     723      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf);
     724      if (!args) {
     725          goto exit;
     726      }
     727      if (!PyObject_TypeCheck(args[0], get_state_ctx(self)->PySSLMemoryBIO_Type)) {
     728          _PyArg_BadArgument("_wrap_bio", "argument 'incoming'", (get_state_ctx(self)->PySSLMemoryBIO_Type)->tp_name, args[0]);
     729          goto exit;
     730      }
     731      incoming = (PySSLMemoryBIO *)args[0];
     732      if (!PyObject_TypeCheck(args[1], get_state_ctx(self)->PySSLMemoryBIO_Type)) {
     733          _PyArg_BadArgument("_wrap_bio", "argument 'outgoing'", (get_state_ctx(self)->PySSLMemoryBIO_Type)->tp_name, args[1]);
     734          goto exit;
     735      }
     736      outgoing = (PySSLMemoryBIO *)args[1];
     737      server_side = _PyLong_AsInt(args[2]);
     738      if (server_side == -1 && PyErr_Occurred()) {
     739          goto exit;
     740      }
     741      if (!noptargs) {
     742          goto skip_optional_pos;
     743      }
     744      if (args[3]) {
     745          hostname_obj = args[3];
     746          if (!--noptargs) {
     747              goto skip_optional_pos;
     748          }
     749      }
     750  skip_optional_pos:
     751      if (!noptargs) {
     752          goto skip_optional_kwonly;
     753      }
     754      if (args[4]) {
     755          owner = args[4];
     756          if (!--noptargs) {
     757              goto skip_optional_kwonly;
     758          }
     759      }
     760      session = args[5];
     761  skip_optional_kwonly:
     762      return_value = _ssl__SSLContext__wrap_bio_impl(self, incoming, outgoing, server_side, hostname_obj, owner, session);
     763  
     764  exit:
     765      return return_value;
     766  }
     767  
     768  PyDoc_STRVAR(_ssl__SSLContext_session_stats__doc__,
     769  "session_stats($self, /)\n"
     770  "--\n"
     771  "\n");
     772  
     773  #define _SSL__SSLCONTEXT_SESSION_STATS_METHODDEF    \
     774      {"session_stats", (PyCFunction)_ssl__SSLContext_session_stats, METH_NOARGS, _ssl__SSLContext_session_stats__doc__},
     775  
     776  static PyObject *
     777  _ssl__SSLContext_session_stats_impl(PySSLContext *self);
     778  
     779  static PyObject *
     780  _ssl__SSLContext_session_stats(PySSLContext *self, PyObject *Py_UNUSED(ignored))
     781  {
     782      return _ssl__SSLContext_session_stats_impl(self);
     783  }
     784  
     785  PyDoc_STRVAR(_ssl__SSLContext_set_default_verify_paths__doc__,
     786  "set_default_verify_paths($self, /)\n"
     787  "--\n"
     788  "\n");
     789  
     790  #define _SSL__SSLCONTEXT_SET_DEFAULT_VERIFY_PATHS_METHODDEF    \
     791      {"set_default_verify_paths", (PyCFunction)_ssl__SSLContext_set_default_verify_paths, METH_NOARGS, _ssl__SSLContext_set_default_verify_paths__doc__},
     792  
     793  static PyObject *
     794  _ssl__SSLContext_set_default_verify_paths_impl(PySSLContext *self);
     795  
     796  static PyObject *
     797  _ssl__SSLContext_set_default_verify_paths(PySSLContext *self, PyObject *Py_UNUSED(ignored))
     798  {
     799      return _ssl__SSLContext_set_default_verify_paths_impl(self);
     800  }
     801  
     802  PyDoc_STRVAR(_ssl__SSLContext_set_ecdh_curve__doc__,
     803  "set_ecdh_curve($self, name, /)\n"
     804  "--\n"
     805  "\n");
     806  
     807  #define _SSL__SSLCONTEXT_SET_ECDH_CURVE_METHODDEF    \
     808      {"set_ecdh_curve", (PyCFunction)_ssl__SSLContext_set_ecdh_curve, METH_O, _ssl__SSLContext_set_ecdh_curve__doc__},
     809  
     810  PyDoc_STRVAR(_ssl__SSLContext_cert_store_stats__doc__,
     811  "cert_store_stats($self, /)\n"
     812  "--\n"
     813  "\n"
     814  "Returns quantities of loaded X.509 certificates.\n"
     815  "\n"
     816  "X.509 certificates with a CA extension and certificate revocation lists\n"
     817  "inside the context\'s cert store.\n"
     818  "\n"
     819  "NOTE: Certificates in a capath directory aren\'t loaded unless they have\n"
     820  "been used at least once.");
     821  
     822  #define _SSL__SSLCONTEXT_CERT_STORE_STATS_METHODDEF    \
     823      {"cert_store_stats", (PyCFunction)_ssl__SSLContext_cert_store_stats, METH_NOARGS, _ssl__SSLContext_cert_store_stats__doc__},
     824  
     825  static PyObject *
     826  _ssl__SSLContext_cert_store_stats_impl(PySSLContext *self);
     827  
     828  static PyObject *
     829  _ssl__SSLContext_cert_store_stats(PySSLContext *self, PyObject *Py_UNUSED(ignored))
     830  {
     831      return _ssl__SSLContext_cert_store_stats_impl(self);
     832  }
     833  
     834  PyDoc_STRVAR(_ssl__SSLContext_get_ca_certs__doc__,
     835  "get_ca_certs($self, /, binary_form=False)\n"
     836  "--\n"
     837  "\n"
     838  "Returns a list of dicts with information of loaded CA certs.\n"
     839  "\n"
     840  "If the optional argument is True, returns a DER-encoded copy of the CA\n"
     841  "certificate.\n"
     842  "\n"
     843  "NOTE: Certificates in a capath directory aren\'t loaded unless they have\n"
     844  "been used at least once.");
     845  
     846  #define _SSL__SSLCONTEXT_GET_CA_CERTS_METHODDEF    \
     847      {"get_ca_certs", _PyCFunction_CAST(_ssl__SSLContext_get_ca_certs), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_get_ca_certs__doc__},
     848  
     849  static PyObject *
     850  _ssl__SSLContext_get_ca_certs_impl(PySSLContext *self, int binary_form);
     851  
     852  static PyObject *
     853  _ssl__SSLContext_get_ca_certs(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     854  {
     855      PyObject *return_value = NULL;
     856      static const char * const _keywords[] = {"binary_form", NULL};
     857      static _PyArg_Parser _parser = {NULL, _keywords, "get_ca_certs", 0};
     858      PyObject *argsbuf[1];
     859      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     860      int binary_form = 0;
     861  
     862      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     863      if (!args) {
     864          goto exit;
     865      }
     866      if (!noptargs) {
     867          goto skip_optional_pos;
     868      }
     869      binary_form = PyObject_IsTrue(args[0]);
     870      if (binary_form < 0) {
     871          goto exit;
     872      }
     873  skip_optional_pos:
     874      return_value = _ssl__SSLContext_get_ca_certs_impl(self, binary_form);
     875  
     876  exit:
     877      return return_value;
     878  }
     879  
     880  static PyObject *
     881  _ssl_MemoryBIO_impl(PyTypeObject *type);
     882  
     883  static PyObject *
     884  _ssl_MemoryBIO(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     885  {
     886      PyObject *return_value = NULL;
     887  
     888      if ((type == get_state_type(type)->PySSLMemoryBIO_Type ||
     889           type->tp_init == get_state_type(type)->PySSLMemoryBIO_Type->tp_init) &&
     890          !_PyArg_NoPositional("MemoryBIO", args)) {
     891          goto exit;
     892      }
     893      if ((type == get_state_type(type)->PySSLMemoryBIO_Type ||
     894           type->tp_init == get_state_type(type)->PySSLMemoryBIO_Type->tp_init) &&
     895          !_PyArg_NoKeywords("MemoryBIO", kwargs)) {
     896          goto exit;
     897      }
     898      return_value = _ssl_MemoryBIO_impl(type);
     899  
     900  exit:
     901      return return_value;
     902  }
     903  
     904  PyDoc_STRVAR(_ssl_MemoryBIO_read__doc__,
     905  "read($self, size=-1, /)\n"
     906  "--\n"
     907  "\n"
     908  "Read up to size bytes from the memory BIO.\n"
     909  "\n"
     910  "If size is not specified, read the entire buffer.\n"
     911  "If the return value is an empty bytes instance, this means either\n"
     912  "EOF or that no data is available. Use the \"eof\" property to\n"
     913  "distinguish between the two.");
     914  
     915  #define _SSL_MEMORYBIO_READ_METHODDEF    \
     916      {"read", _PyCFunction_CAST(_ssl_MemoryBIO_read), METH_FASTCALL, _ssl_MemoryBIO_read__doc__},
     917  
     918  static PyObject *
     919  _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len);
     920  
     921  static PyObject *
     922  _ssl_MemoryBIO_read(PySSLMemoryBIO *self, PyObject *const *args, Py_ssize_t nargs)
     923  {
     924      PyObject *return_value = NULL;
     925      int len = -1;
     926  
     927      if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
     928          goto exit;
     929      }
     930      if (nargs < 1) {
     931          goto skip_optional;
     932      }
     933      len = _PyLong_AsInt(args[0]);
     934      if (len == -1 && PyErr_Occurred()) {
     935          goto exit;
     936      }
     937  skip_optional:
     938      return_value = _ssl_MemoryBIO_read_impl(self, len);
     939  
     940  exit:
     941      return return_value;
     942  }
     943  
     944  PyDoc_STRVAR(_ssl_MemoryBIO_write__doc__,
     945  "write($self, b, /)\n"
     946  "--\n"
     947  "\n"
     948  "Writes the bytes b into the memory BIO.\n"
     949  "\n"
     950  "Returns the number of bytes written.");
     951  
     952  #define _SSL_MEMORYBIO_WRITE_METHODDEF    \
     953      {"write", (PyCFunction)_ssl_MemoryBIO_write, METH_O, _ssl_MemoryBIO_write__doc__},
     954  
     955  static PyObject *
     956  _ssl_MemoryBIO_write_impl(PySSLMemoryBIO *self, Py_buffer *b);
     957  
     958  static PyObject *
     959  _ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg)
     960  {
     961      PyObject *return_value = NULL;
     962      Py_buffer b = {NULL, NULL};
     963  
     964      if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
     965          goto exit;
     966      }
     967      if (!PyBuffer_IsContiguous(&b, 'C')) {
     968          _PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
     969          goto exit;
     970      }
     971      return_value = _ssl_MemoryBIO_write_impl(self, &b);
     972  
     973  exit:
     974      /* Cleanup for b */
     975      if (b.obj) {
     976         PyBuffer_Release(&b);
     977      }
     978  
     979      return return_value;
     980  }
     981  
     982  PyDoc_STRVAR(_ssl_MemoryBIO_write_eof__doc__,
     983  "write_eof($self, /)\n"
     984  "--\n"
     985  "\n"
     986  "Write an EOF marker to the memory BIO.\n"
     987  "\n"
     988  "When all data has been read, the \"eof\" property will be True.");
     989  
     990  #define _SSL_MEMORYBIO_WRITE_EOF_METHODDEF    \
     991      {"write_eof", (PyCFunction)_ssl_MemoryBIO_write_eof, METH_NOARGS, _ssl_MemoryBIO_write_eof__doc__},
     992  
     993  static PyObject *
     994  _ssl_MemoryBIO_write_eof_impl(PySSLMemoryBIO *self);
     995  
     996  static PyObject *
     997  _ssl_MemoryBIO_write_eof(PySSLMemoryBIO *self, PyObject *Py_UNUSED(ignored))
     998  {
     999      return _ssl_MemoryBIO_write_eof_impl(self);
    1000  }
    1001  
    1002  PyDoc_STRVAR(_ssl_RAND_add__doc__,
    1003  "RAND_add($module, string, entropy, /)\n"
    1004  "--\n"
    1005  "\n"
    1006  "Mix string into the OpenSSL PRNG state.\n"
    1007  "\n"
    1008  "entropy (a float) is a lower bound on the entropy contained in\n"
    1009  "string.  See RFC 4086.");
    1010  
    1011  #define _SSL_RAND_ADD_METHODDEF    \
    1012      {"RAND_add", _PyCFunction_CAST(_ssl_RAND_add), METH_FASTCALL, _ssl_RAND_add__doc__},
    1013  
    1014  static PyObject *
    1015  _ssl_RAND_add_impl(PyObject *module, Py_buffer *view, double entropy);
    1016  
    1017  static PyObject *
    1018  _ssl_RAND_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
    1019  {
    1020      PyObject *return_value = NULL;
    1021      Py_buffer view = {NULL, NULL};
    1022      double entropy;
    1023  
    1024      if (!_PyArg_CheckPositional("RAND_add", nargs, 2, 2)) {
    1025          goto exit;
    1026      }
    1027      if (PyUnicode_Check(args[0])) {
    1028          Py_ssize_t len;
    1029          const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
    1030          if (ptr == NULL) {
    1031              goto exit;
    1032          }
    1033          PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, 0);
    1034      }
    1035      else { /* any bytes-like object */
    1036          if (PyObject_GetBuffer(args[0], &view, PyBUF_SIMPLE) != 0) {
    1037              goto exit;
    1038          }
    1039          if (!PyBuffer_IsContiguous(&view, 'C')) {
    1040              _PyArg_BadArgument("RAND_add", "argument 1", "contiguous buffer", args[0]);
    1041              goto exit;
    1042          }
    1043      }
    1044      if (PyFloat_CheckExact(args[1])) {
    1045          entropy = PyFloat_AS_DOUBLE(args[1]);
    1046      }
    1047      else
    1048      {
    1049          entropy = PyFloat_AsDouble(args[1]);
    1050          if (entropy == -1.0 && PyErr_Occurred()) {
    1051              goto exit;
    1052          }
    1053      }
    1054      return_value = _ssl_RAND_add_impl(module, &view, entropy);
    1055  
    1056  exit:
    1057      /* Cleanup for view */
    1058      if (view.obj) {
    1059         PyBuffer_Release(&view);
    1060      }
    1061  
    1062      return return_value;
    1063  }
    1064  
    1065  PyDoc_STRVAR(_ssl_RAND_bytes__doc__,
    1066  "RAND_bytes($module, n, /)\n"
    1067  "--\n"
    1068  "\n"
    1069  "Generate n cryptographically strong pseudo-random bytes.");
    1070  
    1071  #define _SSL_RAND_BYTES_METHODDEF    \
    1072      {"RAND_bytes", (PyCFunction)_ssl_RAND_bytes, METH_O, _ssl_RAND_bytes__doc__},
    1073  
    1074  static PyObject *
    1075  _ssl_RAND_bytes_impl(PyObject *module, int n);
    1076  
    1077  static PyObject *
    1078  _ssl_RAND_bytes(PyObject *module, PyObject *arg)
    1079  {
    1080      PyObject *return_value = NULL;
    1081      int n;
    1082  
    1083      n = _PyLong_AsInt(arg);
    1084      if (n == -1 && PyErr_Occurred()) {
    1085          goto exit;
    1086      }
    1087      return_value = _ssl_RAND_bytes_impl(module, n);
    1088  
    1089  exit:
    1090      return return_value;
    1091  }
    1092  
    1093  PyDoc_STRVAR(_ssl_RAND_pseudo_bytes__doc__,
    1094  "RAND_pseudo_bytes($module, n, /)\n"
    1095  "--\n"
    1096  "\n"
    1097  "Generate n pseudo-random bytes.\n"
    1098  "\n"
    1099  "Return a pair (bytes, is_cryptographic).  is_cryptographic is True\n"
    1100  "if the bytes generated are cryptographically strong.");
    1101  
    1102  #define _SSL_RAND_PSEUDO_BYTES_METHODDEF    \
    1103      {"RAND_pseudo_bytes", (PyCFunction)_ssl_RAND_pseudo_bytes, METH_O, _ssl_RAND_pseudo_bytes__doc__},
    1104  
    1105  static PyObject *
    1106  _ssl_RAND_pseudo_bytes_impl(PyObject *module, int n);
    1107  
    1108  static PyObject *
    1109  _ssl_RAND_pseudo_bytes(PyObject *module, PyObject *arg)
    1110  {
    1111      PyObject *return_value = NULL;
    1112      int n;
    1113  
    1114      n = _PyLong_AsInt(arg);
    1115      if (n == -1 && PyErr_Occurred()) {
    1116          goto exit;
    1117      }
    1118      return_value = _ssl_RAND_pseudo_bytes_impl(module, n);
    1119  
    1120  exit:
    1121      return return_value;
    1122  }
    1123  
    1124  PyDoc_STRVAR(_ssl_RAND_status__doc__,
    1125  "RAND_status($module, /)\n"
    1126  "--\n"
    1127  "\n"
    1128  "Returns True if the OpenSSL PRNG has been seeded with enough data and False if not.\n"
    1129  "\n"
    1130  "It is necessary to seed the PRNG with RAND_add() on some platforms before\n"
    1131  "using the ssl() function.");
    1132  
    1133  #define _SSL_RAND_STATUS_METHODDEF    \
    1134      {"RAND_status", (PyCFunction)_ssl_RAND_status, METH_NOARGS, _ssl_RAND_status__doc__},
    1135  
    1136  static PyObject *
    1137  _ssl_RAND_status_impl(PyObject *module);
    1138  
    1139  static PyObject *
    1140  _ssl_RAND_status(PyObject *module, PyObject *Py_UNUSED(ignored))
    1141  {
    1142      return _ssl_RAND_status_impl(module);
    1143  }
    1144  
    1145  PyDoc_STRVAR(_ssl_get_default_verify_paths__doc__,
    1146  "get_default_verify_paths($module, /)\n"
    1147  "--\n"
    1148  "\n"
    1149  "Return search paths and environment vars that are used by SSLContext\'s set_default_verify_paths() to load default CAs.\n"
    1150  "\n"
    1151  "The values are \'cert_file_env\', \'cert_file\', \'cert_dir_env\', \'cert_dir\'.");
    1152  
    1153  #define _SSL_GET_DEFAULT_VERIFY_PATHS_METHODDEF    \
    1154      {"get_default_verify_paths", (PyCFunction)_ssl_get_default_verify_paths, METH_NOARGS, _ssl_get_default_verify_paths__doc__},
    1155  
    1156  static PyObject *
    1157  _ssl_get_default_verify_paths_impl(PyObject *module);
    1158  
    1159  static PyObject *
    1160  _ssl_get_default_verify_paths(PyObject *module, PyObject *Py_UNUSED(ignored))
    1161  {
    1162      return _ssl_get_default_verify_paths_impl(module);
    1163  }
    1164  
    1165  PyDoc_STRVAR(_ssl_txt2obj__doc__,
    1166  "txt2obj($module, /, txt, name=False)\n"
    1167  "--\n"
    1168  "\n"
    1169  "Lookup NID, short name, long name and OID of an ASN1_OBJECT.\n"
    1170  "\n"
    1171  "By default objects are looked up by OID. With name=True short and\n"
    1172  "long name are also matched.");
    1173  
    1174  #define _SSL_TXT2OBJ_METHODDEF    \
    1175      {"txt2obj", _PyCFunction_CAST(_ssl_txt2obj), METH_FASTCALL|METH_KEYWORDS, _ssl_txt2obj__doc__},
    1176  
    1177  static PyObject *
    1178  _ssl_txt2obj_impl(PyObject *module, const char *txt, int name);
    1179  
    1180  static PyObject *
    1181  _ssl_txt2obj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1182  {
    1183      PyObject *return_value = NULL;
    1184      static const char * const _keywords[] = {"txt", "name", NULL};
    1185      static _PyArg_Parser _parser = {NULL, _keywords, "txt2obj", 0};
    1186      PyObject *argsbuf[2];
    1187      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
    1188      const char *txt;
    1189      int name = 0;
    1190  
    1191      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
    1192      if (!args) {
    1193          goto exit;
    1194      }
    1195      if (!PyUnicode_Check(args[0])) {
    1196          _PyArg_BadArgument("txt2obj", "argument 'txt'", "str", args[0]);
    1197          goto exit;
    1198      }
    1199      Py_ssize_t txt_length;
    1200      txt = PyUnicode_AsUTF8AndSize(args[0], &txt_length);
    1201      if (txt == NULL) {
    1202          goto exit;
    1203      }
    1204      if (strlen(txt) != (size_t)txt_length) {
    1205          PyErr_SetString(PyExc_ValueError, "embedded null character");
    1206          goto exit;
    1207      }
    1208      if (!noptargs) {
    1209          goto skip_optional_pos;
    1210      }
    1211      name = PyObject_IsTrue(args[1]);
    1212      if (name < 0) {
    1213          goto exit;
    1214      }
    1215  skip_optional_pos:
    1216      return_value = _ssl_txt2obj_impl(module, txt, name);
    1217  
    1218  exit:
    1219      return return_value;
    1220  }
    1221  
    1222  PyDoc_STRVAR(_ssl_nid2obj__doc__,
    1223  "nid2obj($module, nid, /)\n"
    1224  "--\n"
    1225  "\n"
    1226  "Lookup NID, short name, long name and OID of an ASN1_OBJECT by NID.");
    1227  
    1228  #define _SSL_NID2OBJ_METHODDEF    \
    1229      {"nid2obj", (PyCFunction)_ssl_nid2obj, METH_O, _ssl_nid2obj__doc__},
    1230  
    1231  static PyObject *
    1232  _ssl_nid2obj_impl(PyObject *module, int nid);
    1233  
    1234  static PyObject *
    1235  _ssl_nid2obj(PyObject *module, PyObject *arg)
    1236  {
    1237      PyObject *return_value = NULL;
    1238      int nid;
    1239  
    1240      nid = _PyLong_AsInt(arg);
    1241      if (nid == -1 && PyErr_Occurred()) {
    1242          goto exit;
    1243      }
    1244      return_value = _ssl_nid2obj_impl(module, nid);
    1245  
    1246  exit:
    1247      return return_value;
    1248  }
    1249  
    1250  #if defined(_MSC_VER)
    1251  
    1252  PyDoc_STRVAR(_ssl_enum_certificates__doc__,
    1253  "enum_certificates($module, /, store_name)\n"
    1254  "--\n"
    1255  "\n"
    1256  "Retrieve certificates from Windows\' cert store.\n"
    1257  "\n"
    1258  "store_name may be one of \'CA\', \'ROOT\' or \'MY\'.  The system may provide\n"
    1259  "more cert storages, too.  The function returns a list of (bytes,\n"
    1260  "encoding_type, trust) tuples.  The encoding_type flag can be interpreted\n"
    1261  "with X509_ASN_ENCODING or PKCS_7_ASN_ENCODING. The trust setting is either\n"
    1262  "a set of OIDs or the boolean True.");
    1263  
    1264  #define _SSL_ENUM_CERTIFICATES_METHODDEF    \
    1265      {"enum_certificates", _PyCFunction_CAST(_ssl_enum_certificates), METH_FASTCALL|METH_KEYWORDS, _ssl_enum_certificates__doc__},
    1266  
    1267  static PyObject *
    1268  _ssl_enum_certificates_impl(PyObject *module, const char *store_name);
    1269  
    1270  static PyObject *
    1271  _ssl_enum_certificates(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1272  {
    1273      PyObject *return_value = NULL;
    1274      static const char * const _keywords[] = {"store_name", NULL};
    1275      static _PyArg_Parser _parser = {NULL, _keywords, "enum_certificates", 0};
    1276      PyObject *argsbuf[1];
    1277      const char *store_name;
    1278  
    1279      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
    1280      if (!args) {
    1281          goto exit;
    1282      }
    1283      if (!PyUnicode_Check(args[0])) {
    1284          _PyArg_BadArgument("enum_certificates", "argument 'store_name'", "str", args[0]);
    1285          goto exit;
    1286      }
    1287      Py_ssize_t store_name_length;
    1288      store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length);
    1289      if (store_name == NULL) {
    1290          goto exit;
    1291      }
    1292      if (strlen(store_name) != (size_t)store_name_length) {
    1293          PyErr_SetString(PyExc_ValueError, "embedded null character");
    1294          goto exit;
    1295      }
    1296      return_value = _ssl_enum_certificates_impl(module, store_name);
    1297  
    1298  exit:
    1299      return return_value;
    1300  }
    1301  
    1302  #endif /* defined(_MSC_VER) */
    1303  
    1304  #if defined(_MSC_VER)
    1305  
    1306  PyDoc_STRVAR(_ssl_enum_crls__doc__,
    1307  "enum_crls($module, /, store_name)\n"
    1308  "--\n"
    1309  "\n"
    1310  "Retrieve CRLs from Windows\' cert store.\n"
    1311  "\n"
    1312  "store_name may be one of \'CA\', \'ROOT\' or \'MY\'.  The system may provide\n"
    1313  "more cert storages, too.  The function returns a list of (bytes,\n"
    1314  "encoding_type) tuples.  The encoding_type flag can be interpreted with\n"
    1315  "X509_ASN_ENCODING or PKCS_7_ASN_ENCODING.");
    1316  
    1317  #define _SSL_ENUM_CRLS_METHODDEF    \
    1318      {"enum_crls", _PyCFunction_CAST(_ssl_enum_crls), METH_FASTCALL|METH_KEYWORDS, _ssl_enum_crls__doc__},
    1319  
    1320  static PyObject *
    1321  _ssl_enum_crls_impl(PyObject *module, const char *store_name);
    1322  
    1323  static PyObject *
    1324  _ssl_enum_crls(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1325  {
    1326      PyObject *return_value = NULL;
    1327      static const char * const _keywords[] = {"store_name", NULL};
    1328      static _PyArg_Parser _parser = {NULL, _keywords, "enum_crls", 0};
    1329      PyObject *argsbuf[1];
    1330      const char *store_name;
    1331  
    1332      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
    1333      if (!args) {
    1334          goto exit;
    1335      }
    1336      if (!PyUnicode_Check(args[0])) {
    1337          _PyArg_BadArgument("enum_crls", "argument 'store_name'", "str", args[0]);
    1338          goto exit;
    1339      }
    1340      Py_ssize_t store_name_length;
    1341      store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length);
    1342      if (store_name == NULL) {
    1343          goto exit;
    1344      }
    1345      if (strlen(store_name) != (size_t)store_name_length) {
    1346          PyErr_SetString(PyExc_ValueError, "embedded null character");
    1347          goto exit;
    1348      }
    1349      return_value = _ssl_enum_crls_impl(module, store_name);
    1350  
    1351  exit:
    1352      return return_value;
    1353  }
    1354  
    1355  #endif /* defined(_MSC_VER) */
    1356  
    1357  #ifndef _SSL_ENUM_CERTIFICATES_METHODDEF
    1358      #define _SSL_ENUM_CERTIFICATES_METHODDEF
    1359  #endif /* !defined(_SSL_ENUM_CERTIFICATES_METHODDEF) */
    1360  
    1361  #ifndef _SSL_ENUM_CRLS_METHODDEF
    1362      #define _SSL_ENUM_CRLS_METHODDEF
    1363  #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
    1364  /*[clinic end generated code: output=2a488dd0cbc777df input=a9049054013a1b77]*/