summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2022-11-10 17:44:05 +0000
committerschwarze <>2022-11-10 17:44:05 +0000
commit61e1293a14728599b7160bc57f2773db4f0e3df9 (patch)
treef0a29195fd194d7c459bef2c2bbc36c02fce65c9
parent569fe027af42ce19d693b022725c4c2c733f6dda (diff)
downloadopenbsd-61e1293a14728599b7160bc57f2773db4f0e3df9.tar.gz
openbsd-61e1293a14728599b7160bc57f2773db4f0e3df9.tar.bz2
openbsd-61e1293a14728599b7160bc57f2773db4f0e3df9.zip
In asn1.h rev. 1.65, beck@ provided ASN1_TIME_set_string_X509(3),
ASN1_TIME_normalize(3), ASN1_TIME_to_tm(3), ASN1_TIME_cmp_time_t(3), and ASN1_TIME_compare(3). Merge documentation from the OpenSSL 1.1.1 branch, which is still under a free license, with tweaks by me in several respects to match our implementation, and also using some feedback from beck@. OK beck@.
-rw-r--r--src/lib/libcrypto/man/ASN1_TIME_set.3150
1 files changed, 139 insertions, 11 deletions
diff --git a/src/lib/libcrypto/man/ASN1_TIME_set.3 b/src/lib/libcrypto/man/ASN1_TIME_set.3
index cd6ab937d0..b8a567ece0 100644
--- a/src/lib/libcrypto/man/ASN1_TIME_set.3
+++ b/src/lib/libcrypto/man/ASN1_TIME_set.3
@@ -1,8 +1,25 @@
1.\" $OpenBSD: ASN1_TIME_set.3,v 1.17 2022/03/31 17:27:16 naddy Exp $ 1.\" $OpenBSD: ASN1_TIME_set.3,v 1.18 2022/11/10 17:44:05 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 2.\" full merge up to: OpenSSL 3d0f1cb9 Jul 11 03:01:24 2017 +0800
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org> 5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>
6.\" and Todd Short <tshort@akamai.com>. 23.\" and Todd Short <tshort@akamai.com>.
7.\" Copyright (c) 2015, 2017 The OpenSSL Project. All rights reserved. 24.\" Copyright (c) 2015, 2017 The OpenSSL Project. All rights reserved.
8.\" 25.\"
@@ -50,7 +67,7 @@
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\" 69.\"
53.Dd $Mdocdate: March 31 2022 $ 70.Dd $Mdocdate: November 10 2022 $
54.Dt ASN1_TIME_SET 3 71.Dt ASN1_TIME_SET 3
55.Os 72.Os
56.Sh NAME 73.Sh NAME
@@ -61,16 +78,21 @@
61.Nm ASN1_UTCTIME_adj , 78.Nm ASN1_UTCTIME_adj ,
62.Nm ASN1_GENERALIZEDTIME_adj , 79.Nm ASN1_GENERALIZEDTIME_adj ,
63.Nm ASN1_TIME_set_string , 80.Nm ASN1_TIME_set_string ,
81.Nm ASN1_TIME_set_string_X509 ,
64.Nm ASN1_UTCTIME_set_string , 82.Nm ASN1_UTCTIME_set_string ,
65.Nm ASN1_GENERALIZEDTIME_set_string , 83.Nm ASN1_GENERALIZEDTIME_set_string ,
84.Nm ASN1_TIME_normalize ,
66.Nm ASN1_TIME_check , 85.Nm ASN1_TIME_check ,
67.Nm ASN1_UTCTIME_check , 86.Nm ASN1_UTCTIME_check ,
68.Nm ASN1_GENERALIZEDTIME_check , 87.Nm ASN1_GENERALIZEDTIME_check ,
69.Nm ASN1_TIME_print , 88.Nm ASN1_TIME_print ,
70.Nm ASN1_UTCTIME_print , 89.Nm ASN1_UTCTIME_print ,
71.Nm ASN1_GENERALIZEDTIME_print , 90.Nm ASN1_GENERALIZEDTIME_print ,
91.Nm ASN1_TIME_to_tm ,
72.Nm ASN1_TIME_diff , 92.Nm ASN1_TIME_diff ,
93.Nm ASN1_TIME_cmp_time_t ,
73.Nm ASN1_UTCTIME_cmp_time_t , 94.Nm ASN1_UTCTIME_cmp_time_t ,
95.Nm ASN1_TIME_compare ,
74.Nm ASN1_TIME_to_generalizedtime 96.Nm ASN1_TIME_to_generalizedtime
75.Nd ASN.1 Time functions 97.Nd ASN.1 Time functions
76.Sh SYNOPSIS 98.Sh SYNOPSIS
@@ -117,6 +139,11 @@
117.Fa "const char *str" 139.Fa "const char *str"
118.Fc 140.Fc
119.Ft int 141.Ft int
142.Fo ASN1_TIME_set_string_X509
143.Fa "ASN1_TIME *s"
144.Fa "const char *str"
145.Fc
146.Ft int
120.Fo ASN1_UTCTIME_set_string 147.Fo ASN1_UTCTIME_set_string
121.Fa "ASN1_UTCTIME *s" 148.Fa "ASN1_UTCTIME *s"
122.Fa "const char *str" 149.Fa "const char *str"
@@ -127,6 +154,10 @@
127.Fa "const char *str" 154.Fa "const char *str"
128.Fc 155.Fc
129.Ft int 156.Ft int
157.Fo ASN1_TIME_normalize
158.Fa "ASN1_TIME *s"
159.Fc
160.Ft int
130.Fo ASN1_TIME_check 161.Fo ASN1_TIME_check
131.Fa "const ASN1_TIME *t" 162.Fa "const ASN1_TIME *t"
132.Fc 163.Fc
@@ -154,6 +185,11 @@
154.Fa "const ASN1_GENERALIZEDTIME *s" 185.Fa "const ASN1_GENERALIZEDTIME *s"
155.Fc 186.Fc
156.Ft int 187.Ft int
188.Fo ASN1_TIME_to_tm
189.Fa "const ASN1_TIME *s"
190.Fa "struct tm *tm"
191.Fc
192.Ft int
157.Fo ASN1_TIME_diff 193.Fo ASN1_TIME_diff
158.Fa "int *pday" 194.Fa "int *pday"
159.Fa "int *psec" 195.Fa "int *psec"
@@ -161,10 +197,20 @@
161.Fa "const ASN1_TIME *to" 197.Fa "const ASN1_TIME *to"
162.Fc 198.Fc
163.Ft int 199.Ft int
200.Fo ASN1_TIME_cmp_time_t
201.Fa "const ASN1_TIME *s"
202.Fa "time_t t"
203.Fc
204.Ft int
164.Fo ASN1_UTCTIME_cmp_time_t 205.Fo ASN1_UTCTIME_cmp_time_t
165.Fa "const ASN1_UTCTIME *s" 206.Fa "const ASN1_UTCTIME *s"
166.Fa "time_t t" 207.Fa "time_t t"
167.Fc 208.Fc
209.Ft int
210.Fo ASN1_TIME_compare
211.Fa "const ASN1_TIME *s"
212.Fa "const ASN1_TIME *t"
213.Fc
168.Ft ASN1_GENERALIZEDTIME * 214.Ft ASN1_GENERALIZEDTIME *
169.Fo ASN1_TIME_to_generalizedtime 215.Fo ASN1_TIME_to_generalizedtime
170.Fa "const ASN1_TIME *t" 216.Fa "const ASN1_TIME *t"
@@ -232,6 +278,7 @@ do not modify the type of the return structure.
232.Pp 278.Pp
233The functions 279The functions
234.Fn ASN1_TIME_set_string , 280.Fn ASN1_TIME_set_string ,
281.Fn ASN1_TIME_set_string_X509 ,
235.Fn ASN1_UTCTIME_set_string , 282.Fn ASN1_UTCTIME_set_string ,
236and 283and
237.Fn ASN1_GENERALIZEDTIME_set_string 284.Fn ASN1_GENERALIZEDTIME_set_string
@@ -239,8 +286,13 @@ set the time structure
239.Fa s 286.Fa s
240to the time represented by the string 287to the time represented by the string
241.Fa str , 288.Fa str ,
242which must be in appropriate ASN.1 time format (for example 289which must be in appropriate ASN.1 time format:
243YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ). 290YYMMDDHHMMSSZ for
291.Vt ASN1_UTCTIME ,
292YYYYMMDDHHMMSSZ for
293.Vt ASN1_GENERALIZEDTIME ,
294or either of the two for
295.Vt ASN1_TIME .
244The string 296The string
245.Fa str 297.Fa str
246is copied into 298is copied into
@@ -252,6 +304,30 @@ is
252these functions only perform a format check on 304these functions only perform a format check on
253.Fa str . 305.Fa str .
254.Pp 306.Pp
307In LibreSSL,
308.Fn ASN1_TIME_set_string
309and
310.Fn ASN1_TIME_set_string_X509
311behave identically.
312In other implementations,
313.Fn ASN1_TIME_set_string ,
314.Fn ASN1_UTCTIME_set_string ,
315and
316.Fn ASN1_GENERALIZEDTIME_set_string
317may accept additional formats that violate RFC 5280.
318.Pp
319The function
320.Fn ASN1_TIME_normalize
321converts an
322.Vt ASN1_GENERALIZEDTIME
323or
324.Vt ASN1_UTCTIME
325into a time value that can be used in a certificate.
326It is intended to be used after the
327.Fn ASN1_TIME_set_string
328functions to ensure the value is valid for use as an
329.Vt ASN1_TIME .
330.Pp
255The functions 331The functions
256.Fn ASN1_TIME_check , 332.Fn ASN1_TIME_check ,
257.Fn ASN1_UTCTIME_check , 333.Fn ASN1_UTCTIME_check ,
@@ -281,6 +357,35 @@ The output of
281may include a fractional part following the second. 357may include a fractional part following the second.
282.Pp 358.Pp
283The function 359The function
360.Fn ASN1_TIME_to_tm
361converts the time
362.Fa s
363to the standard
364.Vt tm
365structure.
366If
367.Fa s
368is
369.Dv NULL ,
370then the current time is converted.
371The output time is GMT.
372The
373.Fa tm_sec , tm_min , tm_hour , tm_mday , tm_mon ,
374and
375.Fa tm_year
376fields of the
377.Vt tm
378structure are set to the proper values,
379whereas all other fields are set to 0.
380If
381.Fa tm
382is
383.Dv NULL ,
384this function performs a format check on
385.Fa s
386only.
387.Pp
388The function
284.Fn ASN1_TIME_diff 389.Fn ASN1_TIME_diff
285sets 390sets
286.Pf * Fa pday 391.Pf * Fa pday
@@ -333,9 +438,12 @@ is
333.Dv NULL , 438.Dv NULL ,
334the current time is used. 439the current time is used.
335.Pp 440.Pp
336The function 441The functions
337.Fn ASN1_UTCTIME_cmp_time_t 442.Fn ASN1_TIME_cmp_time_t ,
338compares the two times represented by 443.Fn ASN1_UTCTIME_cmp_time_t ,
444and
445.Fn ASN1_TIME_compare
446compare the two times represented by
339.Fa s 447.Fa s
340and 448and
341.Fa t . 449.Fa t .
@@ -411,11 +519,15 @@ return a pointer to a time structure or
411if an error occurred. 519if an error occurred.
412.Pp 520.Pp
413.Fn ASN1_TIME_set_string , 521.Fn ASN1_TIME_set_string ,
522.Fn ASN1_TIME_set_string_X509 ,
414.Fn ASN1_UTCTIME_set_string , 523.Fn ASN1_UTCTIME_set_string ,
415and 524and
416.Fn ASN1_GENERALIZEDTIME_set_string 525.Fn ASN1_GENERALIZEDTIME_set_string
417return 1 if the time value is successfully set or 0 otherwise. 526return 1 if the time value is successfully set or 0 otherwise.
418.Pp 527.Pp
528.Fn ASN1_TIME_normalize
529returns 1 on success or 0 on error.
530.Pp
419.Fn ASN1_TIME_check , 531.Fn ASN1_TIME_check ,
420.Fn ASN1_UTCTIME_check , 532.Fn ASN1_UTCTIME_check ,
421and 533and
@@ -429,12 +541,19 @@ and
429return 1 if the time is successfully printed or 0 if an error 541return 1 if the time is successfully printed or 0 if an error
430occurred (I/O error or invalid time format). 542occurred (I/O error or invalid time format).
431.Pp 543.Pp
544.Fn ASN1_TIME_to_tm
545returns 1 if the time is successfully parsed
546or 0 if an error occurred, usually due to an invalid time format.
547.Pp
432.Fn ASN1_TIME_diff 548.Fn ASN1_TIME_diff
433returns 1 for success or 0 for failure. 549returns 1 for success or 0 for failure.
434It can for example fail if a time structure passed in has invalid syntax. 550It can for example fail if a time structure passed in has invalid syntax.
435.Pp 551.Pp
436.Fn ASN1_UTCTIME_cmp_time_t 552.Fn ASN1_TIME_cmp_time_t ,
437returns \-1 if 553.Fn ASN1_UTCTIME_cmp_time_t ,
554and
555.Fn ASN1_TIME_compare
556return \-1 if
438.Fa s 557.Fa s
439is earlier than 558is earlier than
440.Fa t , 559.Fa t ,
@@ -508,6 +627,15 @@ first appeared in OpenSSL 1.0.0 and have been available since
508.Fn ASN1_TIME_diff 627.Fn ASN1_TIME_diff
509first appeared in OpenSSL 1.0.2 and have been available since 628first appeared in OpenSSL 1.0.2 and have been available since
510.Ox 7.1 . 629.Ox 7.1 .
630.Pp
631.Fn ASN1_TIME_set_string_X509 ,
632.Fn ASN1_TIME_normalize ,
633.Fn ASN1_TIME_to_tm ,
634.Fn ASN1_TIME_cmp_time_t ,
635and
636.Fn ASN1_TIME_compare
637first appeared in OpenSSL 1.1.1 and have been available since
638.Ox 7.2 .
511.Sh CAVEATS 639.Sh CAVEATS
512Some applications add offset times directly to a 640Some applications add offset times directly to a
513.Vt time_t 641.Vt time_t