143 #ifndef HEADER_SSL_LOCL_H
144 #define HEADER_SSL_LOCL_H
153 #ifndef OPENSSL_NO_COMP
158 #ifndef OPENSSL_NO_RSA
161 #ifndef OPENSSL_NO_DSA
168 #ifdef OPENSSL_BUILD_SHLIBSSL
169 # undef OPENSSL_EXTERN
170 # define OPENSSL_EXTERN OPENSSL_EXPORT
175 #define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \
176 l|=(((unsigned long)(*((c)++)))<< 8), \
177 l|=(((unsigned long)(*((c)++)))<<16), \
178 l|=(((unsigned long)(*((c)++)))<<24))
181 #define c2ln(c,l1,l2,n) { \
185 case 8: l2 =((unsigned long)(*(--(c))))<<24; \
186 case 7: l2|=((unsigned long)(*(--(c))))<<16; \
187 case 6: l2|=((unsigned long)(*(--(c))))<< 8; \
188 case 5: l2|=((unsigned long)(*(--(c)))); \
189 case 4: l1 =((unsigned long)(*(--(c))))<<24; \
190 case 3: l1|=((unsigned long)(*(--(c))))<<16; \
191 case 2: l1|=((unsigned long)(*(--(c))))<< 8; \
192 case 1: l1|=((unsigned long)(*(--(c)))); \
196 #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
197 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
198 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
199 *((c)++)=(unsigned char)(((l)>>24)&0xff))
201 #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24, \
202 l|=((unsigned long)(*((c)++)))<<16, \
203 l|=((unsigned long)(*((c)++)))<< 8, \
204 l|=((unsigned long)(*((c)++))))
206 #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
207 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
208 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
209 *((c)++)=(unsigned char)(((l) )&0xff))
211 #define l2n6(l,c) (*((c)++)=(unsigned char)(((l)>>40)&0xff), \
212 *((c)++)=(unsigned char)(((l)>>32)&0xff), \
213 *((c)++)=(unsigned char)(((l)>>24)&0xff), \
214 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
215 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
216 *((c)++)=(unsigned char)(((l) )&0xff))
218 #define n2l6(c,l) (l =((BN_ULLONG)(*((c)++)))<<40, \
219 l|=((BN_ULLONG)(*((c)++)))<<32, \
220 l|=((BN_ULLONG)(*((c)++)))<<24, \
221 l|=((BN_ULLONG)(*((c)++)))<<16, \
222 l|=((BN_ULLONG)(*((c)++)))<< 8, \
223 l|=((BN_ULLONG)(*((c)++))))
226 #define l2cn(l1,l2,c,n) { \
229 case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
230 case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
231 case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
232 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
233 case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
234 case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
235 case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
236 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
240 #define n2s(c,s) ((s=(((unsigned int)(c[0]))<< 8)| \
241 (((unsigned int)(c[1])) )),c+=2)
242 #define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \
243 c[1]=(unsigned char)(((s) )&0xff)),c+=2)
245 #define n2l3(c,l) ((l =(((unsigned long)(c[0]))<<16)| \
246 (((unsigned long)(c[1]))<< 8)| \
247 (((unsigned long)(c[2])) )),c+=3)
249 #define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \
250 c[1]=(unsigned char)(((l)>> 8)&0xff), \
251 c[2]=(unsigned char)(((l) )&0xff)),c+=3)
255 #define SSL_DECRYPT 0
256 #define SSL_ENCRYPT 1
258 #define TWO_BYTE_BIT 0x80
259 #define SEC_ESC_BIT 0x40
260 #define TWO_BYTE_MASK 0x7fff
261 #define THREE_BYTE_MASK 0x3fff
263 #define INC32(a) ((a)=((a)+1)&0xffffffffL)
264 #define DEC32(a) ((a)=((a)-1)&0xffffffffL)
265 #define MAX_MAC_SIZE 20
282 #define SSL_kRSA 0x00000001L
283 #define SSL_kDHr 0x00000002L
284 #define SSL_kDHd 0x00000004L
285 #define SSL_kEDH 0x00000008L
286 #define SSL_kKRB5 0x00000010L
287 #define SSL_kECDHr 0x00000020L
288 #define SSL_kECDHe 0x00000040L
289 #define SSL_kEECDH 0x00000080L
290 #define SSL_kPSK 0x00000100L
291 #define SSL_kGOST 0x00000200L
292 #define SSL_kSRP 0x00000400L
295 #define SSL_aRSA 0x00000001L
296 #define SSL_aDSS 0x00000002L
297 #define SSL_aNULL 0x00000004L
298 #define SSL_aDH 0x00000008L
299 #define SSL_aECDH 0x00000010L
300 #define SSL_aKRB5 0x00000020L
301 #define SSL_aECDSA 0x00000040L
302 #define SSL_aPSK 0x00000080L
303 #define SSL_aGOST94 0x00000100L
304 #define SSL_aGOST01 0x00000200L
308 #define SSL_DES 0x00000001L
309 #define SSL_3DES 0x00000002L
310 #define SSL_RC4 0x00000004L
311 #define SSL_RC2 0x00000008L
312 #define SSL_IDEA 0x00000010L
313 #define SSL_eNULL 0x00000020L
314 #define SSL_AES128 0x00000040L
315 #define SSL_AES256 0x00000080L
316 #define SSL_CAMELLIA128 0x00000100L
317 #define SSL_CAMELLIA256 0x00000200L
318 #define SSL_eGOST2814789CNT 0x00000400L
319 #define SSL_SEED 0x00000800L
320 #define SSL_AES128GCM 0x00001000L
321 #define SSL_AES256GCM 0x00002000L
323 #define SSL_AES (SSL_AES128|SSL_AES256|SSL_AES128GCM|SSL_AES256GCM)
324 #define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256)
329 #define SSL_MD5 0x00000001L
330 #define SSL_SHA1 0x00000002L
331 #define SSL_GOST94 0x00000004L
332 #define SSL_GOST89MAC 0x00000008L
333 #define SSL_SHA256 0x00000010L
334 #define SSL_SHA384 0x00000020L
336 #define SSL_AEAD 0x00000040L
339 #define SSL_SSLV2 0x00000001L
340 #define SSL_SSLV3 0x00000002L
341 #define SSL_TLSV1 SSL_SSLV3
342 #define SSL_TLSV1_2 0x00000004L
347 #define SSL_HANDSHAKE_MAC_MD5 0x10
348 #define SSL_HANDSHAKE_MAC_SHA 0x20
349 #define SSL_HANDSHAKE_MAC_GOST94 0x40
350 #define SSL_HANDSHAKE_MAC_SHA256 0x80
351 #define SSL_HANDSHAKE_MAC_SHA384 0x100
352 #define SSL_HANDSHAKE_MAC_DEFAULT (SSL_HANDSHAKE_MAC_MD5 | SSL_HANDSHAKE_MAC_SHA)
356 #define SSL_MAX_DIGEST 6
358 #define TLS1_PRF_DGST_MASK (0xff << TLS1_PRF_DGST_SHIFT)
360 #define TLS1_PRF_DGST_SHIFT 10
361 #define TLS1_PRF_MD5 (SSL_HANDSHAKE_MAC_MD5 << TLS1_PRF_DGST_SHIFT)
362 #define TLS1_PRF_SHA1 (SSL_HANDSHAKE_MAC_SHA << TLS1_PRF_DGST_SHIFT)
363 #define TLS1_PRF_SHA256 (SSL_HANDSHAKE_MAC_SHA256 << TLS1_PRF_DGST_SHIFT)
364 #define TLS1_PRF_SHA384 (SSL_HANDSHAKE_MAC_SHA384 << TLS1_PRF_DGST_SHIFT)
365 #define TLS1_PRF_GOST94 (SSL_HANDSHAKE_MAC_GOST94 << TLS1_PRF_DGST_SHIFT)
366 #define TLS1_PRF (TLS1_PRF_MD5 | TLS1_PRF_SHA1)
370 #define TLS1_STREAM_MAC 0x04
389 #define SSL_EXP_MASK 0x00000003L
390 #define SSL_STRONG_MASK 0x000001fcL
392 #define SSL_NOT_EXP 0x00000001L
393 #define SSL_EXPORT 0x00000002L
395 #define SSL_STRONG_NONE 0x00000004L
396 #define SSL_EXP40 0x00000008L
397 #define SSL_MICRO (SSL_EXP40)
398 #define SSL_EXP56 0x00000010L
399 #define SSL_MINI (SSL_EXP56)
400 #define SSL_LOW 0x00000020L
401 #define SSL_MEDIUM 0x00000040L
402 #define SSL_HIGH 0x00000080L
403 #define SSL_FIPS 0x00000100L
420 #define SSL_IS_EXPORT(a) ((a)&SSL_EXPORT)
421 #define SSL_IS_EXPORT56(a) ((a)&SSL_EXP56)
422 #define SSL_IS_EXPORT40(a) ((a)&SSL_EXP40)
423 #define SSL_C_IS_EXPORT(c) SSL_IS_EXPORT((c)->algo_strength)
424 #define SSL_C_IS_EXPORT56(c) SSL_IS_EXPORT56((c)->algo_strength)
425 #define SSL_C_IS_EXPORT40(c) SSL_IS_EXPORT40((c)->algo_strength)
427 #define SSL_EXPORT_KEYLENGTH(a,s) (SSL_IS_EXPORT40(s) ? 5 : \
428 (a) == SSL_DES ? 8 : 7)
429 #define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024)
430 #define SSL_C_EXPORT_KEYLENGTH(c) SSL_EXPORT_KEYLENGTH((c)->algorithm_enc, \
432 #define SSL_C_EXPORT_PKEYLENGTH(c) SSL_EXPORT_PKEYLENGTH((c)->algo_strength)
438 #define SSL_PKEY_RSA_ENC 0
439 #define SSL_PKEY_RSA_SIGN 1
440 #define SSL_PKEY_DSA_SIGN 2
441 #define SSL_PKEY_DH_RSA 3
442 #define SSL_PKEY_DH_DSA 4
443 #define SSL_PKEY_ECC 5
444 #define SSL_PKEY_GOST94 6
445 #define SSL_PKEY_GOST01 7
446 #define SSL_PKEY_NUM 8
462 #ifndef OPENSSL_NO_EC
466 #define EXPLICIT_PRIME_CURVE_TYPE 1
467 #define EXPLICIT_CHAR2_CURVE_TYPE 2
468 #define NAMED_CURVE_TYPE 3
493 #ifndef OPENSSL_NO_RSA
495 RSA *(*rsa_tmp_cb)(
SSL *ssl,
int is_export,
int keysize);
497 #ifndef OPENSSL_NO_DH
499 DH *(*dh_tmp_cb)(
SSL *ssl,
int is_export,
int keysize);
501 #ifndef OPENSSL_NO_ECDH
504 EC_KEY *(*ecdh_tmp_cb)(
SSL *ssl,
int is_export,
int keysize);
525 #ifndef OPENSSL_NO_RSA
528 #ifndef OPENSSL_NO_DH
531 #ifndef OPENSSL_NO_ECDH
550 #define FP_ICC (int (*)(const void *,const void *))
551 #define ssl_put_cipher_by_char(ssl,ciph,ptr) \
552 ((ssl)->method->put_cipher_by_char((ciph),(ptr)))
553 #define ssl_get_cipher_by_char(ssl,ptr) \
554 ((ssl)->method->get_cipher_by_char(ptr))
575 const char *, size_t,
576 const unsigned char *, size_t,
580 #ifndef OPENSSL_NO_COMP
590 #ifndef OPENSSL_NO_BUF_FREELISTS
615 #define IMPLEMENT_tls_meth_func(version, func_name, s_accept, s_connect, \
617 const SSL_METHOD *func_name(void) \
619 static const SSL_METHOD func_name##_data= { \
631 ssl3_renegotiate_check, \
635 ssl3_dispatch_alert, \
638 ssl3_get_cipher_by_char, \
639 ssl3_put_cipher_by_char, \
644 tls1_default_timeout, \
646 ssl_undefined_void_function, \
647 ssl3_callback_ctrl, \
648 ssl3_ctx_callback_ctrl, \
650 return &func_name##_data; \
653 #define IMPLEMENT_ssl3_meth_func(func_name, s_accept, s_connect, s_get_meth) \
654 const SSL_METHOD *func_name(void) \
656 static const SSL_METHOD func_name##_data= { \
668 ssl3_renegotiate_check, \
672 ssl3_dispatch_alert, \
675 ssl3_get_cipher_by_char, \
676 ssl3_put_cipher_by_char, \
681 ssl3_default_timeout, \
683 ssl_undefined_void_function, \
684 ssl3_callback_ctrl, \
685 ssl3_ctx_callback_ctrl, \
687 return &func_name##_data; \
690 #define IMPLEMENT_ssl23_meth_func(func_name, s_accept, s_connect, s_get_meth) \
691 const SSL_METHOD *func_name(void) \
693 static const SSL_METHOD func_name##_data= { \
703 ssl_undefined_function, \
704 ssl_undefined_function, \
709 ssl3_dispatch_alert, \
712 ssl23_get_cipher_by_char, \
713 ssl23_put_cipher_by_char, \
714 ssl_undefined_const_function, \
718 ssl23_default_timeout, \
719 &ssl3_undef_enc_method, \
720 ssl_undefined_void_function, \
721 ssl3_callback_ctrl, \
722 ssl3_ctx_callback_ctrl, \
724 return &func_name##_data; \
727 #define IMPLEMENT_ssl2_meth_func(func_name, s_accept, s_connect, s_get_meth) \
728 const SSL_METHOD *func_name(void) \
730 static const SSL_METHOD func_name##_data= { \
749 ssl2_get_cipher_by_char, \
750 ssl2_put_cipher_by_char, \
755 ssl2_default_timeout, \
756 &ssl3_undef_enc_method, \
757 ssl_undefined_void_function, \
758 ssl2_callback_ctrl, \
759 ssl2_ctx_callback_ctrl, \
761 return &func_name##_data; \
764 #define IMPLEMENT_dtls1_meth_func(func_name, s_accept, s_connect, s_get_meth) \
765 const SSL_METHOD *func_name(void) \
767 static const SSL_METHOD func_name##_data= { \
779 ssl3_renegotiate_check, \
782 dtls1_write_app_data_bytes, \
783 dtls1_dispatch_alert, \
786 ssl3_get_cipher_by_char, \
787 ssl3_put_cipher_by_char, \
792 dtls1_default_timeout, \
794 ssl_undefined_void_function, \
795 ssl3_callback_ctrl, \
796 ssl3_ctx_callback_ctrl, \
798 return &func_name##_data; \
820 int (*put_cb)(
const SSL_CIPHER *,
unsigned char *));
827 const EVP_MD **md,
int *mac_pkey_type,
int *mac_secret_size,
SSL_COMP **comp);
844 void ssl2_mac(
SSL *s,
unsigned char *mac,
int send_data);
884 unsigned char *p,
int len);
947 unsigned char *p,
unsigned char mt,
unsigned long len,
948 unsigned long frag_off,
unsigned long frag_len);
959 unsigned long frag_off,
int *found);
992 #ifndef OPENSSL_NO_TLSEXT
994 # ifndef OPENSSL_NO_NEXTPROTONEG
1015 #ifndef OPENSSL_NO_NEXTPROTONEG
1050 unsigned int len,
int create_empty_fragement);
1061 const char *str,
int slen,
unsigned char *p);
1063 int tls1_mac(
SSL *ssl,
unsigned char *md,
int snd);
1065 unsigned char *p,
int len);
1067 const char *label,
size_t llen,
1068 const unsigned char *p,
size_t plen,
int use_context);
1073 #ifndef OPENSSL_NO_ECDH
1079 #ifndef OPENSSL_NO_EC
1084 #ifndef OPENSSL_NO_TLSEXT
1094 #ifndef OPENSSL_NO_HEARTBEATS
1101 #ifdef OPENSSL_NO_SHA256
1102 #define tlsext_tick_md EVP_sha1
1104 #define tlsext_tick_md EVP_sha256