diff --git a/src/internal.c b/src/internal.c index afd9bf20..0de93fc0 100644 --- a/src/internal.c +++ b/src/internal.c @@ -4320,10 +4320,19 @@ static int DoUserAuthRequestEcc(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk, #endif } - if (ret == WS_SUCCESS) { - ret = wc_ecc_init_ex(key_ptr, ssh->ctx->heap, INVALID_DEVID); - if (ret == 0) { - ret = WS_SUCCESS; + if (sig_r_ptr != NULL) { + if (mp_init(sig_r_ptr) != MP_OKAY) { + ret = WS_MEMORY_E; + } + } + if (sig_s_ptr != NULL) { + if (mp_init(sig_s_ptr) != MP_OKAY) { + ret = WS_MEMORY_E; + } + } + if (key_ptr != NULL) { + if (wc_ecc_init_ex(key_ptr, ssh->ctx->heap, INVALID_DEVID) != 0) { + ret = WS_MEMORY_E; } } @@ -4395,12 +4404,6 @@ static int DoUserAuthRequestEcc(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk, ret = GetSize(&sz, pk->signature, pk->signatureSz, &i); } - if (ret == WS_SUCCESS) { - if (mp_init(sig_r_ptr) != MP_OKAY) { - ret = WS_FATAL_ERROR; - } - } - if (ret == WS_SUCCESS) { ret = mp_read_unsigned_bin(sig_r_ptr, pk->signature + i, sz); if (ret != 0) @@ -4414,12 +4417,6 @@ static int DoUserAuthRequestEcc(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk, ret = GetSize(&sz, pk->signature, pk->signatureSz, &i); } - if (ret == WS_SUCCESS) { - if (mp_init(sig_s_ptr) != MP_OKAY) { - ret = WS_FATAL_ERROR; - } - } - if (ret == WS_SUCCESS) { ret = mp_read_unsigned_bin(sig_s_ptr, pk->signature + i, sz); if (ret != 0)