Lines 623-626
Link Here
|
623 |
|
623 |
|
624 |
return r; |
624 |
return r; |
625 |
} |
625 |
} |
|
|
626 |
|
627 |
#if OPENSSL_API_COMPAT >= 0x10100000L |
628 |
#define SSL_library_init() OPENSSL_init_ssl(0, NULL) |
629 |
#define SSL_load_error_strings() \ |
630 |
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \ |
631 |
| OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) |
632 |
|
633 |
static void _set_protocol_version(const SSL_METHOD *m, int version) |
634 |
{ |
635 |
SSL_CTX *ctx = SSL_CTX_new(m); |
636 |
SSL_CTX_set_min_proto_version(ctx, version); |
637 |
SSL_CTX_set_max_proto_version(ctx, version); |
638 |
SSL_CTX_free(ctx); |
639 |
} |
640 |
|
641 |
/* |
642 |
* TLSv1_1 and TLSv1_2 are recent additions. Only sufficiently new versions of |
643 |
* OpenSSL support them. |
644 |
*/ |
645 |
const SSL_METHOD *Cryptography_TLSv1_1_method(void) |
646 |
{ |
647 |
const SSL_METHOD *m = TLS_method(); |
648 |
_set_protocol_version(m, TLS1_1_VERSION); |
649 |
return m; |
650 |
} |
651 |
|
652 |
const SSL_METHOD *Cryptography_TLSv1_1_server_method(void) |
653 |
{ |
654 |
const SSL_METHOD *m = TLS_server_method(); |
655 |
_set_protocol_version(m, TLS1_1_VERSION); |
656 |
return m; |
657 |
} |
658 |
|
659 |
const SSL_METHOD *Cryptography_TLSv1_1_client_method(void) |
660 |
{ |
661 |
const SSL_METHOD *m = TLS_client_method(); |
662 |
_set_protocol_version(m, TLS1_1_VERSION); |
663 |
return m; |
664 |
} |
665 |
|
666 |
const SSL_METHOD *Cryptography_TLSv1_2_method(void) |
667 |
{ |
668 |
const SSL_METHOD *m = TLS_method(); |
669 |
_set_protocol_version(m, TLS1_2_VERSION); |
670 |
return m; |
671 |
} |
672 |
|
673 |
const SSL_METHOD *Cryptography_TLSv1_2_server_method(void) |
674 |
{ |
675 |
const SSL_METHOD *m = TLS_server_method(); |
676 |
_set_protocol_version(m, TLS1_2_VERSION); |
677 |
return m; |
678 |
} |
679 |
|
680 |
const SSL_METHOD *Cryptography_TLSv1_2_client_method(void) |
681 |
{ |
682 |
const SSL_METHOD *m = TLS_client_method(); |
683 |
_set_protocol_version(m, TLS1_2_VERSION); |
684 |
return m; |
685 |
} |
686 |
|
687 |
#define TLSv1_1_method Cryptography_TLSv1_1_method |
688 |
#define TLSv1_1_server_method Cryptography_TLSv1_1_server_method |
689 |
#define TLSv1_1_client_method Cryptography_TLSv1_1_client_method |
690 |
#define TLSv1_2_method Cryptography_TLSv1_2_method |
691 |
#define TLSv1_2_server_method Cryptography_TLSv1_2_server_method |
692 |
#define TLSv1_2_client_method Cryptography_TLSv1_2_client_method |
693 |
|
694 |
#ifndef OPENSSL_NO_SSL3_METHOD |
695 |
const SSL_METHOD *Cryptography_SSLv3_method(void) |
696 |
{ |
697 |
const SSL_METHOD *m = TLS_method(); |
698 |
_set_protocol_version(m, SSL3_VERSION); |
699 |
return m; |
700 |
} |
701 |
|
702 |
const SSL_METHOD *Cryptography_SSLv3_server_method(void) |
703 |
{ |
704 |
const SSL_METHOD *m = TLS_server_method(); |
705 |
_set_protocol_version(m, SSL3_VERSION); |
706 |
return m; |
707 |
} |
708 |
|
709 |
const SSL_METHOD *Cryptography_SSLv3_client_method(void) |
710 |
{ |
711 |
const SSL_METHOD *m = TLS_client_method(); |
712 |
_set_protocol_version(m, SSL3_VERSION); |
713 |
return m; |
714 |
} |
715 |
|
716 |
#define SSLv3_method Cryptography_SSLv3_method |
717 |
#define SSLv3_server_method Cryptography_SSLv3_server_method |
718 |
#define SSLv3_client_method Cryptography_SSLv3_client_method |
719 |
#endif |
720 |
|
721 |
const SSL_METHOD *Cryptography_TLSv1_method(void) |
722 |
{ |
723 |
const SSL_METHOD *m = TLS_method(); |
724 |
_set_protocol_version(m, TLS1_VERSION); |
725 |
return m; |
726 |
} |
727 |
|
728 |
const SSL_METHOD *Cryptography_TLSv1_server_method(void) |
729 |
{ |
730 |
const SSL_METHOD *m = TLS_server_method(); |
731 |
_set_protocol_version(m, TLS1_VERSION); |
732 |
return m; |
733 |
} |
734 |
|
735 |
const SSL_METHOD *Cryptography_TLSv1_client_method(void) |
736 |
{ |
737 |
const SSL_METHOD *m = TLS_client_method(); |
738 |
_set_protocol_version(m, TLS1_VERSION); |
739 |
return m; |
740 |
} |
741 |
|
742 |
#define TLSv1_method Cryptography_TLSv1_method |
743 |
#define TLSv1_server_method Cryptography_TLSv1_server_method |
744 |
#define TLSv1_client_method Cryptography_TLSv1_client_method |
745 |
|
746 |
#if !defined(OPENSSL_NO_DTLS) && !CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 |
747 |
const SSL_METHOD *Cryptography_DTLSv1_method(void) |
748 |
{ |
749 |
const SSL_METHOD *m = TLS_method(); |
750 |
_set_protocol_version(m, DTLS1_VERSION); |
751 |
return m; |
752 |
} |
753 |
|
754 |
const SSL_METHOD *Cryptography_DTLSv1_server_method(void) |
755 |
{ |
756 |
const SSL_METHOD *m = TLS_server_method(); |
757 |
_set_protocol_version(m, DTLS1_VERSION); |
758 |
return m; |
759 |
} |
760 |
|
761 |
const SSL_METHOD *Cryptography_DTLSv1_client_method(void) |
762 |
{ |
763 |
const SSL_METHOD *m = TLS_client_method(); |
764 |
_set_protocol_version(m, DTLS1_VERSION); |
765 |
return m; |
766 |
} |
767 |
|
768 |
#define DTLSv1_method Cryptography_DTLSv1_method |
769 |
#define DTLSv1_server_method Cryptography_DTLSv1_server_method |
770 |
#define DTLSv1_client_method Cryptography_DTLSv1_client_method |
771 |
#endif |
772 |
#endif |
626 |
""" |
773 |
""" |