Add ecdsa_from_keypair()
Also fix bug/limitation in mpi_copy: would segfault if src just initialised and not set to a value yet. (This case occurs when copying a context which contains only the public part of the key, eg.)
This commit is contained in:
parent
cc0a9d040d
commit
f499993cb2
3 changed files with 30 additions and 0 deletions
|
@ -283,6 +283,20 @@ int ecdsa_genkey( ecdsa_context *ctx, ecp_group_id gid,
|
|||
ecp_gen_keypair( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Set context from an ecp_keypair
|
||||
*/
|
||||
int ecdsa_from_keypair( ecdsa_context *ctx, const ecp_keypair *key )
|
||||
{
|
||||
int ret = ecp_group_copy( &ctx->grp, &key->grp ) ||
|
||||
mpi_copy( &ctx->d, &key->d ) ||
|
||||
ecp_copy( &ctx->Q, &key->Q );
|
||||
|
||||
if( ret != 0 )
|
||||
ecdsa_free( ctx );
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue