Fix missing return checks in KSDK ED25519 code.

pull/5306/head
Kareem 2022-06-30 13:35:00 -07:00
parent ed1fdc410e
commit 13beadbfc3
2 changed files with 13 additions and 5 deletions

View File

@ -655,8 +655,12 @@ static int ed25519_verify_msg_final_with_sha(const byte* sig, word32 sigLen,
return ret;
#ifdef FREESCALE_LTC_ECC
LTC_PKHA_sc_reduce(h);
LTC_PKHA_SignatureForVerify(rcheck, h, sig + (ED25519_SIG_SIZE/2), key);
ret = LTC_PKHA_sc_reduce(h);
if (ret != kStatus_Success)
return ret;
ret = LTC_PKHA_SignatureForVerify(rcheck, h, sig + (ED25519_SIG_SIZE/2), key);
if (ret != kStatus_Success)
return ret;
#else
sc_reduce(h);

View File

@ -2051,11 +2051,15 @@ status_t LTC_PKHA_SignatureForVerify(uint8_t *rcheck, const unsigned char *a,
if (status == kStatus_Success) {
status = LTC_PKHA_WeierstrassToEd25519(&ltc0, &ltc0);
}
if (((uint32_t)ltc0.X[0]) & 0x01u) {
ltc0.Y[ED25519_KEY_SIZE - 1] |= 0x80u;
if (status == kStatus_Success) {
if (((uint32_t)ltc0.X[0]) & 0x01u) {
ltc0.Y[ED25519_KEY_SIZE - 1] |= 0x80u;
}
XMEMCPY(rcheck, ltc0.Y, ED25519_KEY_SIZE);
}
XMEMCPY(rcheck, ltc0.Y, ED25519_KEY_SIZE);
return status;
}