All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald Freudenberger <freude@linux.ibm.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, Holger Dengler <dengler@linux.ibm.com>
Subject: Re: RFC: s390/crypto: Add hardware acceleration for HMAC modes
Date: Wed, 14 Aug 2024 10:52:55 +0200	[thread overview]
Message-ID: <e3ee41957dea7c296aece5daa56a692b@linux.ibm.com> (raw)
In-Reply-To: <ZrsVYl3NYdRbUMNm@gondor.apana.org.au>

On 2024-08-13 10:12, Herbert Xu wrote:
> On Tue, Aug 13, 2024 at 09:37:24AM +0200, Harald Freudenberger wrote:
>> 
>> +static int hash(const u8 *in, unsigned int inlen,
>> +		u8 *digest, unsigned int digestsize)
>> +{
>> +	struct crypto_shash *htfm;
>> +	const char *alg_name;
>> +	int ret;
>> +
>> +	switch (digestsize) {
>> +	case SHA224_DIGEST_SIZE:
>> +		alg_name = "sha224";
>> +		break;
>> +	case SHA256_DIGEST_SIZE:
>> +		alg_name = "sha256";
>> +		break;
>> +	case SHA384_DIGEST_SIZE:
>> +		alg_name = "sha384";
>> +		break;
>> +	case SHA512_DIGEST_SIZE:
>> +		alg_name = "sha512";
>> +		break;
>> +	default:
>> +		return -EINVAL;
>> +	}
>> +
>> +	htfm = crypto_alloc_shash(alg_name, 0, CRYPTO_ALG_NEED_FALLBACK);
>> +	if (IS_ERR(htfm))
>> +		return PTR_ERR(htfm);
>> +
>> +	ret = crypto_shash_tfm_digest(htfm, in, inlen, digest);
>> +	if (ret)
>> +		pr_err("shash digest error: %d\n", ret);
>> +
>> +	crypto_free_shash(htfm);
>> +	return ret;
>> +}
> 
> The setkey function can be called in softirq context.  Therefore
> calling crypto_alloc_* from it is not allowed.  You could either
> move the allocation to init_tfm and carry it throughout the life
> of the tfm, or perhaps you could call the s390 underlying sha hash
> function directly?
> 
> Cheers,

Ok, good catch. I'll discuss this with Holger when he is back from 
vacation.

Thanks for your work.

      reply	other threads:[~2024-08-14  8:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240807160629.2486-1-dengler@linux.ibm.com>
     [not found] ` <20240807160629.2486-3-dengler@linux.ibm.com>
2024-08-13  7:37   ` RFC: s390/crypto: Add hardware acceleration for HMAC modes Harald Freudenberger
2024-08-13  8:12     ` Herbert Xu
2024-08-14  8:52       ` Harald Freudenberger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3ee41957dea7c296aece5daa56a692b@linux.ibm.com \
    --to=freude@linux.ibm.com \
    --cc=dengler@linux.ibm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.