lkml.org 
[lkml]   [2023]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 03/13] crypto: x86/sha - yield FPU context during long loops
On Fri, Jan 13, 2023 at 07:35:07PM +0000, Elliott, Robert (Servers) wrote:
>
> pkcs_digest() uses shash like this:
> /* Allocate the hashing algorithm we're going to need and find out how
> * big the hash operational data will be.
> */
> tfm = crypto_alloc_shash(sinfo->sig->hash_algo, 0, 0);
> if (IS_ERR(tfm))
> return (PTR_ERR(tfm) == -ENOENT) ? -ENOPKG : PTR_ERR(tfm);
>
> desc_size = crypto_shash_descsize(tfm) + sizeof(*desc);
> sig->digest_size = crypto_shash_digestsize(tfm);
>
> ret = -ENOMEM;
> sig->digest = kmalloc(sig->digest_size, GFP_KERNEL);
> if (!sig->digest)
> goto error_no_desc;
>
> desc = kzalloc(desc_size, GFP_KERNEL);
> if (!desc)
> goto error_no_desc;
>
> desc->tfm = tfm;
>
> /* Digest the message [RFC2315 9.3] */
> ret = crypto_shash_digest(desc, pkcs7->data, pkcs7->data_len,
> sig->digest);
> if (ret < 0)
> goto error;
> pr_devel("MsgDigest = [%*ph]\n", 8, sig->digest);

As this path is sleepable, the conversion should be fairly trivial
with crypto_wait_req.

Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

\
 
 \ /
  Last update: 2023-03-26 23:42    [W:0.102 / U:1.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site