diff mbox

[v2,16/25] crypto: testmgr - Report failure on zero-length crypto_rng_get_bytes

Message ID 62e1366f793c73930bc8cccda73ab9b47cd6756e.1417951990.git.linux@horizon.com (mailing list archive)
State RFC
Delegated to: Herbert Xu
Headers show

Commit Message

George Spelvin Dec. 7, 2014, 12:26 p.m. UTC
If crypto_rng_get_bytes returns an error code, returning it is a good
idea, but if it simply returns zero, the test shouldn't abort successfully.

Signed-off-by: George Spelvin <linux@horizon.com>
---
 crypto/testmgr.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 0e179c72..9faf265f 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1476,6 +1476,8 @@  static int test_cprng(struct crypto_rng *tfm,
 				       "the correct amount of random data for "
 				       "%s (requested %d, got %d)\n", algo,
 				       template[i].rlen, err);
+				if (err >= 0)
+					err = -EINVAL;
 				break;
 			}
 		}