Sortix cross-volatile manual
This manual documents Sortix cross-volatile. You can instead view this document in the latest official manual.
NAME
ASN1_TIME_set, ASN1_UTCTIME_set, ASN1_GENERALIZEDTIME_set, ASN1_TIME_adj, ASN1_UTCTIME_adj, ASN1_GENERALIZEDTIME_adj, ASN1_TIME_set_string, ASN1_TIME_set_string_X509, ASN1_UTCTIME_set_string, ASN1_GENERALIZEDTIME_set_string, ASN1_TIME_normalize, ASN1_TIME_check, ASN1_UTCTIME_check, ASN1_GENERALIZEDTIME_check, ASN1_TIME_print, ASN1_UTCTIME_print, ASN1_GENERALIZEDTIME_print, ASN1_TIME_to_tm, ASN1_TIME_diff, ASN1_TIME_cmp_time_t, ASN1_UTCTIME_cmp_time_t, ASN1_TIME_compare, ASN1_TIME_to_generalizedtime, OPENSSL_gmtime, OPENSSL_timegm, OPENSSL_posix_to_tm, OPENSSL_tm_to_posix — ASN.1 Time functionsSYNOPSIS
#include <openssl/asn1.h>ASN1_TIME_set(ASN1_TIME *s, time_t t);
ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);
ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t);
ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec);
ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec);
ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, long offset_sec);
ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str);
ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
ASN1_TIME_normalize(ASN1_TIME *s);
ASN1_TIME_check(const ASN1_TIME *t);
ASN1_UTCTIME_check(const ASN1_UTCTIME *t);
ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *t);
ASN1_TIME_print(BIO *b, const ASN1_TIME *s);
ASN1_UTCTIME_print(BIO *b, const ASN1_UTCTIME *s);
ASN1_GENERALIZEDTIME_print(BIO *b, const ASN1_GENERALIZEDTIME *s);
ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm);
ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, const ASN1_TIME *to);
ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t);
ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
ASN1_TIME_compare(const ASN1_TIME *s, const ASN1_TIME *t);
ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, ASN1_GENERALIZEDTIME **out);
OPENSSL_gmtime(const time_t *time, struct tm *out_tm);
OPENSSL_timegm(const struct tm *tm, time_t *out_time);
OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm);
OPENSSL_tm_to_posix(struct tm *t_tm, int64_t *out);
DESCRIPTION
An ASN1_TIME object is a shallow wrapper around a string containing an ASN.1 Time value in the restricted format valid in X.509 certificates. An ASN1_TIME object is either an ASN1_UTCTIME object containing a string of the format YYMMDDHHMMSSZ which is valid for the years 1950 to 2049, or an ASN1_GENERALIZEDTIME object containing a string of the format YYYYMMDDHHMMSSZ which is valid for the years 0000 to 1949 and 2050 to 9999. In both cases, the mandatory suffix ‘Z’ represents the GMT time zone. LibreSSL by design does not support the full syntax of ASN.1 times. In particular, it neither supports fractional seconds nor any other time zone.RETURN VALUES
ASN1_TIME_set(), ASN1_UTCTIME_set(), ASN1_GENERALIZEDTIME_set(), ASN1_TIME_adj(), ASN1_UTCTIME_adj(), ASN1_GENERALIZEDTIME_adj(), and ASN1_TIME_to_generalizedtime() return a pointer to a time object or NULL if an error occurred.EXAMPLES
Set a time object to one hour after the current time and print it out:#include <time.h> #include <openssl/asn1.h> ASN1_TIME *asn1_time; time_t t; BIO *b; t = time(NULL); asn1_time = ASN1_TIME_adj(NULL, t, 0, 60 * 60); b = BIO_new_fp(stdout, BIO_NOCLOSE); if (asn1_time != NULL) { ASN1_TIME_print(b, asn1_time); BIO_printf(b, "\n"); } else { BIO_printf(b, "Time out of range or un-representable\n"); } ASN1_STRING_free(asn1_time); BIO_free(b);