Re: RFC: s390/crypto: Add hardware acceleration for HMAC modes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux