diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_time_tm.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_time_tm.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c index aa3cb9994c..fcd3acf9c8 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.9 2015/12/12 21:02:59 beck Exp $ */ | 1 | /* $OpenBSD: a_time_tm.c,v 1.10 2016/11/04 18:07:23 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2015 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2015 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -30,7 +30,7 @@ | |||
30 | #define UTCTIME_LENGTH 13 | 30 | #define UTCTIME_LENGTH 13 |
31 | 31 | ||
32 | int | 32 | int |
33 | asn1_tm_cmp(struct tm *tm1, struct tm *tm2) { | 33 | ASN1_time_tm_cmp(struct tm *tm1, struct tm *tm2) { |
34 | if (tm1->tm_year < tm2->tm_year) | 34 | if (tm1->tm_year < tm2->tm_year) |
35 | return (-1); | 35 | return (-1); |
36 | if (tm1->tm_year > tm2->tm_year) | 36 | if (tm1->tm_year > tm2->tm_year) |
@@ -117,8 +117,8 @@ rfc5280_string_from_tm(struct tm *tm) | |||
117 | * Parse an RFC 5280 format ASN.1 time string. | 117 | * Parse an RFC 5280 format ASN.1 time string. |
118 | * | 118 | * |
119 | * mode must be: | 119 | * mode must be: |
120 | * 0 if we expect to parse a time as specified in RFC 5280 from an X509 object. | 120 | * 0 if we expect to parse a time as specified in RFC 5280 for an X509 object. |
121 | * V_ASN1_UTCTIME if we wish to parse on RFC5280 format UTC time. | 121 | * V_ASN1_UTCTIME if we wish to parse an RFC5280 format UTC time. |
122 | * V_ASN1_GENERALIZEDTIME if we wish to parse an RFC5280 format Generalized time. | 122 | * V_ASN1_GENERALIZEDTIME if we wish to parse an RFC5280 format Generalized time. |
123 | * | 123 | * |
124 | * Returns: | 124 | * Returns: |
@@ -130,7 +130,7 @@ rfc5280_string_from_tm(struct tm *tm) | |||
130 | */ | 130 | */ |
131 | #define ATOI2(ar) ((ar) += 2, ((ar)[-2] - '0') * 10 + ((ar)[-1] - '0')) | 131 | #define ATOI2(ar) ((ar) += 2, ((ar)[-2] - '0') * 10 + ((ar)[-1] - '0')) |
132 | int | 132 | int |
133 | asn1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode) | 133 | ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode) |
134 | { | 134 | { |
135 | size_t i; | 135 | size_t i; |
136 | int type = 0; | 136 | int type = 0; |
@@ -218,7 +218,7 @@ ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode) | |||
218 | int type; | 218 | int type; |
219 | char *tmp; | 219 | char *tmp; |
220 | 220 | ||
221 | if ((type = asn1_time_parse(str, strlen(str), NULL, mode)) == -1) | 221 | if ((type = ASN1_time_parse(str, strlen(str), NULL, mode)) == -1) |
222 | return (0); | 222 | return (0); |
223 | if (mode != 0 && mode != type) | 223 | if (mode != 0 && mode != type) |
224 | return (0); | 224 | return (0); |
@@ -315,7 +315,7 @@ ASN1_TIME_check(ASN1_TIME *t) | |||
315 | { | 315 | { |
316 | if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME) | 316 | if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME) |
317 | return (0); | 317 | return (0); |
318 | return (t->type == asn1_time_parse(t->data, t->length, NULL, t->type)); | 318 | return (t->type == ASN1_time_parse(t->data, t->length, NULL, t->type)); |
319 | } | 319 | } |
320 | 320 | ||
321 | ASN1_GENERALIZEDTIME * | 321 | ASN1_GENERALIZEDTIME * |
@@ -329,7 +329,7 @@ ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out) | |||
329 | return (NULL); | 329 | return (NULL); |
330 | 330 | ||
331 | memset(&tm, 0, sizeof(tm)); | 331 | memset(&tm, 0, sizeof(tm)); |
332 | if (t->type != asn1_time_parse(t->data, t->length, &tm, t->type)) | 332 | if (t->type != ASN1_time_parse(t->data, t->length, &tm, t->type)) |
333 | return (NULL); | 333 | return (NULL); |
334 | if ((str = gentime_string_from_tm(&tm)) == NULL) | 334 | if ((str = gentime_string_from_tm(&tm)) == NULL) |
335 | return (NULL); | 335 | return (NULL); |
@@ -364,7 +364,7 @@ ASN1_UTCTIME_check(ASN1_UTCTIME *d) | |||
364 | { | 364 | { |
365 | if (d->type != V_ASN1_UTCTIME) | 365 | if (d->type != V_ASN1_UTCTIME) |
366 | return (0); | 366 | return (0); |
367 | return (d->type == asn1_time_parse(d->data, d->length, NULL, d->type)); | 367 | return (d->type == ASN1_time_parse(d->data, d->length, NULL, d->type)); |
368 | } | 368 | } |
369 | 369 | ||
370 | int | 370 | int |
@@ -402,13 +402,13 @@ ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t2) | |||
402 | * The danger is that users of this function will not | 402 | * The danger is that users of this function will not |
403 | * differentiate the -2 failure case from t1 < t2. | 403 | * differentiate the -2 failure case from t1 < t2. |
404 | */ | 404 | */ |
405 | if (asn1_time_parse(s->data, s->length, &tm1, V_ASN1_UTCTIME) == -1) | 405 | if (ASN1_time_parse(s->data, s->length, &tm1, V_ASN1_UTCTIME) == -1) |
406 | return (-2); /* XXX */ | 406 | return (-2); /* XXX */ |
407 | 407 | ||
408 | if (gmtime_r(&t2, &tm2) == NULL) | 408 | if (gmtime_r(&t2, &tm2) == NULL) |
409 | return (-2); /* XXX */ | 409 | return (-2); /* XXX */ |
410 | 410 | ||
411 | return asn1_tm_cmp(&tm1, &tm2); | 411 | return ASN1_time_tm_cmp(&tm1, &tm2); |
412 | } | 412 | } |
413 | 413 | ||
414 | /* | 414 | /* |
@@ -420,7 +420,7 @@ ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d) | |||
420 | { | 420 | { |
421 | if (d->type != V_ASN1_GENERALIZEDTIME) | 421 | if (d->type != V_ASN1_GENERALIZEDTIME) |
422 | return (0); | 422 | return (0); |
423 | return (d->type == asn1_time_parse(d->data, d->length, NULL, d->type)); | 423 | return (d->type == ASN1_time_parse(d->data, d->length, NULL, d->type)); |
424 | } | 424 | } |
425 | 425 | ||
426 | int | 426 | int |