Jarkko Sakkinen <[email protected]> wrote:

> >  (1) Rename ->digest and ->digest_len to ->m and ->m_size to represent the
> >      input to the signature verification algorithm, reflecting that
> >      ->digest may no longer actually *be* a digest.
> ...
> These renames emit enough noise to be split into a separate patch.

Yeah, I had considered that, so I've now done that.

> > +           if (sig->algo_takes_data) {
> > +                   sig->m_size = sinfo->authattrs_len;
> > +                   memcpy(sig->m, sinfo->authattrs, sinfo->authattrs_len);
> > +                   sig->m[0] = ASN1_CONS_BIT | ASN1_SET;
> > +                   ret = 0;
> > +           } else {
> > +                   u8 tag = ASN1_CONS_BIT | ASN1_SET;
> > +
> > +                   ret = crypto_shash_init(desc);
> > +                   if (ret < 0)
> > +                           goto error;
> > +                   ret = crypto_shash_update(desc, &tag, 1);
> > +                   if (ret < 0)
> > +                           goto error;
> > +                   ret = crypto_shash_finup(desc, sinfo->authattrs + 1,
> > +                                            sinfo->authattrs_len - 1,
> > +                                            sig->m);
> > +                   if (ret < 0)
> > +                           goto error;
> > +           }

Thinking further on this, I think it's better just to do the copy and modify
unconditionally and then in the second case here just call
crypto_hash_digest().  That means we end up doing a single crypto call on an
aligned buffer.  It's not like expect the authattrs to be particularly big for
an RSA signature.

David


Reply via email to