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