Merge pull request #426 from ejohnstown/sig-init

ECC Userauth Initialization
pull/427/head
David Garske 2022-06-29 19:38:47 -07:00 committed by GitHub
commit e646bd141a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 16 deletions

View File

@ -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)