diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_time_tm.c | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c index 59fd32e9ca..9faa4ba5dc 100644 --- a/src/lib/libcrypto/asn1/a_time_tm.c +++ b/src/lib/libcrypto/asn1/a_time_tm.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: a_time_tm.c,v 1.37 2024/04/11 06:42:09 tb Exp $ */ | 1 | /* $OpenBSD: a_time_tm.c,v 1.38 2024/04/11 06:49:19 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2015 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2015 Bob Beck <beck@openbsd.org> |
| 4 | * | 4 | * |
| @@ -35,29 +35,29 @@ int | |||
| 35 | ASN1_time_tm_cmp(struct tm *tm1, struct tm *tm2) | 35 | ASN1_time_tm_cmp(struct tm *tm1, struct tm *tm2) |
| 36 | { | 36 | { |
| 37 | if (tm1->tm_year < tm2->tm_year) | 37 | if (tm1->tm_year < tm2->tm_year) |
| 38 | return (-1); | 38 | return -1; |
| 39 | if (tm1->tm_year > tm2->tm_year) | 39 | if (tm1->tm_year > tm2->tm_year) |
| 40 | return (1); | 40 | return 1; |
| 41 | if (tm1->tm_mon < tm2->tm_mon) | 41 | if (tm1->tm_mon < tm2->tm_mon) |
| 42 | return (-1); | 42 | return -1; |
| 43 | if (tm1->tm_mon > tm2->tm_mon) | 43 | if (tm1->tm_mon > tm2->tm_mon) |
| 44 | return (1); | 44 | return 1; |
| 45 | if (tm1->tm_mday < tm2->tm_mday) | 45 | if (tm1->tm_mday < tm2->tm_mday) |
| 46 | return (-1); | 46 | return -1; |
| 47 | if (tm1->tm_mday > tm2->tm_mday) | 47 | if (tm1->tm_mday > tm2->tm_mday) |
| 48 | return (1); | 48 | return 1; |
| 49 | if (tm1->tm_hour < tm2->tm_hour) | 49 | if (tm1->tm_hour < tm2->tm_hour) |
| 50 | return (-1); | 50 | return -1; |
| 51 | if (tm1->tm_hour > tm2->tm_hour) | 51 | if (tm1->tm_hour > tm2->tm_hour) |
| 52 | return (1); | 52 | return 1; |
| 53 | if (tm1->tm_min < tm2->tm_min) | 53 | if (tm1->tm_min < tm2->tm_min) |
| 54 | return (-1); | 54 | return -1; |
| 55 | if (tm1->tm_min > tm2->tm_min) | 55 | if (tm1->tm_min > tm2->tm_min) |
| 56 | return (1); | 56 | return 1; |
| 57 | if (tm1->tm_sec < tm2->tm_sec) | 57 | if (tm1->tm_sec < tm2->tm_sec) |
| 58 | return (-1); | 58 | return -1; |
| 59 | if (tm1->tm_sec > tm2->tm_sec) | 59 | if (tm1->tm_sec > tm2->tm_sec) |
| 60 | return (1); | 60 | return 1; |
| 61 | return 0; | 61 | return 0; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| @@ -139,9 +139,9 @@ static int | |||
| 139 | tm_to_rfc5280_time(struct tm *tm, ASN1_TIME *atime) | 139 | tm_to_rfc5280_time(struct tm *tm, ASN1_TIME *atime) |
| 140 | { | 140 | { |
| 141 | if (tm->tm_year >= 50 && tm->tm_year < 150) | 141 | if (tm->tm_year >= 50 && tm->tm_year < 150) |
| 142 | return (tm_to_utctime(tm, atime)); | 142 | return tm_to_utctime(tm, atime); |
| 143 | 143 | ||
| 144 | return (tm_to_gentime(tm, atime)); | 144 | return tm_to_gentime(tm, atime); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | 147 | ||
| @@ -298,7 +298,7 @@ ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode) | |||
| 298 | CBS cbs; | 298 | CBS cbs; |
| 299 | 299 | ||
| 300 | if (bytes == NULL) | 300 | if (bytes == NULL) |
| 301 | return (-1); | 301 | return -1; |
| 302 | 302 | ||
| 303 | CBS_init(&cbs, bytes, len); | 303 | CBS_init(&cbs, bytes, len); |
| 304 | 304 | ||
| @@ -326,16 +326,16 @@ ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode) | |||
| 326 | int type; | 326 | int type; |
| 327 | 327 | ||
| 328 | if ((type = ASN1_time_parse(str, strlen(str), &tm, mode)) == -1) | 328 | if ((type = ASN1_time_parse(str, strlen(str), &tm, mode)) == -1) |
| 329 | return (0); | 329 | return 0; |
| 330 | switch (mode) { | 330 | switch (mode) { |
| 331 | case V_ASN1_UTCTIME: | 331 | case V_ASN1_UTCTIME: |
| 332 | return (type == mode && tm_to_utctime(&tm, s)); | 332 | return type == mode && tm_to_utctime(&tm, s); |
| 333 | case V_ASN1_GENERALIZEDTIME: | 333 | case V_ASN1_GENERALIZEDTIME: |
| 334 | return (type == mode && tm_to_gentime(&tm, s)); | 334 | return type == mode && tm_to_gentime(&tm, s); |
| 335 | case RFC5280: | 335 | case RFC5280: |
| 336 | return (tm_to_rfc5280_time(&tm, s)); | 336 | return tm_to_rfc5280_time(&tm, s); |
| 337 | default: | 337 | default: |
| 338 | return (0); | 338 | return 0; |
| 339 | } | 339 | } |
| 340 | } | 340 | } |
| 341 | 341 | ||
| @@ -388,14 +388,14 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec, | |||
| 388 | ASN1_TIME * | 388 | ASN1_TIME * |
| 389 | ASN1_TIME_set(ASN1_TIME *s, time_t t) | 389 | ASN1_TIME_set(ASN1_TIME *s, time_t t) |
| 390 | { | 390 | { |
| 391 | return (ASN1_TIME_adj(s, t, 0, 0)); | 391 | return ASN1_TIME_adj(s, t, 0, 0); |
| 392 | } | 392 | } |
| 393 | LCRYPTO_ALIAS(ASN1_TIME_set); | 393 | LCRYPTO_ALIAS(ASN1_TIME_set); |
| 394 | 394 | ||
| 395 | ASN1_TIME * | 395 | ASN1_TIME * |
| 396 | ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec) | 396 | ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec) |
| 397 | { | 397 | { |
| 398 | return (ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, RFC5280)); | 398 | return ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, RFC5280); |
| 399 | } | 399 | } |
| 400 | LCRYPTO_ALIAS(ASN1_TIME_adj); | 400 | LCRYPTO_ALIAS(ASN1_TIME_adj); |
| 401 | 401 | ||
| @@ -403,8 +403,8 @@ int | |||
| 403 | ASN1_TIME_check(const ASN1_TIME *t) | 403 | ASN1_TIME_check(const ASN1_TIME *t) |
| 404 | { | 404 | { |
| 405 | if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME) | 405 | if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME) |
| 406 | return (0); | 406 | return 0; |
| 407 | return (t->type == ASN1_time_parse(t->data, t->length, NULL, t->type)); | 407 | return t->type == ASN1_time_parse(t->data, t->length, NULL, t->type); |
| 408 | } | 408 | } |
| 409 | LCRYPTO_ALIAS(ASN1_TIME_check); | 409 | LCRYPTO_ALIAS(ASN1_TIME_check); |
| 410 | 410 | ||
| @@ -444,7 +444,7 @@ LCRYPTO_ALIAS(ASN1_TIME_to_generalizedtime); | |||
| 444 | int | 444 | int |
| 445 | ASN1_TIME_set_string(ASN1_TIME *s, const char *str) | 445 | ASN1_TIME_set_string(ASN1_TIME *s, const char *str) |
| 446 | { | 446 | { |
| 447 | return (ASN1_TIME_set_string_internal(s, str, RFC5280)); | 447 | return ASN1_TIME_set_string_internal(s, str, RFC5280); |
| 448 | } | 448 | } |
| 449 | LCRYPTO_ALIAS(ASN1_TIME_set_string); | 449 | LCRYPTO_ALIAS(ASN1_TIME_set_string); |
| 450 | 450 | ||
| @@ -513,8 +513,8 @@ int | |||
| 513 | ASN1_UTCTIME_check(const ASN1_UTCTIME *d) | 513 | ASN1_UTCTIME_check(const ASN1_UTCTIME *d) |
| 514 | { | 514 | { |
| 515 | if (d->type != V_ASN1_UTCTIME) | 515 | if (d->type != V_ASN1_UTCTIME) |
| 516 | return (0); | 516 | return 0; |
| 517 | return (d->type == ASN1_time_parse(d->data, d->length, NULL, d->type)); | 517 | return d->type == ASN1_time_parse(d->data, d->length, NULL, d->type); |
| 518 | } | 518 | } |
| 519 | LCRYPTO_ALIAS(ASN1_UTCTIME_check); | 519 | LCRYPTO_ALIAS(ASN1_UTCTIME_check); |
| 520 | 520 | ||
| @@ -522,23 +522,23 @@ int | |||
| 522 | ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str) | 522 | ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str) |
| 523 | { | 523 | { |
| 524 | if (s != NULL && s->type != V_ASN1_UTCTIME) | 524 | if (s != NULL && s->type != V_ASN1_UTCTIME) |
| 525 | return (0); | 525 | return 0; |
| 526 | return (ASN1_TIME_set_string_internal(s, str, V_ASN1_UTCTIME)); | 526 | return ASN1_TIME_set_string_internal(s, str, V_ASN1_UTCTIME); |
| 527 | } | 527 | } |
| 528 | LCRYPTO_ALIAS(ASN1_UTCTIME_set_string); | 528 | LCRYPTO_ALIAS(ASN1_UTCTIME_set_string); |
| 529 | 529 | ||
| 530 | ASN1_UTCTIME * | 530 | ASN1_UTCTIME * |
| 531 | ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) | 531 | ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) |
| 532 | { | 532 | { |
| 533 | return (ASN1_UTCTIME_adj(s, t, 0, 0)); | 533 | return ASN1_UTCTIME_adj(s, t, 0, 0); |
| 534 | } | 534 | } |
| 535 | LCRYPTO_ALIAS(ASN1_UTCTIME_set); | 535 | LCRYPTO_ALIAS(ASN1_UTCTIME_set); |
| 536 | 536 | ||
| 537 | ASN1_UTCTIME * | 537 | ASN1_UTCTIME * |
| 538 | ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec) | 538 | ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec) |
| 539 | { | 539 | { |
| 540 | return (ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, | 540 | return ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, |
| 541 | V_ASN1_UTCTIME)); | 541 | V_ASN1_UTCTIME); |
| 542 | } | 542 | } |
| 543 | LCRYPTO_ALIAS(ASN1_UTCTIME_adj); | 543 | LCRYPTO_ALIAS(ASN1_UTCTIME_adj); |
| 544 | 544 | ||
| @@ -559,8 +559,8 @@ int | |||
| 559 | ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d) | 559 | ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d) |
| 560 | { | 560 | { |
| 561 | if (d->type != V_ASN1_GENERALIZEDTIME) | 561 | if (d->type != V_ASN1_GENERALIZEDTIME) |
| 562 | return (0); | 562 | return 0; |
| 563 | return (d->type == ASN1_time_parse(d->data, d->length, NULL, d->type)); | 563 | return d->type == ASN1_time_parse(d->data, d->length, NULL, d->type); |
| 564 | } | 564 | } |
| 565 | LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_check); | 565 | LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_check); |
| 566 | 566 | ||
| @@ -568,15 +568,15 @@ int | |||
| 568 | ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str) | 568 | ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str) |
| 569 | { | 569 | { |
| 570 | if (s != NULL && s->type != V_ASN1_GENERALIZEDTIME) | 570 | if (s != NULL && s->type != V_ASN1_GENERALIZEDTIME) |
| 571 | return (0); | 571 | return 0; |
| 572 | return (ASN1_TIME_set_string_internal(s, str, V_ASN1_GENERALIZEDTIME)); | 572 | return ASN1_TIME_set_string_internal(s, str, V_ASN1_GENERALIZEDTIME); |
| 573 | } | 573 | } |
| 574 | LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_set_string); | 574 | LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_set_string); |
| 575 | 575 | ||
| 576 | ASN1_GENERALIZEDTIME * | 576 | ASN1_GENERALIZEDTIME * |
| 577 | ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t) | 577 | ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t) |
| 578 | { | 578 | { |
| 579 | return (ASN1_GENERALIZEDTIME_adj(s, t, 0, 0)); | 579 | return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0); |
| 580 | } | 580 | } |
| 581 | LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_set); | 581 | LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_set); |
| 582 | 582 | ||
| @@ -584,8 +584,8 @@ ASN1_GENERALIZEDTIME * | |||
| 584 | ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, | 584 | ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, |
| 585 | long offset_sec) | 585 | long offset_sec) |
| 586 | { | 586 | { |
| 587 | return (ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, | 587 | return ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, |
| 588 | V_ASN1_GENERALIZEDTIME)); | 588 | V_ASN1_GENERALIZEDTIME); |
| 589 | } | 589 | } |
| 590 | LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_adj); | 590 | LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_adj); |
| 591 | 591 | ||
