wolfSSL: Use wolfSSL memory allocation in dh5_init()

Signed-off-by: Sean Parkinson <sean@wolfssl.com>
This commit is contained in:
Sean Parkinson 2018-03-29 14:55:55 +10:00 committed by Jouni Malinen
parent 6590d84664
commit 385dd7189a

View file

@ -660,13 +660,13 @@ void * dh5_init(struct wpabuf **priv, struct wpabuf **publ)
wpabuf_free(*publ); wpabuf_free(*publ);
*publ = NULL; *publ = NULL;
dh = os_malloc(sizeof(DhKey)); dh = XMALLOC(sizeof(DhKey), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (!dh) if (!dh)
return NULL; return NULL;
wc_InitDhKey(dh); wc_InitDhKey(dh);
if (wc_InitRng(&rng) != 0) { if (wc_InitRng(&rng) != 0) {
os_free(dh); XFREE(dh, NULL, DYNAMIC_TYPE_TMP_BUFFER);
return NULL; return NULL;
} }
@ -698,7 +698,7 @@ done:
wpabuf_clear_free(privkey); wpabuf_clear_free(privkey);
if (dh) { if (dh) {
wc_FreeDhKey(dh); wc_FreeDhKey(dh);
os_free(dh); XFREE(dh, NULL, DYNAMIC_TYPE_TMP_BUFFER);
} }
wc_FreeRng(&rng); wc_FreeRng(&rng);
return ret; return ret;
@ -712,12 +712,12 @@ void * dh5_init_fixed(const struct wpabuf *priv, const struct wpabuf *publ)
byte *secret; byte *secret;
word32 secret_sz; word32 secret_sz;
dh = os_malloc(sizeof(DhKey)); dh = XMALLOC(sizeof(DhKey), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (!dh) if (!dh)
return NULL; return NULL;
wc_InitDhKey(dh); wc_InitDhKey(dh);
secret = os_malloc(RFC3526_LEN); secret = XMALLOC(RFC3526_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (!secret) if (!secret)
goto done; goto done;
@ -740,9 +740,9 @@ void * dh5_init_fixed(const struct wpabuf *priv, const struct wpabuf *publ)
done: done:
if (dh) { if (dh) {
wc_FreeDhKey(dh); wc_FreeDhKey(dh);
os_free(dh); XFREE(dh, NULL, DYNAMIC_TYPE_TMP_BUFFER);
} }
os_free(secret); XFREE(secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
return ret; return ret;
} }
@ -779,7 +779,7 @@ void dh5_free(void *ctx)
return; return;
wc_FreeDhKey(ctx); wc_FreeDhKey(ctx);
os_free(ctx); XFREE(ctx, NULL, DYNAMIC_TYPE_TMP_BUFFER);
} }
#endif /* CONFIG_WPS_NFC */ #endif /* CONFIG_WPS_NFC */