blob: 4dbc5d0010790bc81afc561ee726c175d259ac95 [file] [log] [blame]
Serhiy Storchaka4b7b82f2015-05-03 16:14:08 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(_ssl__SSLSocket_do_handshake__doc__,
6"do_handshake($self, /)\n"
7"--\n"
8"\n");
9
10#define _SSL__SSLSOCKET_DO_HANDSHAKE_METHODDEF \
11 {"do_handshake", (PyCFunction)_ssl__SSLSocket_do_handshake, METH_NOARGS, _ssl__SSLSocket_do_handshake__doc__},
12
13static PyObject *
14_ssl__SSLSocket_do_handshake_impl(PySSLSocket *self);
15
16static PyObject *
17_ssl__SSLSocket_do_handshake(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
18{
19 return _ssl__SSLSocket_do_handshake_impl(self);
20}
21
22PyDoc_STRVAR(_ssl__test_decode_cert__doc__,
23"_test_decode_cert($module, path, /)\n"
24"--\n"
25"\n");
26
27#define _SSL__TEST_DECODE_CERT_METHODDEF \
28 {"_test_decode_cert", (PyCFunction)_ssl__test_decode_cert, METH_O, _ssl__test_decode_cert__doc__},
29
30static PyObject *
31_ssl__test_decode_cert_impl(PyModuleDef *module, PyObject *path);
32
33static PyObject *
34_ssl__test_decode_cert(PyModuleDef *module, PyObject *arg)
35{
36 PyObject *return_value = NULL;
37 PyObject *path;
38
39 if (!PyArg_Parse(arg, "O&:_test_decode_cert", PyUnicode_FSConverter, &path))
40 goto exit;
41 return_value = _ssl__test_decode_cert_impl(module, path);
42
43exit:
44 return return_value;
45}
46
47PyDoc_STRVAR(_ssl__SSLSocket_peer_certificate__doc__,
48"peer_certificate($self, der=False, /)\n"
49"--\n"
50"\n"
51"Returns the certificate for the peer.\n"
52"\n"
53"If no certificate was provided, returns None. If a certificate was\n"
54"provided, but not validated, returns an empty dictionary. Otherwise\n"
55"returns a dict containing information about the peer certificate.\n"
56"\n"
57"If the optional argument is True, returns a DER-encoded copy of the\n"
58"peer certificate, or None if no certificate was provided. This will\n"
59"return the certificate even if it wasn\'t validated.");
60
61#define _SSL__SSLSOCKET_PEER_CERTIFICATE_METHODDEF \
62 {"peer_certificate", (PyCFunction)_ssl__SSLSocket_peer_certificate, METH_VARARGS, _ssl__SSLSocket_peer_certificate__doc__},
63
64static PyObject *
65_ssl__SSLSocket_peer_certificate_impl(PySSLSocket *self, int binary_mode);
66
67static PyObject *
68_ssl__SSLSocket_peer_certificate(PySSLSocket *self, PyObject *args)
69{
70 PyObject *return_value = NULL;
71 int binary_mode = 0;
72
73 if (!PyArg_ParseTuple(args, "|p:peer_certificate",
74 &binary_mode))
75 goto exit;
76 return_value = _ssl__SSLSocket_peer_certificate_impl(self, binary_mode);
77
78exit:
79 return return_value;
80}
81
82PyDoc_STRVAR(_ssl__SSLSocket_shared_ciphers__doc__,
83"shared_ciphers($self, /)\n"
84"--\n"
85"\n");
86
87#define _SSL__SSLSOCKET_SHARED_CIPHERS_METHODDEF \
88 {"shared_ciphers", (PyCFunction)_ssl__SSLSocket_shared_ciphers, METH_NOARGS, _ssl__SSLSocket_shared_ciphers__doc__},
89
90static PyObject *
91_ssl__SSLSocket_shared_ciphers_impl(PySSLSocket *self);
92
93static PyObject *
94_ssl__SSLSocket_shared_ciphers(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
95{
96 return _ssl__SSLSocket_shared_ciphers_impl(self);
97}
98
99PyDoc_STRVAR(_ssl__SSLSocket_cipher__doc__,
100"cipher($self, /)\n"
101"--\n"
102"\n");
103
104#define _SSL__SSLSOCKET_CIPHER_METHODDEF \
105 {"cipher", (PyCFunction)_ssl__SSLSocket_cipher, METH_NOARGS, _ssl__SSLSocket_cipher__doc__},
106
107static PyObject *
108_ssl__SSLSocket_cipher_impl(PySSLSocket *self);
109
110static PyObject *
111_ssl__SSLSocket_cipher(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
112{
113 return _ssl__SSLSocket_cipher_impl(self);
114}
115
116PyDoc_STRVAR(_ssl__SSLSocket_version__doc__,
117"version($self, /)\n"
118"--\n"
119"\n");
120
121#define _SSL__SSLSOCKET_VERSION_METHODDEF \
122 {"version", (PyCFunction)_ssl__SSLSocket_version, METH_NOARGS, _ssl__SSLSocket_version__doc__},
123
124static PyObject *
125_ssl__SSLSocket_version_impl(PySSLSocket *self);
126
127static PyObject *
128_ssl__SSLSocket_version(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
129{
130 return _ssl__SSLSocket_version_impl(self);
131}
132
133#if defined(OPENSSL_NPN_NEGOTIATED)
134
135PyDoc_STRVAR(_ssl__SSLSocket_selected_npn_protocol__doc__,
136"selected_npn_protocol($self, /)\n"
137"--\n"
138"\n");
139
140#define _SSL__SSLSOCKET_SELECTED_NPN_PROTOCOL_METHODDEF \
141 {"selected_npn_protocol", (PyCFunction)_ssl__SSLSocket_selected_npn_protocol, METH_NOARGS, _ssl__SSLSocket_selected_npn_protocol__doc__},
142
143static PyObject *
144_ssl__SSLSocket_selected_npn_protocol_impl(PySSLSocket *self);
145
146static PyObject *
147_ssl__SSLSocket_selected_npn_protocol(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
148{
149 return _ssl__SSLSocket_selected_npn_protocol_impl(self);
150}
151
152#endif /* defined(OPENSSL_NPN_NEGOTIATED) */
153
154#if defined(HAVE_ALPN)
155
156PyDoc_STRVAR(_ssl__SSLSocket_selected_alpn_protocol__doc__,
157"selected_alpn_protocol($self, /)\n"
158"--\n"
159"\n");
160
161#define _SSL__SSLSOCKET_SELECTED_ALPN_PROTOCOL_METHODDEF \
162 {"selected_alpn_protocol", (PyCFunction)_ssl__SSLSocket_selected_alpn_protocol, METH_NOARGS, _ssl__SSLSocket_selected_alpn_protocol__doc__},
163
164static PyObject *
165_ssl__SSLSocket_selected_alpn_protocol_impl(PySSLSocket *self);
166
167static PyObject *
168_ssl__SSLSocket_selected_alpn_protocol(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
169{
170 return _ssl__SSLSocket_selected_alpn_protocol_impl(self);
171}
172
173#endif /* defined(HAVE_ALPN) */
174
175PyDoc_STRVAR(_ssl__SSLSocket_compression__doc__,
176"compression($self, /)\n"
177"--\n"
178"\n");
179
180#define _SSL__SSLSOCKET_COMPRESSION_METHODDEF \
181 {"compression", (PyCFunction)_ssl__SSLSocket_compression, METH_NOARGS, _ssl__SSLSocket_compression__doc__},
182
183static PyObject *
184_ssl__SSLSocket_compression_impl(PySSLSocket *self);
185
186static PyObject *
187_ssl__SSLSocket_compression(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
188{
189 return _ssl__SSLSocket_compression_impl(self);
190}
191
192PyDoc_STRVAR(_ssl__SSLSocket_write__doc__,
193"write($self, b, /)\n"
194"--\n"
195"\n"
196"Writes the bytes-like object b into the SSL object.\n"
197"\n"
198"Returns the number of bytes written.");
199
200#define _SSL__SSLSOCKET_WRITE_METHODDEF \
201 {"write", (PyCFunction)_ssl__SSLSocket_write, METH_O, _ssl__SSLSocket_write__doc__},
202
203static PyObject *
204_ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b);
205
206static PyObject *
207_ssl__SSLSocket_write(PySSLSocket *self, PyObject *arg)
208{
209 PyObject *return_value = NULL;
210 Py_buffer b = {NULL, NULL};
211
212 if (!PyArg_Parse(arg, "y*:write", &b))
213 goto exit;
214 return_value = _ssl__SSLSocket_write_impl(self, &b);
215
216exit:
217 /* Cleanup for b */
218 if (b.obj)
219 PyBuffer_Release(&b);
220
221 return return_value;
222}
223
224PyDoc_STRVAR(_ssl__SSLSocket_pending__doc__,
225"pending($self, /)\n"
226"--\n"
227"\n"
228"Returns the number of already decrypted bytes available for read, pending on the connection.");
229
230#define _SSL__SSLSOCKET_PENDING_METHODDEF \
231 {"pending", (PyCFunction)_ssl__SSLSocket_pending, METH_NOARGS, _ssl__SSLSocket_pending__doc__},
232
233static PyObject *
234_ssl__SSLSocket_pending_impl(PySSLSocket *self);
235
236static PyObject *
237_ssl__SSLSocket_pending(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
238{
239 return _ssl__SSLSocket_pending_impl(self);
240}
241
242PyDoc_STRVAR(_ssl__SSLSocket_read__doc__,
243"read(size, [buffer])\n"
244"Read up to size bytes from the SSL socket.");
245
246#define _SSL__SSLSOCKET_READ_METHODDEF \
247 {"read", (PyCFunction)_ssl__SSLSocket_read, METH_VARARGS, _ssl__SSLSocket_read__doc__},
248
249static PyObject *
250_ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,
251 Py_buffer *buffer);
252
253static PyObject *
254_ssl__SSLSocket_read(PySSLSocket *self, PyObject *args)
255{
256 PyObject *return_value = NULL;
257 int len;
258 int group_right_1 = 0;
259 Py_buffer buffer = {NULL, NULL};
260
261 switch (PyTuple_GET_SIZE(args)) {
262 case 1:
263 if (!PyArg_ParseTuple(args, "i:read", &len))
264 goto exit;
265 break;
266 case 2:
267 if (!PyArg_ParseTuple(args, "iw*:read", &len, &buffer))
268 goto exit;
269 group_right_1 = 1;
270 break;
271 default:
272 PyErr_SetString(PyExc_TypeError, "_ssl._SSLSocket.read requires 1 to 2 arguments");
273 goto exit;
274 }
275 return_value = _ssl__SSLSocket_read_impl(self, len, group_right_1, &buffer);
276
277exit:
278 /* Cleanup for buffer */
279 if (buffer.obj)
280 PyBuffer_Release(&buffer);
281
282 return return_value;
283}
284
285PyDoc_STRVAR(_ssl__SSLSocket_shutdown__doc__,
286"shutdown($self, /)\n"
287"--\n"
288"\n"
289"Does the SSL shutdown handshake with the remote end.\n"
290"\n"
291"Returns the underlying socket object.");
292
293#define _SSL__SSLSOCKET_SHUTDOWN_METHODDEF \
294 {"shutdown", (PyCFunction)_ssl__SSLSocket_shutdown, METH_NOARGS, _ssl__SSLSocket_shutdown__doc__},
295
296static PyObject *
297_ssl__SSLSocket_shutdown_impl(PySSLSocket *self);
298
299static PyObject *
300_ssl__SSLSocket_shutdown(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
301{
302 return _ssl__SSLSocket_shutdown_impl(self);
303}
304
305PyDoc_STRVAR(_ssl__SSLSocket_tls_unique_cb__doc__,
306"tls_unique_cb($self, /)\n"
307"--\n"
308"\n"
309"Returns the \'tls-unique\' channel binding data, as defined by RFC 5929.\n"
310"\n"
311"If the TLS handshake is not yet complete, None is returned.");
312
313#define _SSL__SSLSOCKET_TLS_UNIQUE_CB_METHODDEF \
314 {"tls_unique_cb", (PyCFunction)_ssl__SSLSocket_tls_unique_cb, METH_NOARGS, _ssl__SSLSocket_tls_unique_cb__doc__},
315
316static PyObject *
317_ssl__SSLSocket_tls_unique_cb_impl(PySSLSocket *self);
318
319static PyObject *
320_ssl__SSLSocket_tls_unique_cb(PySSLSocket *self, PyObject *Py_UNUSED(ignored))
321{
322 return _ssl__SSLSocket_tls_unique_cb_impl(self);
323}
324
325static PyObject *
326_ssl__SSLContext_impl(PyTypeObject *type, int proto_version);
327
328static PyObject *
329_ssl__SSLContext(PyTypeObject *type, PyObject *args, PyObject *kwargs)
330{
331 PyObject *return_value = NULL;
332 int proto_version;
333
334 if ((type == &PySSLContext_Type) &&
335 !_PyArg_NoKeywords("_SSLContext", kwargs))
336 goto exit;
337 if (!PyArg_ParseTuple(args, "i:_SSLContext",
338 &proto_version))
339 goto exit;
340 return_value = _ssl__SSLContext_impl(type, proto_version);
341
342exit:
343 return return_value;
344}
345
346PyDoc_STRVAR(_ssl__SSLContext_set_ciphers__doc__,
347"set_ciphers($self, cipherlist, /)\n"
348"--\n"
349"\n");
350
351#define _SSL__SSLCONTEXT_SET_CIPHERS_METHODDEF \
352 {"set_ciphers", (PyCFunction)_ssl__SSLContext_set_ciphers, METH_O, _ssl__SSLContext_set_ciphers__doc__},
353
354static PyObject *
355_ssl__SSLContext_set_ciphers_impl(PySSLContext *self, const char *cipherlist);
356
357static PyObject *
358_ssl__SSLContext_set_ciphers(PySSLContext *self, PyObject *arg)
359{
360 PyObject *return_value = NULL;
361 const char *cipherlist;
362
363 if (!PyArg_Parse(arg, "s:set_ciphers", &cipherlist))
364 goto exit;
365 return_value = _ssl__SSLContext_set_ciphers_impl(self, cipherlist);
366
367exit:
368 return return_value;
369}
370
371PyDoc_STRVAR(_ssl__SSLContext__set_npn_protocols__doc__,
372"_set_npn_protocols($self, protos, /)\n"
373"--\n"
374"\n");
375
376#define _SSL__SSLCONTEXT__SET_NPN_PROTOCOLS_METHODDEF \
377 {"_set_npn_protocols", (PyCFunction)_ssl__SSLContext__set_npn_protocols, METH_O, _ssl__SSLContext__set_npn_protocols__doc__},
378
379static PyObject *
380_ssl__SSLContext__set_npn_protocols_impl(PySSLContext *self,
381 Py_buffer *protos);
382
383static PyObject *
384_ssl__SSLContext__set_npn_protocols(PySSLContext *self, PyObject *arg)
385{
386 PyObject *return_value = NULL;
387 Py_buffer protos = {NULL, NULL};
388
389 if (!PyArg_Parse(arg, "y*:_set_npn_protocols", &protos))
390 goto exit;
391 return_value = _ssl__SSLContext__set_npn_protocols_impl(self, &protos);
392
393exit:
394 /* Cleanup for protos */
395 if (protos.obj)
396 PyBuffer_Release(&protos);
397
398 return return_value;
399}
400
401PyDoc_STRVAR(_ssl__SSLContext__set_alpn_protocols__doc__,
402"_set_alpn_protocols($self, protos, /)\n"
403"--\n"
404"\n");
405
406#define _SSL__SSLCONTEXT__SET_ALPN_PROTOCOLS_METHODDEF \
407 {"_set_alpn_protocols", (PyCFunction)_ssl__SSLContext__set_alpn_protocols, METH_O, _ssl__SSLContext__set_alpn_protocols__doc__},
408
409static PyObject *
410_ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
411 Py_buffer *protos);
412
413static PyObject *
414_ssl__SSLContext__set_alpn_protocols(PySSLContext *self, PyObject *arg)
415{
416 PyObject *return_value = NULL;
417 Py_buffer protos = {NULL, NULL};
418
419 if (!PyArg_Parse(arg, "y*:_set_alpn_protocols", &protos))
420 goto exit;
421 return_value = _ssl__SSLContext__set_alpn_protocols_impl(self, &protos);
422
423exit:
424 /* Cleanup for protos */
425 if (protos.obj)
426 PyBuffer_Release(&protos);
427
428 return return_value;
429}
430
431PyDoc_STRVAR(_ssl__SSLContext_load_cert_chain__doc__,
432"load_cert_chain($self, /, certfile, keyfile=None, password=None)\n"
433"--\n"
434"\n");
435
436#define _SSL__SSLCONTEXT_LOAD_CERT_CHAIN_METHODDEF \
437 {"load_cert_chain", (PyCFunction)_ssl__SSLContext_load_cert_chain, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext_load_cert_chain__doc__},
438
439static PyObject *
440_ssl__SSLContext_load_cert_chain_impl(PySSLContext *self, PyObject *certfile,
441 PyObject *keyfile, PyObject *password);
442
443static PyObject *
444_ssl__SSLContext_load_cert_chain(PySSLContext *self, PyObject *args, PyObject *kwargs)
445{
446 PyObject *return_value = NULL;
447 static char *_keywords[] = {"certfile", "keyfile", "password", NULL};
448 PyObject *certfile;
449 PyObject *keyfile = NULL;
450 PyObject *password = NULL;
451
452 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OO:load_cert_chain", _keywords,
453 &certfile, &keyfile, &password))
454 goto exit;
455 return_value = _ssl__SSLContext_load_cert_chain_impl(self, certfile, keyfile, password);
456
457exit:
458 return return_value;
459}
460
461PyDoc_STRVAR(_ssl__SSLContext_load_verify_locations__doc__,
462"load_verify_locations($self, /, cafile=None, capath=None, cadata=None)\n"
463"--\n"
464"\n");
465
466#define _SSL__SSLCONTEXT_LOAD_VERIFY_LOCATIONS_METHODDEF \
467 {"load_verify_locations", (PyCFunction)_ssl__SSLContext_load_verify_locations, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext_load_verify_locations__doc__},
468
469static PyObject *
470_ssl__SSLContext_load_verify_locations_impl(PySSLContext *self,
471 PyObject *cafile,
472 PyObject *capath,
473 PyObject *cadata);
474
475static PyObject *
476_ssl__SSLContext_load_verify_locations(PySSLContext *self, PyObject *args, PyObject *kwargs)
477{
478 PyObject *return_value = NULL;
479 static char *_keywords[] = {"cafile", "capath", "cadata", NULL};
480 PyObject *cafile = NULL;
481 PyObject *capath = NULL;
482 PyObject *cadata = NULL;
483
484 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOO:load_verify_locations", _keywords,
485 &cafile, &capath, &cadata))
486 goto exit;
487 return_value = _ssl__SSLContext_load_verify_locations_impl(self, cafile, capath, cadata);
488
489exit:
490 return return_value;
491}
492
493PyDoc_STRVAR(_ssl__SSLContext_load_dh_params__doc__,
494"load_dh_params($self, path, /)\n"
495"--\n"
496"\n");
497
498#define _SSL__SSLCONTEXT_LOAD_DH_PARAMS_METHODDEF \
499 {"load_dh_params", (PyCFunction)_ssl__SSLContext_load_dh_params, METH_O, _ssl__SSLContext_load_dh_params__doc__},
500
501PyDoc_STRVAR(_ssl__SSLContext__wrap_socket__doc__,
502"_wrap_socket($self, /, sock, server_side, server_hostname=None)\n"
503"--\n"
504"\n");
505
506#define _SSL__SSLCONTEXT__WRAP_SOCKET_METHODDEF \
507 {"_wrap_socket", (PyCFunction)_ssl__SSLContext__wrap_socket, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext__wrap_socket__doc__},
508
509static PyObject *
510_ssl__SSLContext__wrap_socket_impl(PySSLContext *self, PyObject *sock,
511 int server_side, PyObject *hostname_obj);
512
513static PyObject *
514_ssl__SSLContext__wrap_socket(PySSLContext *self, PyObject *args, PyObject *kwargs)
515{
516 PyObject *return_value = NULL;
517 static char *_keywords[] = {"sock", "server_side", "server_hostname", NULL};
518 PyObject *sock;
519 int server_side;
520 PyObject *hostname_obj = Py_None;
521
522 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!i|O:_wrap_socket", _keywords,
523 PySocketModule.Sock_Type, &sock, &server_side, &hostname_obj))
524 goto exit;
525 return_value = _ssl__SSLContext__wrap_socket_impl(self, sock, server_side, hostname_obj);
526
527exit:
528 return return_value;
529}
530
531PyDoc_STRVAR(_ssl__SSLContext__wrap_bio__doc__,
532"_wrap_bio($self, /, incoming, outgoing, server_side,\n"
533" server_hostname=None)\n"
534"--\n"
535"\n");
536
537#define _SSL__SSLCONTEXT__WRAP_BIO_METHODDEF \
538 {"_wrap_bio", (PyCFunction)_ssl__SSLContext__wrap_bio, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext__wrap_bio__doc__},
539
540static PyObject *
541_ssl__SSLContext__wrap_bio_impl(PySSLContext *self, PySSLMemoryBIO *incoming,
542 PySSLMemoryBIO *outgoing, int server_side,
543 PyObject *hostname_obj);
544
545static PyObject *
546_ssl__SSLContext__wrap_bio(PySSLContext *self, PyObject *args, PyObject *kwargs)
547{
548 PyObject *return_value = NULL;
549 static char *_keywords[] = {"incoming", "outgoing", "server_side", "server_hostname", NULL};
550 PySSLMemoryBIO *incoming;
551 PySSLMemoryBIO *outgoing;
552 int server_side;
553 PyObject *hostname_obj = Py_None;
554
555 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!i|O:_wrap_bio", _keywords,
556 &PySSLMemoryBIO_Type, &incoming, &PySSLMemoryBIO_Type, &outgoing, &server_side, &hostname_obj))
557 goto exit;
558 return_value = _ssl__SSLContext__wrap_bio_impl(self, incoming, outgoing, server_side, hostname_obj);
559
560exit:
561 return return_value;
562}
563
564PyDoc_STRVAR(_ssl__SSLContext_session_stats__doc__,
565"session_stats($self, /)\n"
566"--\n"
567"\n");
568
569#define _SSL__SSLCONTEXT_SESSION_STATS_METHODDEF \
570 {"session_stats", (PyCFunction)_ssl__SSLContext_session_stats, METH_NOARGS, _ssl__SSLContext_session_stats__doc__},
571
572static PyObject *
573_ssl__SSLContext_session_stats_impl(PySSLContext *self);
574
575static PyObject *
576_ssl__SSLContext_session_stats(PySSLContext *self, PyObject *Py_UNUSED(ignored))
577{
578 return _ssl__SSLContext_session_stats_impl(self);
579}
580
581PyDoc_STRVAR(_ssl__SSLContext_set_default_verify_paths__doc__,
582"set_default_verify_paths($self, /)\n"
583"--\n"
584"\n");
585
586#define _SSL__SSLCONTEXT_SET_DEFAULT_VERIFY_PATHS_METHODDEF \
587 {"set_default_verify_paths", (PyCFunction)_ssl__SSLContext_set_default_verify_paths, METH_NOARGS, _ssl__SSLContext_set_default_verify_paths__doc__},
588
589static PyObject *
590_ssl__SSLContext_set_default_verify_paths_impl(PySSLContext *self);
591
592static PyObject *
593_ssl__SSLContext_set_default_verify_paths(PySSLContext *self, PyObject *Py_UNUSED(ignored))
594{
595 return _ssl__SSLContext_set_default_verify_paths_impl(self);
596}
597
598#if !defined(OPENSSL_NO_ECDH)
599
600PyDoc_STRVAR(_ssl__SSLContext_set_ecdh_curve__doc__,
601"set_ecdh_curve($self, name, /)\n"
602"--\n"
603"\n");
604
605#define _SSL__SSLCONTEXT_SET_ECDH_CURVE_METHODDEF \
606 {"set_ecdh_curve", (PyCFunction)_ssl__SSLContext_set_ecdh_curve, METH_O, _ssl__SSLContext_set_ecdh_curve__doc__},
607
608#endif /* !defined(OPENSSL_NO_ECDH) */
609
610PyDoc_STRVAR(_ssl__SSLContext_set_servername_callback__doc__,
611"set_servername_callback($self, method, /)\n"
612"--\n"
613"\n"
614"Set a callback that will be called when a server name is provided by the SSL/TLS client in the SNI extension.\n"
615"\n"
616"If the argument is None then the callback is disabled. The method is called\n"
617"with the SSLSocket, the server name as a string, and the SSLContext object.\n"
618"See RFC 6066 for details of the SNI extension.");
619
620#define _SSL__SSLCONTEXT_SET_SERVERNAME_CALLBACK_METHODDEF \
621 {"set_servername_callback", (PyCFunction)_ssl__SSLContext_set_servername_callback, METH_O, _ssl__SSLContext_set_servername_callback__doc__},
622
623PyDoc_STRVAR(_ssl__SSLContext_cert_store_stats__doc__,
624"cert_store_stats($self, /)\n"
625"--\n"
626"\n"
627"Returns quantities of loaded X.509 certificates.\n"
628"\n"
629"X.509 certificates with a CA extension and certificate revocation lists\n"
630"inside the context\'s cert store.\n"
631"\n"
632"NOTE: Certificates in a capath directory aren\'t loaded unless they have\n"
633"been used at least once.");
634
635#define _SSL__SSLCONTEXT_CERT_STORE_STATS_METHODDEF \
636 {"cert_store_stats", (PyCFunction)_ssl__SSLContext_cert_store_stats, METH_NOARGS, _ssl__SSLContext_cert_store_stats__doc__},
637
638static PyObject *
639_ssl__SSLContext_cert_store_stats_impl(PySSLContext *self);
640
641static PyObject *
642_ssl__SSLContext_cert_store_stats(PySSLContext *self, PyObject *Py_UNUSED(ignored))
643{
644 return _ssl__SSLContext_cert_store_stats_impl(self);
645}
646
647PyDoc_STRVAR(_ssl__SSLContext_get_ca_certs__doc__,
648"get_ca_certs($self, /, binary_form=False)\n"
649"--\n"
650"\n"
651"Returns a list of dicts with information of loaded CA certs.\n"
652"\n"
653"If the optional argument is True, returns a DER-encoded copy of the CA\n"
654"certificate.\n"
655"\n"
656"NOTE: Certificates in a capath directory aren\'t loaded unless they have\n"
657"been used at least once.");
658
659#define _SSL__SSLCONTEXT_GET_CA_CERTS_METHODDEF \
660 {"get_ca_certs", (PyCFunction)_ssl__SSLContext_get_ca_certs, METH_VARARGS|METH_KEYWORDS, _ssl__SSLContext_get_ca_certs__doc__},
661
662static PyObject *
663_ssl__SSLContext_get_ca_certs_impl(PySSLContext *self, int binary_form);
664
665static PyObject *
666_ssl__SSLContext_get_ca_certs(PySSLContext *self, PyObject *args, PyObject *kwargs)
667{
668 PyObject *return_value = NULL;
669 static char *_keywords[] = {"binary_form", NULL};
670 int binary_form = 0;
671
672 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|p:get_ca_certs", _keywords,
673 &binary_form))
674 goto exit;
675 return_value = _ssl__SSLContext_get_ca_certs_impl(self, binary_form);
676
677exit:
678 return return_value;
679}
680
681static PyObject *
682_ssl_MemoryBIO_impl(PyTypeObject *type);
683
684static PyObject *
685_ssl_MemoryBIO(PyTypeObject *type, PyObject *args, PyObject *kwargs)
686{
687 PyObject *return_value = NULL;
688
689 if ((type == &PySSLMemoryBIO_Type) &&
690 !_PyArg_NoPositional("MemoryBIO", args))
691 goto exit;
692 if ((type == &PySSLMemoryBIO_Type) &&
693 !_PyArg_NoKeywords("MemoryBIO", kwargs))
694 goto exit;
695 return_value = _ssl_MemoryBIO_impl(type);
696
697exit:
698 return return_value;
699}
700
701PyDoc_STRVAR(_ssl_MemoryBIO_read__doc__,
702"read($self, size=-1, /)\n"
703"--\n"
704"\n"
705"Read up to size bytes from the memory BIO.\n"
706"\n"
707"If size is not specified, read the entire buffer.\n"
708"If the return value is an empty bytes instance, this means either\n"
709"EOF or that no data is available. Use the \"eof\" property to\n"
710"distinguish between the two.");
711
712#define _SSL_MEMORYBIO_READ_METHODDEF \
713 {"read", (PyCFunction)_ssl_MemoryBIO_read, METH_VARARGS, _ssl_MemoryBIO_read__doc__},
714
715static PyObject *
716_ssl_MemoryBIO_read_impl(PySSLMemoryBIO *self, int len);
717
718static PyObject *
719_ssl_MemoryBIO_read(PySSLMemoryBIO *self, PyObject *args)
720{
721 PyObject *return_value = NULL;
722 int len = -1;
723
724 if (!PyArg_ParseTuple(args, "|i:read",
725 &len))
726 goto exit;
727 return_value = _ssl_MemoryBIO_read_impl(self, len);
728
729exit:
730 return return_value;
731}
732
733PyDoc_STRVAR(_ssl_MemoryBIO_write__doc__,
734"write($self, b, /)\n"
735"--\n"
736"\n"
737"Writes the bytes b into the memory BIO.\n"
738"\n"
739"Returns the number of bytes written.");
740
741#define _SSL_MEMORYBIO_WRITE_METHODDEF \
742 {"write", (PyCFunction)_ssl_MemoryBIO_write, METH_O, _ssl_MemoryBIO_write__doc__},
743
744static PyObject *
745_ssl_MemoryBIO_write_impl(PySSLMemoryBIO *self, Py_buffer *b);
746
747static PyObject *
748_ssl_MemoryBIO_write(PySSLMemoryBIO *self, PyObject *arg)
749{
750 PyObject *return_value = NULL;
751 Py_buffer b = {NULL, NULL};
752
753 if (!PyArg_Parse(arg, "y*:write", &b))
754 goto exit;
755 return_value = _ssl_MemoryBIO_write_impl(self, &b);
756
757exit:
758 /* Cleanup for b */
759 if (b.obj)
760 PyBuffer_Release(&b);
761
762 return return_value;
763}
764
765PyDoc_STRVAR(_ssl_MemoryBIO_write_eof__doc__,
766"write_eof($self, /)\n"
767"--\n"
768"\n"
769"Write an EOF marker to the memory BIO.\n"
770"\n"
771"When all data has been read, the \"eof\" property will be True.");
772
773#define _SSL_MEMORYBIO_WRITE_EOF_METHODDEF \
774 {"write_eof", (PyCFunction)_ssl_MemoryBIO_write_eof, METH_NOARGS, _ssl_MemoryBIO_write_eof__doc__},
775
776static PyObject *
777_ssl_MemoryBIO_write_eof_impl(PySSLMemoryBIO *self);
778
779static PyObject *
780_ssl_MemoryBIO_write_eof(PySSLMemoryBIO *self, PyObject *Py_UNUSED(ignored))
781{
782 return _ssl_MemoryBIO_write_eof_impl(self);
783}
784
785PyDoc_STRVAR(_ssl_RAND_add__doc__,
786"RAND_add($module, string, entropy, /)\n"
787"--\n"
788"\n"
789"Mix string into the OpenSSL PRNG state.\n"
790"\n"
791"entropy (a float) is a lower bound on the entropy contained in\n"
792"string. See RFC 1750.");
793
794#define _SSL_RAND_ADD_METHODDEF \
795 {"RAND_add", (PyCFunction)_ssl_RAND_add, METH_VARARGS, _ssl_RAND_add__doc__},
796
797static PyObject *
798_ssl_RAND_add_impl(PyModuleDef *module, Py_buffer *view, double entropy);
799
800static PyObject *
801_ssl_RAND_add(PyModuleDef *module, PyObject *args)
802{
803 PyObject *return_value = NULL;
804 Py_buffer view = {NULL, NULL};
805 double entropy;
806
807 if (!PyArg_ParseTuple(args, "s*d:RAND_add",
808 &view, &entropy))
809 goto exit;
810 return_value = _ssl_RAND_add_impl(module, &view, entropy);
811
812exit:
813 /* Cleanup for view */
814 if (view.obj)
815 PyBuffer_Release(&view);
816
817 return return_value;
818}
819
820PyDoc_STRVAR(_ssl_RAND_bytes__doc__,
821"RAND_bytes($module, n, /)\n"
822"--\n"
823"\n"
824"Generate n cryptographically strong pseudo-random bytes.");
825
826#define _SSL_RAND_BYTES_METHODDEF \
827 {"RAND_bytes", (PyCFunction)_ssl_RAND_bytes, METH_O, _ssl_RAND_bytes__doc__},
828
829static PyObject *
830_ssl_RAND_bytes_impl(PyModuleDef *module, int n);
831
832static PyObject *
833_ssl_RAND_bytes(PyModuleDef *module, PyObject *arg)
834{
835 PyObject *return_value = NULL;
836 int n;
837
838 if (!PyArg_Parse(arg, "i:RAND_bytes", &n))
839 goto exit;
840 return_value = _ssl_RAND_bytes_impl(module, n);
841
842exit:
843 return return_value;
844}
845
846PyDoc_STRVAR(_ssl_RAND_pseudo_bytes__doc__,
847"RAND_pseudo_bytes($module, n, /)\n"
848"--\n"
849"\n"
850"Generate n pseudo-random bytes.\n"
851"\n"
852"Return a pair (bytes, is_cryptographic). is_cryptographic is True\n"
853"if the bytes generated are cryptographically strong.");
854
855#define _SSL_RAND_PSEUDO_BYTES_METHODDEF \
856 {"RAND_pseudo_bytes", (PyCFunction)_ssl_RAND_pseudo_bytes, METH_O, _ssl_RAND_pseudo_bytes__doc__},
857
858static PyObject *
859_ssl_RAND_pseudo_bytes_impl(PyModuleDef *module, int n);
860
861static PyObject *
862_ssl_RAND_pseudo_bytes(PyModuleDef *module, PyObject *arg)
863{
864 PyObject *return_value = NULL;
865 int n;
866
867 if (!PyArg_Parse(arg, "i:RAND_pseudo_bytes", &n))
868 goto exit;
869 return_value = _ssl_RAND_pseudo_bytes_impl(module, n);
870
871exit:
872 return return_value;
873}
874
875PyDoc_STRVAR(_ssl_RAND_status__doc__,
876"RAND_status($module, /)\n"
877"--\n"
878"\n"
879"Returns 1 if the OpenSSL PRNG has been seeded with enough data and 0 if not.\n"
880"\n"
881"It is necessary to seed the PRNG with RAND_add() on some platforms before\n"
882"using the ssl() function.");
883
884#define _SSL_RAND_STATUS_METHODDEF \
885 {"RAND_status", (PyCFunction)_ssl_RAND_status, METH_NOARGS, _ssl_RAND_status__doc__},
886
887static PyObject *
888_ssl_RAND_status_impl(PyModuleDef *module);
889
890static PyObject *
891_ssl_RAND_status(PyModuleDef *module, PyObject *Py_UNUSED(ignored))
892{
893 return _ssl_RAND_status_impl(module);
894}
895
896#if defined(HAVE_RAND_EGD)
897
898PyDoc_STRVAR(_ssl_RAND_egd__doc__,
899"RAND_egd($module, path, /)\n"
900"--\n"
901"\n"
902"Queries the entropy gather daemon (EGD) on the socket named by \'path\'.\n"
903"\n"
904"Returns number of bytes read. Raises SSLError if connection to EGD\n"
905"fails or if it does not provide enough data to seed PRNG.");
906
907#define _SSL_RAND_EGD_METHODDEF \
908 {"RAND_egd", (PyCFunction)_ssl_RAND_egd, METH_O, _ssl_RAND_egd__doc__},
909
910static PyObject *
911_ssl_RAND_egd_impl(PyModuleDef *module, PyObject *path);
912
913static PyObject *
914_ssl_RAND_egd(PyModuleDef *module, PyObject *arg)
915{
916 PyObject *return_value = NULL;
917 PyObject *path;
918
919 if (!PyArg_Parse(arg, "O&:RAND_egd", PyUnicode_FSConverter, &path))
920 goto exit;
921 return_value = _ssl_RAND_egd_impl(module, path);
922
923exit:
924 return return_value;
925}
926
927#endif /* defined(HAVE_RAND_EGD) */
928
929PyDoc_STRVAR(_ssl_get_default_verify_paths__doc__,
930"get_default_verify_paths($module, /)\n"
931"--\n"
932"\n"
933"Return search paths and environment vars that are used by SSLContext\'s set_default_verify_paths() to load default CAs.\n"
934"\n"
935"The values are \'cert_file_env\', \'cert_file\', \'cert_dir_env\', \'cert_dir\'.");
936
937#define _SSL_GET_DEFAULT_VERIFY_PATHS_METHODDEF \
938 {"get_default_verify_paths", (PyCFunction)_ssl_get_default_verify_paths, METH_NOARGS, _ssl_get_default_verify_paths__doc__},
939
940static PyObject *
941_ssl_get_default_verify_paths_impl(PyModuleDef *module);
942
943static PyObject *
944_ssl_get_default_verify_paths(PyModuleDef *module, PyObject *Py_UNUSED(ignored))
945{
946 return _ssl_get_default_verify_paths_impl(module);
947}
948
949PyDoc_STRVAR(_ssl_txt2obj__doc__,
950"txt2obj($module, /, txt, name=False)\n"
951"--\n"
952"\n"
953"Lookup NID, short name, long name and OID of an ASN1_OBJECT.\n"
954"\n"
955"By default objects are looked up by OID. With name=True short and\n"
956"long name are also matched.");
957
958#define _SSL_TXT2OBJ_METHODDEF \
959 {"txt2obj", (PyCFunction)_ssl_txt2obj, METH_VARARGS|METH_KEYWORDS, _ssl_txt2obj__doc__},
960
961static PyObject *
962_ssl_txt2obj_impl(PyModuleDef *module, const char *txt, int name);
963
964static PyObject *
965_ssl_txt2obj(PyModuleDef *module, PyObject *args, PyObject *kwargs)
966{
967 PyObject *return_value = NULL;
968 static char *_keywords[] = {"txt", "name", NULL};
969 const char *txt;
970 int name = 0;
971
972 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|p:txt2obj", _keywords,
973 &txt, &name))
974 goto exit;
975 return_value = _ssl_txt2obj_impl(module, txt, name);
976
977exit:
978 return return_value;
979}
980
981PyDoc_STRVAR(_ssl_nid2obj__doc__,
982"nid2obj($module, nid, /)\n"
983"--\n"
984"\n"
985"Lookup NID, short name, long name and OID of an ASN1_OBJECT by NID.");
986
987#define _SSL_NID2OBJ_METHODDEF \
988 {"nid2obj", (PyCFunction)_ssl_nid2obj, METH_O, _ssl_nid2obj__doc__},
989
990static PyObject *
991_ssl_nid2obj_impl(PyModuleDef *module, int nid);
992
993static PyObject *
994_ssl_nid2obj(PyModuleDef *module, PyObject *arg)
995{
996 PyObject *return_value = NULL;
997 int nid;
998
999 if (!PyArg_Parse(arg, "i:nid2obj", &nid))
1000 goto exit;
1001 return_value = _ssl_nid2obj_impl(module, nid);
1002
1003exit:
1004 return return_value;
1005}
1006
1007#if defined(_MSC_VER)
1008
1009PyDoc_STRVAR(_ssl_enum_certificates__doc__,
1010"enum_certificates($module, /, store_name)\n"
1011"--\n"
1012"\n"
1013"Retrieve certificates from Windows\' cert store.\n"
1014"\n"
1015"store_name may be one of \'CA\', \'ROOT\' or \'MY\'. The system may provide\n"
1016"more cert storages, too. The function returns a list of (bytes,\n"
1017"encoding_type, trust) tuples. The encoding_type flag can be interpreted\n"
1018"with X509_ASN_ENCODING or PKCS_7_ASN_ENCODING. The trust setting is either\n"
1019"a set of OIDs or the boolean True.");
1020
1021#define _SSL_ENUM_CERTIFICATES_METHODDEF \
1022 {"enum_certificates", (PyCFunction)_ssl_enum_certificates, METH_VARARGS|METH_KEYWORDS, _ssl_enum_certificates__doc__},
1023
1024static PyObject *
1025_ssl_enum_certificates_impl(PyModuleDef *module, const char *store_name);
1026
1027static PyObject *
1028_ssl_enum_certificates(PyModuleDef *module, PyObject *args, PyObject *kwargs)
1029{
1030 PyObject *return_value = NULL;
1031 static char *_keywords[] = {"store_name", NULL};
1032 const char *store_name;
1033
1034 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:enum_certificates", _keywords,
1035 &store_name))
1036 goto exit;
1037 return_value = _ssl_enum_certificates_impl(module, store_name);
1038
1039exit:
1040 return return_value;
1041}
1042
1043#endif /* defined(_MSC_VER) */
1044
1045#if defined(_MSC_VER)
1046
1047PyDoc_STRVAR(_ssl_enum_crls__doc__,
1048"enum_crls($module, /, store_name)\n"
1049"--\n"
1050"\n"
1051"Retrieve CRLs from Windows\' cert store.\n"
1052"\n"
1053"store_name may be one of \'CA\', \'ROOT\' or \'MY\'. The system may provide\n"
1054"more cert storages, too. The function returns a list of (bytes,\n"
1055"encoding_type) tuples. The encoding_type flag can be interpreted with\n"
1056"X509_ASN_ENCODING or PKCS_7_ASN_ENCODING.");
1057
1058#define _SSL_ENUM_CRLS_METHODDEF \
1059 {"enum_crls", (PyCFunction)_ssl_enum_crls, METH_VARARGS|METH_KEYWORDS, _ssl_enum_crls__doc__},
1060
1061static PyObject *
1062_ssl_enum_crls_impl(PyModuleDef *module, const char *store_name);
1063
1064static PyObject *
1065_ssl_enum_crls(PyModuleDef *module, PyObject *args, PyObject *kwargs)
1066{
1067 PyObject *return_value = NULL;
1068 static char *_keywords[] = {"store_name", NULL};
1069 const char *store_name;
1070
1071 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:enum_crls", _keywords,
1072 &store_name))
1073 goto exit;
1074 return_value = _ssl_enum_crls_impl(module, store_name);
1075
1076exit:
1077 return return_value;
1078}
1079
1080#endif /* defined(_MSC_VER) */
1081
1082#ifndef _SSL__SSLSOCKET_SELECTED_NPN_PROTOCOL_METHODDEF
1083 #define _SSL__SSLSOCKET_SELECTED_NPN_PROTOCOL_METHODDEF
1084#endif /* !defined(_SSL__SSLSOCKET_SELECTED_NPN_PROTOCOL_METHODDEF) */
1085
1086#ifndef _SSL__SSLSOCKET_SELECTED_ALPN_PROTOCOL_METHODDEF
1087 #define _SSL__SSLSOCKET_SELECTED_ALPN_PROTOCOL_METHODDEF
1088#endif /* !defined(_SSL__SSLSOCKET_SELECTED_ALPN_PROTOCOL_METHODDEF) */
1089
1090#ifndef _SSL__SSLCONTEXT_SET_ECDH_CURVE_METHODDEF
1091 #define _SSL__SSLCONTEXT_SET_ECDH_CURVE_METHODDEF
1092#endif /* !defined(_SSL__SSLCONTEXT_SET_ECDH_CURVE_METHODDEF) */
1093
1094#ifndef _SSL_RAND_EGD_METHODDEF
1095 #define _SSL_RAND_EGD_METHODDEF
1096#endif /* !defined(_SSL_RAND_EGD_METHODDEF) */
1097
1098#ifndef _SSL_ENUM_CERTIFICATES_METHODDEF
1099 #define _SSL_ENUM_CERTIFICATES_METHODDEF
1100#endif /* !defined(_SSL_ENUM_CERTIFICATES_METHODDEF) */
1101
1102#ifndef _SSL_ENUM_CRLS_METHODDEF
1103 #define _SSL_ENUM_CRLS_METHODDEF
1104#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
1105/*[clinic end generated code: output=a14999cb565a69a2 input=a9049054013a1b77]*/