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