Skip to contentSkip to conversation

crypto: drbg - Use str_true_false() and str_enabled_disabled() helpers

PATCH In review Thorsten Blum 2 participants 2 messages Oct 16, 2024 – Oct 26, 2024 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: drbg - Use str_true_false() and str_enabled_disabled() helpers

Remove hard-coded strings by using the helper functions str_true_false() and str_enabled_disabled().

---
 crypto/drbg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
crypto/drbg.c +3 -2
index 3addce90930c..c323f40bed4f 100644
@@ -101,6 +101,7 @@
 #include <crypto/internal/cipher.h>
 #include <linux/kernel.h>
 #include <linux/jiffies.h>
+#include <linux/string_choices.h>
 
 /***************************************************************
  * Backend cipher definitions available to DRBG
@@ -1412,7 +1413,7 @@ static int drbg_generate(struct drbg_state *drbg,
 	if (drbg->pr || drbg->seeded == DRBG_SEED_STATE_UNSEEDED) {
 		pr_devel("DRBG: reseeding before generation (prediction "
 			 "resistance: %s, state %s)\n",
-			 drbg->pr ? "true" : "false",
+			 str_true_false(drbg->pr),
 			 (drbg->seeded ==  DRBG_SEED_STATE_FULL ?
 			  "seeded" : "unseeded"));
 		/* 9.3.1 steps 7.1 through 7.3 */
@@ -1562,7 +1563,7 @@ static int drbg_instantiate(struct drbg_state *drbg, struct drbg_string *pers,
 	bool reseed = true;
 
 	pr_devel("DRBG: Initializing DRBG core %d with prediction resistance "
-		 "%s\n", coreref, pr ? "enabled" : "disabled");
+		 "%s\n", coreref, str_enabled_disabled(pr));
 	mutex_lock(&drbg->drbg_mutex);
 
 	/* 9.1 step 1 is implicit with the selected DRBG type */
Signature · 1 line
2.47.0
maintainer
#1 lore raw
Quoted 7 lines · Thorsten Blum

Remove hard-coded strings by using the helper functions str_true_false() and str_enabled_disabled().

---
 crypto/drbg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch applied. Thanks.

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