mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-24 13:45:05 +00:00
Fixed additional patterns: - _PyOpcode_* → _TyOpcode_* (all opcode metadata) - _PyUOpName → _TyUOpName - _PyFunction_* → _TyFunction_* - _PyListIterObject → _TyListIterObject - _Py_T_OBJECT → _Ty_T_OBJECT - Py_BEGIN_ALLOW_THREADS, Py_END_ALLOW_THREADS → Ty_* - PyDoc_STRVAR, PyDoc_STR → TyDoc_* - PyInterpreterState, PyThread_*, PyTime_t → Ty* - PyStructSequence_* → TyStructSequence_* - PyLockStatus → TyLockStatus - PyVarObject_HEAD_INIT → TyVarObject_HEAD_INIT - PyBaseExceptionObject → TyBaseExceptionObject - Fixed _PyExc_ → _TyExc_ in exception macros Build is progressing further. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
81 lines
2.2 KiB
C
81 lines
2.2 KiB
C
#ifndef Ty_SSL_H
|
|
#define Ty_SSL_H
|
|
|
|
/* OpenSSL header files */
|
|
#include "openssl/evp.h"
|
|
#include "openssl/x509.h"
|
|
|
|
/*
|
|
* ssl module state
|
|
*/
|
|
typedef struct {
|
|
/* Types */
|
|
TyTypeObject *PySSLContext_Type;
|
|
TyTypeObject *PySSLSocket_Type;
|
|
TyTypeObject *PySSLMemoryBIO_Type;
|
|
TyTypeObject *PySSLSession_Type;
|
|
TyTypeObject *PySSLCertificate_Type;
|
|
/* SSL error object */
|
|
TyObject *PySSLErrorObject;
|
|
TyObject *PySSLCertVerificationErrorObject;
|
|
TyObject *PySSLZeroReturnErrorObject;
|
|
TyObject *PySSLWantReadErrorObject;
|
|
TyObject *PySSLWantWriteErrorObject;
|
|
TyObject *PySSLSyscallErrorObject;
|
|
TyObject *PySSLEOFErrorObject;
|
|
/* Error mappings */
|
|
TyObject *err_codes_to_names;
|
|
TyObject *lib_codes_to_names;
|
|
/* socket type from module CAPI */
|
|
TyTypeObject *Sock_Type;
|
|
/* Interned strings */
|
|
TyObject *str_library;
|
|
TyObject *str_reason;
|
|
TyObject *str_verify_code;
|
|
TyObject *str_verify_message;
|
|
/* keylog lock */
|
|
TyThread_type_lock keylog_lock;
|
|
} _sslmodulestate;
|
|
|
|
static struct TyModuleDef _sslmodule_def;
|
|
|
|
Ty_LOCAL_INLINE(_sslmodulestate*)
|
|
get_ssl_state(TyObject *module)
|
|
{
|
|
void *state = TyModule_GetState(module);
|
|
assert(state != NULL);
|
|
return (_sslmodulestate *)state;
|
|
}
|
|
|
|
#define get_state_type(type) \
|
|
(get_ssl_state(TyType_GetModuleByDef(type, &_sslmodule_def)))
|
|
#define get_state_ctx(c) (((PySSLContext *)(c))->state)
|
|
#define get_state_sock(s) (((PySSLSocket *)(s))->ctx->state)
|
|
#define get_state_obj(o) ((_sslmodulestate *)TyType_GetModuleState(Ty_TYPE(o)))
|
|
#define get_state_mbio(b) get_state_obj(b)
|
|
#define get_state_cert(c) get_state_obj(c)
|
|
|
|
/* ************************************************************************
|
|
* certificate
|
|
*/
|
|
|
|
enum py_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,
|
|
};
|
|
|
|
typedef struct {
|
|
PyObject_HEAD
|
|
X509 *cert;
|
|
Ty_hash_t hash;
|
|
} PySSLCertificate;
|
|
|
|
/* ************************************************************************
|
|
* helpers and utils
|
|
*/
|
|
static TyObject *_PySSL_BytesFromBIO(_sslmodulestate *state, BIO *bio);
|
|
static TyObject *_PySSL_UnicodeFromBIO(_sslmodulestate *state, BIO *bio, const char *error);
|
|
|
|
#endif /* Ty_SSL_H */
|