diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/man/ASN1_TIME_set.3 | 136 |
1 files changed, 72 insertions, 64 deletions
diff --git a/src/lib/libcrypto/man/ASN1_TIME_set.3 b/src/lib/libcrypto/man/ASN1_TIME_set.3 index b8a567ece0..4f6a99673a 100644 --- a/src/lib/libcrypto/man/ASN1_TIME_set.3 +++ b/src/lib/libcrypto/man/ASN1_TIME_set.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: ASN1_TIME_set.3,v 1.18 2022/11/10 17:44:05 schwarze Exp $ | 1 | .\" $OpenBSD: ASN1_TIME_set.3,v 1.19 2022/11/13 22:11:44 schwarze Exp $ |
| 2 | .\" full merge up to: OpenSSL 3d0f1cb9 Jul 11 03:01:24 2017 +0800 | 2 | .\" full merge up to: OpenSSL 3d0f1cb9 Jul 11 03:01:24 2017 +0800 |
| 3 | .\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 | 3 | .\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 |
| 4 | .\" | 4 | .\" |
| @@ -6,14 +6,15 @@ | |||
| 6 | .\" The changes are covered by the following Copyright and license: | 6 | .\" The changes are covered by the following Copyright and license: |
| 7 | .\" | 7 | .\" |
| 8 | .\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> | 8 | .\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> |
| 9 | .\" Copyright (c) 2022 Bob Beck <beck@openbsd.org> | ||
| 9 | .\" | 10 | .\" |
| 10 | .\" Permission to use, copy, modify, and distribute this software for any | 11 | .\" Permission to use, copy, modify, and distribute this software for any |
| 11 | .\" purpose with or without fee is hereby granted, provided that the above | 12 | .\" purpose with or without fee is hereby granted, provided that the above |
| 12 | .\" copyright notice and this permission notice appear in all copies. | 13 | .\" copyright notice and this permission notice appear in all copies. |
| 13 | .\" | 14 | .\" |
| 14 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 15 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES |
| 15 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 16 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 16 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 17 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR |
| 17 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 18 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 18 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 19 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 19 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 20 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| @@ -67,7 +68,7 @@ | |||
| 67 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 68 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 68 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 69 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
| 69 | .\" | 70 | .\" |
| 70 | .Dd $Mdocdate: November 10 2022 $ | 71 | .Dd $Mdocdate: November 13 2022 $ |
| 71 | .Dt ASN1_TIME_SET 3 | 72 | .Dt ASN1_TIME_SET 3 |
| 72 | .Os | 73 | .Os |
| 73 | .Sh NAME | 74 | .Sh NAME |
| @@ -217,12 +218,35 @@ | |||
| 217 | .Fa "ASN1_GENERALIZEDTIME **out" | 218 | .Fa "ASN1_GENERALIZEDTIME **out" |
| 218 | .Fc | 219 | .Fc |
| 219 | .Sh DESCRIPTION | 220 | .Sh DESCRIPTION |
| 221 | An | ||
| 222 | .Vt ASN1_TIME | ||
| 223 | object is a shallow wrapper around a string containing an ASN.1 | ||
| 224 | .Vt Time | ||
| 225 | value in the restricted format valid in X.509 certificates. | ||
| 226 | An | ||
| 227 | .Vt ASN1_TIME | ||
| 228 | object is either an | ||
| 229 | .Vt ASN1_UTCTIME | ||
| 230 | object containing a string of the format | ||
| 231 | .Ar YYMMDDHHMMSS Ns Cm Z | ||
| 232 | which is valid for the years 1950 to 2049, or an | ||
| 233 | .Vt ASN1_GENERALIZEDTIME | ||
| 234 | object containing a string of the format | ||
| 235 | .Ar YYYYMMDDHHMMSS Ns Cm Z | ||
| 236 | which is valid for the years 0000 to 1949 and 2050 to 9999. | ||
| 237 | In both cases, the mandatory suffix | ||
| 238 | .Sq Cm Z | ||
| 239 | represents the GMT time zone. | ||
| 240 | LibreSSL by design does not support the full syntax of ASN.1 times. | ||
| 241 | In particular, it neither supports fractional seconds | ||
| 242 | nor any other time zone. | ||
| 243 | .Pp | ||
| 220 | The functions | 244 | The functions |
| 221 | .Fn ASN1_TIME_set , | 245 | .Fn ASN1_TIME_set , |
| 222 | .Fn ASN1_UTCTIME_set , | 246 | .Fn ASN1_UTCTIME_set , |
| 223 | and | 247 | and |
| 224 | .Fn ASN1_GENERALIZEDTIME_set | 248 | .Fn ASN1_GENERALIZEDTIME_set |
| 225 | set the time structure | 249 | set the time object |
| 226 | .Fa s | 250 | .Fa s |
| 227 | to the time represented by the | 251 | to the time represented by the |
| 228 | .Vt time_t | 252 | .Vt time_t |
| @@ -232,14 +256,14 @@ If | |||
| 232 | .Fa s | 256 | .Fa s |
| 233 | is | 257 | is |
| 234 | .Dv NULL , | 258 | .Dv NULL , |
| 235 | a new time structure is allocated and returned. | 259 | a new time object is allocated and returned. |
| 236 | .Pp | 260 | .Pp |
| 237 | The functions | 261 | The functions |
| 238 | .Fn ASN1_TIME_adj , | 262 | .Fn ASN1_TIME_adj , |
| 239 | .Fn ASN1_UTCTIME_adj , | 263 | .Fn ASN1_UTCTIME_adj , |
| 240 | and | 264 | and |
| 241 | .Fn ASN1_GENERALIZEDTIME_adj | 265 | .Fn ASN1_GENERALIZEDTIME_adj |
| 242 | set the time structure | 266 | set the time object |
| 243 | .Fa s | 267 | .Fa s |
| 244 | to the time represented by the time | 268 | to the time represented by the time |
| 245 | .Fa offset_day | 269 | .Fa offset_day |
| @@ -262,7 +286,7 @@ If | |||
| 262 | .Fa s | 286 | .Fa s |
| 263 | is | 287 | is |
| 264 | .Dv NULL , | 288 | .Dv NULL , |
| 265 | a new time structure is allocated and returned. | 289 | a new time object is allocated and returned. |
| 266 | .Pp | 290 | .Pp |
| 267 | .Fn ASN1_TIME_adj | 291 | .Fn ASN1_TIME_adj |
| 268 | may change the type from | 292 | may change the type from |
| @@ -274,7 +298,7 @@ The functions | |||
| 274 | .Fn ASN1_UTCTIME_adj | 298 | .Fn ASN1_UTCTIME_adj |
| 275 | and | 299 | and |
| 276 | .Fn ASN1_GENERALIZEDTIME_adj | 300 | .Fn ASN1_GENERALIZEDTIME_adj |
| 277 | do not modify the type of the return structure. | 301 | do not modify the type of the return object. |
| 278 | .Pp | 302 | .Pp |
| 279 | The functions | 303 | The functions |
| 280 | .Fn ASN1_TIME_set_string , | 304 | .Fn ASN1_TIME_set_string , |
| @@ -282,9 +306,9 @@ The functions | |||
| 282 | .Fn ASN1_UTCTIME_set_string , | 306 | .Fn ASN1_UTCTIME_set_string , |
| 283 | and | 307 | and |
| 284 | .Fn ASN1_GENERALIZEDTIME_set_string | 308 | .Fn ASN1_GENERALIZEDTIME_set_string |
| 285 | set the time structure | 309 | set the time object |
| 286 | .Fa s | 310 | .Fa s |
| 287 | to the time represented by the string | 311 | to the time string |
| 288 | .Fa str , | 312 | .Fa str , |
| 289 | which must be in appropriate ASN.1 time format: | 313 | which must be in appropriate ASN.1 time format: |
| 290 | YYMMDDHHMMSSZ for | 314 | YYMMDDHHMMSSZ for |
| @@ -308,32 +332,28 @@ In LibreSSL, | |||
| 308 | .Fn ASN1_TIME_set_string | 332 | .Fn ASN1_TIME_set_string |
| 309 | and | 333 | and |
| 310 | .Fn ASN1_TIME_set_string_X509 | 334 | .Fn ASN1_TIME_set_string_X509 |
| 311 | behave identically. | 335 | behave identically and always set the time object |
| 312 | In other implementations, | 336 | to a valid value to use in an X.509 certificate. |
| 313 | .Fn ASN1_TIME_set_string , | ||
| 314 | .Fn ASN1_UTCTIME_set_string , | ||
| 315 | and | ||
| 316 | .Fn ASN1_GENERALIZEDTIME_set_string | 337 | .Fn ASN1_GENERALIZEDTIME_set_string |
| 317 | may accept additional formats that violate RFC 5280. | 338 | may encode a time string that is not valid in an X.509 certificate. |
| 318 | .Pp | 339 | .Pp |
| 319 | The function | 340 | The function |
| 320 | .Fn ASN1_TIME_normalize | 341 | .Fn ASN1_TIME_normalize |
| 321 | converts an | 342 | converts an |
| 322 | .Vt ASN1_GENERALIZEDTIME | 343 | .Vt ASN1_GENERALIZEDTIME |
| 323 | or | 344 | into a time value that can be used in a certificate |
| 345 | by changing it to an | ||
| 324 | .Vt ASN1_UTCTIME | 346 | .Vt ASN1_UTCTIME |
| 325 | into a time value that can be used in a certificate. | 347 | if possible. |
| 326 | It is intended to be used after the | 348 | It has no effect on an |
| 327 | .Fn ASN1_TIME_set_string | 349 | .Vt ASN1_UTCTIME . |
| 328 | functions to ensure the value is valid for use as an | ||
| 329 | .Vt ASN1_TIME . | ||
| 330 | .Pp | 350 | .Pp |
| 331 | The functions | 351 | The functions |
| 332 | .Fn ASN1_TIME_check , | 352 | .Fn ASN1_TIME_check , |
| 333 | .Fn ASN1_UTCTIME_check , | 353 | .Fn ASN1_UTCTIME_check , |
| 334 | and | 354 | and |
| 335 | .Fn ASN1_GENERALIZEDTIME_check | 355 | .Fn ASN1_GENERALIZEDTIME_check |
| 336 | check the syntax of the time structure | 356 | check the syntax of the time string contained in the object |
| 337 | .Fa s . | 357 | .Fa s . |
| 338 | .Pp | 358 | .Pp |
| 339 | The functions | 359 | The functions |
| @@ -350,11 +370,8 @@ in human readable format. | |||
| 350 | It will be of the format MMM DD HH:MM:SS YYYY [GMT], for example "Feb 3 | 370 | It will be of the format MMM DD HH:MM:SS YYYY [GMT], for example "Feb 3 |
| 351 | 00:55:52 2015 GMT". | 371 | 00:55:52 2015 GMT". |
| 352 | It does not include a newline. | 372 | It does not include a newline. |
| 353 | If the time structure has an invalid format, | 373 | If the time string has an invalid format, |
| 354 | it prints out "Bad time value" and returns an error. | 374 | it prints out "Bad time value" and returns an error. |
| 355 | The output of | ||
| 356 | .Fn ASN1_GENERALIZEDTIME_print | ||
| 357 | may include a fractional part following the second. | ||
| 358 | .Pp | 375 | .Pp |
| 359 | The function | 376 | The function |
| 360 | .Fn ASN1_TIME_to_tm | 377 | .Fn ASN1_TIME_to_tm |
| @@ -368,7 +385,7 @@ If | |||
| 368 | is | 385 | is |
| 369 | .Dv NULL , | 386 | .Dv NULL , |
| 370 | then the current time is converted. | 387 | then the current time is converted. |
| 371 | The output time is GMT. | 388 | The output time is always in the GMT time zone. |
| 372 | The | 389 | The |
| 373 | .Fa tm_sec , tm_min , tm_hour , tm_mday , tm_mon , | 390 | .Fa tm_sec , tm_min , tm_hour , tm_mday , tm_mon , |
| 374 | and | 391 | and |
| @@ -465,33 +482,15 @@ is | |||
| 465 | then a new object is allocated and must be freed after use. | 482 | then a new object is allocated and must be freed after use. |
| 466 | .Pp | 483 | .Pp |
| 467 | The | 484 | The |
| 468 | .Vt ASN1_TIME | ||
| 469 | structure corresponds to the ASN.1 structure | ||
| 470 | .Sy Time | ||
| 471 | defined in RFC 5280 et al. | ||
| 472 | The time setting functions obey the rules outlined in RFC 5280: if the | ||
| 473 | date can be represented by UTCTime it is used, otherwise GeneralizedTime is | ||
| 474 | used. | ||
| 475 | .Pp | ||
| 476 | The | ||
| 477 | .Vt ASN1_TIME , | 485 | .Vt ASN1_TIME , |
| 478 | .Vt ASN1_UTCTIME , | 486 | .Vt ASN1_UTCTIME , |
| 479 | and | 487 | and |
| 480 | .Vt ASN1_GENERALIZEDTIME | 488 | .Vt ASN1_GENERALIZEDTIME |
| 481 | structures are represented as | 489 | objects are represented as |
| 482 | .Vt ASN1_STRING | 490 | .Vt ASN1_STRING |
| 483 | structures internally and can be freed using | 491 | objects internally and can be freed using |
| 484 | .Xr ASN1_STRING_free 3 . | 492 | .Xr ASN1_STRING_free 3 . |
| 485 | .Pp | 493 | .Pp |
| 486 | The | ||
| 487 | .Vt ASN1_TIME | ||
| 488 | structure can represent years from 0000 to 9999 but no attempt is | ||
| 489 | made to correct ancient calendar changes (for example from Julian | ||
| 490 | to Gregorian calendars). | ||
| 491 | .Pp | ||
| 492 | .Vt ASN1_UTCTIME | ||
| 493 | is limited to a year range of 1950 through 2049. | ||
| 494 | .Pp | ||
| 495 | It is recommended that | 494 | It is recommended that |
| 496 | .Vt ASN1_TIME | 495 | .Vt ASN1_TIME |
| 497 | functions be used instead of | 496 | functions be used instead of |
| @@ -514,7 +513,7 @@ functions operate on either format. | |||
| 514 | .Fn ASN1_GENERALIZEDTIME_adj , | 513 | .Fn ASN1_GENERALIZEDTIME_adj , |
| 515 | and | 514 | and |
| 516 | .Fn ASN1_TIME_to_generalizedtime | 515 | .Fn ASN1_TIME_to_generalizedtime |
| 517 | return a pointer to a time structure or | 516 | return a pointer to a time object or |
| 518 | .Dv NULL | 517 | .Dv NULL |
| 519 | if an error occurred. | 518 | if an error occurred. |
| 520 | .Pp | 519 | .Pp |
| @@ -532,7 +531,8 @@ returns 1 on success or 0 on error. | |||
| 532 | .Fn ASN1_UTCTIME_check , | 531 | .Fn ASN1_UTCTIME_check , |
| 533 | and | 532 | and |
| 534 | .Fn ASN1_GENERALIZEDTIME_check | 533 | .Fn ASN1_GENERALIZEDTIME_check |
| 535 | return 1 if the time structure is syntactically correct or 0 otherwise. | 534 | return 1 if the time string contained in the object is syntactically |
| 535 | correct or 0 otherwise. | ||
| 536 | .Pp | 536 | .Pp |
| 537 | .Fn ASN1_TIME_print , | 537 | .Fn ASN1_TIME_print , |
| 538 | .Fn ASN1_UTCTIME_print , | 538 | .Fn ASN1_UTCTIME_print , |
| @@ -547,7 +547,7 @@ or 0 if an error occurred, usually due to an invalid time format. | |||
| 547 | .Pp | 547 | .Pp |
| 548 | .Fn ASN1_TIME_diff | 548 | .Fn ASN1_TIME_diff |
| 549 | returns 1 for success or 0 for failure. | 549 | returns 1 for success or 0 for failure. |
| 550 | It can for example fail if a time structure passed in has invalid syntax. | 550 | It can for example fail if a time string passed in has invalid syntax. |
| 551 | .Pp | 551 | .Pp |
| 552 | .Fn ASN1_TIME_cmp_time_t , | 552 | .Fn ASN1_TIME_cmp_time_t , |
| 553 | .Fn ASN1_UTCTIME_cmp_time_t , | 553 | .Fn ASN1_UTCTIME_cmp_time_t , |
| @@ -563,27 +563,42 @@ is later than | |||
| 563 | .Fa t , | 563 | .Fa t , |
| 564 | or \-2 on error. | 564 | or \-2 on error. |
| 565 | .Sh EXAMPLES | 565 | .Sh EXAMPLES |
| 566 | Set a time structure to one hour after the current time and print it | 566 | Set a time object to one hour after the current time and print it |
| 567 | out: | 567 | out: |
| 568 | .Bd -literal -offset indent | 568 | .Bd -literal -offset indent |
| 569 | #include <time.h> | 569 | #include <time.h> |
| 570 | #include <openssl/asn1.h> | 570 | #include <openssl/asn1.h> |
| 571 | 571 | ||
| 572 | ASN1_TIME *tm; | 572 | ASN1_TIME *asn1_time; |
| 573 | time_t t; | 573 | time_t t; |
| 574 | BIO *b; | 574 | BIO *b; |
| 575 | 575 | ||
| 576 | t = time(NULL); | 576 | t = time(NULL); |
| 577 | tm = ASN1_TIME_adj(NULL, t, 0, 60 * 60); | 577 | asn1_time = ASN1_TIME_adj(NULL, t, 0, 60 * 60); |
| 578 | b = BIO_new_fp(stdout, BIO_NOCLOSE); | 578 | b = BIO_new_fp(stdout, BIO_NOCLOSE); |
| 579 | ASN1_TIME_print(b, tm); | 579 | if (asn1_time != NULL) { |
| 580 | ASN1_STRING_free(tm); | 580 | ASN1_TIME_print(b, asn1_time); |
| 581 | BIO_printf(b, "\en"); | ||
| 582 | } else { | ||
| 583 | BIO_printf(b, "Time out of range or un-representable\en"); | ||
| 584 | } | ||
| 585 | ASN1_STRING_free(asn1_time); | ||
| 581 | BIO_free(b); | 586 | BIO_free(b); |
| 582 | .Ed | 587 | .Ed |
| 583 | .Sh SEE ALSO | 588 | .Sh SEE ALSO |
| 584 | .Xr ASN1_TIME_new 3 , | 589 | .Xr ASN1_TIME_new 3 , |
| 585 | .Xr ASN1_time_parse 3 , | 590 | .Xr ASN1_time_parse 3 , |
| 586 | .Xr X509_cmp_time 3 | 591 | .Xr X509_cmp_time 3 |
| 592 | .Sh STANDARDS | ||
| 593 | The usage of the ASN.1 | ||
| 594 | .Vt Time , | ||
| 595 | .Vt UTCTime , | ||
| 596 | and | ||
| 597 | .Vt GeneralizedTime | ||
| 598 | data types in X.509 certificates is specified in | ||
| 599 | RFC 5280, Internet X.509 Public Key Infrastructure Certificate and | ||
| 600 | Certificate Revocation List (CRL) Profile, | ||
| 601 | section 4.1.2.5 (TBS Certificate Validity). | ||
| 587 | .Sh HISTORY | 602 | .Sh HISTORY |
| 588 | .Fn ASN1_UTCTIME_check | 603 | .Fn ASN1_UTCTIME_check |
| 589 | and | 604 | and |
| @@ -654,10 +669,3 @@ and | |||
| 654 | parameters instead of directly manipulating a | 669 | parameters instead of directly manipulating a |
| 655 | .Vt time_t | 670 | .Vt time_t |
| 656 | value. | 671 | value. |
| 657 | .Sh BUGS | ||
| 658 | .Fn ASN1_TIME_print , | ||
| 659 | .Fn ASN1_UTCTIME_print , | ||
| 660 | and | ||
| 661 | .Fn ASN1_GENERALIZEDTIME_print | ||
| 662 | do not print the time zone: they either print "GMT" or nothing. | ||
| 663 | But all certificates complying with RFC 5280 et al use GMT anyway. | ||
