1.\" $OpenBSD: X509_cmp_time.3,v 1.12 2024/03/05 18:30:40 tb 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: March 5 2024 $ 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 111and compares it to 112.Fa cmp_time , 113or to the current time if 114.Fa cmp_time 115is 116.Dv NULL . 117.Fn X509_cmp_current_time 118compares it to the current time. 119.Pp 120.Fn X509_time_adj_ex 121sets 122.Fa out_time 123to a time 124.Fa offset_day 125and 126.Fa offset_sec 127later than 128.Fa in_time . 129The values of 130.Fa offset_day 131and 132.Fa offset_sec 133can be negative to set a time before 134.Fa in_time . 135The 136.Fa offset_sec 137value can also exceed the number of seconds in a day. 138If 139.Fa in_time 140is 141.Dv NULL , 142the current time is used instead. 143If 144.Fa out_time 145is 146.Dv NULL , 147a new 148.Vt ASN1_TIME 149structure is allocated and returned. 150.Pp 151.Fn X509_time_adj 152does the same with a 0 day offset. 153.Pp 154.Fn X509_gmtime_adj 155does the same using the current time instead of 156.Fa in_time , 157that is, it sets 158.Fa out_time 159to a time 160.Fa offset_sec 161seconds later than the current time. 162.Sh RETURN VALUES 163.Fn X509_cmp_time 164and 165.Fn X509_cmp_current_time 166return -1 if 167.Fa asn1_time 168is earlier than or equal to 169.Fa cmp_time , 1701 if it is later, or 0 on error. 171.Pp 172.Fn X509_time_adj_ex , 173.Fn X509_time_adj , 174and 175.Fn X509_gmtime_adj 176return a pointer to the updated or newly allocated 177.Vt ASN1_TIME 178structure or 179.Dv NULL 180on error. 181.Sh SEE ALSO 182.Xr ASN1_TIME_new 3 , 183.Xr ASN1_TIME_set 3 , 184.Xr time 3 185.Sh HISTORY 186.Fn X509_cmp_current_time 187and 188.Fn X509_gmtime_adj 189first appeared in SSLeay 0.6.0 and have been available since 190.Ox 2.4 . 191.Pp 192.Fn X509_cmp_time 193and 194.Fn X509_time_adj 195first appeared in OpenSSL 0.9.6 and have been available since 196.Ox 2.9 . 197.Pp 198.Fn X509_time_adj_ex 199first appeared in OpenSSL 1.0.0 and has been available since 200.Ox 4.9 . 201