Lee, Chun-Yi <[email protected]> wrote:

> +             desc_size = crypto_shash_descsize(tfm) + sizeof(*desc);
> +             digest_size = crypto_shash_digestsize(tfm);
> +             digest = kzalloc(digest_size + desc_size, GFP_KERNEL);
> +             if (!digest) {
> +                     pr_err("digest memory buffer allocate fail\n");
> +                     ret = -ENOMEM;
> +                     goto error_digest;
> +             }
> +             desc = (void *)digest + digest_size;
> +             desc->tfm = tfm;
> +             desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
> +             ret = crypto_shash_init(desc);
> +             if (ret < 0)
> +                     goto error_shash;
> +
> +             ret = crypto_shash_finup(desc, mod, modlen, digest);
> +             if (ret < 0)
> +                     goto error_shash;

Can you use the digest generated by mod_make_digest() to avoid computing the
hash twice?

David
_______________________________________________
kernel mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/kernel

Reply via email to