Skip to content

Commit

Permalink
fix curve25519 test sanitizer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrett committed Oct 30, 2024
1 parent 589bcaa commit 20cf6b7
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -35110,29 +35110,38 @@ static wc_test_ret_t curve255519_der_test(void)
if (ret < 0) {
ret = WC_TEST_RET_ENC_EC(ret);
}
/* Decode private key */
idx = 0;
ret = wc_Curve25519KeyDecode(kCurve25519PrivDer, &idx, &key,
(word32)sizeof(kCurve25519PrivDer));
if (ret < 0) {
ret = WC_TEST_RET_ENC_EC(ret);
if (ret == 0) {
/* Decode private key */
idx = 0;
ret = wc_Curve25519KeyDecode(kCurve25519PrivDer, &idx, &key,
(word32)sizeof(kCurve25519PrivDer));
if (ret < 0) {
ret = WC_TEST_RET_ENC_EC(ret);
}
}
/* Both public and private flags should be set */
if ((ret == 0) && (!key.pubSet && !key.privSet)) {
ret = WC_TEST_RET_ENC_NC;
}
if (ret == 0) {
/* Export key to temporary DER */
ret = wc_Curve25519KeyToDer(&key, output, sizeof(output), 1);
if (ret < 0) {
outputSz = (word32)sizeof(output);
ret = wc_Curve25519KeyToDer(&key, output, outputSz, 1);
if (ret >= 0) {
outputSz = (word32)ret;
ret = 0;
}
else {
ret = WC_TEST_RET_ENC_EC(ret);
}

/* Re-import temporary DER */
idx = 0;
ret = wc_Curve25519KeyDecode(output, &idx, &key, sizeof(output));
if (ret < 0) {
ret = WC_TEST_RET_ENC_EC(ret);
if (ret == 0) {
idx = 0;
ret = wc_Curve25519KeyDecode(output, &idx, &key, sizeof(output));
if (ret < 0) {
ret = WC_TEST_RET_ENC_EC(ret);
}
}

/* Ensure public and private keys survived combined keypair
Expand Down

0 comments on commit 20cf6b7

Please sign in to comment.