1.\" $OpenBSD: X509_cmp_time.3,v 1.11 2021/11/12 14:34:57 schwarze Exp $ 2.\" full merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 3.\" 4.\" This file is a derived work. 5.\" The changes are covered by the following Copyright and license: 6.\" 7.\" Copyright (c) 2017, 2021 Ingo Schwarze <schwarze@openbsd.org> 8.\" 9.\" Permission to use, copy, modify, and distribute this software for any 10.\" purpose with or without fee is hereby granted, provided that the above 11.\" copyright notice and this permission notice appear in all copies. 12.\" 13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20.\" 21.\" The original file was written by Emilia Kasper <emilia@openssl.org> 22.\" Copyright (c) 2017 The OpenSSL Project. All rights reserved. 23.\" 24.\" Redistribution and use in source and binary forms, with or without 25.\" modification, are permitted provided that the following conditions 26.\" are met: 27.\" 28.\" 1. Redistributions of source code must retain the above copyright 29.\" notice, this list of conditions and the following disclaimer. 30.\" 31.\" 2. Redistributions in binary form must reproduce the above copyright 32.\" notice, this list of conditions and the following disclaimer in 33.\" the documentation and/or other materials provided with the 34.\" distribution. 35.\" 36.\" 3. All advertising materials mentioning features or use of this 37.\" software must display the following acknowledgment: 38.\" "This product includes software developed by the OpenSSL Project 39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 40.\" 41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 42.\" endorse or promote products derived from this software without 43.\" prior written permission. For written permission, please contact 44.\" openssl-core@openssl.org. 45.\" 46.\" 5. Products derived from this software may not be called "OpenSSL" 47.\" nor may "OpenSSL" appear in their names without prior written 48.\" permission of the OpenSSL Project. 49.\" 50.\" 6. Redistributions of any form whatsoever must retain the following 51.\" acknowledgment: 52.\" "This product includes software developed by the OpenSSL Project 53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 54.\" 55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" 68.Dd $Mdocdate: November 12 2021 $ 69.Dt X509_CMP_TIME 3 70.Os 71.Sh NAME 72.Nm X509_cmp_time , 73.Nm X509_cmp_current_time , 74.Nm X509_time_adj_ex , 75.Nm X509_time_adj , 76.Nm X509_gmtime_adj 77.Nd ASN.1 Time utilities 78.Sh SYNOPSIS 79.In openssl/x509.h 80.Ft int 81.Fo X509_cmp_time 82.Fa "const ASN1_TIME *asn1_time" 83.Fa "time_t *cmp_time" 84.Fc 85.Ft int 86.Fo X509_cmp_current_time 87.Fa "const ASN1_TIME *asn1_time" 88.Fc 89.Ft ASN1_TIME * 90.Fo X509_time_adj_ex 91.Fa "ASN1_TIME *out_time" 92.Fa "int offset_day" 93.Fa "long offset_sec" 94.Fa "time_t *in_time" 95.Fc 96.Ft ASN1_TIME * 97.Fo X509_time_adj 98.Fa "ASN1_TIME *out_time" 99.Fa "long offset_sec" 100.Fa "time_t *in_time" 101.Fc 102.Ft ASN1_TIME * 103.Fo X509_gmtime_adj 104.Fa "ASN1_TIME *out_time" 105.Fa "long offset_sec" 106.Fc 107.Sh DESCRIPTION 108.Fn X509_cmp_time 109parses 110.Fa asn1_time 111with 112.Xr ASN1_time_parse 3 113and compares it to 114.Fa cmp_time , 115or to the current time if 116.Fa cmp_time 117is 118.Dv NULL . 119.Fn X509_cmp_current_time 120compares it to the current time. 121.Pp 122.Fn X509_time_adj_ex 123sets 124.Fa out_time 125to a time 126.Fa offset_day 127and 128.Fa offset_sec 129later than 130.Fa in_time . 131The values of 132.Fa offset_day 133and 134.Fa offset_sec 135can be negative to set a time before 136.Fa in_time . 137The 138.Fa offset_sec 139value can also exceed the number of seconds in a day. 140If 141.Fa in_time 142is 143.Dv NULL , 144the current time is used instead. 145If 146.Fa out_time 147is 148.Dv NULL , 149a new 150.Vt ASN1_TIME 151structure is allocated and returned. 152.Pp 153.Fn X509_time_adj 154does the same with a 0 day offset. 155.Pp 156.Fn X509_gmtime_adj 157does the same using the current time instead of 158.Fa in_time , 159that is, it sets 160.Fa out_time 161to a time 162.Fa offset_sec 163seconds later than the current time. 164.Sh RETURN VALUES 165.Fn X509_cmp_time 166and 167.Fn X509_cmp_current_time 168return -1 if 169.Fa asn1_time 170is earlier than or equal to 171.Fa cmp_time , 1721 if it is later, or 0 on error. 173.Pp 174.Fn X509_time_adj_ex , 175.Fn X509_time_adj , 176and 177.Fn X509_gmtime_adj 178return a pointer to the updated or newly allocated 179.Vt ASN1_TIME 180structure or 181.Dv NULL 182on error. 183.Sh SEE ALSO 184.Xr ASN1_TIME_new 3 , 185.Xr ASN1_time_parse 3 , 186.Xr ASN1_TIME_set 3 , 187.Xr time 3 188.Sh HISTORY 189.Fn X509_cmp_current_time 190and 191.Fn X509_gmtime_adj 192first appeared in SSLeay 0.6.0 and have been available since 193.Ox 2.4 . 194.Pp 195.Fn X509_cmp_time 196and 197.Fn X509_time_adj 198first appeared in OpenSSL 0.9.6 and have been available since 199.Ox 2.9 . 200.Pp 201.Fn X509_time_adj_ex 202first appeared in OpenSSL 1.0.0 and has been available since 203.Ox 4.9 . 204