@@ -3499,8 +3499,11 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
/* Compute party A's public key */
err = crypto_wait_req(crypto_kpp_generate_public_key(req), &wait);
if (err) {
- pr_err("alg: %s: Party A: generate public key test failed. err %d\n",
- alg, err);
+ if (err != vec->gen_pubkey_error)
+ pr_err("alg: %s: Party A: generate public key test failed. err %d (expected %d)\n",
+ alg, err, vec->gen_pubkey_error);
+ else
+ err = 0;
goto free_output;
}
@@ -3537,8 +3540,11 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
crypto_req_done, &wait);
err = crypto_wait_req(crypto_kpp_compute_shared_secret(req), &wait);
if (err) {
- pr_err("alg: %s: Party A: compute shared secret test failed. err %d\n",
- alg, err);
+ if (err != vec->comp_ss_error)
+ pr_err("alg: %s: Party A: compute shared secret test failed. err %d (expected %d)\n",
+ alg, err, vec->comp_ss_error);
+ else
+ err = 0;
goto free_all;
}
@@ -166,6 +166,8 @@ struct kpp_testvec {
unsigned short expected_a_public_size;
unsigned short expected_ss_size;
bool genkey;
+ int gen_pubkey_error;
+ int comp_ss_error;
};
static const char zeroed_string[48];
The Curve25519 drivers we will be implementing will perform validation of the inputs, and in order to ensure that these checks work as expected, we need to be able to test for expected errors. So implement this in the KPP test routines in the testmgr framework. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- crypto/testmgr.c | 14 ++++++++++---- crypto/testmgr.h | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.20.1