105901b04Schristos=pod
205901b04Schristos
305901b04Schristos=head1 NAME
405901b04Schristos
5*66bae5e7SchristosX509_cmp_time, X509_cmp_current_time, X509_cmp_timeframe,
6*66bae5e7SchristosX509_time_adj, X509_time_adj_ex, X509_gmtime_adj
705901b04Schristos- X509 time functions
805901b04Schristos
905901b04Schristos=head1 SYNOPSIS
1005901b04Schristos
1105901b04Schristos int X509_cmp_time(const ASN1_TIME *asn1_time, time_t *in_tm);
1205901b04Schristos int X509_cmp_current_time(const ASN1_TIME *asn1_time);
13*66bae5e7Schristos int X509_cmp_timeframe(const X509_VERIFY_PARAM *vpm,
14*66bae5e7Schristos                        const ASN1_TIME *start, const ASN1_TIME *end);
1505901b04Schristos ASN1_TIME *X509_time_adj(ASN1_TIME *asn1_time, long offset_sec, time_t *in_tm);
1605901b04Schristos ASN1_TIME *X509_time_adj_ex(ASN1_TIME *asn1_time, int offset_day, long
1705901b04Schristos                             offset_sec, time_t *in_tm);
18*66bae5e7Schristos ASN1_TIME *X509_gmtime_adj(ASN1_TIME *asn1_time, long offset_sec);
1905901b04Schristos
2005901b04Schristos=head1 DESCRIPTION
2105901b04Schristos
22*66bae5e7SchristosX509_cmp_time() compares the ASN1_TIME in I<asn1_time> with the time
23*66bae5e7Schristosin <in_tm>.
2405901b04Schristos
25*66bae5e7SchristosX509_cmp_current_time() compares the ASN1_TIME in
26*66bae5e7SchristosI<asn1_time> with the current time, expressed as time_t.
2705901b04Schristos
28*66bae5e7SchristosX509_cmp_timeframe() compares the given time period with the reference time
29*66bae5e7Schristosincluded in the verification parameters I<vpm> if they are not NULL and contain
30*66bae5e7SchristosB<X509_V_FLAG_USE_CHECK_TIME>; else the current time is used as reference time.
31*66bae5e7Schristos
32*66bae5e7SchristosX509_time_adj_ex() sets the ASN1_TIME structure I<asn1_time> to the time
33*66bae5e7SchristosI<offset_day> and I<offset_sec> after I<in_tm>.
34*66bae5e7Schristos
35*66bae5e7SchristosX509_time_adj() sets the ASN1_TIME structure I<asn1_time> to the time
36*66bae5e7SchristosI<offset_sec> after I<in_tm>. This method can only handle second
3705901b04Schristosoffsets up to the capacity of long, so the newer X509_time_adj_ex()
3805901b04SchristosAPI should be preferred.
3905901b04Schristos
40*66bae5e7SchristosIn both methods, if I<asn1_time> is NULL, a new ASN1_TIME structure
4105901b04Schristosis allocated and returned.
4205901b04Schristos
43*66bae5e7SchristosIn all methods, if I<in_tm> is NULL, the current time, expressed as
4405901b04Schristostime_t, is used.
4505901b04Schristos
46*66bae5e7SchristosI<asn1_time> must satisfy the ASN1_TIME format mandated by RFC 5280,
47*66bae5e7Schristosi.e., its format must be either YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ.
48*66bae5e7Schristos
49*66bae5e7SchristosX509_gmtime_adj() sets the ASN1_TIME structure I<asn1_time> to the time
50*66bae5e7SchristosI<offset_sec> after the current time. It is equivalent to calling
51*66bae5e7SchristosX509_time_adj() with the last parameter as NULL.
52*66bae5e7Schristos
5305901b04Schristos=head1 BUGS
5405901b04Schristos
5505901b04SchristosUnlike many standard comparison functions, X509_cmp_time() and
5605901b04SchristosX509_cmp_current_time() return 0 on error.
5705901b04Schristos
5805901b04Schristos=head1 RETURN VALUES
5905901b04Schristos
60*66bae5e7SchristosX509_cmp_time() and X509_cmp_current_time() return -1 if I<asn1_time>
61*66bae5e7Schristosis earlier than, or equal to, I<in_tm> (resp. current time), and 1
6205901b04Schristosotherwise. These methods return 0 on error.
6305901b04Schristos
64*66bae5e7SchristosX509_cmp_timeframe() returns 0 if I<vpm> is not NULL and the verification
65*66bae5e7Schristosparameters do not contain B<X509_V_FLAG_USE_CHECK_TIME>
66*66bae5e7Schristosbut do contain B<X509_V_FLAG_NO_CHECK_TIME>. Otherwise it returns
67*66bae5e7Schristos1 if the end time is not NULL and the reference time (which has determined as
68*66bae5e7Schristosstated above) is past the end time, -1 if the start time is not NULL and the
69*66bae5e7Schristosreference time is before, else 0 to indicate that the reference time is in range
70*66bae5e7Schristos(implying that the end time is not before the start time if both are present).
71*66bae5e7Schristos
72*66bae5e7SchristosX509_time_adj(), X509_time_adj_ex() and X509_gmtime_adj() return a pointer to
73*66bae5e7Schristosthe updated ASN1_TIME structure, and NULL on error.
74*66bae5e7Schristos
75*66bae5e7Schristos=head1 HISTORY
76*66bae5e7Schristos
77*66bae5e7SchristosX509_cmp_timeframe() was added in OpenSSL 3.0.
7805901b04Schristos
7905901b04Schristos=head1 COPYRIGHT
8005901b04Schristos
81*66bae5e7SchristosCopyright 2017-2022 The OpenSSL Project Authors. All Rights Reserved.
8205901b04Schristos
83*66bae5e7SchristosLicensed under the Apache License 2.0 (the "License").  You may not use
8405901b04Schristosthis file except in compliance with the License.  You can obtain a copy
8505901b04Schristosin the file LICENSE in the source distribution or at
8605901b04SchristosL<https://www.openssl.org/source/license.html>.
8705901b04Schristos
8805901b04Schristos=cut
89