Re: [RFC PATCH v2 4/4] crypto: testmgr - add genkey kpp test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 17.05.2017 18:26, Tudor Ambarus wrote:
The test considers a party that already has a private-public
key pair and a party that provides a NULL key. The kernel will
generate the private-public key pair for the latter, computes
the shared secret on both ends and verifies it it's the same.

The explicit private-public key pairs were copied from
the previous test vectors.

Signed-off-by: Tudor Ambarus <tudor.ambarus@xxxxxxxxxxxxx>
---
  crypto/testmgr.c |  76 +++++++++++++++++++++++----
  crypto/testmgr.h | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 220 insertions(+), 11 deletions(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 6f5f3ed..faf5fd8 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1997,6 +1997,9 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
  	struct kpp_request *req;
  	void *input_buf = NULL;
  	void *output_buf = NULL;
+	void *a_public = NULL;
+	void *a_ss = NULL;
+	void *shared_secret = NULL;
  	struct tcrypt_result result;
  	unsigned int out_len_max;
  	int err = -ENOMEM;
@@ -2026,20 +2029,31 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec,
  	kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
  				 tcrypt_complete, &result);
- /* Compute public key */
+	/* Compute party A's public key */
  	err = wait_async_op(&result, crypto_kpp_generate_public_key(req));
  	if (err) {
-		pr_err("alg: %s: generate public key test failed. err %d\n",
+		pr_err("alg: %s: Party A: generate public key test failed. err %d\n",
  		       alg, err);
  		goto free_output;
  	}
-	/* Verify calculated public key */
-	if (memcmp(vec->expected_a_public, sg_virt(req->dst),
-		   vec->expected_a_public_size)) {
-		pr_err("alg: %s: generate public key test failed. Invalid output\n",
-		       alg);
-		err = -EINVAL;
-		goto free_output;
+
+	if (vec->genkey) {
+		/* Save party A's public key */
+		a_public = kzalloc(out_len_max, GFP_KERNEL);
+		if (!a_public) {
+			err = -ENOMEM;
+			goto free_output;
+		}
+		memcpy(a_public, sg_virt(req->dst), sizeof(*a_public));

The size is wrong, I'll correct it in the next version.



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux