Re: [PATCH v11 2/8] pkcs7: Allow the signing algo to calculate the digest itself

From
Ignat Korchagin <hidden>
Date
2026-01-07 14:00:01
Also in
keyrings, linux-crypto, lkml
Reply to
David Howells, 2026-01-07
On Wed, Jan 7, 2026 at 1:53 PM David Howells [off-list ref] wrote:
Ignat Korchagin [off-list ref] wrote:
quoted
quoted
+                       ret = -ENOMEM;
+                       sig->digest = kmalloc(umax(sinfo->authattrs_len, sig->digest_size),
+                                             GFP_KERNEL);
Can we refactor this so we allocate the right size from the start.
The problem is that we don't know the right size until we've tried parsing it.
quoted
Alternatively, should we just unconditionally use this approach
"overallocating" some times?
In some ways, what I'd rather do is push the hash calculation down into the
crypto/ layer for all public key algos.
Probably better indeed
Also, we probably don't actually need to copy the authattrs, just retain a
pointer into the source buffer and the length since we don't intend to keep
the digest around beyond the verification procedure.  So I might be able to
get away with just a flag saying I don't need to free it.

However, there's an intermediate hash if there are authattrs, so I will need
to store that somewhere - though that could be allocated on demand.

David
Ignat
Thread (26 messages) 26 messages, 4 authors, last reply 2026-01-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help