mirror of https://github.com/openssl/openssl.git
				
				
				
			Use correct signature algorithm list when sending or checking.
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2298)
This commit is contained in:
		
							parent
							
								
									f24fcf2912
								
							
						
					
					
						commit
						e93f7d9c98
					
				|  | @ -4237,7 +4237,7 @@ int ssl3_get_req_cert_type(SSL *s, unsigned char *p) | ||||||
|         return (int)s->cert->ctype_num; |         return (int)s->cert->ctype_num; | ||||||
|     } |     } | ||||||
|     /* get configured sigalgs */ |     /* get configured sigalgs */ | ||||||
|     siglen = tls12_get_psigalgs(s, &sig); |     siglen = tls12_get_psigalgs(s, 1, &sig); | ||||||
|     if (s->cert->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT) |     if (s->cert->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT) | ||||||
|         nostrict = 0; |         nostrict = 0; | ||||||
|     for (i = 0; i < siglen; i += 2, sig += 2) { |     for (i = 0; i < siglen; i += 2, sig += 2) { | ||||||
|  |  | ||||||
|  | @ -2084,7 +2084,7 @@ int ssl3_send_certificate_request(SSL *s) | ||||||
| 
 | 
 | ||||||
|         if (SSL_USE_SIGALGS(s)) { |         if (SSL_USE_SIGALGS(s)) { | ||||||
|             const unsigned char *psigs; |             const unsigned char *psigs; | ||||||
|             nl = tls12_get_psigalgs(s, &psigs); |             nl = tls12_get_psigalgs(s, 1, &psigs); | ||||||
|             s2n(nl, p); |             s2n(nl, p); | ||||||
|             memcpy(p, psigs, nl); |             memcpy(p, psigs, nl); | ||||||
|             p += nl; |             p += nl; | ||||||
|  |  | ||||||
|  | @ -1430,7 +1430,7 @@ int ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len, | ||||||
| long ssl_get_algorithm2(SSL *s); | long ssl_get_algorithm2(SSL *s); | ||||||
| int tls1_save_sigalgs(SSL *s, const unsigned char *data, int dsize); | int tls1_save_sigalgs(SSL *s, const unsigned char *data, int dsize); | ||||||
| int tls1_process_sigalgs(SSL *s); | int tls1_process_sigalgs(SSL *s); | ||||||
| size_t tls12_get_psigalgs(SSL *s, const unsigned char **psigs); | size_t tls12_get_psigalgs(SSL *s, int sent, const unsigned char **psigs); | ||||||
| int tls12_check_peer_sigalg(const EVP_MD **pmd, SSL *s, | int tls12_check_peer_sigalg(const EVP_MD **pmd, SSL *s, | ||||||
|                             const unsigned char *sig, EVP_PKEY *pkey); |                             const unsigned char *sig, EVP_PKEY *pkey); | ||||||
| void ssl_set_client_disabled(SSL *s); | void ssl_set_client_disabled(SSL *s); | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								ssl/t1_lib.c
								
								
								
								
							
							
						
						
									
										12
									
								
								ssl/t1_lib.c
								
								
								
								
							|  | @ -1035,7 +1035,7 @@ static unsigned char suiteb_sigalgs[] = { | ||||||
|         tlsext_sigalg_ecdsa(TLSEXT_hash_sha384) |         tlsext_sigalg_ecdsa(TLSEXT_hash_sha384) | ||||||
| }; | }; | ||||||
| # endif | # endif | ||||||
| size_t tls12_get_psigalgs(SSL *s, const unsigned char **psigs) | size_t tls12_get_psigalgs(SSL *s, int sent, const unsigned char **psigs) | ||||||
| { | { | ||||||
|     /*
 |     /*
 | ||||||
|      * If Suite B mode use Suite B sigalgs only, ignore any other |      * If Suite B mode use Suite B sigalgs only, ignore any other | ||||||
|  | @ -1057,7 +1057,7 @@ size_t tls12_get_psigalgs(SSL *s, const unsigned char **psigs) | ||||||
|     } |     } | ||||||
| # endif | # endif | ||||||
|     /* If server use client authentication sigalgs if not NULL */ |     /* If server use client authentication sigalgs if not NULL */ | ||||||
|     if (s->server && s->cert->client_sigalgs) { |     if (s->server == sent && s->cert->client_sigalgs) { | ||||||
|         *psigs = s->cert->client_sigalgs; |         *psigs = s->cert->client_sigalgs; | ||||||
|         return s->cert->client_sigalgslen; |         return s->cert->client_sigalgslen; | ||||||
|     } else if (s->cert->conf_sigalgs) { |     } else if (s->cert->conf_sigalgs) { | ||||||
|  | @ -1121,7 +1121,7 @@ int tls12_check_peer_sigalg(const EVP_MD **pmd, SSL *s, | ||||||
| # endif | # endif | ||||||
| 
 | 
 | ||||||
|     /* Check signature matches a type we sent */ |     /* Check signature matches a type we sent */ | ||||||
|     sent_sigslen = tls12_get_psigalgs(s, &sent_sigs); |     sent_sigslen = tls12_get_psigalgs(s, 1, &sent_sigs); | ||||||
|     for (i = 0; i < sent_sigslen; i += 2, sent_sigs += 2) { |     for (i = 0; i < sent_sigslen; i += 2, sent_sigs += 2) { | ||||||
|         if (sig[0] == sent_sigs[0] && sig[1] == sent_sigs[1]) |         if (sig[0] == sent_sigs[0] && sig[1] == sent_sigs[1]) | ||||||
|             break; |             break; | ||||||
|  | @ -1169,7 +1169,7 @@ void ssl_set_client_disabled(SSL *s) | ||||||
|      * Now go through all signature algorithms seeing if we support any for |      * Now go through all signature algorithms seeing if we support any for | ||||||
|      * RSA, DSA, ECDSA. Do this for all versions not just TLS 1.2. |      * RSA, DSA, ECDSA. Do this for all versions not just TLS 1.2. | ||||||
|      */ |      */ | ||||||
|     sigalgslen = tls12_get_psigalgs(s, &sigalgs); |     sigalgslen = tls12_get_psigalgs(s, 1, &sigalgs); | ||||||
|     for (i = 0; i < sigalgslen; i += 2, sigalgs += 2) { |     for (i = 0; i < sigalgslen; i += 2, sigalgs += 2) { | ||||||
|         switch (sigalgs[1]) { |         switch (sigalgs[1]) { | ||||||
| # ifndef OPENSSL_NO_RSA | # ifndef OPENSSL_NO_RSA | ||||||
|  | @ -1440,7 +1440,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, | ||||||
|     if (SSL_CLIENT_USE_SIGALGS(s)) { |     if (SSL_CLIENT_USE_SIGALGS(s)) { | ||||||
|         size_t salglen; |         size_t salglen; | ||||||
|         const unsigned char *salg; |         const unsigned char *salg; | ||||||
|         salglen = tls12_get_psigalgs(s, &salg); |         salglen = tls12_get_psigalgs(s, 1, &salg); | ||||||
| 
 | 
 | ||||||
|         /*-
 |         /*-
 | ||||||
|          * check for enough space. |          * check for enough space. | ||||||
|  | @ -3803,7 +3803,7 @@ static int tls1_set_shared_sigalgs(SSL *s) | ||||||
|         conf = c->conf_sigalgs; |         conf = c->conf_sigalgs; | ||||||
|         conflen = c->conf_sigalgslen; |         conflen = c->conf_sigalgslen; | ||||||
|     } else |     } else | ||||||
|         conflen = tls12_get_psigalgs(s, &conf); |         conflen = tls12_get_psigalgs(s, 0, &conf); | ||||||
|     if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || is_suiteb) { |     if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || is_suiteb) { | ||||||
|         pref = conf; |         pref = conf; | ||||||
|         preflen = conflen; |         preflen = conflen; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue