CryptoAuthLib
Atmel CryptoAuthentication Library
atcacert_date.h
Go to the documentation of this file.
1 
42 #ifndef ATCACERT_DATE_H
43 #define ATCACERT_DATE_H
44 
45 #include "atcacert.h"
46 
58 typedef struct atcacert_tm_utc_s {
59  int tm_sec; // 0 to 59
60  int tm_min; // 0 to 59
61  int tm_hour; // 0 to 23
62  int tm_mday; // 1 to 31
63  int tm_mon; // 0 to 11
64  int tm_year; // years since 1900
66 
70 typedef enum atcacert_date_format_e {
77 
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
84 
85 static const size_t ATCACERT_DATE_FORMAT_SIZES[] = {
91 };
92 
93 // Inform function naming when compiling in C++
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 
110  const atcacert_tm_utc_t* timestamp,
111  uint8_t* formatted_date,
112  size_t* formatted_date_size);
113 
125  const uint8_t* formatted_date,
126  size_t formatted_date_size,
127  atcacert_tm_utc_t* timestamp);
128 
140 int atcacert_date_enc_compcert( const atcacert_tm_utc_t* issue_date,
141  uint8_t expire_years,
142  uint8_t enc_dates[3]);
143 
157 int atcacert_date_dec_compcert( const uint8_t enc_dates[3],
158  atcacert_date_format_t expire_date_format,
159  atcacert_tm_utc_t* issue_date,
160  atcacert_tm_utc_t* expire_date);
161 
171 
173  uint8_t formatted_date[DATEFMT_ISO8601_SEP_SIZE]);
174 
175 int atcacert_date_dec_iso8601_sep( const uint8_t formatted_date[DATEFMT_ISO8601_SEP_SIZE],
176  atcacert_tm_utc_t* timestamp);
177 
179  uint8_t formatted_date[DATEFMT_RFC5280_UTC_SIZE]);
180 
181 int atcacert_date_dec_rfc5280_utc( const uint8_t formatted_date[DATEFMT_RFC5280_UTC_SIZE],
182  atcacert_tm_utc_t* timestamp);
183 
185  uint8_t formatted_date[DATEFMT_RFC5280_GEN_SIZE]);
186 
187 int atcacert_date_dec_rfc5280_gen( const uint8_t formatted_date[DATEFMT_RFC5280_GEN_SIZE],
188  atcacert_tm_utc_t* timestamp);
189 
191  uint8_t formatted_date[DATEFMT_POSIX_UINT32_BE_SIZE]);
192 
193 int atcacert_date_dec_posix_uint32_be( const uint8_t formatted_date[DATEFMT_POSIX_UINT32_BE_SIZE],
194  atcacert_tm_utc_t* timestamp);
195 
197  uint8_t formatted_date[DATEFMT_POSIX_UINT32_LE_SIZE]);
198 
199 int atcacert_date_dec_posix_uint32_le( const uint8_t formatted_date[DATEFMT_POSIX_UINT32_LE_SIZE],
200  atcacert_tm_utc_t* timestamp);
201 
202 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif
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_sec
Definition: atcacert_date.h:59
POSIX (aka UNIX) date format. Seconds since Jan 1, 1970. 32 bit unsigned integer, little endian...
Definition: atcacert_date.h:74
POSIX (aka UNIX) date format. Seconds since Jan 1, 1970. 32 bit unsigned integer, big endian...
Definition: atcacert_date.h:73
Definition: atcacert_date.h:58
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
atcacert_date_format_e
Definition: atcacert_date.h:70
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 tm_year
Definition: atcacert_date.h:64
#define DATEFMT_RFC5280_GEN_SIZE
Definition: atcacert_date.h:82
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
RFC 5280 (X.509) 4.1.2.5.1 UTCTime format YYMMDDhhmmssZ.
Definition: atcacert_date.h:72
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 atcacert_date_dec_rfc5280_gen(const uint8_t formatted_date[DATEFMT_RFC5280_GEN_SIZE], atcacert_tm_utc_t *timestamp)
Definition: atcacert_date.c:475
ISO8601 full date YYYY-MM-DDThh:mm:ssZ.
Definition: atcacert_date.h:71
int tm_min
Definition: atcacert_date.h:60
#define DATEFMT_POSIX_UINT32_LE_SIZE
Definition: atcacert_date.h:81
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
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
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
int tm_mday
Definition: atcacert_date.h:62
#define DATEFMT_ISO8601_SEP_SIZE
Definition: atcacert_date.h:78
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 tm_hour
Definition: atcacert_date.h:61
RFC 5280 (X.509) 4.1.2.5.2 GeneralizedTime format YYYYMMDDhhmmssZ.
Definition: atcacert_date.h:75
#define DATEFMT_RFC5280_UTC_SIZE
Definition: atcacert_date.h:79
enum atcacert_date_format_e atcacert_date_format_t
struct atcacert_tm_utc_s atcacert_tm_utc_t
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
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
#define DATEFMT_POSIX_UINT32_BE_SIZE
Definition: atcacert_date.h:80
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
Declarations common to all atcacert code.
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_posix_uint32_le(const atcacert_tm_utc_t *timestamp, uint8_t formatted_date[DATEFMT_POSIX_UINT32_LE_SIZE])
Definition: atcacert_date.c:764