- Notifications
You must be signed in to change notification settings - Fork 31.7k
/
Copy path_ssl.h
80 lines (70 loc) · 2.25 KB
/
_ssl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndefPy_SSL_H
#definePy_SSL_H
/* OpenSSL header files */
#include"openssl/evp.h"
#include"openssl/x509.h"
/*
* ssl module state
*/
typedefstruct {
/* Types */
PyTypeObject*PySSLContext_Type;
PyTypeObject*PySSLSocket_Type;
PyTypeObject*PySSLMemoryBIO_Type;
PyTypeObject*PySSLSession_Type;
PyTypeObject*PySSLCertificate_Type;
/* SSL error object */
PyObject*PySSLErrorObject;
PyObject*PySSLCertVerificationErrorObject;
PyObject*PySSLZeroReturnErrorObject;
PyObject*PySSLWantReadErrorObject;
PyObject*PySSLWantWriteErrorObject;
PyObject*PySSLSyscallErrorObject;
PyObject*PySSLEOFErrorObject;
/* Error mappings */
PyObject*err_codes_to_names;
PyObject*lib_codes_to_names;
/* socket type from module CAPI */
PyTypeObject*Sock_Type;
/* Interned strings */
PyObject*str_library;
PyObject*str_reason;
PyObject*str_verify_code;
PyObject*str_verify_message;
/* keylog lock */
PyThread_type_lockkeylog_lock;
} _sslmodulestate;
staticstructPyModuleDef_sslmodule_def;
Py_LOCAL_INLINE(_sslmodulestate*)
get_ssl_state(PyObject*module)
{
void*state=PyModule_GetState(module);
assert(state!=NULL);
return (_sslmodulestate*)state;
}
#defineget_state_type(type) \
(get_ssl_state(PyType_GetModuleByDef(type, &_sslmodule_def)))
#defineget_state_ctx(c) (((PySSLContext *)(c))->state)
#defineget_state_sock(s) (((PySSLSocket *)(s))->ctx->state)
#defineget_state_obj(o) ((_sslmodulestate *)PyType_GetModuleState(Py_TYPE(o)))
#defineget_state_mbio(b) get_state_obj(b)
#defineget_state_cert(c) get_state_obj(c)
/* ************************************************************************
* certificate
*/
enumpy_ssl_encoding {
PY_SSL_ENCODING_PEM=X509_FILETYPE_PEM,
PY_SSL_ENCODING_DER=X509_FILETYPE_ASN1,
PY_SSL_ENCODING_PEM_AUX=X509_FILETYPE_PEM+0x100,
};
typedefstruct {
PyObject_HEAD
X509*cert;
Py_hash_thash;
} PySSLCertificate;
/* ************************************************************************
* helpers and utils
*/
staticPyObject*_PySSL_BytesFromBIO(_sslmodulestate*state, BIO*bio);
staticPyObject*_PySSL_UnicodeFromBIO(_sslmodulestate*state, BIO*bio, constchar*error);
#endif/* Py_SSL_H */