📄 ssl_locl.h
字号:
#define SSL_EXP_MASK 0x00000003L#define SSL_NOT_EXP 0x00000001L#define SSL_EXPORT 0x00000002L#define SSL_STRONG_MASK 0x000000fcL#define SSL_STRONG_NONE 0x00000004L#define SSL_EXP40 0x00000008L#define SSL_MICRO (SSL_EXP40)#define SSL_EXP56 0x00000010L#define SSL_MINI (SSL_EXP56)#define SSL_LOW 0x00000020L#define SSL_MEDIUM 0x00000040L#define SSL_HIGH 0x00000080L/* we have used 000000ff - 24 bits left to go *//* * Macros to check the export status and cipher strength for export ciphers. * Even though the macros for EXPORT and EXPORT40/56 have similar names, * their meaning is different: * *_EXPORT macros check the 'exportable' status. * *_EXPORT40/56 macros are used to check whether a certain cipher strength * is given. * Since the SSL_IS_EXPORT* and SSL_EXPORT* macros depend on the correct * algorithm structure element to be passed (algorithms, algo_strength) and no * typechecking can be done as they are all of type unsigned long, their * direct usage is discouraged. * Use the SSL_C_* macros instead. */#define SSL_IS_EXPORT(a) ((a)&SSL_EXPORT)#define SSL_IS_EXPORT56(a) ((a)&SSL_EXP56)#define SSL_IS_EXPORT40(a) ((a)&SSL_EXP40)#define SSL_C_IS_EXPORT(c) SSL_IS_EXPORT((c)->algo_strength)#define SSL_C_IS_EXPORT56(c) SSL_IS_EXPORT56((c)->algo_strength)#define SSL_C_IS_EXPORT40(c) SSL_IS_EXPORT40((c)->algo_strength)#define SSL_EXPORT_KEYLENGTH(a,s) (SSL_IS_EXPORT40(s) ? 5 : \ ((a)&SSL_ENC_MASK) == SSL_DES ? 8 : 7)#define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024)#define SSL_C_EXPORT_KEYLENGTH(c) SSL_EXPORT_KEYLENGTH((c)->algorithms, \ (c)->algo_strength)#define SSL_C_EXPORT_PKEYLENGTH(c) SSL_EXPORT_PKEYLENGTH((c)->algo_strength)#define SSL_ALL 0xffffffffL#define SSL_ALL_CIPHERS (SSL_MKEY_MASK|SSL_AUTH_MASK|SSL_ENC_MASK|\ SSL_MAC_MASK)#define SSL_ALL_STRENGTHS (SSL_EXP_MASK|SSL_STRONG_MASK)/* Mostly for SSLv3 */#define SSL_PKEY_RSA_ENC 0#define SSL_PKEY_RSA_SIGN 1#define SSL_PKEY_DSA_SIGN 2#define SSL_PKEY_DH_RSA 3#define SSL_PKEY_DH_DSA 4#define SSL_PKEY_ECC 5#define SSL_PKEY_NUM 6/* SSL_kRSA <- RSA_ENC | (RSA_TMP & RSA_SIGN) | * <- (EXPORT & (RSA_ENC | RSA_TMP) & RSA_SIGN) * SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN) * SSL_kEDH <- RSA_ENC | RSA_SIGN | DSA_SIGN * SSL_aRSA <- RSA_ENC | RSA_SIGN * SSL_aDSS <- DSA_SIGN *//*#define CERT_INVALID 0#define CERT_PUBLIC_KEY 1#define CERT_PRIVATE_KEY 2*/#ifndef OPENSSL_NO_EC/* From ECC-TLS draft, used in encoding the curve type in * ECParameters */#define EXPLICIT_PRIME_CURVE_TYPE 1 #define EXPLICIT_CHAR2_CURVE_TYPE 2#define NAMED_CURVE_TYPE 3#endif /* OPENSSL_NO_EC */typedef struct cert_pkey_st { X509 *x509; EVP_PKEY *privatekey; } CERT_PKEY;typedef struct cert_st { /* Current active set */ CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array * Probably it would make more sense to store * an index, not a pointer. */ /* The following masks are for the key and auth * algorithms that are supported by the certs below */ int valid; unsigned long mask; unsigned long export_mask;#ifndef OPENSSL_NO_RSA RSA *rsa_tmp; RSA *(*rsa_tmp_cb)(SSL *ssl,int is_export,int keysize);#endif#ifndef OPENSSL_NO_DH DH *dh_tmp; DH *(*dh_tmp_cb)(SSL *ssl,int is_export,int keysize);#endif#ifndef OPENSSL_NO_ECDH EC_KEY *ecdh_tmp; /* Callback for generating ephemeral ECDH keys */ EC_KEY *(*ecdh_tmp_cb)(SSL *ssl,int is_export,int keysize);#endif CERT_PKEY pkeys[SSL_PKEY_NUM]; int references; /* >1 only if SSL_copy_session_id is used */ } CERT;typedef struct sess_cert_st { STACK_OF(X509) *cert_chain; /* as received from peer (not for SSL2) */ /* The 'peer_...' members are used only by clients. */ int peer_cert_type; CERT_PKEY *peer_key; /* points to an element of peer_pkeys (never NULL!) */ CERT_PKEY peer_pkeys[SSL_PKEY_NUM]; /* Obviously we don't have the private keys of these, * so maybe we shouldn't even use the CERT_PKEY type here. */#ifndef OPENSSL_NO_RSA RSA *peer_rsa_tmp; /* not used for SSL 2 */#endif#ifndef OPENSSL_NO_DH DH *peer_dh_tmp; /* not used for SSL 2 */#endif#ifndef OPENSSL_NO_ECDH EC_KEY *peer_ecdh_tmp;#endif int references; /* actually always 1 at the moment */ } SESS_CERT;/*#define MAC_DEBUG *//*#define ERR_DEBUG *//*#define ABORT_DEBUG *//*#define PKT_DEBUG 1 *//*#define DES_DEBUG *//*#define DES_OFB_DEBUG *//*#define SSL_DEBUG *//*#define RSA_DEBUG */ /*#define IDEA_DEBUG */ #define FP_ICC (int (*)(const void *,const void *))#define ssl_put_cipher_by_char(ssl,ciph,ptr) \ ((ssl)->method->put_cipher_by_char((ciph),(ptr)))#define ssl_get_cipher_by_char(ssl,ptr) \ ((ssl)->method->get_cipher_by_char(ptr))/* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff * It is a bit of a mess of functions, but hell, think of it as * an opaque structure :-) */typedef struct ssl3_enc_method { int (*enc)(SSL *, int); int (*mac)(SSL *, unsigned char *, int); int (*setup_key_block)(SSL *); int (*generate_master_secret)(SSL *, unsigned char *, unsigned char *, int); int (*change_cipher_state)(SSL *, int); int (*final_finish_mac)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char *, int, unsigned char *); int finish_mac_length; int (*cert_verify_mac)(SSL *, EVP_MD_CTX *, unsigned char *); const char *client_finished_label; int client_finished_label_len; const char *server_finished_label; int server_finished_label_len; int (*alert_value)(int); } SSL3_ENC_METHOD;/* Used for holding the relevant compression methods loaded into SSL_CTX */typedef struct ssl3_comp_st { int comp_id; /* The identifier byte for this compression type */ char *name; /* Text name used for the compression type */ COMP_METHOD *method; /* The method :-) */ } SSL3_COMP;extern SSL3_ENC_METHOD ssl3_undef_enc_method;OPENSSL_EXTERN SSL_CIPHER ssl2_ciphers[];OPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[];SSL_METHOD *ssl_bad_method(int ver);SSL_METHOD *sslv2_base_method(void);SSL_METHOD *sslv23_base_method(void);SSL_METHOD *sslv3_base_method(void);extern SSL3_ENC_METHOD TLSv1_enc_data;extern SSL3_ENC_METHOD SSLv3_enc_data;extern SSL3_ENC_METHOD DTLSv1_enc_data;#define IMPLEMENT_tls1_meth_func(func_name, s_accept, s_connect, s_get_meth) \SSL_METHOD *func_name(void) \ { \ static SSL_METHOD func_name##_data= { \ TLS1_VERSION, \ tls1_new, \ tls1_clear, \ tls1_free, \ s_accept, \ s_connect, \ ssl3_read, \ ssl3_peek, \ ssl3_write, \ ssl3_shutdown, \ ssl3_renegotiate, \ ssl3_renegotiate_check, \ ssl3_get_message, \ ssl3_read_bytes, \ ssl3_write_bytes, \ ssl3_dispatch_alert, \ ssl3_ctrl, \ ssl3_ctx_ctrl, \ ssl3_get_cipher_by_char, \ ssl3_put_cipher_by_char, \ ssl3_pending, \ ssl3_num_ciphers, \ ssl3_get_cipher, \ s_get_meth, \ tls1_default_timeout, \ &TLSv1_enc_data, \ ssl_undefined_void_function, \ ssl3_callback_ctrl, \ ssl3_ctx_callback_ctrl, \ }; \ return &func_name##_data; \ }#define IMPLEMENT_ssl3_meth_func(func_name, s_accept, s_connect, s_get_meth) \SSL_METHOD *func_name(void) \ { \ static SSL_METHOD func_name##_data= { \ SSL3_VERSION, \ ssl3_new, \ ssl3_clear, \ ssl3_free, \ s_accept, \ s_connect, \ ssl3_read, \ ssl3_peek, \ ssl3_write, \ ssl3_shutdown, \ ssl3_renegotiate, \ ssl3_renegotiate_check, \ ssl3_get_message, \ ssl3_read_bytes, \ ssl3_write_bytes, \ ssl3_dispatch_alert, \ ssl3_ctrl, \ ssl3_ctx_ctrl, \ ssl3_get_cipher_by_char, \ ssl3_put_cipher_by_char, \ ssl3_pending, \ ssl3_num_ciphers, \ ssl3_get_cipher, \ s_get_meth, \ ssl3_default_timeout, \ &SSLv3_enc_data, \ ssl_undefined_void_function, \ ssl3_callback_ctrl, \ ssl3_ctx_callback_ctrl, \ }; \ return &func_name##_data; \ }#define IMPLEMENT_ssl23_meth_func(func_name, s_accept, s_connect, s_get_meth) \SSL_METHOD *func_name(void) \ { \ static SSL_METHOD func_name##_data= { \ TLS1_VERSION, \ tls1_new, \ tls1_clear, \ tls1_free, \ s_accept, \ s_connect, \ ssl23_read, \ ssl23_peek, \ ssl23_write, \ ssl_undefined_function, \ ssl_undefined_function, \ ssl_ok, \ ssl3_get_message, \ ssl3_read_bytes, \ ssl3_write_bytes, \ ssl3_dispatch_alert, \ ssl3_ctrl, \ ssl3_ctx_ctrl, \ ssl23_get_cipher_by_char, \ ssl23_put_cipher_by_char, \ ssl_undefined_const_function, \ ssl23_num_ciphers, \ ssl23_get_cipher, \ s_get_meth, \ ssl23_default_timeout, \ &ssl3_undef_enc_method, \ ssl_undefined_void_function, \ ssl3_callback_ctrl, \ ssl3_ctx_callback_ctrl, \ }; \ return &func_name##_data; \ }#define IMPLEMENT_ssl2_meth_func(func_name, s_accept, s_connect, s_get_meth) \SSL_METHOD *func_name(void) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -