diff options
| author | schwarze <> | 2016-11-10 14:42:21 +0000 |
|---|---|---|
| committer | schwarze <> | 2016-11-10 14:42:21 +0000 |
| commit | f2cab2f8e47b7edbc2370e189d86846ca4ddb34a (patch) | |
| tree | 8b7dd72814a620bdbbc40bb07eadb90b594561ec /src | |
| parent | 1fd34fbb8e4a38d225a14c2555a5599c63f52907 (diff) | |
| download | openbsd-f2cab2f8e47b7edbc2370e189d86846ca4ddb34a.tar.gz openbsd-f2cab2f8e47b7edbc2370e189d86846ca4ddb34a.tar.bz2 openbsd-f2cab2f8e47b7edbc2370e189d86846ca4ddb34a.zip | |
import from OpenSSL,
deleting ASN1_TIME_diff() which we don't have
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/man/ASN1_TIME_set.3 | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/ASN1_TIME_set.3 b/src/lib/libcrypto/man/ASN1_TIME_set.3 new file mode 100644 index 0000000000..784b98944d --- /dev/null +++ b/src/lib/libcrypto/man/ASN1_TIME_set.3 | |||
| @@ -0,0 +1,246 @@ | |||
| 1 | .\" $OpenBSD: ASN1_TIME_set.3,v 1.1 2016/11/10 14:42:21 schwarze Exp $ | ||
| 2 | .\" OpenSSL 99d63d46 Mon Jun 6 00:43:05 2016 -0400 | ||
| 3 | .\" | ||
| 4 | .\" This file was written by Dr. Stephen Henson. | ||
| 5 | .\" Copyright (c) 2015 The OpenSSL Project. All rights reserved. | ||
| 6 | .\" | ||
| 7 | .\" Redistribution and use in source and binary forms, with or without | ||
| 8 | .\" modification, are permitted provided that the following conditions | ||
| 9 | .\" are met: | ||
| 10 | .\" | ||
| 11 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 12 | .\" notice, this list of conditions and the following disclaimer. | ||
| 13 | .\" | ||
| 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 15 | .\" notice, this list of conditions and the following disclaimer in | ||
| 16 | .\" the documentation and/or other materials provided with the | ||
| 17 | .\" distribution. | ||
| 18 | .\" | ||
| 19 | .\" 3. All advertising materials mentioning features or use of this | ||
| 20 | .\" software must display the following acknowledgment: | ||
| 21 | .\" "This product includes software developed by the OpenSSL Project | ||
| 22 | .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 23 | .\" | ||
| 24 | .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 25 | .\" endorse or promote products derived from this software without | ||
| 26 | .\" prior written permission. For written permission, please contact | ||
| 27 | .\" openssl-core@openssl.org. | ||
| 28 | .\" | ||
| 29 | .\" 5. Products derived from this software may not be called "OpenSSL" | ||
| 30 | .\" nor may "OpenSSL" appear in their names without prior written | ||
| 31 | .\" permission of the OpenSSL Project. | ||
| 32 | .\" | ||
| 33 | .\" 6. Redistributions of any form whatsoever must retain the following | ||
| 34 | .\" acknowledgment: | ||
| 35 | .\" "This product includes software developed by the OpenSSL Project | ||
| 36 | .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 37 | .\" | ||
| 38 | .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 39 | .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 40 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 41 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 42 | .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 43 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 44 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 45 | .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 46 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 47 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 48 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 49 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 50 | .\" | ||
| 51 | .Dd $Mdocdate: November 10 2016 $ | ||
| 52 | .Dt ASN1_TIME_SET 3 | ||
| 53 | .Os | ||
| 54 | .Sh NAME | ||
| 55 | .Nm ASN1_TIME_set , | ||
| 56 | .Nm ASN1_TIME_adj , | ||
| 57 | .Nm ASN1_TIME_check , | ||
| 58 | .Nm ASN1_TIME_set_string , | ||
| 59 | .Nm ASN1_TIME_print | ||
| 60 | .Nd ASN.1 Time functions | ||
| 61 | .Sh SYNOPSIS | ||
| 62 | .Ft ASN1_TIME * | ||
| 63 | .Fo ASN1_TIME_set | ||
| 64 | .Fa "ASN1_TIME *s" | ||
| 65 | .Fa "time_t t" | ||
| 66 | .Fc | ||
| 67 | .Ft ASN1_TIME * | ||
| 68 | .Fo ASN1_TIME_adj | ||
| 69 | .Fa "ASN1_TIME *s" | ||
| 70 | .Fa "time_t t" | ||
| 71 | .Fa "int offset_day" | ||
| 72 | .Fa "long offset_sec" | ||
| 73 | .Fc | ||
| 74 | .Ft int | ||
| 75 | .Fo ASN1_TIME_set_string | ||
| 76 | .Fa "ASN1_TIME *s" | ||
| 77 | .Fa "const char *str" | ||
| 78 | .Fc | ||
| 79 | .Ft int | ||
| 80 | .Fo ASN1_TIME_check | ||
| 81 | .Fa "const ASN1_TIME *t" | ||
| 82 | .Fc | ||
| 83 | .Ft int | ||
| 84 | .Fo ASN1_TIME_print | ||
| 85 | .Fa "BIO *b" | ||
| 86 | .Fa "const ASN1_TIME *s" | ||
| 87 | .Fc | ||
| 88 | .Sh DESCRIPTION | ||
| 89 | The function | ||
| 90 | .Fn ASN1_TIME_set | ||
| 91 | sets the | ||
| 92 | .Vt ASN1_TIME | ||
| 93 | structure | ||
| 94 | .Fa s | ||
| 95 | to the time represented by the | ||
| 96 | .Vt time_t | ||
| 97 | value | ||
| 98 | .Fa t . | ||
| 99 | If | ||
| 100 | .Fa s | ||
| 101 | is | ||
| 102 | .Dv NULL , | ||
| 103 | a new | ||
| 104 | .Vt ASN1_TIME | ||
| 105 | structure is allocated and returned. | ||
| 106 | .Pp | ||
| 107 | .Fn ASN1_TIME_adj | ||
| 108 | sets the | ||
| 109 | .Vt ASN1_TIME | ||
| 110 | structure | ||
| 111 | .Fa s | ||
| 112 | to the time represented by the time | ||
| 113 | .Fa offset_day | ||
| 114 | and | ||
| 115 | .Fa offset_sec | ||
| 116 | after the | ||
| 117 | .Vt time_t | ||
| 118 | value | ||
| 119 | .Fa t . | ||
| 120 | The values of | ||
| 121 | .Fa offset_day | ||
| 122 | or | ||
| 123 | .Fa offset_sec | ||
| 124 | can be negative to set a time before | ||
| 125 | .Fa t . | ||
| 126 | The | ||
| 127 | .Fa offset_sec | ||
| 128 | value can also exceed the number of seconds in a day. | ||
| 129 | If | ||
| 130 | .Fa s | ||
| 131 | is | ||
| 132 | .Dv NULL , | ||
| 133 | a new | ||
| 134 | .Vt ASN1_TIME | ||
| 135 | structure is allocated and returned. | ||
| 136 | .Pp | ||
| 137 | .Fn ASN1_TIME_set_string | ||
| 138 | sets the | ||
| 139 | .Vt ASN1_TIME | ||
| 140 | structure | ||
| 141 | .Fa s | ||
| 142 | to the time represented by the string | ||
| 143 | .Fa str , | ||
| 144 | which must be in appropriate ASN.1 time format (for example | ||
| 145 | YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ). | ||
| 146 | .Pp | ||
| 147 | .Fn ASN1_TIME_check | ||
| 148 | checks the syntax of the | ||
| 149 | .Vt ASN1_TIME | ||
| 150 | structure | ||
| 151 | .Fa s . | ||
| 152 | .Pp | ||
| 153 | .Fn ASN1_TIME_print | ||
| 154 | prints out the time | ||
| 155 | .Fa s | ||
| 156 | to | ||
| 157 | .Vt BIO | ||
| 158 | .Fa b | ||
| 159 | in human readable format. | ||
| 160 | It will be of the format MMM DD HH:MM:SS YYYY [GMT], for example "Feb 3 | ||
| 161 | 00:55:52 2015 GMT". | ||
| 162 | It does not include a newline. | ||
| 163 | If the time structure has an invalid format, | ||
| 164 | it prints out "Bad time value" and returns an error. | ||
| 165 | .Pp | ||
| 166 | The | ||
| 167 | .Vt ASN1_TIME | ||
| 168 | structure corresponds to the ASN.1 structure | ||
| 169 | .Sy Time | ||
| 170 | defined in RFC5280 et al. | ||
| 171 | The time setting functions obey the rules outlined in RFC5280: if the | ||
| 172 | date can be represented by UTCTime it is used, else GeneralizedTime is | ||
| 173 | used. | ||
| 174 | .Pp | ||
| 175 | The | ||
| 176 | .Vt ASN1_TIME | ||
| 177 | structure is represented as an | ||
| 178 | .Vt ASN1_STRING | ||
| 179 | internally and can be freed up using | ||
| 180 | .Xr ASN1_STRING_free 3 . | ||
| 181 | .Pp | ||
| 182 | The | ||
| 183 | .Vt ASN1_TIME | ||
| 184 | structure can represent years from 0000 to 9999 but no attempt is | ||
| 185 | made to correct ancient calendar changes (for example from Julian | ||
| 186 | to Gregorian calendars). | ||
| 187 | .Sh RETURN VALUES | ||
| 188 | .Fn ASN1_TIME_set | ||
| 189 | and | ||
| 190 | .Fn ASN1_TIME_adj | ||
| 191 | return a pointer to an | ||
| 192 | .Vt ASN1_TIME | ||
| 193 | structure or | ||
| 194 | .Dv NULL | ||
| 195 | if an error occurred. | ||
| 196 | .Pp | ||
| 197 | .Fn ASN1_TIME_set_string | ||
| 198 | returns 1 if the time value is successfully set or 0 otherwise. | ||
| 199 | .Pp | ||
| 200 | .Fn ASN1_TIME_check | ||
| 201 | returns 1 if the structure is syntactically correct or 0 otherwise. | ||
| 202 | .Pp | ||
| 203 | .Fn ASN1_TIME_print | ||
| 204 | returns 1 if the time is successfully printed out or 0 if an error | ||
| 205 | occurred (I/O error or invalid time format). | ||
| 206 | .Sh EXAMPLES | ||
| 207 | Set a time structure to one hour after the current time and print it | ||
| 208 | out: | ||
| 209 | .Bd -literal -offset indent | ||
| 210 | #include <time.h> | ||
| 211 | #include <openssl/asn1.h> | ||
| 212 | |||
| 213 | ASN1_TIME *tm; | ||
| 214 | time_t t; | ||
| 215 | BIO *b; | ||
| 216 | |||
| 217 | t = time(NULL); | ||
| 218 | tm = ASN1_TIME_adj(NULL, t, 0, 60 * 60); | ||
| 219 | b = BIO_new_fp(stdout, BIO_NOCLOSE); | ||
| 220 | ASN1_TIME_print(b, tm); | ||
| 221 | ASN1_STRING_free(tm); | ||
| 222 | BIO_free(b); | ||
| 223 | .Ed | ||
| 224 | .Sh CAVEATS | ||
| 225 | Some applications add offset times directly to a | ||
| 226 | .Vt time_t | ||
| 227 | value and pass the results to | ||
| 228 | .Fn ASN1_TIME_set | ||
| 229 | (or equivalent). | ||
| 230 | This can cause problems as the | ||
| 231 | .Vt time_t | ||
| 232 | value can overflow on some systems resulting in unexpected results. | ||
| 233 | New applications should use | ||
| 234 | .Fn ASN1_TIME_adj | ||
| 235 | instead and pass the offset value in the | ||
| 236 | .Fa offset_sec | ||
| 237 | and | ||
| 238 | .Fa offset_day | ||
| 239 | parameters instead of directly manipulating a | ||
| 240 | .Vt time_t | ||
| 241 | value. | ||
| 242 | .Sh BUGS | ||
| 243 | .Fn ASN1_TIME_print | ||
| 244 | currently does not print out the time zone: it either prints out "GMT" | ||
| 245 | or nothing. | ||
| 246 | But all certificates complying with RFC5280 et al use GMT anyway. | ||
