mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-10-31 03:30:35 -04:00 
			
		
		
		
	 dbfb7bd873
			
		
	
	
		dbfb7bd873
		
	
	
	
	
		
			
			- wrong cipher suite filter condition - name conversion - format issue Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
		
			
				
	
	
		
			120 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			120 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  *  TLS 1.3 functionality shared between client and server
 | |
|  *
 | |
|  *  Copyright The Mbed TLS Contributors
 | |
|  *  SPDX-License-Identifier: Apache-2.0
 | |
|  *
 | |
|  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
 | |
|  *  not use this file except in compliance with the License.
 | |
|  *  You may obtain a copy of the License at
 | |
|  *
 | |
|  *  http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  *  Unless required by applicable law or agreed to in writing, software
 | |
|  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 | |
|  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  *  See the License for the specific language governing permissions and
 | |
|  *  limitations under the License.
 | |
|  */
 | |
| 
 | |
| #include "common.h"
 | |
| 
 | |
| #if defined(MBEDTLS_SSL_TLS_C)
 | |
| 
 | |
| #if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
 | |
| 
 | |
| #include "mbedtls/error.h"
 | |
| 
 | |
| #include "ssl_misc.h"
 | |
| 
 | |
| int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl,
 | |
|                                            unsigned hs_type,
 | |
|                                            unsigned char **buf,
 | |
|                                            size_t *buf_len )
 | |
| {
 | |
|     /*
 | |
|      * Reserve 4 bytes for hanshake header. ( Section 4,RFC 8446 )
 | |
|      *    ...
 | |
|      *    HandshakeType msg_type;
 | |
|      *    uint24 length;
 | |
|      *    ...
 | |
|      */
 | |
|     *buf = ssl->out_msg + 4;
 | |
|     *buf_len = MBEDTLS_SSL_OUT_CONTENT_LEN - 4;
 | |
| 
 | |
|     ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE;
 | |
|     ssl->out_msg[0]  = hs_type;
 | |
| 
 | |
|     return( 0 );
 | |
| }
 | |
| 
 | |
| int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl,
 | |
|                                             size_t buf_len,
 | |
|                                             size_t msg_len )
 | |
| {
 | |
|     int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
 | |
|     size_t msg_len_with_header;
 | |
|     ((void) buf_len);
 | |
| 
 | |
|     /* Add reserved 4 bytes for handshake header */
 | |
|     msg_len_with_header = msg_len + 4;
 | |
|     ssl->out_msglen = msg_len_with_header;
 | |
|     MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext( ssl, 0 ) );
 | |
| 
 | |
| cleanup:
 | |
|     return( ret );
 | |
| }
 | |
| 
 | |
| void mbedtls_ssl_tls13_add_hs_hdr_to_checksum( mbedtls_ssl_context *ssl,
 | |
|                                                unsigned hs_type,
 | |
|                                                size_t total_hs_len )
 | |
| {
 | |
|     unsigned char hs_hdr[4];
 | |
| 
 | |
|     /* Build HS header for checksum update. */
 | |
|     hs_hdr[0] = MBEDTLS_BYTE_0( hs_type );
 | |
|     hs_hdr[1] = MBEDTLS_BYTE_2( total_hs_len );
 | |
|     hs_hdr[2] = MBEDTLS_BYTE_1( total_hs_len );
 | |
|     hs_hdr[3] = MBEDTLS_BYTE_0( total_hs_len );
 | |
| 
 | |
|     ssl->handshake->update_checksum( ssl, hs_hdr, sizeof( hs_hdr ) );
 | |
| }
 | |
| 
 | |
| #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
 | |
| 
 | |
| /*
 | |
|  * mbedtls_ssl_tls13_write_sig_alg_ext( )
 | |
|  *
 | |
|  * enum {
 | |
|  *    ....
 | |
|  *   ecdsa_secp256r1_sha256( 0x0403 ),
 | |
|  *   ecdsa_secp384r1_sha384( 0x0503 ),
 | |
|  *   ecdsa_secp521r1_sha512( 0x0603 ),
 | |
|  *    ....
 | |
|  * } SignatureScheme;
 | |
|  *
 | |
|  * struct {
 | |
|  *    SignatureScheme supported_signature_algorithms<2..2^16-2>;
 | |
|  * } SignatureSchemeList;
 | |
|  *
 | |
|  * Only if we handle at least one key exchange that needs signatures.
 | |
|  */
 | |
| 
 | |
| int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl,
 | |
|                                          unsigned char *buf,
 | |
|                                          unsigned char *end,
 | |
|                                          size_t *olen )
 | |
| {
 | |
|     ((void) ssl);
 | |
|     ((void) buf);
 | |
|     ((void) end);
 | |
|     ((void) olen);
 | |
|     return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE );
 | |
| }
 | |
| 
 | |
| #endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
 | |
| 
 | |
| #endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
 | |
| 
 | |
| #endif /* MBEDTLS_SSL_TLS_C */
 |