Guards tls_prf functions with TLS1_2
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
parent
c73c618094
commit
53d23e2c95
@ -577,7 +577,7 @@ static int tls_prf_sha384( const unsigned char *secret, size_t slen,
|
|||||||
|
|
||||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||||
|
|
||||||
static void ssl_update_checksum_start( mbedtls_ssl_context *, const unsigned char *, size_t );
|
|
||||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||||
#if defined(MBEDTLS_SHA256_C)
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
static void ssl_calc_verify_tls_sha256( const mbedtls_ssl_context *,unsigned char*, size_t * );
|
static void ssl_calc_verify_tls_sha256( const mbedtls_ssl_context *,unsigned char*, size_t * );
|
||||||
@ -590,13 +590,15 @@ static void ssl_calc_finished_tls_sha384( mbedtls_ssl_context *, unsigned char *
|
|||||||
#endif
|
#endif
|
||||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||||
|
|
||||||
|
static void ssl_update_checksum_start( mbedtls_ssl_context *, const unsigned char *, size_t );
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA256_C)
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
static void ssl_update_checksum_sha256( mbedtls_ssl_context *, const unsigned char *, size_t );
|
static void ssl_update_checksum_sha256( mbedtls_ssl_context *, const unsigned char *, size_t );
|
||||||
#endif
|
#endif /* MBEDTLS_SHA256_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA384_C)
|
#if defined(MBEDTLS_SHA384_C)
|
||||||
static void ssl_update_checksum_sha384( mbedtls_ssl_context *, const unsigned char *, size_t );
|
static void ssl_update_checksum_sha384( mbedtls_ssl_context *, const unsigned char *, size_t );
|
||||||
#endif
|
#endif /* MBEDTLS_SHA384_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) && \
|
#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) && \
|
||||||
defined(MBEDTLS_USE_PSA_CRYPTO)
|
defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
@ -620,28 +622,6 @@ static int ssl_use_opaque_psk( mbedtls_ssl_context const *ssl )
|
|||||||
#endif /* MBEDTLS_USE_PSA_CRYPTO &&
|
#endif /* MBEDTLS_USE_PSA_CRYPTO &&
|
||||||
MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */
|
MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */
|
||||||
|
|
||||||
static mbedtls_tls_prf_types tls_prf_get_type( mbedtls_ssl_tls_prf_cb *tls_prf )
|
|
||||||
{
|
|
||||||
((void) tls_prf);
|
|
||||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
|
||||||
#if defined(MBEDTLS_SHA384_C)
|
|
||||||
if( tls_prf == tls_prf_sha384 )
|
|
||||||
{
|
|
||||||
return( MBEDTLS_SSL_TLS_PRF_SHA384 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#if defined(MBEDTLS_SHA256_C)
|
|
||||||
if( tls_prf == tls_prf_sha256 )
|
|
||||||
{
|
|
||||||
return( MBEDTLS_SSL_TLS_PRF_SHA256 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
|
||||||
return( MBEDTLS_SSL_TLS_PRF_NONE );
|
|
||||||
}
|
|
||||||
|
|
||||||
int mbedtls_ssl_tls_prf( const mbedtls_tls_prf_types prf,
|
int mbedtls_ssl_tls_prf( const mbedtls_tls_prf_types prf,
|
||||||
const unsigned char *secret, size_t slen,
|
const unsigned char *secret, size_t slen,
|
||||||
const char *label,
|
const char *label,
|
||||||
@ -671,6 +651,30 @@ int mbedtls_ssl_tls_prf( const mbedtls_tls_prf_types prf,
|
|||||||
return( tls_prf( secret, slen, label, random, rlen, dstbuf, dlen ) );
|
return( tls_prf( secret, slen, label, random, rlen, dstbuf, dlen ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SSL_PROTO_TLS1_2) || \
|
||||||
|
defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||||
|
static mbedtls_tls_prf_types tls_prf_get_type( mbedtls_ssl_tls_prf_cb *tls_prf )
|
||||||
|
{
|
||||||
|
((void) tls_prf);
|
||||||
|
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||||
|
#if defined(MBEDTLS_SHA384_C)
|
||||||
|
if( tls_prf == tls_prf_sha384 )
|
||||||
|
{
|
||||||
|
return( MBEDTLS_SSL_TLS_PRF_SHA384 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
|
if( tls_prf == tls_prf_sha256 )
|
||||||
|
{
|
||||||
|
return( MBEDTLS_SSL_TLS_PRF_SHA256 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||||
|
return( MBEDTLS_SSL_TLS_PRF_NONE );
|
||||||
|
}
|
||||||
|
|
||||||
/* Type for the TLS PRF */
|
/* Type for the TLS PRF */
|
||||||
typedef int ssl_tls_prf_t(const unsigned char *, size_t, const char *,
|
typedef int ssl_tls_prf_t(const unsigned char *, size_t, const char *,
|
||||||
const unsigned char *, size_t,
|
const unsigned char *, size_t,
|
||||||
@ -1113,6 +1117,7 @@ end:
|
|||||||
mbedtls_platform_zeroize( keyblk, sizeof( keyblk ) );
|
mbedtls_platform_zeroize( keyblk, sizeof( keyblk ) );
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 || MBEDTLS_SSL_CONTEXT_SERIALIZATION */
|
||||||
|
|
||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
static void ssl_clear_peer_cert( mbedtls_ssl_session *session )
|
static void ssl_clear_peer_cert( mbedtls_ssl_session *session )
|
||||||
@ -6214,10 +6219,10 @@ static tls_prf_fn ssl_tls12prf_from_cs( int ciphersuite_id )
|
|||||||
(void) ciphersuite_id;
|
(void) ciphersuite_id;
|
||||||
#endif
|
#endif
|
||||||
return( tls_prf_sha256 );
|
return( tls_prf_sha256 );
|
||||||
#else
|
#else /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||||
(void) ciphersuite_id;
|
(void) ciphersuite_id;
|
||||||
return( NULL );
|
return( NULL );
|
||||||
#endif
|
#endif /* !MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1186,6 +1186,7 @@ int psk_dummy_callback( void *p_info, mbedtls_ssl_context *ssl,
|
|||||||
#define SSL_CID_LEN_MIN MBEDTLS_SSL_CID_OUT_LEN_MAX
|
#define SSL_CID_LEN_MIN MBEDTLS_SSL_CID_OUT_LEN_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||||
static int psa_cipher_encrypt_helper( mbedtls_ssl_transform *transform,
|
static int psa_cipher_encrypt_helper( mbedtls_ssl_transform *transform,
|
||||||
const unsigned char *iv, size_t iv_len,
|
const unsigned char *iv, size_t iv_len,
|
||||||
const unsigned char *input, size_t ilen,
|
const unsigned char *input, size_t ilen,
|
||||||
@ -1226,6 +1227,7 @@ static int psa_cipher_encrypt_helper( mbedtls_ssl_transform *transform,
|
|||||||
iv, iv_len, input, ilen, output, olen );
|
iv, iv_len, input, ilen, output, olen );
|
||||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
}
|
}
|
||||||
|
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||||
|
|
||||||
static int build_transforms( mbedtls_ssl_transform *t_in,
|
static int build_transforms( mbedtls_ssl_transform *t_in,
|
||||||
mbedtls_ssl_transform *t_out,
|
mbedtls_ssl_transform *t_out,
|
||||||
@ -4198,7 +4200,7 @@ void ssl_tls13_key_evolution( int hash_alg,
|
|||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE depends_on:MBEDTLS_SSL_PROTO_TLS1_2 */
|
||||||
void ssl_tls_prf( int type, data_t * secret, data_t * random,
|
void ssl_tls_prf( int type, data_t * secret, data_t * random,
|
||||||
char *label, data_t *result_str, int exp_ret )
|
char *label, data_t *result_str, int exp_ret )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user