diff mbox

crypto/drbg: report backend_cra_name when allocation fails

Message ID 1433942868-16447-2-git-send-email-sergey.senozhatsky@gmail.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Sergey Senozhatsky June 10, 2015, 1:27 p.m. UTC
Be more verbose and also report ->backend_cra_name when
crypto_alloc_shash() or crypto_alloc_cipher() fail in
drbg_init_hash_kernel() or drbg_init_sym_kernel()
correspondingly.

Example
 DRBG: could not allocate digest TFM handle: hmac(sha256)

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 crypto/drbg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Stephan Mueller June 10, 2015, 3:09 p.m. UTC | #1
Am Wednesday 10 June 2015, 22:27:48 schrieb Sergey Senozhatsky:

Hi Sergey,

>Be more verbose and also report ->backend_cra_name when
>crypto_alloc_shash() or crypto_alloc_cipher() fail in
>drbg_init_hash_kernel() or drbg_init_sym_kernel()
>correspondingly.
>
>Example
> DRBG: could not allocate digest TFM handle: hmac(sha256)
>
>Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

Headscratch -- the Kconfig should have HMAC selected for compilation. When 
HMAC is available (regardless whether it is a module or not), it is pulled in 
by the kernel crypto API. Thus, there should not have been the error that HMAC 
is missing.

Can you send your .config file, please?

Ciao
Stephan
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergey Senozhatsky June 10, 2015, 11:38 p.m. UTC | #2
On (06/10/15 17:09), Stephan Mueller wrote:
> Hi Sergey,
> 
> >Be more verbose and also report ->backend_cra_name when
> >crypto_alloc_shash() or crypto_alloc_cipher() fail in
> >drbg_init_hash_kernel() or drbg_init_sym_kernel()
> >correspondingly.
> >
> >Example
> > DRBG: could not allocate digest TFM handle: hmac(sha256)
> >
> >Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> 
> Headscratch -- the Kconfig should have HMAC selected for compilation. When 
> HMAC is available (regardless whether it is a module or not), it is pulled in 
> by the kernel crypto API. Thus, there should not have been the error that HMAC 
> is missing.
> 
> Can you send your .config file, please?
> 

Hi Stephan,

sure, will post it later (as soon as I get back to my laptop).

	-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Herbert Xu June 11, 2015, 2 p.m. UTC | #3
On Wed, Jun 10, 2015 at 10:27:48PM +0900, Sergey Senozhatsky wrote:
> Be more verbose and also report ->backend_cra_name when
> crypto_alloc_shash() or crypto_alloc_cipher() fail in
> drbg_init_hash_kernel() or drbg_init_sym_kernel()
> correspondingly.
> 
> Example
>  DRBG: could not allocate digest TFM handle: hmac(sha256)
> 
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

Patch applied.
diff mbox

Patch

diff --git a/crypto/drbg.c b/crypto/drbg.c
index 04836b4..d42f678 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1590,7 +1590,8 @@  static int drbg_init_hash_kernel(struct drbg_state *drbg)
 
 	tfm = crypto_alloc_shash(drbg->core->backend_cra_name, 0, 0);
 	if (IS_ERR(tfm)) {
-		pr_info("DRBG: could not allocate digest TFM handle\n");
+		pr_info("DRBG: could not allocate digest TFM handle: %s\n",
+				drbg->core->backend_cra_name);
 		return PTR_ERR(tfm);
 	}
 	BUG_ON(drbg_blocklen(drbg) != crypto_shash_digestsize(tfm));
@@ -1641,7 +1642,8 @@  static int drbg_init_sym_kernel(struct drbg_state *drbg)
 
 	tfm = crypto_alloc_cipher(drbg->core->backend_cra_name, 0, 0);
 	if (IS_ERR(tfm)) {
-		pr_info("DRBG: could not allocate cipher TFM handle\n");
+		pr_info("DRBG: could not allocate cipher TFM handle: %s\n",
+				drbg->core->backend_cra_name);
 		return PTR_ERR(tfm);
 	}
 	BUG_ON(drbg_blocklen(drbg) != crypto_cipher_blocksize(tfm));