]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[crypto] Generalise rsa_parse_integer() to asn1_enter_unsigned()
authorMichael Brown <mcb30@ipxe.org>
Thu, 11 Dec 2025 15:02:28 +0000 (15:02 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 11 Dec 2025 15:09:58 +0000 (15:09 +0000)
commitfb1188936ca29af61709afd8b866ea55d4a05a67
tree5f319cca897d210a2e087ca8337633351726b414
parentc7f129fedef8c576c3399e20defcb32ad16fad36
[crypto] Generalise rsa_parse_integer() to asn1_enter_unsigned()

ECDSA signature values and private keys are fixed-length unsigned
integers modulo N (the group order of the elliptic curve) and are
therefore most naturally represented in ASN.1 using ASN1_OCTET_STRING.

Private key representations do use ASN1_OCTET_STRING, but signature
values tend to use ASN1_INTEGER, which adds no value but does ensure
that the encoding becomes variable-length and requires handling a
pointless extra zero byte if the MSB of the unsigned value happens to
be set.

RSA also makes use of ASN1_INTEGER for modulus and exponent values.
Generalise the existing rsa_parse_integer() to asn1_enter_unsigned()
to allow this code to be reused for ECDSA.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/crypto/asn1.c
src/crypto/rsa.c
src/include/ipxe/asn1.h