mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 18:25:49 +01:00
TinyCrypt ECDHE-PSK: Implement mbedtls_ssl_psk_derive_premaster()
This commit is contained in:
parent
d91ede14c4
commit
982da7ee0a
@ -2158,6 +2158,20 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch
|
|||||||
int ret;
|
int ret;
|
||||||
size_t zlen;
|
size_t zlen;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_TINYCRYPT)
|
||||||
|
const struct uECC_Curve_t * uecc_curve = uECC_secp256r1();
|
||||||
|
((void) ret);
|
||||||
|
|
||||||
|
if( !uECC_shared_secret( ssl->handshake->ecdh_peerkey,
|
||||||
|
ssl->handshake->ecdh_privkey,
|
||||||
|
p + 2,
|
||||||
|
uecc_curve ) )
|
||||||
|
{
|
||||||
|
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||||
|
}
|
||||||
|
|
||||||
|
zlen = NUM_ECC_BYTES;
|
||||||
|
#else /* MBEDTLS_USE_TINYCRYPT */
|
||||||
if( ( ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, &zlen,
|
if( ( ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, &zlen,
|
||||||
p + 2, end - ( p + 2 ),
|
p + 2, end - ( p + 2 ),
|
||||||
mbedtls_ssl_conf_get_frng( ssl->conf ),
|
mbedtls_ssl_conf_get_frng( ssl->conf ),
|
||||||
@ -2167,12 +2181,14 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch
|
|||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx,
|
||||||
|
MBEDTLS_DEBUG_ECDH_Z );
|
||||||
|
#endif /* MBEDTLS_USE_TINYCRYPT */
|
||||||
|
|
||||||
*(p++) = (unsigned char)( zlen >> 8 );
|
*(p++) = (unsigned char)( zlen >> 8 );
|
||||||
*(p++) = (unsigned char)( zlen );
|
*(p++) = (unsigned char)( zlen );
|
||||||
p += zlen;
|
p += zlen;
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx,
|
|
||||||
MBEDTLS_DEBUG_ECDH_Z );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
||||||
|
Loading…
Reference in New Issue
Block a user