mirror of https://github.com/wolfSSL/wolfssl.git
Address second round of review findings on curve448 cryptocb support
Restore key devId on the keygen stub's error return, full-buffer-check callback output, cover the new/delete NULL out-params, drop a dead guard.pull/11209/head
parent
eb1cde51ab
commit
93d71fdda9
|
|
@ -1106,8 +1106,17 @@ int test_wc_curve448_cryptocb(void)
|
|||
|
||||
wc_curve448_free(&keyB);
|
||||
#ifndef WC_NO_CONSTRUCTORS
|
||||
/* result_code and key_p are both optional */
|
||||
{
|
||||
curve448_key* keyC = NULL;
|
||||
ExpectNotNull(keyC = wc_curve448_new(HEAP_HINT, devId, NULL));
|
||||
if (keyC != NULL) {
|
||||
DoExpectIntEQ(wc_curve448_delete(keyC, NULL), 0);
|
||||
}
|
||||
}
|
||||
if (keyA != NULL) {
|
||||
DoExpectIntEQ(wc_curve448_delete(keyA, &keyA), 0);
|
||||
ExpectNull(keyA);
|
||||
}
|
||||
ExpectIntEQ(wc_curve448_delete(NULL, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
|
|
|||
|
|
@ -342,9 +342,9 @@ int wc_curve448_shared_secret_ex(curve448_key* private_key,
|
|||
wc_MemZero_Add("wc_curve448_shared_secret_ex o", o, CURVE448_PUB_KEY_SIZE);
|
||||
#endif
|
||||
|
||||
if (ret == 0) {
|
||||
ret = curve448(o, private_key->k, public_key->p);
|
||||
}
|
||||
/* ret is 0 here: the argument checks return early and the cryptocb block
|
||||
* either returns or resets it. */
|
||||
ret = curve448(o, private_key->k, public_key->p);
|
||||
#ifndef WOLFSSL_NO_ECDHX_SHARED_ZERO_CHECK
|
||||
if (ret == 0) {
|
||||
byte t = 0;
|
||||
|
|
|
|||
|
|
@ -80467,7 +80467,10 @@ static wc_test_ret_t curve448_onlycb_test(myCryptoDevCtx *ctx)
|
|||
ret = wc_curve448_make_key(&rng, CURVE448_KEY_SIZE, &key);
|
||||
if (ret != 0)
|
||||
ret = WC_TEST_RET_ENC_EC(ret);
|
||||
else if (!key.privSet || !key.pubSet || (key.p[0] != 0xC3) ||
|
||||
else if (!key.privSet || !key.pubSet ||
|
||||
!curve448_buf_is(key.p, 0xC3, CURVE448_PUB_KEY_SIZE) ||
|
||||
(key.k[0] != 0x58) ||
|
||||
!curve448_buf_is(key.k + 1, 0x5A, CURVE448_KEY_SIZE - 2) ||
|
||||
(key.k[CURVE448_KEY_SIZE-1] != 0xDA))
|
||||
ret = WC_TEST_RET_ENC_NC;
|
||||
|
||||
|
|
@ -80557,7 +80560,8 @@ static wc_test_ret_t curve448_onlycb_test(myCryptoDevCtx *ctx)
|
|||
ret = wc_curve448_shared_secret(&key, &pubKey, out, &outLen);
|
||||
if (ret != 0)
|
||||
ret = WC_TEST_RET_ENC_EC(ret);
|
||||
else if ((outLen != CURVE448_KEY_SIZE) || (out[0] != 0xA5))
|
||||
else if ((outLen != CURVE448_KEY_SIZE) ||
|
||||
!curve448_buf_is(out, 0xA5, CURVE448_PUB_KEY_SIZE))
|
||||
ret = WC_TEST_RET_ENC_NC;
|
||||
}
|
||||
if (ret == 0) {
|
||||
|
|
@ -81206,12 +81210,12 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
|
|||
printf("CryptoDevCb: exampleVar %d\n", myCtx->exampleVar);
|
||||
#endif
|
||||
if (myCtx->exampleVar == 99) {
|
||||
info->pk.curve448kg.key->devId = devIdArg;
|
||||
/* the dispatcher must hand over a usable payload */
|
||||
if ((info->pk.curve448kg.rng == NULL) ||
|
||||
(info->pk.curve448kg.size != CURVE448_KEY_SIZE)) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
info->pk.curve448kg.key->devId = devIdArg;
|
||||
/* deterministic key material so the caller can prove the
|
||||
* callback's output actually reached it */
|
||||
XMEMSET(info->pk.curve448kg.key->k, 0x5A, CURVE448_KEY_SIZE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue