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