123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545 |
- /*[clinic input]
- preserve
- [clinic start generated code]*/
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # include "pycore_gc.h" // PyGC_Head
- # include "pycore_runtime.h" // _Py_ID()
- #endif
- PyDoc_STRVAR(_ssl__SSLSocket_do_handshake__doc__,
- "do_handshake($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLSOCKET_DO_HANDSHAKE_METHODDEF \
- {"do_handshake", (PyCFunction)_ssl__SSLSocket_do_handshake, METH_NOARGS, _ssl__SSLSocket_do_handshake__doc__},
- static PyObject *
- _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_do_handshake(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_do_handshake_impl(self);
- }
- PyDoc_STRVAR(_ssl__test_decode_cert__doc__,
- "_test_decode_cert($module, path, /)\n"
- "--\n"
- "\n");
- #define _SSL__TEST_DECODE_CERT_METHODDEF \
- {"_test_decode_cert", (PyCFunction)_ssl__test_decode_cert, METH_O, _ssl__test_decode_cert__doc__},
- static PyObject *
- _ssl__test_decode_cert_impl(PyObject *module, PyObject *path);
- static PyObject *
- _ssl__test_decode_cert(PyObject *module, PyObject *arg)
- {
- PyObject *return_value = NULL;
- PyObject *path;
- if (!PyUnicode_FSConverter(arg, &path)) {
- goto exit;
- }
- return_value = _ssl__test_decode_cert_impl(module, path);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLSocket_getpeercert__doc__,
- "getpeercert($self, der=False, /)\n"
- "--\n"
- "\n"
- "Returns the certificate for the peer.\n"
- "\n"
- "If no certificate was provided, returns None. If a certificate was\n"
- "provided, but not validated, returns an empty dictionary. Otherwise\n"
- "returns a dict containing information about the peer certificate.\n"
- "\n"
- "If the optional argument is True, returns a DER-encoded copy of the\n"
- "peer certificate, or None if no certificate was provided. This will\n"
- "return the certificate even if it wasn\'t validated.");
- #define _SSL__SSLSOCKET_GETPEERCERT_METHODDEF \
- {"getpeercert", _PyCFunction_CAST(_ssl__SSLSocket_getpeercert), METH_FASTCALL, _ssl__SSLSocket_getpeercert__doc__},
- static PyObject *
- _ssl__SSLSocket_getpeercert_impl(PySSLSocket *self, int binary_mode);
- static PyObject *
- _ssl__SSLSocket_getpeercert(PySSLSocket *self, PyObject *const *args, Py_ssize_t nargs)
- {
- PyObject *return_value = NULL;
- int binary_mode = 0;
- if (!_PyArg_CheckPositional("getpeercert", nargs, 0, 1)) {
- goto exit;
- }
- if (nargs < 1) {
- goto skip_optional;
- }
- binary_mode = PyObject_IsTrue(args[0]);
- if (binary_mode < 0) {
- goto exit;
- }
- skip_optional:
- return_value = _ssl__SSLSocket_getpeercert_impl(self, binary_mode);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLSocket_get_verified_chain__doc__,
- "get_verified_chain($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLSOCKET_GET_VERIFIED_CHAIN_METHODDEF \
- {"get_verified_chain", (PyCFunction)_ssl__SSLSocket_get_verified_chain, METH_NOARGS, _ssl__SSLSocket_get_verified_chain__doc__},
- static PyObject *
- _ssl__SSLSocket_get_verified_chain_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_get_verified_chain(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_get_verified_chain_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_get_unverified_chain__doc__,
- "get_unverified_chain($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLSOCKET_GET_UNVERIFIED_CHAIN_METHODDEF \
- {"get_unverified_chain", (PyCFunction)_ssl__SSLSocket_get_unverified_chain, METH_NOARGS, _ssl__SSLSocket_get_unverified_chain__doc__},
- static PyObject *
- _ssl__SSLSocket_get_unverified_chain_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_get_unverified_chain(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_get_unverified_chain_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_shared_ciphers__doc__,
- "shared_ciphers($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLSOCKET_SHARED_CIPHERS_METHODDEF \
- {"shared_ciphers", (PyCFunction)_ssl__SSLSocket_shared_ciphers, METH_NOARGS, _ssl__SSLSocket_shared_ciphers__doc__},
- static PyObject *
- _ssl__SSLSocket_shared_ciphers_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_shared_ciphers(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_shared_ciphers_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_cipher__doc__,
- "cipher($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLSOCKET_CIPHER_METHODDEF \
- {"cipher", (PyCFunction)_ssl__SSLSocket_cipher, METH_NOARGS, _ssl__SSLSocket_cipher__doc__},
- static PyObject *
- _ssl__SSLSocket_cipher_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_cipher(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_cipher_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_version__doc__,
- "version($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLSOCKET_VERSION_METHODDEF \
- {"version", (PyCFunction)_ssl__SSLSocket_version, METH_NOARGS, _ssl__SSLSocket_version__doc__},
- static PyObject *
- _ssl__SSLSocket_version_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_version(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_version_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_selected_alpn_protocol__doc__,
- "selected_alpn_protocol($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLSOCKET_SELECTED_ALPN_PROTOCOL_METHODDEF \
- {"selected_alpn_protocol", (PyCFunction)_ssl__SSLSocket_selected_alpn_protocol, METH_NOARGS, _ssl__SSLSocket_selected_alpn_protocol__doc__},
- static PyObject *
- _ssl__SSLSocket_selected_alpn_protocol_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_selected_alpn_protocol(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_selected_alpn_protocol_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_compression__doc__,
- "compression($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLSOCKET_COMPRESSION_METHODDEF \
- {"compression", (PyCFunction)_ssl__SSLSocket_compression, METH_NOARGS, _ssl__SSLSocket_compression__doc__},
- static PyObject *
- _ssl__SSLSocket_compression_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_compression(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_compression_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_write__doc__,
- "write($self, b, /)\n"
- "--\n"
- "\n"
- "Writes the bytes-like object b into the SSL object.\n"
- "\n"
- "Returns the number of bytes written.");
- #define _SSL__SSLSOCKET_WRITE_METHODDEF \
- {"write", (PyCFunction)_ssl__SSLSocket_write, METH_O, _ssl__SSLSocket_write__doc__},
- static PyObject *
- _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b);
- static PyObject *
- _ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- Py_buffer b = {NULL, NULL};
- if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
- goto exit;
- }
- if (!PyBuffer_IsContiguous(&b, 'C')) {
- _PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
- goto exit;
- }
- return_value = _ssl__SSLSocket_write_impl(self, &b);
- exit:
- /* Cleanup for b */
- if (b.obj) {
- PyBuffer_Release(&b);
- }
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLSocket_pending__doc__,
- "pending($self, /)\n"
- "--\n"
- "\n"
- "Returns the number of already decrypted bytes available for read, pending on the connection.");
- #define _SSL__SSLSOCKET_PENDING_METHODDEF \
- {"pending", (PyCFunction)_ssl__SSLSocket_pending, METH_NOARGS, _ssl__SSLSocket_pending__doc__},
- static PyObject *
- _ssl__SSLSocket_pending_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_pending(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_pending_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_read__doc__,
- "read(size, [buffer])\n"
- "Read up to size bytes from the SSL socket.");
- #define _SSL__SSLSOCKET_READ_METHODDEF \
- {"read", (PyCFunction)_ssl__SSLSocket_read, METH_VARARGS, _ssl__SSLSocket_read__doc__},
- static PyObject *
- _ssl__SSLSocket_read_impl(PySSLSocket *self, Py_ssize_t len,
- int group_right_1, Py_buffer *buffer);
- static PyObject *
- _ssl__SSLSocket_read(PySSLSocket *self, PyObject *args)
- {
- PyObject *return_value = NULL;
- Py_ssize_t len;
- int group_right_1 = 0;
- Py_buffer buffer = {NULL, NULL};
- switch (PyTuple_GET_SIZE(args)) {
- case 1:
- if (!PyArg_ParseTuple(args, "n:read", &len)) {
- goto exit;
- }
- break;
- case 2:
- if (!PyArg_ParseTuple(args, "nw*:read", &len, &buffer)) {
- goto exit;
- }
- group_right_1 = 1;
- break;
- default:
- PyErr_SetString(PyExc_TypeError, "_ssl._SSLSocket.read requires 1 to 2 arguments");
- goto exit;
- }
- return_value = _ssl__SSLSocket_read_impl(self, len, group_right_1, &buffer);
- exit:
- /* Cleanup for buffer */
- if (buffer.obj) {
- PyBuffer_Release(&buffer);
- }
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLSocket_shutdown__doc__,
- "shutdown($self, /)\n"
- "--\n"
- "\n"
- "Does the SSL shutdown handshake with the remote end.");
- #define _SSL__SSLSOCKET_SHUTDOWN_METHODDEF \
- {"shutdown", (PyCFunction)_ssl__SSLSocket_shutdown, METH_NOARGS, _ssl__SSLSocket_shutdown__doc__},
- static PyObject *
- _ssl__SSLSocket_shutdown_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_shutdown(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_shutdown_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLSocket_get_channel_binding__doc__,
- "get_channel_binding($self, /, cb_type=\'tls-unique\')\n"
- "--\n"
- "\n"
- "Get channel binding data for current connection.\n"
- "\n"
- "Raise ValueError if the requested `cb_type` is not supported. Return bytes\n"
- "of the data or None if the data is not available (e.g. before the handshake).\n"
- "Only \'tls-unique\' channel binding data from RFC 5929 is supported.");
- #define _SSL__SSLSOCKET_GET_CHANNEL_BINDING_METHODDEF \
- {"get_channel_binding", _PyCFunction_CAST(_ssl__SSLSocket_get_channel_binding), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLSocket_get_channel_binding__doc__},
- static PyObject *
- _ssl__SSLSocket_get_channel_binding_impl(PySSLSocket *self,
- const char *cb_type);
- static PyObject *
- _ssl__SSLSocket_get_channel_binding(PySSLSocket *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(cb_type), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"cb_type", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "get_channel_binding",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
- const char *cb_type = "tls-unique";
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("get_channel_binding", "argument 'cb_type'", "str", args[0]);
- goto exit;
- }
- Py_ssize_t cb_type_length;
- cb_type = PyUnicode_AsUTF8AndSize(args[0], &cb_type_length);
- if (cb_type == NULL) {
- goto exit;
- }
- if (strlen(cb_type) != (size_t)cb_type_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- skip_optional_pos:
- return_value = _ssl__SSLSocket_get_channel_binding_impl(self, cb_type);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLSocket_verify_client_post_handshake__doc__,
- "verify_client_post_handshake($self, /)\n"
- "--\n"
- "\n"
- "Initiate TLS 1.3 post-handshake authentication");
- #define _SSL__SSLSOCKET_VERIFY_CLIENT_POST_HANDSHAKE_METHODDEF \
- {"verify_client_post_handshake", (PyCFunction)_ssl__SSLSocket_verify_client_post_handshake, METH_NOARGS, _ssl__SSLSocket_verify_client_post_handshake__doc__},
- static PyObject *
- _ssl__SSLSocket_verify_client_post_handshake_impl(PySSLSocket *self);
- static PyObject *
- _ssl__SSLSocket_verify_client_post_handshake(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLSocket_verify_client_post_handshake_impl(self);
- }
- static PyObject *
- _ssl__SSLContext_impl(PyTypeObject *type, int proto_version);
- static PyObject *
- _ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs)
- {
- PyObject *return_value = NULL;
- PyTypeObject *base_tp = get_state_type(type)->PySSLContext_Type;
- int proto_version;
- if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
- !_PyArg_NoKeywords("_SSLContext", kwargs)) {
- goto exit;
- }
- if (!_PyArg_CheckPositional("_SSLContext", PyTuple_GET_SIZE(args), 1, 1)) {
- goto exit;
- }
- proto_version = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0));
- if (proto_version == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = _ssl__SSLContext_impl(type, proto_version);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLContext_set_ciphers__doc__,
- "set_ciphers($self, cipherlist, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT_SET_CIPHERS_METHODDEF \
- {"set_ciphers", (PyCFunction)_ssl__SSLContext_set_ciphers, METH_O, _ssl__SSLContext_set_ciphers__doc__},
- static PyObject *
- _ssl__SSLContext_set_ciphers_impl(PySSLContext *self, const char *cipherlist);
- static PyObject *
- _ssl__SSLContext_set_ciphers(PySSLContext *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- const char *cipherlist;
- if (!PyUnicode_Check(arg)) {
- _PyArg_BadArgument("set_ciphers", "argument", "str", arg);
- goto exit;
- }
- Py_ssize_t cipherlist_length;
- cipherlist = PyUnicode_AsUTF8AndSize(arg, &cipherlist_length);
- if (cipherlist == NULL) {
- goto exit;
- }
- if (strlen(cipherlist) != (size_t)cipherlist_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- return_value = _ssl__SSLContext_set_ciphers_impl(self, cipherlist);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLContext_get_ciphers__doc__,
- "get_ciphers($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT_GET_CIPHERS_METHODDEF \
- {"get_ciphers", (PyCFunction)_ssl__SSLContext_get_ciphers, METH_NOARGS, _ssl__SSLContext_get_ciphers__doc__},
- static PyObject *
- _ssl__SSLContext_get_ciphers_impl(PySSLContext *self);
- static PyObject *
- _ssl__SSLContext_get_ciphers(PySSLContext *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLContext_get_ciphers_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLContext__set_alpn_protocols__doc__,
- "_set_alpn_protocols($self, protos, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT__SET_ALPN_PROTOCOLS_METHODDEF \
- {"_set_alpn_protocols", (PyCFunction)_ssl__SSLContext__set_alpn_protocols, METH_O, _ssl__SSLContext__set_alpn_protocols__doc__},
- static PyObject *
- _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
- Py_buffer *protos);
- static PyObject *
- _ssl__SSLContext__set_alpn_protocols(PySSLContext *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- Py_buffer protos = {NULL, NULL};
- if (PyObject_GetBuffer(arg, &protos, PyBUF_SIMPLE) != 0) {
- goto exit;
- }
- if (!PyBuffer_IsContiguous(&protos, 'C')) {
- _PyArg_BadArgument("_set_alpn_protocols", "argument", "contiguous buffer", arg);
- goto exit;
- }
- return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos);
- exit:
- /* Cleanup for protos */
- if (protos.obj) {
- PyBuffer_Release(&protos);
- }
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLContext_load_cert_chain__doc__,
- "load_cert_chain($self, /, certfile, keyfile=None, password=None)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT_LOAD_CERT_CHAIN_METHODDEF \
- {"load_cert_chain", _PyCFunction_CAST(_ssl__SSLContext_load_cert_chain), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_cert_chain__doc__},
- static PyObject *
- _ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile,
- PyObject *keyfile, PyObject *password);
- static PyObject *
- _ssl__SSLContext_load_cert_chain(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 3
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(certfile), &_Py_ID(keyfile), &_Py_ID(password), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"certfile", "keyfile", "password", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "load_cert_chain",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
- PyObject *certfile;
- PyObject *keyfile = Py_None;
- PyObject *password = Py_None;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- certfile = args[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[1]) {
- keyfile = args[1];
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- password = args[2];
- skip_optional_pos:
- return_value = _ssl__SSLContext_load_cert_chain_impl(self, certfile, keyfile, password);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLContext_load_verify_locations__doc__,
- "load_verify_locations($self, /, cafile=None, capath=None, cadata=None)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT_LOAD_VERIFY_LOCATIONS_METHODDEF \
- {"load_verify_locations", _PyCFunction_CAST(_ssl__SSLContext_load_verify_locations), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_load_verify_locations__doc__},
- static PyObject *
- _ssl__SSLContext_load_verify_locations_impl(PySSLContext *self,
- PyObject *cafile,
- PyObject *capath,
- PyObject *cadata);
- static PyObject *
- _ssl__SSLContext_load_verify_locations(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 3
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(cafile), &_Py_ID(capath), &_Py_ID(cadata), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"cafile", "capath", "cadata", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "load_verify_locations",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[3];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
- PyObject *cafile = Py_None;
- PyObject *capath = Py_None;
- PyObject *cadata = Py_None;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[0]) {
- cafile = args[0];
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- if (args[1]) {
- capath = args[1];
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- cadata = args[2];
- skip_optional_pos:
- return_value = _ssl__SSLContext_load_verify_locations_impl(self, cafile, capath, cadata);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLContext_load_dh_params__doc__,
- "load_dh_params($self, path, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT_LOAD_DH_PARAMS_METHODDEF \
- {"load_dh_params", (PyCFunction)_ssl__SSLContext_load_dh_params, METH_O, _ssl__SSLContext_load_dh_params__doc__},
- PyDoc_STRVAR(_ssl__SSLContext__wrap_socket__doc__,
- "_wrap_socket($self, /, sock, server_side, server_hostname=None, *,\n"
- " owner=None, session=None)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT__WRAP_SOCKET_METHODDEF \
- {"_wrap_socket", _PyCFunction_CAST(_ssl__SSLContext__wrap_socket), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_socket__doc__},
- static PyObject *
- _ssl__SSLContext__wrap_socket_impl(PySSLContext *self, PyObject *sock,
- int server_side, PyObject *hostname_obj,
- PyObject *owner, PyObject *session);
- static PyObject *
- _ssl__SSLContext__wrap_socket(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 5
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(sock), &_Py_ID(server_side), &_Py_ID(server_hostname), &_Py_ID(owner), &_Py_ID(session), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"sock", "server_side", "server_hostname", "owner", "session", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "_wrap_socket",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[5];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
- PyObject *sock;
- int server_side;
- PyObject *hostname_obj = Py_None;
- PyObject *owner = Py_None;
- PyObject *session = Py_None;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyObject_TypeCheck(args[0], get_state_ctx(self)->Sock_Type)) {
- _PyArg_BadArgument("_wrap_socket", "argument 'sock'", (get_state_ctx(self)->Sock_Type)->tp_name, args[0]);
- goto exit;
- }
- sock = args[0];
- server_side = PyObject_IsTrue(args[1]);
- if (server_side < 0) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[2]) {
- hostname_obj = args[2];
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- skip_optional_pos:
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- if (args[3]) {
- owner = args[3];
- if (!--noptargs) {
- goto skip_optional_kwonly;
- }
- }
- session = args[4];
- skip_optional_kwonly:
- return_value = _ssl__SSLContext__wrap_socket_impl(self, sock, server_side, hostname_obj, owner, session);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLContext__wrap_bio__doc__,
- "_wrap_bio($self, /, incoming, outgoing, server_side,\n"
- " server_hostname=None, *, owner=None, session=None)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT__WRAP_BIO_METHODDEF \
- {"_wrap_bio", _PyCFunction_CAST(_ssl__SSLContext__wrap_bio), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext__wrap_bio__doc__},
- static PyObject *
- _ssl__SSLContext__wrap_bio_impl(PySSLContext *self, PySSLMemoryBIO *incoming,
- PySSLMemoryBIO *outgoing, int server_side,
- PyObject *hostname_obj, PyObject *owner,
- PyObject *session);
- static PyObject *
- _ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 6
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(incoming), &_Py_ID(outgoing), &_Py_ID(server_side), &_Py_ID(server_hostname), &_Py_ID(owner), &_Py_ID(session), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"incoming", "outgoing", "server_side", "server_hostname", "owner", "session", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "_wrap_bio",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[6];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
- PySSLMemoryBIO *incoming;
- PySSLMemoryBIO *outgoing;
- int server_side;
- PyObject *hostname_obj = Py_None;
- PyObject *owner = Py_None;
- PyObject *session = Py_None;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyObject_TypeCheck(args[0], get_state_ctx(self)->PySSLMemoryBIO_Type)) {
- _PyArg_BadArgument("_wrap_bio", "argument 'incoming'", (get_state_ctx(self)->PySSLMemoryBIO_Type)->tp_name, args[0]);
- goto exit;
- }
- incoming = (PySSLMemoryBIO *)args[0];
- if (!PyObject_TypeCheck(args[1], get_state_ctx(self)->PySSLMemoryBIO_Type)) {
- _PyArg_BadArgument("_wrap_bio", "argument 'outgoing'", (get_state_ctx(self)->PySSLMemoryBIO_Type)->tp_name, args[1]);
- goto exit;
- }
- outgoing = (PySSLMemoryBIO *)args[1];
- server_side = PyObject_IsTrue(args[2]);
- if (server_side < 0) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (args[3]) {
- hostname_obj = args[3];
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- skip_optional_pos:
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- if (args[4]) {
- owner = args[4];
- if (!--noptargs) {
- goto skip_optional_kwonly;
- }
- }
- session = args[5];
- skip_optional_kwonly:
- return_value = _ssl__SSLContext__wrap_bio_impl(self, incoming, outgoing, server_side, hostname_obj, owner, session);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl__SSLContext_session_stats__doc__,
- "session_stats($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT_SESSION_STATS_METHODDEF \
- {"session_stats", (PyCFunction)_ssl__SSLContext_session_stats, METH_NOARGS, _ssl__SSLContext_session_stats__doc__},
- static PyObject *
- _ssl__SSLContext_session_stats_impl(PySSLContext *self);
- static PyObject *
- _ssl__SSLContext_session_stats(PySSLContext *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLContext_session_stats_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLContext_set_default_verify_paths__doc__,
- "set_default_verify_paths($self, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT_SET_DEFAULT_VERIFY_PATHS_METHODDEF \
- {"set_default_verify_paths", (PyCFunction)_ssl__SSLContext_set_default_verify_paths, METH_NOARGS, _ssl__SSLContext_set_default_verify_paths__doc__},
- static PyObject *
- _ssl__SSLContext_set_default_verify_paths_impl(PySSLContext *self);
- static PyObject *
- _ssl__SSLContext_set_default_verify_paths(PySSLContext *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLContext_set_default_verify_paths_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLContext_set_ecdh_curve__doc__,
- "set_ecdh_curve($self, name, /)\n"
- "--\n"
- "\n");
- #define _SSL__SSLCONTEXT_SET_ECDH_CURVE_METHODDEF \
- {"set_ecdh_curve", (PyCFunction)_ssl__SSLContext_set_ecdh_curve, METH_O, _ssl__SSLContext_set_ecdh_curve__doc__},
- PyDoc_STRVAR(_ssl__SSLContext_cert_store_stats__doc__,
- "cert_store_stats($self, /)\n"
- "--\n"
- "\n"
- "Returns quantities of loaded X.509 certificates.\n"
- "\n"
- "X.509 certificates with a CA extension and certificate revocation lists\n"
- "inside the context\'s cert store.\n"
- "\n"
- "NOTE: Certificates in a capath directory aren\'t loaded unless they have\n"
- "been used at least once.");
- #define _SSL__SSLCONTEXT_CERT_STORE_STATS_METHODDEF \
- {"cert_store_stats", (PyCFunction)_ssl__SSLContext_cert_store_stats, METH_NOARGS, _ssl__SSLContext_cert_store_stats__doc__},
- static PyObject *
- _ssl__SSLContext_cert_store_stats_impl(PySSLContext *self);
- static PyObject *
- _ssl__SSLContext_cert_store_stats(PySSLContext *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl__SSLContext_cert_store_stats_impl(self);
- }
- PyDoc_STRVAR(_ssl__SSLContext_get_ca_certs__doc__,
- "get_ca_certs($self, /, binary_form=False)\n"
- "--\n"
- "\n"
- "Returns a list of dicts with information of loaded CA certs.\n"
- "\n"
- "If the optional argument is True, returns a DER-encoded copy of the CA\n"
- "certificate.\n"
- "\n"
- "NOTE: Certificates in a capath directory aren\'t loaded unless they have\n"
- "been used at least once.");
- #define _SSL__SSLCONTEXT_GET_CA_CERTS_METHODDEF \
- {"get_ca_certs", _PyCFunction_CAST(_ssl__SSLContext_get_ca_certs), METH_FASTCALL|METH_KEYWORDS, _ssl__SSLContext_get_ca_certs__doc__},
- static PyObject *
- _ssl__SSLContext_get_ca_certs_impl(PySSLContext *self, int binary_form);
- static PyObject *
- _ssl__SSLContext_get_ca_certs(PySSLContext *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(binary_form), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"binary_form", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "get_ca_certs",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
- int binary_form = 0;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- binary_form = PyObject_IsTrue(args[0]);
- if (binary_form < 0) {
- goto exit;
- }
- skip_optional_pos:
- return_value = _ssl__SSLContext_get_ca_certs_impl(self, binary_form);
- exit:
- return return_value;
- }
- static PyObject *
- _ssl_MemoryBIO_impl(PyTypeObject *type);
- static PyObject *
- _ssl_MemoryBIO(PyTypeObject *type, PyObject *args, PyObject *kwargs)
- {
- PyObject *return_value = NULL;
- PyTypeObject *base_tp = get_state_type(type)->PySSLMemoryBIO_Type;
- if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
- !_PyArg_NoPositional("MemoryBIO", args)) {
- goto exit;
- }
- if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
- !_PyArg_NoKeywords("MemoryBIO", kwargs)) {
- goto exit;
- }
- return_value = _ssl_MemoryBIO_impl(type);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl_MemoryBIO_read__doc__,
- "read($self, size=-1, /)\n"
- "--\n"
- "\n"
- "Read up to size bytes from the memory BIO.\n"
- "\n"
- "If size is not specified, read the entire buffer.\n"
- "If the return value is an empty bytes instance, this means either\n"
- "EOF or that no data is available. Use the \"eof\" property to\n"
- "distinguish between the two.");
- #define _SSL_MEMORYBIO_READ_METHODDEF \
- {"read", _PyCFunction_CAST(_ssl_MemoryBIO_read), METH_FASTCALL, _ssl_MemoryBIO_read__doc__},
- static PyObject *
- _ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len);
- static PyObject *
- _ssl_MemoryBIO_read(PySSLMemoryBIO *self, PyObject *const *args, Py_ssize_t nargs)
- {
- PyObject *return_value = NULL;
- int len = -1;
- if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
- goto exit;
- }
- if (nargs < 1) {
- goto skip_optional;
- }
- len = _PyLong_AsInt(args[0]);
- if (len == -1 && PyErr_Occurred()) {
- goto exit;
- }
- skip_optional:
- return_value = _ssl_MemoryBIO_read_impl(self, len);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl_MemoryBIO_write__doc__,
- "write($self, b, /)\n"
- "--\n"
- "\n"
- "Writes the bytes b into the memory BIO.\n"
- "\n"
- "Returns the number of bytes written.");
- #define _SSL_MEMORYBIO_WRITE_METHODDEF \
- {"write", (PyCFunction)_ssl_MemoryBIO_write, METH_O, _ssl_MemoryBIO_write__doc__},
- static PyObject *
- _ssl_MemoryBIO_write_impl(PySSLMemoryBIO *self, Py_buffer *b);
- static PyObject *
- _ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- Py_buffer b = {NULL, NULL};
- if (PyObject_GetBuffer(arg, &b, PyBUF_SIMPLE) != 0) {
- goto exit;
- }
- if (!PyBuffer_IsContiguous(&b, 'C')) {
- _PyArg_BadArgument("write", "argument", "contiguous buffer", arg);
- goto exit;
- }
- return_value = _ssl_MemoryBIO_write_impl(self, &b);
- exit:
- /* Cleanup for b */
- if (b.obj) {
- PyBuffer_Release(&b);
- }
- return return_value;
- }
- PyDoc_STRVAR(_ssl_MemoryBIO_write_eof__doc__,
- "write_eof($self, /)\n"
- "--\n"
- "\n"
- "Write an EOF marker to the memory BIO.\n"
- "\n"
- "When all data has been read, the \"eof\" property will be True.");
- #define _SSL_MEMORYBIO_WRITE_EOF_METHODDEF \
- {"write_eof", (PyCFunction)_ssl_MemoryBIO_write_eof, METH_NOARGS, _ssl_MemoryBIO_write_eof__doc__},
- static PyObject *
- _ssl_MemoryBIO_write_eof_impl(PySSLMemoryBIO *self);
- static PyObject *
- _ssl_MemoryBIO_write_eof(PySSLMemoryBIO *self, PyObject *Py_UNUSED(ignored))
- {
- return _ssl_MemoryBIO_write_eof_impl(self);
- }
- PyDoc_STRVAR(_ssl_RAND_add__doc__,
- "RAND_add($module, string, entropy, /)\n"
- "--\n"
- "\n"
- "Mix string into the OpenSSL PRNG state.\n"
- "\n"
- "entropy (a float) is a lower bound on the entropy contained in\n"
- "string. See RFC 4086.");
- #define _SSL_RAND_ADD_METHODDEF \
- {"RAND_add", _PyCFunction_CAST(_ssl_RAND_add), METH_FASTCALL, _ssl_RAND_add__doc__},
- static PyObject *
- _ssl_RAND_add_impl(PyObject *module, Py_buffer *view, double entropy);
- static PyObject *
- _ssl_RAND_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
- {
- PyObject *return_value = NULL;
- Py_buffer view = {NULL, NULL};
- double entropy;
- if (!_PyArg_CheckPositional("RAND_add", nargs, 2, 2)) {
- goto exit;
- }
- if (PyUnicode_Check(args[0])) {
- Py_ssize_t len;
- const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
- if (ptr == NULL) {
- goto exit;
- }
- PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, 0);
- }
- else { /* any bytes-like object */
- if (PyObject_GetBuffer(args[0], &view, PyBUF_SIMPLE) != 0) {
- goto exit;
- }
- if (!PyBuffer_IsContiguous(&view, 'C')) {
- _PyArg_BadArgument("RAND_add", "argument 1", "contiguous buffer", args[0]);
- goto exit;
- }
- }
- if (PyFloat_CheckExact(args[1])) {
- entropy = PyFloat_AS_DOUBLE(args[1]);
- }
- else
- {
- entropy = PyFloat_AsDouble(args[1]);
- if (entropy == -1.0 && PyErr_Occurred()) {
- goto exit;
- }
- }
- return_value = _ssl_RAND_add_impl(module, &view, entropy);
- exit:
- /* Cleanup for view */
- if (view.obj) {
- PyBuffer_Release(&view);
- }
- return return_value;
- }
- PyDoc_STRVAR(_ssl_RAND_bytes__doc__,
- "RAND_bytes($module, n, /)\n"
- "--\n"
- "\n"
- "Generate n cryptographically strong pseudo-random bytes.");
- #define _SSL_RAND_BYTES_METHODDEF \
- {"RAND_bytes", (PyCFunction)_ssl_RAND_bytes, METH_O, _ssl_RAND_bytes__doc__},
- static PyObject *
- _ssl_RAND_bytes_impl(PyObject *module, int n);
- static PyObject *
- _ssl_RAND_bytes(PyObject *module, PyObject *arg)
- {
- PyObject *return_value = NULL;
- int n;
- n = _PyLong_AsInt(arg);
- if (n == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = _ssl_RAND_bytes_impl(module, n);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl_RAND_status__doc__,
- "RAND_status($module, /)\n"
- "--\n"
- "\n"
- "Returns True if the OpenSSL PRNG has been seeded with enough data and False if not.\n"
- "\n"
- "It is necessary to seed the PRNG with RAND_add() on some platforms before\n"
- "using the ssl() function.");
- #define _SSL_RAND_STATUS_METHODDEF \
- {"RAND_status", (PyCFunction)_ssl_RAND_status, METH_NOARGS, _ssl_RAND_status__doc__},
- static PyObject *
- _ssl_RAND_status_impl(PyObject *module);
- static PyObject *
- _ssl_RAND_status(PyObject *module, PyObject *Py_UNUSED(ignored))
- {
- return _ssl_RAND_status_impl(module);
- }
- PyDoc_STRVAR(_ssl_get_default_verify_paths__doc__,
- "get_default_verify_paths($module, /)\n"
- "--\n"
- "\n"
- "Return search paths and environment vars that are used by SSLContext\'s set_default_verify_paths() to load default CAs.\n"
- "\n"
- "The values are \'cert_file_env\', \'cert_file\', \'cert_dir_env\', \'cert_dir\'.");
- #define _SSL_GET_DEFAULT_VERIFY_PATHS_METHODDEF \
- {"get_default_verify_paths", (PyCFunction)_ssl_get_default_verify_paths, METH_NOARGS, _ssl_get_default_verify_paths__doc__},
- static PyObject *
- _ssl_get_default_verify_paths_impl(PyObject *module);
- static PyObject *
- _ssl_get_default_verify_paths(PyObject *module, PyObject *Py_UNUSED(ignored))
- {
- return _ssl_get_default_verify_paths_impl(module);
- }
- PyDoc_STRVAR(_ssl_txt2obj__doc__,
- "txt2obj($module, /, txt, name=False)\n"
- "--\n"
- "\n"
- "Lookup NID, short name, long name and OID of an ASN1_OBJECT.\n"
- "\n"
- "By default objects are looked up by OID. With name=True short and\n"
- "long name are also matched.");
- #define _SSL_TXT2OBJ_METHODDEF \
- {"txt2obj", _PyCFunction_CAST(_ssl_txt2obj), METH_FASTCALL|METH_KEYWORDS, _ssl_txt2obj__doc__},
- static PyObject *
- _ssl_txt2obj_impl(PyObject *module, const char *txt, int name);
- static PyObject *
- _ssl_txt2obj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 2
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(txt), &_Py_ID(name), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"txt", "name", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "txt2obj",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[2];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
- const char *txt;
- int name = 0;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("txt2obj", "argument 'txt'", "str", args[0]);
- goto exit;
- }
- Py_ssize_t txt_length;
- txt = PyUnicode_AsUTF8AndSize(args[0], &txt_length);
- if (txt == NULL) {
- goto exit;
- }
- if (strlen(txt) != (size_t)txt_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- name = PyObject_IsTrue(args[1]);
- if (name < 0) {
- goto exit;
- }
- skip_optional_pos:
- return_value = _ssl_txt2obj_impl(module, txt, name);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(_ssl_nid2obj__doc__,
- "nid2obj($module, nid, /)\n"
- "--\n"
- "\n"
- "Lookup NID, short name, long name and OID of an ASN1_OBJECT by NID.");
- #define _SSL_NID2OBJ_METHODDEF \
- {"nid2obj", (PyCFunction)_ssl_nid2obj, METH_O, _ssl_nid2obj__doc__},
- static PyObject *
- _ssl_nid2obj_impl(PyObject *module, int nid);
- static PyObject *
- _ssl_nid2obj(PyObject *module, PyObject *arg)
- {
- PyObject *return_value = NULL;
- int nid;
- nid = _PyLong_AsInt(arg);
- if (nid == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = _ssl_nid2obj_impl(module, nid);
- exit:
- return return_value;
- }
- #if defined(_MSC_VER)
- PyDoc_STRVAR(_ssl_enum_certificates__doc__,
- "enum_certificates($module, /, store_name)\n"
- "--\n"
- "\n"
- "Retrieve certificates from Windows\' cert store.\n"
- "\n"
- "store_name may be one of \'CA\', \'ROOT\' or \'MY\'. The system may provide\n"
- "more cert storages, too. The function returns a list of (bytes,\n"
- "encoding_type, trust) tuples. The encoding_type flag can be interpreted\n"
- "with X509_ASN_ENCODING or PKCS_7_ASN_ENCODING. The trust setting is either\n"
- "a set of OIDs or the boolean True.");
- #define _SSL_ENUM_CERTIFICATES_METHODDEF \
- {"enum_certificates", _PyCFunction_CAST(_ssl_enum_certificates), METH_FASTCALL|METH_KEYWORDS, _ssl_enum_certificates__doc__},
- static PyObject *
- _ssl_enum_certificates_impl(PyObject *module, const char *store_name);
- static PyObject *
- _ssl_enum_certificates(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(store_name), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"store_name", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "enum_certificates",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- const char *store_name;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("enum_certificates", "argument 'store_name'", "str", args[0]);
- goto exit;
- }
- Py_ssize_t store_name_length;
- store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length);
- if (store_name == NULL) {
- goto exit;
- }
- if (strlen(store_name) != (size_t)store_name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- return_value = _ssl_enum_certificates_impl(module, store_name);
- exit:
- return return_value;
- }
- #endif /* defined(_MSC_VER) */
- #if defined(_MSC_VER)
- PyDoc_STRVAR(_ssl_enum_crls__doc__,
- "enum_crls($module, /, store_name)\n"
- "--\n"
- "\n"
- "Retrieve CRLs from Windows\' cert store.\n"
- "\n"
- "store_name may be one of \'CA\', \'ROOT\' or \'MY\'. The system may provide\n"
- "more cert storages, too. The function returns a list of (bytes,\n"
- "encoding_type) tuples. The encoding_type flag can be interpreted with\n"
- "X509_ASN_ENCODING or PKCS_7_ASN_ENCODING.");
- #define _SSL_ENUM_CRLS_METHODDEF \
- {"enum_crls", _PyCFunction_CAST(_ssl_enum_crls), METH_FASTCALL|METH_KEYWORDS, _ssl_enum_crls__doc__},
- static PyObject *
- _ssl_enum_crls_impl(PyObject *module, const char *store_name);
- static PyObject *
- _ssl_enum_crls(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(store_name), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"store_name", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "enum_crls",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- const char *store_name;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("enum_crls", "argument 'store_name'", "str", args[0]);
- goto exit;
- }
- Py_ssize_t store_name_length;
- store_name = PyUnicode_AsUTF8AndSize(args[0], &store_name_length);
- if (store_name == NULL) {
- goto exit;
- }
- if (strlen(store_name) != (size_t)store_name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- return_value = _ssl_enum_crls_impl(module, store_name);
- exit:
- return return_value;
- }
- #endif /* defined(_MSC_VER) */
- #ifndef _SSL_ENUM_CERTIFICATES_METHODDEF
- #define _SSL_ENUM_CERTIFICATES_METHODDEF
- #endif /* !defined(_SSL_ENUM_CERTIFICATES_METHODDEF) */
- #ifndef _SSL_ENUM_CRLS_METHODDEF
- #define _SSL_ENUM_CRLS_METHODDEF
- #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
- /*[clinic end generated code: output=4d9b81fa81f520f0 input=a9049054013a1b77]*/
|