]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/ASN1_TIME_set.3
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r305575, and update
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / ASN1_TIME_set.3
1 .\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.35)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .if !\nF .nr F 0
58 .if \nF>0 \{\
59 .    de IX
60 .    tm Index:\\$1\t\\n%\t"\\$2"
61 ..
62 .    if !\nF==2 \{\
63 .        nr % 0
64 .        nr F 2
65 .    \}
66 .\}
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "ASN1_TIME_set 3"
132 .TH ASN1_TIME_set 3 "2017-05-25" "1.0.2l" "OpenSSL"
133 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
134 .\" way too many mistakes in technical documents.
135 .if n .ad l
136 .nh
137 .SH "NAME"
138 ASN1_TIME_set, ASN1_TIME_adj, ASN1_TIME_check, ASN1_TIME_set_string,
139 ASN1_TIME_print, ASN1_TIME_diff \- ASN.1 Time functions.
140 .SH "SYNOPSIS"
141 .IX Header "SYNOPSIS"
142 .Vb 6
143 \& ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);
144 \& ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
145 \&                          int offset_day, long offset_sec);
146 \& int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
147 \& int ASN1_TIME_check(const ASN1_TIME *t);
148 \& int ASN1_TIME_print(BIO *b, const ASN1_TIME *s);
149 \&
150 \& int ASN1_TIME_diff(int *pday, int *psec,
151 \&                    const ASN1_TIME *from, const ASN1_TIME *to);
152 .Ve
153 .SH "DESCRIPTION"
154 .IX Header "DESCRIPTION"
155 The function \fIASN1_TIME_set()\fR sets the \s-1ASN1_TIME\s0 structure \fBs\fR to the
156 time represented by the time_t value \fBt\fR. If \fBs\fR is \s-1NULL\s0 a new \s-1ASN1_TIME\s0
157 structure is allocated and returned.
158 .PP
159 \&\fIASN1_TIME_adj()\fR sets the \s-1ASN1_TIME\s0 structure \fBs\fR to the time represented
160 by the time \fBoffset_day\fR and \fBoffset_sec\fR after the time_t value \fBt\fR.
161 The values of \fBoffset_day\fR or \fBoffset_sec\fR can be negative to set a
162 time before \fBt\fR. The \fBoffset_sec\fR value can also exceed the number of
163 seconds in a day. If \fBs\fR is \s-1NULL\s0 a new \s-1ASN1_TIME\s0 structure is allocated
164 and returned.
165 .PP
166 \&\fIASN1_TIME_set_string()\fR sets \s-1ASN1_TIME\s0 structure \fBs\fR to the time
167 represented by string \fBstr\fR which must be in appropriate \s-1ASN.1\s0 time
168 format (for example \s-1YYMMDDHHMMSSZ\s0 or \s-1YYYYMMDDHHMMSSZ\s0).
169 .PP
170 \&\fIASN1_TIME_check()\fR checks the syntax of \s-1ASN1_TIME\s0 structure \fBs\fR.
171 .PP
172 \&\fIASN1_TIME_print()\fR prints out the time \fBs\fR to \s-1BIO \s0\fBb\fR in human readable
173 format. It will be of the format \s-1MMM DD HH:MM:SS YYYY\s0 [\s-1GMT\s0], for example
174 \&\*(L"Feb  3 00:55:52 2015 \s-1GMT\*(R"\s0 it does not include a newline. If the time
175 structure has invalid format it prints out \*(L"Bad time value\*(R" and returns
176 an error.
177 .PP
178 \&\fIASN1_TIME_diff()\fR sets \fB*pday\fR and \fB*psec\fR to the time difference between
179 \&\fBfrom\fR and \fBto\fR. If \fBto\fR represents a time later than \fBfrom\fR then
180 one or both (depending on the time difference) of \fB*pday\fR and \fB*psec\fR
181 will be positive. If \fBto\fR represents a time earlier than \fBfrom\fR then
182 one or both of \fB*pday\fR and \fB*psec\fR will be negative. If \fBto\fR and \fBfrom\fR
183 represent the same time then \fB*pday\fR and \fB*psec\fR will both be zero.
184 If both \fB*pday\fR and \fB*psec\fR are non-zero they will always have the same
185 sign. The value of \fB*psec\fR will always be less than the number of seconds
186 in a day. If \fBfrom\fR or \fBto\fR is \s-1NULL\s0 the current time is used.
187 .SH "NOTES"
188 .IX Header "NOTES"
189 The \s-1ASN1_TIME\s0 structure corresponds to the \s-1ASN.1\s0 structure \fBTime\fR
190 defined in \s-1RFC5280\s0 et al. The time setting functions obey the rules outlined
191 in \s-1RFC5280:\s0 if the date can be represented by UTCTime it is used, else
192 GeneralizedTime is used.
193 .PP
194 The \s-1ASN1_TIME\s0 structure is represented as an \s-1ASN1_STRING\s0 internally and can
195 be freed up using \fIASN1_STRING_free()\fR.
196 .PP
197 The \s-1ASN1_TIME\s0 structure can represent years from 0000 to 9999 but no attempt
198 is made to correct ancient calendar changes (for example from Julian to
199 Gregorian calendars).
200 .PP
201 Some applications add offset times directly to a time_t value and pass the
202 results to \fIASN1_TIME_set()\fR (or equivalent). This can cause problems as the
203 time_t value can overflow on some systems resulting in unexpected results.
204 New applications should use \fIASN1_TIME_adj()\fR instead and pass the offset value
205 in the \fBoffset_sec\fR and \fBoffset_day\fR parameters instead of directly
206 manipulating a time_t value.
207 .SH "BUGS"
208 .IX Header "BUGS"
209 \&\fIASN1_TIME_print()\fR currently does not print out the time zone: it either prints
210 out \*(L"\s-1GMT\*(R"\s0 or nothing. But all certificates complying with \s-1RFC5280\s0 et al use \s-1GMT\s0
211 anyway.
212 .SH "EXAMPLES"
213 .IX Header "EXAMPLES"
214 Set a time structure to one hour after the current time and print it out:
215 .PP
216 .Vb 11
217 \& #include <time.h>
218 \& #include <openssl/asn1.h>
219 \& ASN1_TIME *tm;
220 \& time_t t;
221 \& BIO *b;
222 \& t = time(NULL);
223 \& tm = ASN1_TIME_adj(NULL, t, 0, 60 * 60);
224 \& b = BIO_new_fp(stdout, BIO_NOCLOSE);
225 \& ASN1_TIME_print(b, tm);
226 \& ASN1_STRING_free(tm);
227 \& BIO_free(b);
228 .Ve
229 .PP
230 Determine if one time is later or sooner than the current time:
231 .PP
232 .Vb 1
233 \& int day, sec;
234 \&
235 \& if (!ASN1_TIME_diff(&day, &sec, NULL, to))
236 \&        /* Invalid time format */
237 \&
238 \& if (day > 0 || sec > 0)
239 \&   printf("Later\en");
240 \& else if (day < 0 || sec < 0)
241 \&   printf("Sooner\en");
242 \& else
243 \&   printf("Same\en");
244 .Ve
245 .SH "RETURN VALUES"
246 .IX Header "RETURN VALUES"
247 \&\fIASN1_TIME_set()\fR and \fIASN1_TIME_adj()\fR return a pointer to an \s-1ASN1_TIME\s0 structure
248 or \s-1NULL\s0 if an error occurred.
249 .PP
250 \&\fIASN1_TIME_set_string()\fR returns 1 if the time value is successfully set and
251 0 otherwise.
252 .PP
253 \&\fIASN1_TIME_check()\fR returns 1 if the structure is syntactically correct and 0
254 otherwise.
255 .PP
256 \&\fIASN1_TIME_print()\fR returns 1 if the time is successfully printed out and 0 if
257 an error occurred (I/O error or invalid time format).
258 .PP
259 \&\fIASN1_TIME_diff()\fR returns 1 for sucess and 0 for failure. It can fail if the
260 pass \s-1ASN1_TIME\s0 structure has invalid syntax for example.