mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-25 19:55:45 +01:00
Stop using deprecated functions in the library
all.sh -k '*deprecated*' now passes again Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
513c243317
commit
f5cf71e14a
@ -850,20 +850,21 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
|
|||||||
* Encrypt and authenticate
|
* Encrypt and authenticate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if( ( ret = mbedtls_cipher_auth_encrypt( &transform->cipher_ctx_enc,
|
if( ( ret = mbedtls_cipher_auth_encrypt_ext( &transform->cipher_ctx_enc,
|
||||||
iv, transform->ivlen,
|
iv, transform->ivlen,
|
||||||
add_data, add_data_len, /* add data */
|
add_data, add_data_len,
|
||||||
data, rec->data_len, /* source */
|
data, rec->data_len, /* src */
|
||||||
data, &rec->data_len, /* destination */
|
data, rec->buf_len - (data - rec->buf), /* dst */
|
||||||
data + rec->data_len, transform->taglen ) ) != 0 )
|
&rec->data_len,
|
||||||
|
transform->taglen ) ) != 0 )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_auth_encrypt", ret );
|
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_auth_encrypt", ret );
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
MBEDTLS_SSL_DEBUG_BUF( 4, "after encrypt: tag",
|
MBEDTLS_SSL_DEBUG_BUF( 4, "after encrypt: tag",
|
||||||
data + rec->data_len, transform->taglen );
|
data + rec->data_len - transform->taglen,
|
||||||
|
transform->taglen );
|
||||||
/* Account for authentication tag. */
|
/* Account for authentication tag. */
|
||||||
rec->data_len += transform->taglen;
|
|
||||||
post_avail -= transform->taglen;
|
post_avail -= transform->taglen;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1420,12 +1421,11 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
|||||||
/*
|
/*
|
||||||
* Decrypt and authenticate
|
* Decrypt and authenticate
|
||||||
*/
|
*/
|
||||||
if( ( ret = mbedtls_cipher_auth_decrypt( &transform->cipher_ctx_dec,
|
if( ( ret = mbedtls_cipher_auth_decrypt_ext( &transform->cipher_ctx_dec,
|
||||||
iv, transform->ivlen,
|
iv, transform->ivlen,
|
||||||
add_data, add_data_len,
|
add_data, add_data_len,
|
||||||
data, rec->data_len,
|
data, rec->data_len + transform->taglen, /* src */
|
||||||
data, &olen,
|
data, rec->buf_len - (data - rec->buf), &olen, /* dst */
|
||||||
data + rec->data_len,
|
|
||||||
transform->taglen ) ) != 0 )
|
transform->taglen ) ) != 0 )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_auth_decrypt", ret );
|
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_cipher_auth_decrypt", ret );
|
||||||
|
@ -209,7 +209,6 @@ int mbedtls_ssl_ticket_write( void *p_ticket,
|
|||||||
unsigned char *iv = start + TICKET_KEY_NAME_BYTES;
|
unsigned char *iv = start + TICKET_KEY_NAME_BYTES;
|
||||||
unsigned char *state_len_bytes = iv + TICKET_IV_BYTES;
|
unsigned char *state_len_bytes = iv + TICKET_IV_BYTES;
|
||||||
unsigned char *state = state_len_bytes + TICKET_CRYPT_LEN_BYTES;
|
unsigned char *state = state_len_bytes + TICKET_CRYPT_LEN_BYTES;
|
||||||
unsigned char *tag;
|
|
||||||
size_t clear_len, ciph_len;
|
size_t clear_len, ciph_len;
|
||||||
|
|
||||||
*tlen = 0;
|
*tlen = 0;
|
||||||
@ -250,23 +249,23 @@ int mbedtls_ssl_ticket_write( void *p_ticket,
|
|||||||
state_len_bytes[1] = ( clear_len ) & 0xff;
|
state_len_bytes[1] = ( clear_len ) & 0xff;
|
||||||
|
|
||||||
/* Encrypt and authenticate */
|
/* Encrypt and authenticate */
|
||||||
tag = state + clear_len;
|
if( ( ret = mbedtls_cipher_auth_encrypt_ext( &key->ctx,
|
||||||
if( ( ret = mbedtls_cipher_auth_encrypt( &key->ctx,
|
|
||||||
iv, TICKET_IV_BYTES,
|
iv, TICKET_IV_BYTES,
|
||||||
/* Additional data: key name, IV and length */
|
/* Additional data: key name, IV and length */
|
||||||
key_name, TICKET_ADD_DATA_LEN,
|
key_name, TICKET_ADD_DATA_LEN,
|
||||||
state, clear_len, state, &ciph_len,
|
state, clear_len,
|
||||||
tag, TICKET_AUTH_TAG_BYTES ) ) != 0 )
|
state, end - state, &ciph_len,
|
||||||
|
TICKET_AUTH_TAG_BYTES ) ) != 0 )
|
||||||
{
|
{
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if( ciph_len != clear_len )
|
if( ciph_len != clear_len + TICKET_AUTH_TAG_BYTES )
|
||||||
{
|
{
|
||||||
ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
*tlen = TICKET_MIN_LEN + ciph_len;
|
*tlen = TICKET_MIN_LEN + ciph_len - TICKET_AUTH_TAG_BYTES;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
#if defined(MBEDTLS_THREADING_C)
|
#if defined(MBEDTLS_THREADING_C)
|
||||||
@ -308,7 +307,6 @@ int mbedtls_ssl_ticket_parse( void *p_ticket,
|
|||||||
unsigned char *iv = buf + TICKET_KEY_NAME_BYTES;
|
unsigned char *iv = buf + TICKET_KEY_NAME_BYTES;
|
||||||
unsigned char *enc_len_p = iv + TICKET_IV_BYTES;
|
unsigned char *enc_len_p = iv + TICKET_IV_BYTES;
|
||||||
unsigned char *ticket = enc_len_p + TICKET_CRYPT_LEN_BYTES;
|
unsigned char *ticket = enc_len_p + TICKET_CRYPT_LEN_BYTES;
|
||||||
unsigned char *tag;
|
|
||||||
size_t enc_len, clear_len;
|
size_t enc_len, clear_len;
|
||||||
|
|
||||||
if( ctx == NULL || ctx->f_rng == NULL )
|
if( ctx == NULL || ctx->f_rng == NULL )
|
||||||
@ -326,7 +324,6 @@ int mbedtls_ssl_ticket_parse( void *p_ticket,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
enc_len = ( enc_len_p[0] << 8 ) | enc_len_p[1];
|
enc_len = ( enc_len_p[0] << 8 ) | enc_len_p[1];
|
||||||
tag = ticket + enc_len;
|
|
||||||
|
|
||||||
if( len != TICKET_MIN_LEN + enc_len )
|
if( len != TICKET_MIN_LEN + enc_len )
|
||||||
{
|
{
|
||||||
@ -344,13 +341,13 @@ int mbedtls_ssl_ticket_parse( void *p_ticket,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Decrypt and authenticate */
|
/* Decrypt and authenticate */
|
||||||
if( ( ret = mbedtls_cipher_auth_decrypt( &key->ctx,
|
if( ( ret = mbedtls_cipher_auth_decrypt_ext( &key->ctx,
|
||||||
iv, TICKET_IV_BYTES,
|
iv, TICKET_IV_BYTES,
|
||||||
/* Additional data: key name, IV and length */
|
/* Additional data: key name, IV and length */
|
||||||
key_name, TICKET_ADD_DATA_LEN,
|
key_name, TICKET_ADD_DATA_LEN,
|
||||||
ticket, enc_len,
|
ticket, enc_len + TICKET_AUTH_TAG_BYTES,
|
||||||
ticket, &clear_len,
|
ticket, enc_len, &clear_len,
|
||||||
tag, TICKET_AUTH_TAG_BYTES ) ) != 0 )
|
TICKET_AUTH_TAG_BYTES ) ) != 0 )
|
||||||
{
|
{
|
||||||
if( ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED )
|
if( ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED )
|
||||||
ret = MBEDTLS_ERR_SSL_INVALID_MAC;
|
ret = MBEDTLS_ERR_SSL_INVALID_MAC;
|
||||||
|
Loading…
Reference in New Issue
Block a user