diff options
Diffstat (limited to 'src/lib/libssl/s3_clnt.c')
-rw-r--r-- | src/lib/libssl/s3_clnt.c | 389 |
1 files changed, 302 insertions, 87 deletions
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c index eec45cfa48..e5853ede95 100644 --- a/src/lib/libssl/s3_clnt.c +++ b/src/lib/libssl/s3_clnt.c | |||
@@ -55,15 +55,68 @@ | |||
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | /* ==================================================================== | ||
59 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | ||
60 | * | ||
61 | * Redistribution and use in source and binary forms, with or without | ||
62 | * modification, are permitted provided that the following conditions | ||
63 | * are met: | ||
64 | * | ||
65 | * 1. Redistributions of source code must retain the above copyright | ||
66 | * notice, this list of conditions and the following disclaimer. | ||
67 | * | ||
68 | * 2. Redistributions in binary form must reproduce the above copyright | ||
69 | * notice, this list of conditions and the following disclaimer in | ||
70 | * the documentation and/or other materials provided with the | ||
71 | * distribution. | ||
72 | * | ||
73 | * 3. All advertising materials mentioning features or use of this | ||
74 | * software must display the following acknowledgment: | ||
75 | * "This product includes software developed by the OpenSSL Project | ||
76 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
77 | * | ||
78 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
79 | * endorse or promote products derived from this software without | ||
80 | * prior written permission. For written permission, please contact | ||
81 | * openssl-core@openssl.org. | ||
82 | * | ||
83 | * 5. Products derived from this software may not be called "OpenSSL" | ||
84 | * nor may "OpenSSL" appear in their names without prior written | ||
85 | * permission of the OpenSSL Project. | ||
86 | * | ||
87 | * 6. Redistributions of any form whatsoever must retain the following | ||
88 | * acknowledgment: | ||
89 | * "This product includes software developed by the OpenSSL Project | ||
90 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
91 | * | ||
92 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
93 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
94 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
95 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
96 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
97 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
98 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
99 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
100 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
101 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
102 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
103 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
104 | * ==================================================================== | ||
105 | * | ||
106 | * This product includes cryptographic software written by Eric Young | ||
107 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
108 | * Hudson (tjh@cryptsoft.com). | ||
109 | * | ||
110 | */ | ||
58 | 111 | ||
59 | #include <stdio.h> | 112 | #include <stdio.h> |
60 | #include <openssl/buffer.h> | 113 | #include <openssl/buffer.h> |
61 | #include <openssl/rand.h> | 114 | #include <openssl/rand.h> |
62 | #include <openssl/objects.h> | 115 | #include <openssl/objects.h> |
63 | #include <openssl/md5.h> | ||
64 | #include <openssl/sha.h> | ||
65 | #include <openssl/evp.h> | 116 | #include <openssl/evp.h> |
66 | #include "ssl_locl.h" | 117 | #include "ssl_locl.h" |
118 | #include "kssl_lcl.h" | ||
119 | #include <openssl/md5.h> | ||
67 | 120 | ||
68 | static SSL_METHOD *ssl3_get_client_method(int ver); | 121 | static SSL_METHOD *ssl3_get_client_method(int ver); |
69 | static int ssl3_client_hello(SSL *s); | 122 | static int ssl3_client_hello(SSL *s); |
@@ -106,7 +159,7 @@ int ssl3_connect(SSL *s) | |||
106 | BUF_MEM *buf; | 159 | BUF_MEM *buf; |
107 | unsigned long Time=time(NULL),l; | 160 | unsigned long Time=time(NULL),l; |
108 | long num1; | 161 | long num1; |
109 | void (*cb)()=NULL; | 162 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
110 | int ret= -1; | 163 | int ret= -1; |
111 | int new_state,state,skip=0;; | 164 | int new_state,state,skip=0;; |
112 | 165 | ||
@@ -119,8 +172,8 @@ int ssl3_connect(SSL *s) | |||
119 | else if (s->ctx->info_callback != NULL) | 172 | else if (s->ctx->info_callback != NULL) |
120 | cb=s->ctx->info_callback; | 173 | cb=s->ctx->info_callback; |
121 | 174 | ||
122 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
123 | s->in_handshake++; | 175 | s->in_handshake++; |
176 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
124 | 177 | ||
125 | for (;;) | 178 | for (;;) |
126 | { | 179 | { |
@@ -143,7 +196,7 @@ int ssl3_connect(SSL *s) | |||
143 | 196 | ||
144 | if ((s->version & 0xff00 ) != 0x0300) | 197 | if ((s->version & 0xff00 ) != 0x0300) |
145 | { | 198 | { |
146 | SSLerr(SSL_F_SSL3_CONNECT, SSL_R_INTERNAL_ERROR); | 199 | SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR); |
147 | ret = -1; | 200 | ret = -1; |
148 | goto end; | 201 | goto end; |
149 | } | 202 | } |
@@ -441,9 +494,9 @@ int ssl3_connect(SSL *s) | |||
441 | skip=0; | 494 | skip=0; |
442 | } | 495 | } |
443 | end: | 496 | end: |
497 | s->in_handshake--; | ||
444 | if (cb != NULL) | 498 | if (cb != NULL) |
445 | cb(s,SSL_CB_CONNECT_EXIT,ret); | 499 | cb(s,SSL_CB_CONNECT_EXIT,ret); |
446 | s->in_handshake--; | ||
447 | return(ret); | 500 | return(ret); |
448 | } | 501 | } |
449 | 502 | ||
@@ -554,7 +607,7 @@ static int ssl3_get_server_hello(SSL *s) | |||
554 | &ok); | 607 | &ok); |
555 | 608 | ||
556 | if (!ok) return((int)n); | 609 | if (!ok) return((int)n); |
557 | d=p=(unsigned char *)s->init_buf->data; | 610 | d=p=(unsigned char *)s->init_msg; |
558 | 611 | ||
559 | if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff))) | 612 | if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff))) |
560 | { | 613 | { |
@@ -687,16 +740,13 @@ static int ssl3_get_server_certificate(SSL *s) | |||
687 | STACK_OF(X509) *sk=NULL; | 740 | STACK_OF(X509) *sk=NULL; |
688 | SESS_CERT *sc; | 741 | SESS_CERT *sc; |
689 | EVP_PKEY *pkey=NULL; | 742 | EVP_PKEY *pkey=NULL; |
743 | int need_cert = 1; /* VRS: 0=> will allow null cert if auth == KRB5 */ | ||
690 | 744 | ||
691 | n=ssl3_get_message(s, | 745 | n=ssl3_get_message(s, |
692 | SSL3_ST_CR_CERT_A, | 746 | SSL3_ST_CR_CERT_A, |
693 | SSL3_ST_CR_CERT_B, | 747 | SSL3_ST_CR_CERT_B, |
694 | -1, | 748 | -1, |
695 | #if defined(MSDOS) && !defined(WIN32) | 749 | s->max_cert_list, |
696 | 1024*30, /* 30k max cert list :-) */ | ||
697 | #else | ||
698 | 1024*100, /* 100k max cert list :-) */ | ||
699 | #endif | ||
700 | &ok); | 750 | &ok); |
701 | 751 | ||
702 | if (!ok) return((int)n); | 752 | if (!ok) return((int)n); |
@@ -713,7 +763,7 @@ static int ssl3_get_server_certificate(SSL *s) | |||
713 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE); | 763 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE); |
714 | goto f_err; | 764 | goto f_err; |
715 | } | 765 | } |
716 | d=p=(unsigned char *)s->init_buf->data; | 766 | d=p=(unsigned char *)s->init_msg; |
717 | 767 | ||
718 | if ((sk=sk_X509_new_null()) == NULL) | 768 | if ((sk=sk_X509_new_null()) == NULL) |
719 | { | 769 | { |
@@ -763,7 +813,12 @@ static int ssl3_get_server_certificate(SSL *s) | |||
763 | } | 813 | } |
764 | 814 | ||
765 | i=ssl_verify_cert_chain(s,sk); | 815 | i=ssl_verify_cert_chain(s,sk); |
766 | if ((s->verify_mode != SSL_VERIFY_NONE) && (!i)) | 816 | if ((s->verify_mode != SSL_VERIFY_NONE) && (!i) |
817 | #ifndef OPENSSL_NO_KRB5 | ||
818 | && (s->s3->tmp.new_cipher->algorithms & (SSL_MKEY_MASK|SSL_AUTH_MASK)) | ||
819 | != (SSL_aKRB5|SSL_kKRB5) | ||
820 | #endif /* OPENSSL_NO_KRB5 */ | ||
821 | ) | ||
767 | { | 822 | { |
768 | al=ssl_verify_alarm_type(s->verify_result); | 823 | al=ssl_verify_alarm_type(s->verify_result); |
769 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED); | 824 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED); |
@@ -782,39 +837,66 @@ static int ssl3_get_server_certificate(SSL *s) | |||
782 | * certificate, which we don't include in s3_srvr.c */ | 837 | * certificate, which we don't include in s3_srvr.c */ |
783 | x=sk_X509_value(sk,0); | 838 | x=sk_X509_value(sk,0); |
784 | sk=NULL; | 839 | sk=NULL; |
840 | /* VRS 19990621: possible memory leak; sk=null ==> !sk_pop_free() @end*/ | ||
785 | 841 | ||
786 | pkey=X509_get_pubkey(x); | 842 | pkey=X509_get_pubkey(x); |
787 | 843 | ||
788 | if ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey)) | 844 | /* VRS: allow null cert if auth == KRB5 */ |
845 | need_cert = ((s->s3->tmp.new_cipher->algorithms | ||
846 | & (SSL_MKEY_MASK|SSL_AUTH_MASK)) | ||
847 | == (SSL_aKRB5|SSL_kKRB5))? 0: 1; | ||
848 | |||
849 | #ifdef KSSL_DEBUG | ||
850 | printf("pkey,x = %p, %p\n", pkey,x); | ||
851 | printf("ssl_cert_type(x,pkey) = %d\n", ssl_cert_type(x,pkey)); | ||
852 | printf("cipher, alg, nc = %s, %lx, %d\n", s->s3->tmp.new_cipher->name, | ||
853 | s->s3->tmp.new_cipher->algorithms, need_cert); | ||
854 | #endif /* KSSL_DEBUG */ | ||
855 | |||
856 | if (need_cert && ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey))) | ||
789 | { | 857 | { |
790 | x=NULL; | 858 | x=NULL; |
791 | al=SSL3_AL_FATAL; | 859 | al=SSL3_AL_FATAL; |
792 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS); | 860 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, |
861 | SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS); | ||
793 | goto f_err; | 862 | goto f_err; |
794 | } | 863 | } |
795 | 864 | ||
796 | i=ssl_cert_type(x,pkey); | 865 | i=ssl_cert_type(x,pkey); |
797 | if (i < 0) | 866 | if (need_cert && i < 0) |
798 | { | 867 | { |
799 | x=NULL; | 868 | x=NULL; |
800 | al=SSL3_AL_FATAL; | 869 | al=SSL3_AL_FATAL; |
801 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNKNOWN_CERTIFICATE_TYPE); | 870 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, |
871 | SSL_R_UNKNOWN_CERTIFICATE_TYPE); | ||
802 | goto f_err; | 872 | goto f_err; |
803 | } | 873 | } |
804 | 874 | ||
805 | sc->peer_cert_type=i; | 875 | if (need_cert) |
806 | CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); | 876 | { |
807 | if (sc->peer_pkeys[i].x509 != NULL) /* Why would this ever happen? | 877 | sc->peer_cert_type=i; |
808 | * We just created sc a couple of | 878 | CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); |
809 | * lines ago. */ | 879 | /* Why would the following ever happen? |
810 | X509_free(sc->peer_pkeys[i].x509); | 880 | * We just created sc a couple of lines ago. */ |
811 | sc->peer_pkeys[i].x509=x; | 881 | if (sc->peer_pkeys[i].x509 != NULL) |
812 | sc->peer_key= &(sc->peer_pkeys[i]); | 882 | X509_free(sc->peer_pkeys[i].x509); |
813 | 883 | sc->peer_pkeys[i].x509=x; | |
814 | if (s->session->peer != NULL) | 884 | sc->peer_key= &(sc->peer_pkeys[i]); |
815 | X509_free(s->session->peer); | 885 | |
816 | CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); | 886 | if (s->session->peer != NULL) |
817 | s->session->peer=x; | 887 | X509_free(s->session->peer); |
888 | CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); | ||
889 | s->session->peer=x; | ||
890 | } | ||
891 | else | ||
892 | { | ||
893 | sc->peer_cert_type=i; | ||
894 | sc->peer_key= NULL; | ||
895 | |||
896 | if (s->session->peer != NULL) | ||
897 | X509_free(s->session->peer); | ||
898 | s->session->peer=NULL; | ||
899 | } | ||
818 | s->session->verify_result = s->verify_result; | 900 | s->session->verify_result = s->verify_result; |
819 | 901 | ||
820 | x=NULL; | 902 | x=NULL; |
@@ -834,7 +916,7 @@ err: | |||
834 | 916 | ||
835 | static int ssl3_get_key_exchange(SSL *s) | 917 | static int ssl3_get_key_exchange(SSL *s) |
836 | { | 918 | { |
837 | #ifndef NO_RSA | 919 | #ifndef OPENSSL_NO_RSA |
838 | unsigned char *q,md_buf[EVP_MAX_MD_SIZE*2]; | 920 | unsigned char *q,md_buf[EVP_MAX_MD_SIZE*2]; |
839 | #endif | 921 | #endif |
840 | EVP_MD_CTX md_ctx; | 922 | EVP_MD_CTX md_ctx; |
@@ -842,18 +924,20 @@ static int ssl3_get_key_exchange(SSL *s) | |||
842 | int al,i,j,param_len,ok; | 924 | int al,i,j,param_len,ok; |
843 | long n,alg; | 925 | long n,alg; |
844 | EVP_PKEY *pkey=NULL; | 926 | EVP_PKEY *pkey=NULL; |
845 | #ifndef NO_RSA | 927 | #ifndef OPENSSL_NO_RSA |
846 | RSA *rsa=NULL; | 928 | RSA *rsa=NULL; |
847 | #endif | 929 | #endif |
848 | #ifndef NO_DH | 930 | #ifndef OPENSSL_NO_DH |
849 | DH *dh=NULL; | 931 | DH *dh=NULL; |
850 | #endif | 932 | #endif |
851 | 933 | ||
934 | /* use same message size as in ssl3_get_certificate_request() | ||
935 | * as ServerKeyExchange message may be skipped */ | ||
852 | n=ssl3_get_message(s, | 936 | n=ssl3_get_message(s, |
853 | SSL3_ST_CR_KEY_EXCH_A, | 937 | SSL3_ST_CR_KEY_EXCH_A, |
854 | SSL3_ST_CR_KEY_EXCH_B, | 938 | SSL3_ST_CR_KEY_EXCH_B, |
855 | -1, | 939 | -1, |
856 | 1024*8, /* ?? */ | 940 | s->max_cert_list, |
857 | &ok); | 941 | &ok); |
858 | 942 | ||
859 | if (!ok) return((int)n); | 943 | if (!ok) return((int)n); |
@@ -864,18 +948,18 @@ static int ssl3_get_key_exchange(SSL *s) | |||
864 | return(1); | 948 | return(1); |
865 | } | 949 | } |
866 | 950 | ||
867 | param=p=(unsigned char *)s->init_buf->data; | 951 | param=p=(unsigned char *)s->init_msg; |
868 | 952 | ||
869 | if (s->session->sess_cert != NULL) | 953 | if (s->session->sess_cert != NULL) |
870 | { | 954 | { |
871 | #ifndef NO_RSA | 955 | #ifndef OPENSSL_NO_RSA |
872 | if (s->session->sess_cert->peer_rsa_tmp != NULL) | 956 | if (s->session->sess_cert->peer_rsa_tmp != NULL) |
873 | { | 957 | { |
874 | RSA_free(s->session->sess_cert->peer_rsa_tmp); | 958 | RSA_free(s->session->sess_cert->peer_rsa_tmp); |
875 | s->session->sess_cert->peer_rsa_tmp=NULL; | 959 | s->session->sess_cert->peer_rsa_tmp=NULL; |
876 | } | 960 | } |
877 | #endif | 961 | #endif |
878 | #ifndef NO_DH | 962 | #ifndef OPENSSL_NO_DH |
879 | if (s->session->sess_cert->peer_dh_tmp) | 963 | if (s->session->sess_cert->peer_dh_tmp) |
880 | { | 964 | { |
881 | DH_free(s->session->sess_cert->peer_dh_tmp); | 965 | DH_free(s->session->sess_cert->peer_dh_tmp); |
@@ -890,8 +974,9 @@ static int ssl3_get_key_exchange(SSL *s) | |||
890 | 974 | ||
891 | param_len=0; | 975 | param_len=0; |
892 | alg=s->s3->tmp.new_cipher->algorithms; | 976 | alg=s->s3->tmp.new_cipher->algorithms; |
977 | EVP_MD_CTX_init(&md_ctx); | ||
893 | 978 | ||
894 | #ifndef NO_RSA | 979 | #ifndef OPENSSL_NO_RSA |
895 | if (alg & SSL_kRSA) | 980 | if (alg & SSL_kRSA) |
896 | { | 981 | { |
897 | if ((rsa=RSA_new()) == NULL) | 982 | if ((rsa=RSA_new()) == NULL) |
@@ -935,17 +1020,17 @@ static int ssl3_get_key_exchange(SSL *s) | |||
935 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); | 1020 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); |
936 | else | 1021 | else |
937 | { | 1022 | { |
938 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1023 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
939 | goto err; | 1024 | goto err; |
940 | } | 1025 | } |
941 | s->session->sess_cert->peer_rsa_tmp=rsa; | 1026 | s->session->sess_cert->peer_rsa_tmp=rsa; |
942 | rsa=NULL; | 1027 | rsa=NULL; |
943 | } | 1028 | } |
944 | #else /* NO_RSA */ | 1029 | #else /* OPENSSL_NO_RSA */ |
945 | if (0) | 1030 | if (0) |
946 | ; | 1031 | ; |
947 | #endif | 1032 | #endif |
948 | #ifndef NO_DH | 1033 | #ifndef OPENSSL_NO_DH |
949 | else if (alg & SSL_kEDH) | 1034 | else if (alg & SSL_kEDH) |
950 | { | 1035 | { |
951 | if ((dh=DH_new()) == NULL) | 1036 | if ((dh=DH_new()) == NULL) |
@@ -999,14 +1084,14 @@ static int ssl3_get_key_exchange(SSL *s) | |||
999 | p+=i; | 1084 | p+=i; |
1000 | n-=param_len; | 1085 | n-=param_len; |
1001 | 1086 | ||
1002 | #ifndef NO_RSA | 1087 | #ifndef OPENSSL_NO_RSA |
1003 | if (alg & SSL_aRSA) | 1088 | if (alg & SSL_aRSA) |
1004 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); | 1089 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); |
1005 | #else | 1090 | #else |
1006 | if (0) | 1091 | if (0) |
1007 | ; | 1092 | ; |
1008 | #endif | 1093 | #endif |
1009 | #ifndef NO_DSA | 1094 | #ifndef OPENSSL_NO_DSA |
1010 | else if (alg & SSL_aDSS) | 1095 | else if (alg & SSL_aDSS) |
1011 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509); | 1096 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509); |
1012 | #endif | 1097 | #endif |
@@ -1021,7 +1106,7 @@ static int ssl3_get_key_exchange(SSL *s) | |||
1021 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER); | 1106 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER); |
1022 | goto f_err; | 1107 | goto f_err; |
1023 | } | 1108 | } |
1024 | #endif /* !NO_DH */ | 1109 | #endif /* !OPENSSL_NO_DH */ |
1025 | if (alg & SSL_aFZA) | 1110 | if (alg & SSL_aFZA) |
1026 | { | 1111 | { |
1027 | al=SSL_AD_HANDSHAKE_FAILURE; | 1112 | al=SSL_AD_HANDSHAKE_FAILURE; |
@@ -1048,7 +1133,7 @@ static int ssl3_get_key_exchange(SSL *s) | |||
1048 | goto f_err; | 1133 | goto f_err; |
1049 | } | 1134 | } |
1050 | 1135 | ||
1051 | #ifndef NO_RSA | 1136 | #ifndef OPENSSL_NO_RSA |
1052 | if (pkey->type == EVP_PKEY_RSA) | 1137 | if (pkey->type == EVP_PKEY_RSA) |
1053 | { | 1138 | { |
1054 | int num; | 1139 | int num; |
@@ -1057,12 +1142,12 @@ static int ssl3_get_key_exchange(SSL *s) | |||
1057 | q=md_buf; | 1142 | q=md_buf; |
1058 | for (num=2; num > 0; num--) | 1143 | for (num=2; num > 0; num--) |
1059 | { | 1144 | { |
1060 | EVP_DigestInit(&md_ctx,(num == 2) | 1145 | EVP_DigestInit_ex(&md_ctx,(num == 2) |
1061 | ?s->ctx->md5:s->ctx->sha1); | 1146 | ?s->ctx->md5:s->ctx->sha1, NULL); |
1062 | EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); | 1147 | EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); |
1063 | EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); | 1148 | EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); |
1064 | EVP_DigestUpdate(&md_ctx,param,param_len); | 1149 | EVP_DigestUpdate(&md_ctx,param,param_len); |
1065 | EVP_DigestFinal(&md_ctx,q,(unsigned int *)&i); | 1150 | EVP_DigestFinal_ex(&md_ctx,q,(unsigned int *)&i); |
1066 | q+=i; | 1151 | q+=i; |
1067 | j+=i; | 1152 | j+=i; |
1068 | } | 1153 | } |
@@ -1084,11 +1169,11 @@ static int ssl3_get_key_exchange(SSL *s) | |||
1084 | } | 1169 | } |
1085 | else | 1170 | else |
1086 | #endif | 1171 | #endif |
1087 | #ifndef NO_DSA | 1172 | #ifndef OPENSSL_NO_DSA |
1088 | if (pkey->type == EVP_PKEY_DSA) | 1173 | if (pkey->type == EVP_PKEY_DSA) |
1089 | { | 1174 | { |
1090 | /* lets do DSS */ | 1175 | /* lets do DSS */ |
1091 | EVP_VerifyInit(&md_ctx,EVP_dss1()); | 1176 | EVP_VerifyInit_ex(&md_ctx,EVP_dss1(), NULL); |
1092 | EVP_VerifyUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); | 1177 | EVP_VerifyUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); |
1093 | EVP_VerifyUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); | 1178 | EVP_VerifyUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); |
1094 | EVP_VerifyUpdate(&md_ctx,param,param_len); | 1179 | EVP_VerifyUpdate(&md_ctx,param,param_len); |
@@ -1103,7 +1188,7 @@ static int ssl3_get_key_exchange(SSL *s) | |||
1103 | else | 1188 | else |
1104 | #endif | 1189 | #endif |
1105 | { | 1190 | { |
1106 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1191 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
1107 | goto err; | 1192 | goto err; |
1108 | } | 1193 | } |
1109 | } | 1194 | } |
@@ -1112,7 +1197,7 @@ static int ssl3_get_key_exchange(SSL *s) | |||
1112 | /* still data left over */ | 1197 | /* still data left over */ |
1113 | if (!(alg & SSL_aNULL)) | 1198 | if (!(alg & SSL_aNULL)) |
1114 | { | 1199 | { |
1115 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1200 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
1116 | goto err; | 1201 | goto err; |
1117 | } | 1202 | } |
1118 | if (n != 0) | 1203 | if (n != 0) |
@@ -1123,19 +1208,21 @@ static int ssl3_get_key_exchange(SSL *s) | |||
1123 | } | 1208 | } |
1124 | } | 1209 | } |
1125 | EVP_PKEY_free(pkey); | 1210 | EVP_PKEY_free(pkey); |
1211 | EVP_MD_CTX_cleanup(&md_ctx); | ||
1126 | return(1); | 1212 | return(1); |
1127 | f_err: | 1213 | f_err: |
1128 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 1214 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
1129 | err: | 1215 | err: |
1130 | EVP_PKEY_free(pkey); | 1216 | EVP_PKEY_free(pkey); |
1131 | #ifndef NO_RSA | 1217 | #ifndef OPENSSL_NO_RSA |
1132 | if (rsa != NULL) | 1218 | if (rsa != NULL) |
1133 | RSA_free(rsa); | 1219 | RSA_free(rsa); |
1134 | #endif | 1220 | #endif |
1135 | #ifndef NO_DH | 1221 | #ifndef OPENSSL_NO_DH |
1136 | if (dh != NULL) | 1222 | if (dh != NULL) |
1137 | DH_free(dh); | 1223 | DH_free(dh); |
1138 | #endif | 1224 | #endif |
1225 | EVP_MD_CTX_cleanup(&md_ctx); | ||
1139 | return(-1); | 1226 | return(-1); |
1140 | } | 1227 | } |
1141 | 1228 | ||
@@ -1152,11 +1239,7 @@ static int ssl3_get_certificate_request(SSL *s) | |||
1152 | SSL3_ST_CR_CERT_REQ_A, | 1239 | SSL3_ST_CR_CERT_REQ_A, |
1153 | SSL3_ST_CR_CERT_REQ_B, | 1240 | SSL3_ST_CR_CERT_REQ_B, |
1154 | -1, | 1241 | -1, |
1155 | #if defined(MSDOS) && !defined(WIN32) | 1242 | s->max_cert_list, |
1156 | 1024*30, /* 30k max cert list :-) */ | ||
1157 | #else | ||
1158 | 1024*100, /* 100k max cert list :-) */ | ||
1159 | #endif | ||
1160 | &ok); | 1243 | &ok); |
1161 | 1244 | ||
1162 | if (!ok) return((int)n); | 1245 | if (!ok) return((int)n); |
@@ -1188,7 +1271,7 @@ static int ssl3_get_certificate_request(SSL *s) | |||
1188 | } | 1271 | } |
1189 | } | 1272 | } |
1190 | 1273 | ||
1191 | d=p=(unsigned char *)s->init_buf->data; | 1274 | d=p=(unsigned char *)s->init_msg; |
1192 | 1275 | ||
1193 | if ((ca_sk=sk_X509_NAME_new(ca_dn_cmp)) == NULL) | 1276 | if ((ca_sk=sk_X509_NAME_new(ca_dn_cmp)) == NULL) |
1194 | { | 1277 | { |
@@ -1308,6 +1391,7 @@ static int ssl3_get_server_done(SSL *s) | |||
1308 | /* should contain no data */ | 1391 | /* should contain no data */ |
1309 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR); | 1392 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR); |
1310 | SSLerr(SSL_F_SSL3_GET_SERVER_DONE,SSL_R_LENGTH_MISMATCH); | 1393 | SSLerr(SSL_F_SSL3_GET_SERVER_DONE,SSL_R_LENGTH_MISMATCH); |
1394 | return -1; | ||
1311 | } | 1395 | } |
1312 | ret=1; | 1396 | ret=1; |
1313 | return(ret); | 1397 | return(ret); |
@@ -1318,10 +1402,13 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1318 | unsigned char *p,*d; | 1402 | unsigned char *p,*d; |
1319 | int n; | 1403 | int n; |
1320 | unsigned long l; | 1404 | unsigned long l; |
1321 | #ifndef NO_RSA | 1405 | #ifndef OPENSSL_NO_RSA |
1322 | unsigned char *q; | 1406 | unsigned char *q; |
1323 | EVP_PKEY *pkey=NULL; | 1407 | EVP_PKEY *pkey=NULL; |
1324 | #endif | 1408 | #endif |
1409 | #ifndef OPENSSL_NO_KRB5 | ||
1410 | KSSL_ERR kssl_err; | ||
1411 | #endif /* OPENSSL_NO_KRB5 */ | ||
1325 | 1412 | ||
1326 | if (s->state == SSL3_ST_CW_KEY_EXCH_A) | 1413 | if (s->state == SSL3_ST_CW_KEY_EXCH_A) |
1327 | { | 1414 | { |
@@ -1330,8 +1417,10 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1330 | 1417 | ||
1331 | l=s->s3->tmp.new_cipher->algorithms; | 1418 | l=s->s3->tmp.new_cipher->algorithms; |
1332 | 1419 | ||
1333 | #ifndef NO_RSA | 1420 | /* Fool emacs indentation */ |
1334 | if (l & SSL_kRSA) | 1421 | if (0) {} |
1422 | #ifndef OPENSSL_NO_RSA | ||
1423 | else if (l & SSL_kRSA) | ||
1335 | { | 1424 | { |
1336 | RSA *rsa; | 1425 | RSA *rsa; |
1337 | unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; | 1426 | unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; |
@@ -1345,7 +1434,7 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1345 | (pkey->type != EVP_PKEY_RSA) || | 1434 | (pkey->type != EVP_PKEY_RSA) || |
1346 | (pkey->pkey.rsa == NULL)) | 1435 | (pkey->pkey.rsa == NULL)) |
1347 | { | 1436 | { |
1348 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1437 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
1349 | goto err; | 1438 | goto err; |
1350 | } | 1439 | } |
1351 | rsa=pkey->pkey.rsa; | 1440 | rsa=pkey->pkey.rsa; |
@@ -1388,10 +1477,136 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1388 | tmp_buf,SSL_MAX_MASTER_KEY_LENGTH); | 1477 | tmp_buf,SSL_MAX_MASTER_KEY_LENGTH); |
1389 | memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH); | 1478 | memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH); |
1390 | } | 1479 | } |
1391 | else | ||
1392 | #endif | 1480 | #endif |
1393 | #ifndef NO_DH | 1481 | #ifndef OPENSSL_NO_KRB5 |
1394 | if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | 1482 | else if (l & SSL_kKRB5) |
1483 | { | ||
1484 | krb5_error_code krb5rc; | ||
1485 | KSSL_CTX *kssl_ctx = s->kssl_ctx; | ||
1486 | /* krb5_data krb5_ap_req; */ | ||
1487 | krb5_data *enc_ticket; | ||
1488 | krb5_data authenticator, *authp = NULL; | ||
1489 | EVP_CIPHER_CTX ciph_ctx; | ||
1490 | EVP_CIPHER *enc = NULL; | ||
1491 | unsigned char iv[EVP_MAX_IV_LENGTH]; | ||
1492 | unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; | ||
1493 | unsigned char epms[SSL_MAX_MASTER_KEY_LENGTH | ||
1494 | + EVP_MAX_IV_LENGTH]; | ||
1495 | int padl, outl = sizeof(epms); | ||
1496 | |||
1497 | EVP_CIPHER_CTX_init(&ciph_ctx); | ||
1498 | |||
1499 | #ifdef KSSL_DEBUG | ||
1500 | printf("ssl3_send_client_key_exchange(%lx & %lx)\n", | ||
1501 | l, SSL_kKRB5); | ||
1502 | #endif /* KSSL_DEBUG */ | ||
1503 | |||
1504 | authp = NULL; | ||
1505 | #ifdef KRB5SENDAUTH | ||
1506 | if (KRB5SENDAUTH) authp = &authenticator; | ||
1507 | #endif /* KRB5SENDAUTH */ | ||
1508 | |||
1509 | krb5rc = kssl_cget_tkt(kssl_ctx, &enc_ticket, authp, | ||
1510 | &kssl_err); | ||
1511 | enc = kssl_map_enc(kssl_ctx->enctype); | ||
1512 | if (enc == NULL) | ||
1513 | goto err; | ||
1514 | #ifdef KSSL_DEBUG | ||
1515 | { | ||
1516 | printf("kssl_cget_tkt rtn %d\n", krb5rc); | ||
1517 | if (krb5rc && kssl_err.text) | ||
1518 | printf("kssl_cget_tkt kssl_err=%s\n", kssl_err.text); | ||
1519 | } | ||
1520 | #endif /* KSSL_DEBUG */ | ||
1521 | |||
1522 | if (krb5rc) | ||
1523 | { | ||
1524 | ssl3_send_alert(s,SSL3_AL_FATAL, | ||
1525 | SSL_AD_HANDSHAKE_FAILURE); | ||
1526 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
1527 | kssl_err.reason); | ||
1528 | goto err; | ||
1529 | } | ||
1530 | |||
1531 | /* 20010406 VRS - Earlier versions used KRB5 AP_REQ | ||
1532 | ** in place of RFC 2712 KerberosWrapper, as in: | ||
1533 | ** | ||
1534 | ** Send ticket (copy to *p, set n = length) | ||
1535 | ** n = krb5_ap_req.length; | ||
1536 | ** memcpy(p, krb5_ap_req.data, krb5_ap_req.length); | ||
1537 | ** if (krb5_ap_req.data) | ||
1538 | ** kssl_krb5_free_data_contents(NULL,&krb5_ap_req); | ||
1539 | ** | ||
1540 | ** Now using real RFC 2712 KerberosWrapper | ||
1541 | ** (Thanks to Simon Wilkinson <sxw@sxw.org.uk>) | ||
1542 | ** Note: 2712 "opaque" types are here replaced | ||
1543 | ** with a 2-byte length followed by the value. | ||
1544 | ** Example: | ||
1545 | ** KerberosWrapper= xx xx asn1ticket 0 0 xx xx encpms | ||
1546 | ** Where "xx xx" = length bytes. Shown here with | ||
1547 | ** optional authenticator omitted. | ||
1548 | */ | ||
1549 | |||
1550 | /* KerberosWrapper.Ticket */ | ||
1551 | s2n(enc_ticket->length,p); | ||
1552 | memcpy(p, enc_ticket->data, enc_ticket->length); | ||
1553 | p+= enc_ticket->length; | ||
1554 | n = enc_ticket->length + 2; | ||
1555 | |||
1556 | /* KerberosWrapper.Authenticator */ | ||
1557 | if (authp && authp->length) | ||
1558 | { | ||
1559 | s2n(authp->length,p); | ||
1560 | memcpy(p, authp->data, authp->length); | ||
1561 | p+= authp->length; | ||
1562 | n+= authp->length + 2; | ||
1563 | |||
1564 | free(authp->data); | ||
1565 | authp->data = NULL; | ||
1566 | authp->length = 0; | ||
1567 | } | ||
1568 | else | ||
1569 | { | ||
1570 | s2n(0,p);/* null authenticator length */ | ||
1571 | n+=2; | ||
1572 | } | ||
1573 | |||
1574 | if (RAND_bytes(tmp_buf,SSL_MAX_MASTER_KEY_LENGTH) <= 0) | ||
1575 | goto err; | ||
1576 | |||
1577 | /* 20010420 VRS. Tried it this way; failed. | ||
1578 | ** EVP_EncryptInit_ex(&ciph_ctx,enc, NULL,NULL); | ||
1579 | ** EVP_CIPHER_CTX_set_key_length(&ciph_ctx, | ||
1580 | ** kssl_ctx->length); | ||
1581 | ** EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv); | ||
1582 | */ | ||
1583 | |||
1584 | memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */ | ||
1585 | EVP_EncryptInit_ex(&ciph_ctx,enc, NULL, | ||
1586 | kssl_ctx->key,iv); | ||
1587 | EVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf, | ||
1588 | SSL_MAX_MASTER_KEY_LENGTH); | ||
1589 | EVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl); | ||
1590 | outl += padl; | ||
1591 | EVP_CIPHER_CTX_cleanup(&ciph_ctx); | ||
1592 | |||
1593 | /* KerberosWrapper.EncryptedPreMasterSecret */ | ||
1594 | s2n(outl,p); | ||
1595 | memcpy(p, epms, outl); | ||
1596 | p+=outl; | ||
1597 | n+=outl + 2; | ||
1598 | |||
1599 | s->session->master_key_length= | ||
1600 | s->method->ssl3_enc->generate_master_secret(s, | ||
1601 | s->session->master_key, | ||
1602 | tmp_buf, SSL_MAX_MASTER_KEY_LENGTH); | ||
1603 | |||
1604 | memset(tmp_buf, 0, SSL_MAX_MASTER_KEY_LENGTH); | ||
1605 | memset(epms, 0, outl); | ||
1606 | } | ||
1607 | #endif | ||
1608 | #ifndef OPENSSL_NO_DH | ||
1609 | else if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | ||
1395 | { | 1610 | { |
1396 | DH *dh_srvr,*dh_clnt; | 1611 | DH *dh_srvr,*dh_clnt; |
1397 | 1612 | ||
@@ -1445,11 +1660,11 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1445 | 1660 | ||
1446 | /* perhaps clean things up a bit EAY EAY EAY EAY*/ | 1661 | /* perhaps clean things up a bit EAY EAY EAY EAY*/ |
1447 | } | 1662 | } |
1448 | else | ||
1449 | #endif | 1663 | #endif |
1664 | else | ||
1450 | { | 1665 | { |
1451 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); | 1666 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); |
1452 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1667 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
1453 | goto err; | 1668 | goto err; |
1454 | } | 1669 | } |
1455 | 1670 | ||
@@ -1473,11 +1688,11 @@ static int ssl3_send_client_verify(SSL *s) | |||
1473 | unsigned char *p,*d; | 1688 | unsigned char *p,*d; |
1474 | unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; | 1689 | unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; |
1475 | EVP_PKEY *pkey; | 1690 | EVP_PKEY *pkey; |
1476 | #ifndef NO_RSA | 1691 | #ifndef OPENSSL_NO_RSA |
1477 | unsigned u=0; | 1692 | unsigned u=0; |
1478 | #endif | 1693 | #endif |
1479 | unsigned long n; | 1694 | unsigned long n; |
1480 | #ifndef NO_DSA | 1695 | #ifndef OPENSSL_NO_DSA |
1481 | int j; | 1696 | int j; |
1482 | #endif | 1697 | #endif |
1483 | 1698 | ||
@@ -1490,7 +1705,7 @@ static int ssl3_send_client_verify(SSL *s) | |||
1490 | s->method->ssl3_enc->cert_verify_mac(s,&(s->s3->finish_dgst2), | 1705 | s->method->ssl3_enc->cert_verify_mac(s,&(s->s3->finish_dgst2), |
1491 | &(data[MD5_DIGEST_LENGTH])); | 1706 | &(data[MD5_DIGEST_LENGTH])); |
1492 | 1707 | ||
1493 | #ifndef NO_RSA | 1708 | #ifndef OPENSSL_NO_RSA |
1494 | if (pkey->type == EVP_PKEY_RSA) | 1709 | if (pkey->type == EVP_PKEY_RSA) |
1495 | { | 1710 | { |
1496 | s->method->ssl3_enc->cert_verify_mac(s, | 1711 | s->method->ssl3_enc->cert_verify_mac(s, |
@@ -1507,7 +1722,7 @@ static int ssl3_send_client_verify(SSL *s) | |||
1507 | } | 1722 | } |
1508 | else | 1723 | else |
1509 | #endif | 1724 | #endif |
1510 | #ifndef NO_DSA | 1725 | #ifndef OPENSSL_NO_DSA |
1511 | if (pkey->type == EVP_PKEY_DSA) | 1726 | if (pkey->type == EVP_PKEY_DSA) |
1512 | { | 1727 | { |
1513 | if (!DSA_sign(pkey->save_type, | 1728 | if (!DSA_sign(pkey->save_type, |
@@ -1524,7 +1739,7 @@ static int ssl3_send_client_verify(SSL *s) | |||
1524 | else | 1739 | else |
1525 | #endif | 1740 | #endif |
1526 | { | 1741 | { |
1527 | SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,SSL_R_INTERNAL_ERROR); | 1742 | SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_INTERNAL_ERROR); |
1528 | goto err; | 1743 | goto err; |
1529 | } | 1744 | } |
1530 | *(d++)=SSL3_MT_CERTIFICATE_VERIFY; | 1745 | *(d++)=SSL3_MT_CERTIFICATE_VERIFY; |
@@ -1623,10 +1838,10 @@ static int ssl3_check_cert_and_algorithm(SSL *s) | |||
1623 | long algs; | 1838 | long algs; |
1624 | EVP_PKEY *pkey=NULL; | 1839 | EVP_PKEY *pkey=NULL; |
1625 | SESS_CERT *sc; | 1840 | SESS_CERT *sc; |
1626 | #ifndef NO_RSA | 1841 | #ifndef OPENSSL_NO_RSA |
1627 | RSA *rsa; | 1842 | RSA *rsa; |
1628 | #endif | 1843 | #endif |
1629 | #ifndef NO_DH | 1844 | #ifndef OPENSSL_NO_DH |
1630 | DH *dh; | 1845 | DH *dh; |
1631 | #endif | 1846 | #endif |
1632 | 1847 | ||
@@ -1634,20 +1849,20 @@ static int ssl3_check_cert_and_algorithm(SSL *s) | |||
1634 | 1849 | ||
1635 | if (sc == NULL) | 1850 | if (sc == NULL) |
1636 | { | 1851 | { |
1637 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_INTERNAL_ERROR); | 1852 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,ERR_R_INTERNAL_ERROR); |
1638 | goto err; | 1853 | goto err; |
1639 | } | 1854 | } |
1640 | 1855 | ||
1641 | algs=s->s3->tmp.new_cipher->algorithms; | 1856 | algs=s->s3->tmp.new_cipher->algorithms; |
1642 | 1857 | ||
1643 | /* we don't have a certificate */ | 1858 | /* we don't have a certificate */ |
1644 | if (algs & (SSL_aDH|SSL_aNULL)) | 1859 | if (algs & (SSL_aDH|SSL_aNULL|SSL_aKRB5)) |
1645 | return(1); | 1860 | return(1); |
1646 | 1861 | ||
1647 | #ifndef NO_RSA | 1862 | #ifndef OPENSSL_NO_RSA |
1648 | rsa=s->session->sess_cert->peer_rsa_tmp; | 1863 | rsa=s->session->sess_cert->peer_rsa_tmp; |
1649 | #endif | 1864 | #endif |
1650 | #ifndef NO_DH | 1865 | #ifndef OPENSSL_NO_DH |
1651 | dh=s->session->sess_cert->peer_dh_tmp; | 1866 | dh=s->session->sess_cert->peer_dh_tmp; |
1652 | #endif | 1867 | #endif |
1653 | 1868 | ||
@@ -1665,14 +1880,14 @@ static int ssl3_check_cert_and_algorithm(SSL *s) | |||
1665 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT); | 1880 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT); |
1666 | goto f_err; | 1881 | goto f_err; |
1667 | } | 1882 | } |
1668 | #ifndef NO_DSA | 1883 | #ifndef OPENSSL_NO_DSA |
1669 | else if ((algs & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN)) | 1884 | else if ((algs & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN)) |
1670 | { | 1885 | { |
1671 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT); | 1886 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT); |
1672 | goto f_err; | 1887 | goto f_err; |
1673 | } | 1888 | } |
1674 | #endif | 1889 | #endif |
1675 | #ifndef NO_RSA | 1890 | #ifndef OPENSSL_NO_RSA |
1676 | if ((algs & SSL_kRSA) && | 1891 | if ((algs & SSL_kRSA) && |
1677 | !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) | 1892 | !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) |
1678 | { | 1893 | { |
@@ -1680,7 +1895,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s) | |||
1680 | goto f_err; | 1895 | goto f_err; |
1681 | } | 1896 | } |
1682 | #endif | 1897 | #endif |
1683 | #ifndef NO_DH | 1898 | #ifndef OPENSSL_NO_DH |
1684 | if ((algs & SSL_kEDH) && | 1899 | if ((algs & SSL_kEDH) && |
1685 | !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) | 1900 | !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) |
1686 | { | 1901 | { |
@@ -1692,7 +1907,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s) | |||
1692 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT); | 1907 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT); |
1693 | goto f_err; | 1908 | goto f_err; |
1694 | } | 1909 | } |
1695 | #ifndef NO_DSA | 1910 | #ifndef OPENSSL_NO_DSA |
1696 | else if ((algs & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA)) | 1911 | else if ((algs & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA)) |
1697 | { | 1912 | { |
1698 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT); | 1913 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT); |
@@ -1703,7 +1918,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s) | |||
1703 | 1918 | ||
1704 | if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP)) | 1919 | if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP)) |
1705 | { | 1920 | { |
1706 | #ifndef NO_RSA | 1921 | #ifndef OPENSSL_NO_RSA |
1707 | if (algs & SSL_kRSA) | 1922 | if (algs & SSL_kRSA) |
1708 | { | 1923 | { |
1709 | if (rsa == NULL | 1924 | if (rsa == NULL |
@@ -1715,7 +1930,7 @@ static int ssl3_check_cert_and_algorithm(SSL *s) | |||
1715 | } | 1930 | } |
1716 | else | 1931 | else |
1717 | #endif | 1932 | #endif |
1718 | #ifndef NO_DH | 1933 | #ifndef OPENSSL_NO_DH |
1719 | if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | 1934 | if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) |
1720 | { | 1935 | { |
1721 | if (dh == NULL | 1936 | if (dh == NULL |