X.509 time decoding, parsing, comparison, and validity helpers. More...
Go to the source code of this file.
Typedefs | |
| typedef qsc_asn1_time | qsc_x509_time |
| Alias for the normalized ASN.1 time representation used by X.509 helpers. | |
Functions | |
| QSC_EXPORT_API bool | qsc_x509_time_decode (qsc_x509_time *out, const qsc_encoding_ber_element *elem) |
| Decode an ASN.1 X.509 time element. | |
| QSC_EXPORT_API bool | qsc_x509_time_parse_utctime (const char *s, size_t len, qsc_x509_time *out) |
| Parse a UTCTime string. | |
| QSC_EXPORT_API bool | qsc_x509_time_parse_generalizedtime (const char *s, size_t len, qsc_x509_time *out) |
| Parse a GeneralizedTime string. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_validity_decode (qsc_x509_validity *validity, const qsc_encoding_ber_element *elem) |
| Decode a certificate Validity sequence. | |
| QSC_EXPORT_API int32_t | qsc_x509_time_compare (const qsc_x509_time *a, const qsc_x509_time *b) |
| Compare two X.509 time values. | |
| QSC_EXPORT_API bool | qsc_x509_time_is_valid (const qsc_x509_time *time) |
| Test whether a normalized X.509 time value is structurally valid. | |
| QSC_EXPORT_API bool | qsc_x509_validity_is_valid (const qsc_x509_validity *validity, const qsc_x509_time *tnow) |
| Test whether a validity interval is current at a supplied time. | |
X.509 time decoding, parsing, comparison, and validity helpers.
This header defines the public interface used to decode and manipulate X.509 time values and certificate validity intervals. The X.509 time alias is mapped directly to the ASN.1 time representation used by the underlying encoding layer.
The interface supports decoding of ASN.1 Time elements, parsing of UTCTime and GeneralizedTime text forms, comparison of normalized time values, basic structural validity checks, and evaluation of whether a certificate validity interval is current at a supplied reference time.
| typedef qsc_asn1_time qsc_x509_time |
Alias for the normalized ASN.1 time representation used by X.509 helpers.
The X.509 time type is defined as a direct alias of qsc_asn1_time so that X.509 validity processing and ASN.1 time parsing operate on the same canonical structure.
| QSC_EXPORT_API int32_t qsc_x509_time_compare | ( | const qsc_x509_time * | a, |
| const qsc_x509_time * | b ) |
Compare two X.509 time values.
Performs an ordered comparison of two normalized time values.
| a | [const][struct] The first time value. |
| b | [const][struct] The second time value. |
a is earlier than b, zero if the values are equal, or a positive value if a is later than b. | QSC_EXPORT_API bool qsc_x509_time_decode | ( | qsc_x509_time * | out, |
| const qsc_encoding_ber_element * | elem ) |
Decode an ASN.1 X.509 time element.
Decodes an ASN.1 time element and normalizes the result into the supplied X.509 time object. The input element may represent either a UTCTime or a GeneralizedTime value.
| out | [struct] The destination decoded time object. |
| elem | [const][struct] The ASN.1 element containing the encoded time value. |
| QSC_EXPORT_API bool qsc_x509_time_is_valid | ( | const qsc_x509_time * | time | ) |
Test whether a normalized X.509 time value is structurally valid.
Checks that the supplied time object contains a valid normalized calendar and clock representation suitable for X.509 validity evaluation.
| time | [const][struct] The time object to validate. |
| QSC_EXPORT_API bool qsc_x509_time_parse_generalizedtime | ( | const char * | s, |
| size_t | len, | ||
| qsc_x509_time * | out ) |
Parse a GeneralizedTime string.
Parses a character string encoded in ASN.1 GeneralizedTime textual form and writes the normalized result to the supplied X.509 time object. The accepted form is exactly YYYYMMDDHHMMSSZ as required by DER.
| s | [const] The input GeneralizedTime character buffer. |
| len | The length of the input buffer in bytes. |
| out | [struct] The destination parsed time object. |
| QSC_EXPORT_API bool qsc_x509_time_parse_utctime | ( | const char * | s, |
| size_t | len, | ||
| qsc_x509_time * | out ) |
Parse a UTCTime string.
Parses a character string encoded in ASN.1 UTCTime textual form and writes the normalized result to the supplied X.509 time object. The accepted form is exactly YYMMDDHHMMSSZ as required by DER.
| s | [const] The input UTCTime character buffer. |
| len | The length of the input buffer in bytes. |
| out | [struct] The destination parsed time object. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_validity_decode | ( | qsc_x509_validity * | validity, |
| const qsc_encoding_ber_element * | elem ) |
Decode a certificate Validity sequence.
Decodes an ASN.1 Validity sequence and writes the notBefore and notAfter values to the supplied X.509 validity structure. The function accepts only a two-element DER Validity sequence and rejects intervals where notBefore is later than notAfter.
| validity | [struct] The destination validity object. |
| elem | [const][struct] The ASN.1 element containing the encoded Validity sequence. |
| QSC_EXPORT_API bool qsc_x509_validity_is_valid | ( | const qsc_x509_validity * | validity, |
| const qsc_x509_time * | tnow ) |
Test whether a validity interval is current at a supplied time.
Evaluates whether the supplied reference time falls within the certificate validity interval described by the notBefore and notAfter fields.
| validity | [const][struct] The certificate validity interval. |
| tnow | [const][struct] The reference time used for evaluation. |