update libressl to v2.7.4
[unleashed.git] / lib / libcrypto / man / ASN1_time_parse.3
blob8604e181230f240bd082ab9d53a98179da268eb4
1 .\" $OpenBSD: ASN1_time_parse.3,v 1.7 2018/03/23 23:18:17 schwarze Exp $
2 .\"
3 .\" Copyright (c) 2016 Bob Beck <beck@openbsd.org>
4 .\"
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
8 .\"
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\"
17 .Dd $Mdocdate: March 23 2018 $
18 .Dt ASN1_TIME_PARSE 3
19 .Os
20 .Sh NAME
21 .Nm ASN1_time_parse ,
22 .Nm ASN1_time_tm_cmp ,
23 .Nm ASN1_TIME_set_tm
24 .Nd LibreSSL utilities for ASN.1 time types
25 .Sh SYNOPSIS
26 .In openssl/asn1.h
27 .Ft int
28 .Fn ASN1_time_parse "const char *bytes" "size_t len" "struct tm *tm" "int mode"
29 .Ft int
30 .Fn ASN1_time_tm_cmp "struct tm *tm1" "struct tm *tm2"
31 .Ft ASN1_TIME *
32 .Fn ASN1_TIME_set_tm "ASN1_TIME *s" "struct tm *tm"
33 .Sh DESCRIPTION
34 The
35 .Fn ASN1_time_parse
36 function parses an ASN.1 time string of
37 .Ar len
38 bytes starting at
39 .Ar bytes .
40 The resulting time is stored in
41 .Ar tm
43 .Ar tm
44 is not
45 .Dv NULL .
46 .Pp
47 The
48 .Ar mode
49 parameter must be one of
50 .Bl -bullet -offset four
51 .It
52 0 to parse a time as specified in RFC 5280 for an X509 object,
53 which may be either a UTC time or a Generalized time.
54 .It
55 .Dv V_ASN1_UTCTIME
56 to parse an RFC 5280 format UTC time.
57 .It
58 .Dv V_ASN1_GENERALIZEDTIME
59 to parse an RFC 5280 format Generalized time.
60 .El
61 .Pp
62 The
63 .Fn ASN1_time_tm_cmp
64 function compares two times in
65 .Ar tm1
66 and
67 .Ar tm2 .
68 .Pp
69 The function
70 .Fn ASN1_TIME_set_tm
71 sets the
72 .Vt ASN1_TIME
73 structure
74 .Fa s
75 to the time represented by the
76 .Vt struct tm
77 value pointed to by
78 .Fa tm .
80 .Fa s
82 .Dv NULL ,
83 a new
84 .Vt ASN1_TIME
85 structure is allocated and returned.
86 .Sh RETURN VALUES
87 .Fn ASN1_parse_time
88 returns
89 .Bl -bullet -offset four
90 .It
91 -1 if the string was invalid for the
92 .Ar mode
93 specified.
94 .It
95 .Dv V_ASN1_UTCTIME
96 if the string parsed as a valid UTC time.
97 .It
98 .Dv V_ASN1_GENERALIZEDTIME
99 if the string parsed as a valid Generalized time.
102 .Fn ASN1_time_tm_cmp
103 returns
104 .Bl -bullet -offset four
106 -1 if
107 .Ar tm1
108 is less than
109 .Ar tm2 .
111 1 if
112 .Ar tm1
113 is greater than
114 .Ar tm2 .
116 0 if
117 .Ar tm1
118 is the same as
119 .Ar tm2 .
122 .Fn ASN1_TIME_set_tm
123 returns a pointer to an
124 .Vt ASN1_TIME
125 structure or
126 .Dv NULL
127 if an error occurred.
128 .Sh HISTORY
129 .Fn ASN1_time_parse
131 .Fn ASN1_time_tm_cmp
132 first appeared in
133 .Ox 6.1
135 .Fn ASN1_TIME_set_tm
137 .Ox 6.2 .