RustCrypto / formats

Cryptography-related format encoders/decoders: DER, PEM, PKCS, PKIX
243 stars 129 forks source link

der: return `Tag::Integer.length_error()` on empty ints #1400

Closed tarcieri closed 4 months ago

tarcieri commented 4 months ago

From X.690 § 8.3.1:

8.3 Encoding of an integer value 8.3.1 The encoding of an integer value shall be primitive. The contents octets shall consist of one or more octets.

Previously this returned ErrorKind::Noncanonical, however this restriction applies to all INTEGER encodings including BER, so ErrorKind::Length is more appropriate.