Skip to contentSkip to conversation

crypto: testmgr - fix RNG return code enforcement

PATCH Applied Alexander Bergmann 2 participants 2 messages Mar 11, 2015 – Mar 13, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: testmgr - fix RNG return code enforcement

From 0c7233769665f03e9f91342770dba7279f928c23 Mon Sep 17 00:00:00 2001
From: Stephan Mueller <[email protected]>
Date: Tue, 10 Mar 2015 17:00:36 +0100
Subject: [PATCH] crypto: testmgr - fix RNG return code enforcement

Due to the change to RNGs to always return zero in success case, the invocation of the RNGs in the test manager must be updated as otherwise the RNG self tests are not properly executed any more.

---
 crypto/testmgr.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
crypto/testmgr.c +5 -5
index f4ed6d4..1f879ad 100644
@@ -1474,11 +1474,11 @@ static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template,
 		for (j = 0; j < template[i].loops; j++) {
 			err = crypto_rng_get_bytes(tfm, result,
 						   template[i].rlen);
-			if (err != template[i].rlen) {
+			if (err < 0) {
 				printk(KERN_ERR "alg: cprng: Failed to obtain "
 				       "the correct amount of random data for "
-				       "%s (requested %d, got %d)\n", algo,
-				       template[i].rlen, err);
+				       "%s (requested %d)\n", algo,
+				       template[i].rlen);
 				goto out;
 			}
 		}
@@ -1759,7 +1759,7 @@ static int drbg_cavs_test(struct drbg_testvec *test, int pr,
 		ret = crypto_drbg_get_bytes_addtl(drng,
 			buf, test->expectedlen, &addtl);
 	}
-	if (ret <= 0) {
+	if (ret < 0) {
 		printk(KERN_ERR "alg: drbg: could not obtain random data for "
 		       "driver %s\n", driver);
 		goto outbuf;
@@ -1774,7 +1774,7 @@ static int drbg_cavs_test(struct drbg_testvec *test, int pr,
 		ret = crypto_drbg_get_bytes_addtl(drng,
 			buf, test->expectedlen, &addtl);
 	}
-	if (ret <= 0) {
+	if (ret < 0) {
 		printk(KERN_ERR "alg: drbg: could not obtain random data for "
 		       "driver %s\n", driver);
 		goto outbuf;
Signature · 7 lines
1.8.1.4

-- 
Alexander Bergmann <[email protected]>, Security Engineer,
SUSE Linux GmbH,
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton, HRB 21284 (AG Nürnberg)
maintainer Applied
#1 lore raw
Quoted 11 lines · Alexander Bergmann

From 0c7233769665f03e9f91342770dba7279f928c23 Mon Sep 17 00:00:00 2001
From: Stephan Mueller <[email protected]>
Date: Tue, 10 Mar 2015 17:00:36 +0100
Subject: [PATCH] crypto: testmgr - fix RNG return code enforcement

Due to the change to RNGs to always return zero in success case, the invocation of the RNGs in the test manager must be updated as otherwise the RNG self tests are not properly executed any more.

Applied.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt