crypto: drbg - Use str_true_false() and str_enabled_disabled() helpers
authorThorsten Blum <thorsten.blum@linux.dev>
Wed, 16 Oct 2024 13:57:28 +0000 (15:57 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 28 Oct 2024 10:33:10 +0000 (18:33 +0800)
Remove hard-coded strings by using the helper functions str_true_false()
and str_enabled_disabled().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/drbg.c

index 3addce9..c323f40 100644 (file)
 #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 */