|
Botan 3.13.0
Crypto and TLS for C&
|
#include <pkix_types.h>
Public Member Functions | |
| std::vector< uint8_t > | BER_encode () const |
| bool | conforms_to_rfc5280 () const |
| void | decode_from (BER_Decoder &from) override |
| std::span< const uint8_t > | der_contents () const |
| void | encode_into (DER_Encoder &to) const override |
| bool | is_negative () const |
| bool | is_zero () const |
| std::vector< uint8_t > | magnitude () const |
| size_t | octet_length () const |
| std::strong_ordering | operator<=> (const X509_Serial_Number &other) const |
| bool | operator== (const X509_Serial_Number &other) const |
| BigInt | to_bigint () const |
| std::string | to_string () const |
| X509_Serial_Number () | |
| X509_Serial_Number (const BigInt &value) | |
Static Public Member Functions | |
| static X509_Serial_Number | from_bytes (std::span< const uint8_t > bytes) |
| static X509_Serial_Number | from_der_contents (std::span< const uint8_t > contents) |
| static X509_Serial_Number | random (RandomNumberGenerator &rng) |
X.509 certificate serial number (RFC 5280 CertificateSerialNumber)
Stores the value as the contents octets of the DER INTEGER encoding (two's complement, minimal length), so the sign is preserved and equality on the stored bytes is value equality.
RFC 5280 4.1.2.2: The serial number MUST be a positive integer assigned by the CA to each certificate. and Note: Non-conforming CAs may issue certificates with serial numbers that are negative or zero. Certificate users SHOULD be prepared to gracefully handle such certificates.
so non-conforming values are representable, and can be detected with is_negative, is_zero and octet_length.
Definition at line 65 of file pkix_types.h.
|
inline |
Serial number zero
Definition at line 70 of file pkix_types.h.
Referenced by decode_from(), from_bytes(), from_der_contents(), operator<=>(), operator==(), and random().
|
explicit |
Create from an integer value
Definition at line 20 of file x509_serial.cpp.
|
inherited |
Return the encoding of this object. This is a convenience method when just one object needs to be serialized. Use DER_Encoder for complicated encodings.
Definition at line 21 of file asn1_obj.cpp.
References encode_into().
Referenced by decode_from(), Botan::PKCS12::export_to(), Botan::Certificate_Store_In_SQL::find_all_certs(), Botan::Certificate_Store_In_SQL::find_cert(), Botan::X509_Certificate::fingerprint(), Botan::Certificate_Store_In_SQL::insert_cert(), Botan::X509_Object::PEM_encode(), and Botan::PSS_Params::PSS_Params().
|
inline |
True if this serial number satisfies the RFC 5280 4.1.2.2 rules for conforming CAs: a positive integer of at most 20 octets
Definition at line 118 of file pkix_types.h.
References is_negative(), is_zero(), and octet_length().
|
overridevirtual |
Decode whatever this object is from from
| from | the BER_Decoder that will be read from |
Implements Botan::ASN1_Object.
Definition at line 108 of file x509_serial.cpp.
References Botan::BER_Decoder::decode(), and X509_Serial_Number().
|
inline |
The contents octets of the DER INTEGER encoding (big-endian two's complement, minimal length)
Definition at line 124 of file pkix_types.h.
|
overridevirtual |
Encode whatever this object is into to
| to | the DER_Encoder that will be written to |
Implements Botan::ASN1_Object.
Definition at line 103 of file x509_serial.cpp.
References Botan::DER_Encoder::add_object(), BOTAN_STATE_CHECK, Botan::Integer, and Botan::Universal.
|
static |
Create from an unsigned big-endian encoded integer
Definition at line 22 of file x509_serial.cpp.
References X509_Serial_Number().
Referenced by random().
|
static |
Create from the contents octets of a BER INTEGER (big-endian two's complement). Redundant leading octets are normalized away; an empty input is rejected.
Definition at line 40 of file x509_serial.cpp.
References X509_Serial_Number().
| bool Botan::X509_Serial_Number::is_negative | ( | ) | const |
Return true if the serial number is negative
TODO(Botan4) remove this once negative serial numbers are prohibited
Definition at line 65 of file x509_serial.cpp.
References BOTAN_STATE_CHECK.
Referenced by Botan::PKIX::check_chain(), conforms_to_rfc5280(), Botan::X509_Certificate::is_serial_negative(), magnitude(), operator<=>(), and to_string().
| bool Botan::X509_Serial_Number::is_zero | ( | ) | const |
Return true if the serial number is the integer zero
Definition at line 70 of file x509_serial.cpp.
Referenced by conforms_to_rfc5280(), magnitude(), and to_string().
| std::vector< uint8_t > Botan::X509_Serial_Number::magnitude | ( | ) | const |
The absolute value as unsigned big-endian bytes without leading zeros. Note this loses the sign, and is empty for a zero serial; it matches X509_Certificate::serial_number.
Definition at line 74 of file x509_serial.cpp.
References BOTAN_STATE_CHECK, is_negative(), is_zero(), Botan::BigInt::serialize(), and to_bigint().
Referenced by to_string().
|
inline |
Number of contents octets in the DER encoding of this value
Definition at line 112 of file pkix_types.h.
Referenced by conforms_to_rfc5280().
| std::strong_ordering Botan::X509_Serial_Number::operator<=> | ( | const X509_Serial_Number & | other | ) | const |
Numeric ordering
Definition at line 116 of file x509_serial.cpp.
References BOTAN_STATE_CHECK, is_negative(), and X509_Serial_Number().
|
inline |
Definition at line 143 of file pkix_types.h.
References X509_Serial_Number().
|
static |
Generate a serial number suitable for issuing a certificate.
The result is positive, never zero, and contains 126 bits of output from the RNG. The topmost bit is cleared, and the 127th bit is set.
Definition at line 57 of file x509_serial.cpp.
References from_bytes(), Botan::RandomNumberGenerator::randomize(), and X509_Serial_Number().
Referenced by Botan::X509_CA::make_cert().
| BigInt Botan::X509_Serial_Number::to_bigint | ( | ) | const |
Definition at line 89 of file x509_serial.cpp.
References BOTAN_STATE_CHECK, and Botan::ASN1::integer_from_contents().
Referenced by botan_x509_cert_serial_number(), botan_x509_crl_entry_serial_number(), and magnitude().
| std::string Botan::X509_Serial_Number::to_string | ( | ) | const |
The value in hex, prefixed with '-' if negative
Definition at line 94 of file x509_serial.cpp.
References BOTAN_STATE_CHECK, Botan::hex_encode(), is_negative(), is_zero(), and magnitude().
Referenced by Botan::X509_Certificate::to_string().