forked from wolfSSL/wolfssl
Improve handling of mp_init / mp_clear for DH and DSA after speed-up.
This commit is contained in:
@ -51,20 +51,21 @@
|
||||
|
||||
void wc_InitDhKey(DhKey* key)
|
||||
{
|
||||
(void)key;
|
||||
/* TomsFastMath doesn't use memory allocation */
|
||||
#ifndef USE_FAST_MATH
|
||||
key->p.dp = NULL;
|
||||
key->g.dp = NULL;
|
||||
#endif
|
||||
if (key) {
|
||||
mp_init(&key->p);
|
||||
mp_init(&key->g);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wc_FreeDhKey(DhKey* key)
|
||||
{
|
||||
(void)key;
|
||||
mp_clear(&key->p);
|
||||
mp_clear(&key->g);
|
||||
if (key) {
|
||||
#ifndef USE_FAST_MATH
|
||||
mp_clear(&key->p);
|
||||
mp_clear(&key->g);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,18 +52,20 @@ enum {
|
||||
|
||||
void wc_InitDsaKey(DsaKey* key)
|
||||
{
|
||||
if (key == NULL)
|
||||
return;
|
||||
|
||||
key->type = -1; /* haven't decided yet */
|
||||
key->heap = NULL;
|
||||
|
||||
/* TomsFastMath doesn't use memory allocation */
|
||||
#ifndef USE_FAST_MATH
|
||||
key->p.dp = 0; /* public alloc parts */
|
||||
key->q.dp = 0;
|
||||
key->g.dp = 0;
|
||||
key->y.dp = 0;
|
||||
/* public alloc parts */
|
||||
mp_init(&key->p);
|
||||
mp_init(&key->q);
|
||||
mp_init(&key->g);
|
||||
mp_init(&key->y);
|
||||
|
||||
key->x.dp = 0; /* private alloc parts */
|
||||
#endif
|
||||
/* private alloc parts */
|
||||
mp_init(&key->x);
|
||||
}
|
||||
|
||||
|
||||
@ -78,11 +80,14 @@ int wc_InitDsaKey_h(DsaKey* key, void* h)
|
||||
|
||||
void wc_FreeDsaKey(DsaKey* key)
|
||||
{
|
||||
(void)key;
|
||||
/* TomsFastMath doesn't use memory allocation */
|
||||
#ifndef USE_FAST_MATH
|
||||
if (key == NULL)
|
||||
return;
|
||||
|
||||
if (key->type == DSA_PRIVATE)
|
||||
mp_clear(&key->x);
|
||||
mp_forcezero(&key->x);
|
||||
|
||||
#ifndef USE_FAST_MATH
|
||||
mp_clear(&key->x);
|
||||
mp_clear(&key->y);
|
||||
mp_clear(&key->g);
|
||||
mp_clear(&key->q);
|
||||
|
Reference in New Issue
Block a user