42 #ifndef ATCACERT_DATE_H
43 #define ATCACERT_DATE_H
78 #define DATEFMT_ISO8601_SEP_SIZE (20)
79 #define DATEFMT_RFC5280_UTC_SIZE (13)
80 #define DATEFMT_POSIX_UINT32_BE_SIZE (4)
81 #define DATEFMT_POSIX_UINT32_LE_SIZE (4)
82 #define DATEFMT_RFC5280_GEN_SIZE (15)
83 #define DATEFMT_MAX_SIZE DATEFMT_ISO8601_SEP_SIZE
85 static const size_t ATCACERT_DATE_FORMAT_SIZES[] = {
111 uint8_t* formatted_date,
112 size_t* formatted_date_size);
125 const uint8_t* formatted_date,
126 size_t formatted_date_size,
141 uint8_t expire_years,
142 uint8_t enc_dates[3]);
int tm_mday
Definition: atcacert_date.h:62
Declarations common to all atcacert code.
int tm_min
Definition: atcacert_date.h:60
int tm_mon
Definition: atcacert_date.h:63
int atcacert_date_enc_rfc5280_gen(const atcacert_tm_utc_t *timestamp, uint8_t formatted_date[DATEFMT_RFC5280_GEN_SIZE])
Definition: atcacert_date.c:435
POSIX (aka UNIX) date format. Seconds since Jan 1, 1970. 32 bit unsigned integer, big endian...
Definition: atcacert_date.h:73
ISO8601 full date YYYY-MM-DDThh:mm:ssZ.
Definition: atcacert_date.h:71
int atcacert_date_enc(atcacert_date_format_t format, const atcacert_tm_utc_t *timestamp, uint8_t *formatted_date, size_t *formatted_date_size)
Format a timestamp according to the format type.
Definition: atcacert_date.c:46
#define DATEFMT_POSIX_UINT32_LE_SIZE
Definition: atcacert_date.h:81
#define DATEFMT_ISO8601_SEP_SIZE
Definition: atcacert_date.h:78
POSIX (aka UNIX) date format. Seconds since Jan 1, 1970. 32 bit unsigned integer, little endian...
Definition: atcacert_date.h:74
RFC 5280 (X.509) 4.1.2.5.1 UTCTime format YYMMDDhhmmssZ.
Definition: atcacert_date.h:72
atcacert_date_format_e
Definition: atcacert_date.h:70
int atcacert_date_enc_posix_uint32_be(const atcacert_tm_utc_t *timestamp, uint8_t formatted_date[DATEFMT_POSIX_UINT32_BE_SIZE])
Definition: atcacert_date.c:696
#define DATEFMT_RFC5280_GEN_SIZE
Definition: atcacert_date.h:82
struct atcacert_tm_utc_s atcacert_tm_utc_t
int atcacert_date_dec_rfc5280_utc(const uint8_t formatted_date[DATEFMT_RFC5280_UTC_SIZE], atcacert_tm_utc_t *timestamp)
Definition: atcacert_date.c:382
#define DATEFMT_RFC5280_UTC_SIZE
Definition: atcacert_date.h:79
int atcacert_date_dec_rfc5280_gen(const uint8_t formatted_date[DATEFMT_RFC5280_GEN_SIZE], atcacert_tm_utc_t *timestamp)
Definition: atcacert_date.c:475
Definition: atcacert_date.h:58
int tm_sec
Definition: atcacert_date.h:59
int atcacert_date_dec_posix_uint32_be(const uint8_t formatted_date[DATEFMT_POSIX_UINT32_BE_SIZE], atcacert_tm_utc_t *timestamp)
Definition: atcacert_date.c:747
RFC 5280 (X.509) 4.1.2.5.2 GeneralizedTime format YYYYMMDDhhmmssZ.
Definition: atcacert_date.h:75
int atcacert_date_enc_iso8601_sep(const atcacert_tm_utc_t *timestamp, uint8_t formatted_date[DATEFMT_ISO8601_SEP_SIZE])
Definition: atcacert_date.c:224
int atcacert_date_get_max_date(atcacert_date_format_t format, atcacert_tm_utc_t *timestamp)
Return the maximum date available for the given format.
Definition: atcacert_date.c:97
int tm_hour
Definition: atcacert_date.h:61
int atcacert_date_enc_posix_uint32_le(const atcacert_tm_utc_t *timestamp, uint8_t formatted_date[DATEFMT_POSIX_UINT32_LE_SIZE])
Definition: atcacert_date.c:764
#define DATEFMT_POSIX_UINT32_BE_SIZE
Definition: atcacert_date.h:80
enum atcacert_date_format_e atcacert_date_format_t
int atcacert_date_enc_rfc5280_utc(const atcacert_tm_utc_t *timestamp, uint8_t formatted_date[DATEFMT_RFC5280_UTC_SIZE])
Definition: atcacert_date.c:338
int atcacert_date_enc_compcert(const atcacert_tm_utc_t *issue_date, uint8_t expire_years, uint8_t enc_dates[3])
Encode the issue and expire dates in the format used by the compressed certificate.
Definition: atcacert_date.c:802
int atcacert_date_dec(atcacert_date_format_t format, const uint8_t *formatted_date, size_t formatted_date_size, atcacert_tm_utc_t *timestamp)
Parse a formatted timestamp according to the specified format.
Definition: atcacert_date.c:74
int atcacert_date_dec_compcert(const uint8_t enc_dates[3], atcacert_date_format_t expire_date_format, atcacert_tm_utc_t *issue_date, atcacert_tm_utc_t *expire_date)
Decode the issue and expire dates from the format used by the compressed certificate.
Definition: atcacert_date.c:846
int tm_year
Definition: atcacert_date.h:64
int atcacert_date_dec_iso8601_sep(const uint8_t formatted_date[DATEFMT_ISO8601_SEP_SIZE], atcacert_tm_utc_t *timestamp)
Definition: atcacert_date.c:274
int atcacert_date_dec_posix_uint32_le(const uint8_t formatted_date[DATEFMT_POSIX_UINT32_LE_SIZE], atcacert_tm_utc_t *timestamp)
Definition: atcacert_date.c:785