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
|
.\" $OpenBSD: ASN1_time_parse.3,v 1.1 2016/11/04 18:07:23 beck 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: November 4 2016 $
.Dt ASN1_TIME_PARSE 3
.Os
.Sh NAME
.Nm ASN1_time_parse,
.Nm ASN1_time_tm_cmp
.Nd LibreSSL utilities for asn1 format time.
.Sh SYNOPSIS
.In 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"
.Sh DESCRIPTION
The
.Nm ASN1_time_parse
function parses an asn1 time string of
.Ar len
bytes starting at
.Ar bytes .
The resulting time is stored in
.Ar tm
if
.Ar tm
is non NULL.
.Pp
The
.Ar mode
parameter must be one of
.Bl -bullet -offset four
.It
.Ar 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
.Ar V_ASN1_UTCTIME
to parse an RFC 5280 format UTC time.
.It
.Ar V_ASN1_GENERALIZEDTIME
to parse an RFC 5280 format Generalized time.
.El
.Pp
The
.Nm ASN1_time_tm_cmp
function compares two times in
.Ar tm1
and
.Ar tm2
.Sh RETURN VALUES
.Nm ASN1_parse_time
returns
.Bl -bullet -offset four
.It
.Ar -1
if the string was invalid for the
.Ar mode
specified
.It
.Ar V_ASN1_UTCTIME
if the string parsed as a valid UTC time.
.It :
.Ar V_ASN1_GENERALIZEDTIME
if the string parsed as a valid Generalized time.
.El
.Pp
.Nm ASN1_time_tm_cmp
returns
.Bl -bullet -offset four
.It
.Ar -1
if tm1 is less than tm2.
.It
.Ar 1
if tm1 is greater than tm2.
.It
.Ar 0
if tm1 is the same as tm2.
.El
|