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

From
David Howells <dhowells@redhat.com>
Date
2026-01-08 12:59:33
Also in
keyrings, linux-crypto, lkml
Reply to
David Howells, 2026-01-07
David Howells [off-list ref] wrote:
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.
Actually, we probably do need to copy it.  The problem is that we have to
modify the tag on the authenticatedAttributes (PKCS#7)/signedAttrs (CMS) blob
before we digest it, e.g. in pkcs7_digest():

	memcpy(sig->digest, sinfo->authattrs, sinfo->authattrs_len);
	((u8 *)sig->digest)[0] = ASN1_CONS_BIT | ASN1_SET;

as specified in RFC9882 and other places:

	3.2.  Signature Generation and Verification
	...
	When signed attributes are included, ML-DSA (pure mode) signatures are
	computed over the complete DER encoding of the SignedAttrs value
	contained in the SignerInfo's signedAttrs field.  As described in
	Section 5.4 of [RFC5652], this encoding includes the tag and length
	octets, but an EXPLICIT SET OF tag is used rather than the IMPLICIT
	[0] tag that appears in the final message. ...

We might be able to get away with modifying it in place - but I don't know
that that's true for all users.

David
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