Add ecdh_calc_secret()
This commit is contained in:
parent
5cceb41d2c
commit
424fda5d7b
3 changed files with 35 additions and 1 deletions
|
@ -186,6 +186,23 @@ int ecdh_read_public( ecdh_context *ctx,
|
|||
return ecp_tls_read_point( &ctx->grp, &ctx->Qp, &buf, blen );
|
||||
}
|
||||
|
||||
/*
|
||||
* Derive and export the shared secret
|
||||
*/
|
||||
int ecdh_calc_secret( ecdh_context *ctx, size_t *olen,
|
||||
unsigned char *buf, size_t blen )
|
||||
{
|
||||
int ret;
|
||||
|
||||
if( ( ret = ecdh_compute_shared( &ctx->grp, &ctx->z, &ctx->Qp, &ctx->d ) )
|
||||
!= 0 )
|
||||
return( ret );
|
||||
|
||||
*olen = mpi_size( &ctx->z );
|
||||
return mpi_write_binary( &ctx->z, buf, blen );
|
||||
}
|
||||
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue