lkml.org 
[lkml]   [2018]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK
    On Thu, Jul 12, 2018 at 11:22 PM, Herbert Xu
    <herbert@gondor.apana.org.au> wrote:
    > On Thu, Jul 12, 2018 at 11:16:28PM -0700, Kees Cook wrote:
    >>
    >> Is this correct? It seems like you did the bulk of
    >> AHASH_REQUEST_ON_STACK conversions in 2016. Can shash grow an sg
    >> interface?
    >
    > shash does not need to grow an sg interface. All users of
    > AHASH_REQUEST_ON_STACK set the CRYPTO_ALG_ASYNC flag to zero
    > when allocating the tfm.

    On a plane today I started converting all these to shash. IIUC, it
    just looks like this (apologies for whitespace damage):


    static int crypt_iv_essiv_init(struct crypt_config *cc)
    {
    struct iv_essiv_private *essiv = &cc->iv_gen_private.essiv;
    - AHASH_REQUEST_ON_STACK(req, essiv->hash_tfm);
    - struct scatterlist sg;
    + SHASH_DESC_ON_STACK(desc, essiv->hash_tfm);
    struct crypto_cipher *essiv_tfm;
    int err;

    - sg_init_one(&sg, cc->key, cc->key_size);
    - ahash_request_set_tfm(req, essiv->hash_tfm);
    - ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL);
    - ahash_request_set_crypt(req, &sg, essiv->salt, cc->key_size);
    + desc->tfm = essiv->hash_tfm;
    + desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;

    - err = crypto_ahash_digest(req);
    - ahash_request_zero(req);
    + err = crypto_shash_digest(desc, key, cc->key_size, essiv->salt);
    + shash_desc_zero(desc);
    if (err)
    return err;


    (I left out all the s/ahash/shash/ in types and function declarations.)

    Does this look like what you were thinking of for converting these
    away from ahash? The only one I couldn't make sense of was in
    drivers/crypto/inside-secure/safexcel_hash.c. I have no idea what's
    happening there.

    -Kees

    --
    Kees Cook
    Pixel Security
    \
     
     \ /
      Last update: 2018-07-15 22:07    [W:2.779 / U:0.236 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site