OpenCoverage

a_time.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_time.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10/*--
11 * This is an implementation of the ASN1 Time structure which is:-
12 * Time ::= CHOICE {-
13 * utcTime UTCTime,-
14 * generalTime GeneralizedTime }-
15 */-
16-
17#include <stdio.h>-
18#include <time.h>-
19#include "internal/ctype.h"-
20#include "internal/cryptlib.h"-
21#include <openssl/asn1t.h>-
22#include "asn1_locl.h"-
23-
24IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)-
25-
26IMPLEMENT_ASN1_FUNCTIONS(ASN1_TIME)
executed 8321 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
never executed: return (ASN1_TIME *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(ASN1_TIME_it)));
never executed: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(ASN1_TIME_it)));
executed 117 times by 1 test: return (ASN1_TIME *)ASN1_item_new((&(ASN1_TIME_it)));
Executed by:
  • libcrypto.so.1.1
0-8321
27-
28static int is_utc(const int year)-
29{-
30 if (50 <= year && year <= 149)
50 <= yearDescription
TRUEevaluated 8344 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
year <= 149Description
TRUEevaluated 8341 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-8344
31 return 1;
executed 8341 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
8341
32 return 0;
executed 10 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
10
33}-
34-
35static int leap_year(const int year)-
36{-
37 if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0))
year % 400 == 0Description
TRUEevaluated 1472 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 22368 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
year % 100 != 0Description
TRUEevaluated 21978 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 390 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
year % 4 == 0Description
TRUEevaluated 1877 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 20101 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
390-22368
38 return 1;
executed 3349 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
3349
39 return 0;
executed 20491 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
20491
40}-
41-
42/*-
43 * Compute the day of the week and the day of the year from the year, month-
44 * and day. The day of the year is straightforward, the day of the week uses-
45 * a form of Zeller's congruence. For this months start with March and are-
46 * numbered 4 through 15.-
47 */-
48static void determine_days(struct tm *tm)-
49{-
50 static const int ydays[12] = {-
51 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334-
52 };-
53 int y = tm->tm_year + 1900;-
54 int m = tm->tm_mon;-
55 int d = tm->tm_mday;-
56 int c;-
57-
58 tm->tm_yday = ydays[m] + d - 1;-
59 if (m >= 2) {
m >= 2Description
TRUEevaluated 13300 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 21900 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
13300-21900
60 /* March and onwards can be one day further into the year */-
61 tm->tm_yday += leap_year(y);-
62 m += 2;-
63 } else {
executed 13300 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
13300
64 /* Treat January and February as part of the previous year */-
65 m += 14;-
66 y--;-
67 }
executed 21900 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
21900
68 c = y / 100;-
69 y %= 100;-
70 /* Zeller's congruance */-
71 tm->tm_wday = (d + (13 * m) / 5 + y + y / 4 + c / 4 + 5 * c + 6) % 7;-
72}
executed 35200 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
35200
73-
74int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)-
75{-
76 static const int min[9] = { 0, 0, 1, 1, 0, 0, 0, 0, 0 };-
77 static const int max[9] = { 99, 99, 12, 31, 23, 59, 59, 12, 59 };-
78 static const int mdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };-
79 char *a;-
80 int n, i, i2, l, o, min_l = 11, strict = 0, end = 6, btz = 5, md;-
81 struct tm tmp;-
82-
83 /*-
84 * ASN1_STRING_FLAG_X509_TIME is used to enforce RFC 5280-
85 * time string format, in which:-
86 *-
87 * 1. "seconds" is a 'MUST'-
88 * 2. "Zulu" timezone is a 'MUST'-
89 * 3. "+|-" is not allowed to indicate a time zone-
90 */-
91 if (d->type == V_ASN1_UTCTIME) {
d->type == 23Description
TRUEevaluated 25351 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18809 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
18809-25351
92 if (d->flags & ASN1_STRING_FLAG_X509_TIME) {
d->flags & 0x100Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 25331 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
20-25331
93 min_l = 13;-
94 strict = 1;-
95 }
executed 20 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
20
96 } else if (d->type == V_ASN1_GENERALIZEDTIME) {
executed 25351 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
d->type == 24Description
TRUEevaluated 18809 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-25351
97 end = 7;-
98 btz = 6;-
99 if (d->flags & ASN1_STRING_FLAG_X509_TIME) {
d->flags & 0x100Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18789 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
20-18789
100 min_l = 15;-
101 strict = 1;-
102 } else {
executed 20 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
20
103 min_l = 13;-
104 }
executed 18789 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
18789
105 } else {-
106 return 0;
never executed: return 0;
0
107 }-
108-
109 l = d->length;-
110 a = (char *)d->data;-
111 o = 0;-
112 memset(&tmp, 0, sizeof(tmp));-
113-
114 /*-
115 * GENERALIZEDTIME is similar to UTCTIME except the year is represented-
116 * as YYYY. This stuff treats everything as a two digit field so make-
117 * first two fields 00 to 99-
118 */-
119-
120 if (l < min_l)
l < min_lDescription
TRUEevaluated 6457 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 37703 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
6457-37703
121 goto err;
executed 6457 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
6457
122 for (i = 0; i < end; i++) {
i < endDescription
TRUEevaluated 229866 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 27854 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
27854-229866
123 if (!strict && (i == btz) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
!strictDescription
TRUEevaluated 229715 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 151 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(i == btz)Description
TRUEevaluated 34041 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 195674 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(a[o] == 'Z')Description
TRUEevaluated 1521 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 32520 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(a[o] == '+')Description
TRUEevaluated 723 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 31797 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(a[o] == '-')Description
TRUEevaluated 3184 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 28613 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
151-229715
124 i++;-
125 break;
executed 5428 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
5428
126 }-
127 if (!ossl_isdigit(a[o]))
!(ossl_ctype_c...((a[o]), 0x4))Description
TRUEevaluated 977 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 223461 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
977-223461
128 goto err;
executed 977 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
977
129 n = a[o] - '0';-
130 /* incomplete 2-digital number */-
131 if (++o == l)
++o == lDescription
TRUEevaluated 486 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 222975 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
486-222975
132 goto err;
executed 486 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
486
133-
134 if (!ossl_isdigit(a[o]))
!(ossl_ctype_c...((a[o]), 0x4))Description
TRUEevaluated 848 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 222127 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
848-222127
135 goto err;
executed 848 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
848
136 n = (n * 10) + a[o] - '0';-
137 /* no more bytes to read, but we haven't seen time-zone yet */-
138 if (++o == l)
++o == lDescription
TRUEevaluated 106 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 222021 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
106-222021
139 goto err;
executed 106 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
106
140-
141 i2 = (d->type == V_ASN1_UTCTIME) ? i + 1 : i;
(d->type == 23)Description
TRUEevaluated 126322 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 95699 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
95699-126322
142-
143 if ((n < min[i2]) || (n > max[i2]))
(n < min[i2])Description
TRUEevaluated 531 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 221490 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(n > max[i2])Description
TRUEevaluated 676 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 220814 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
531-221490
144 goto err;
executed 1207 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
1207
145 switch (i2) {-
146 case 0:
executed 15100 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
15100
147 /* UTC will never be here */-
148 tmp.tm_year = n * 100 - 1900;-
149 break;
executed 15100 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
15100
150 case 1:
executed 37083 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
37083
151 if (d->type == V_ASN1_UTCTIME)
d->type == 23Description
TRUEevaluated 22271 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14812 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
14812-22271
152 tmp.tm_year = n < 50 ? n + 100 : n;
executed 22271 times by 1 test: tmp.tm_year = n < 50 ? n + 100 : n;
Executed by:
  • libcrypto.so.1.1
n < 50Description
TRUEevaluated 19393 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2878 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2878-22271
153 else-
154 tmp.tm_year += n;
executed 14812 times by 1 test: tmp.tm_year += n;
Executed by:
  • libcrypto.so.1.1
14812
155 break;
executed 37083 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
37083
156 case 2:
executed 36351 times by 1 test: case 2:
Executed by:
  • libcrypto.so.1.1
36351
157 tmp.tm_mon = n - 1;-
158 break;
executed 36351 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
36351
159 case 3:
executed 35997 times by 1 test: case 3:
Executed by:
  • libcrypto.so.1.1
35997
160 /* check if tm_mday is valid in tm_mon */-
161 if (tmp.tm_mon == 1) {
tmp.tm_mon == 1Description
TRUEevaluated 10540 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 25457 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
10540-25457
162 /* it's February */-
163 md = mdays[1] + leap_year(tmp.tm_year + 1900);-
164 } else {
executed 10540 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10540
165 md = mdays[tmp.tm_mon];-
166 }
executed 25457 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
25457
167 if (n > md)
n > mdDescription
TRUEevaluated 797 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 35200 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
797-35200
168 goto err;
executed 797 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
797
169 tmp.tm_mday = n;-
170 determine_days(&tmp);-
171 break;
executed 35200 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
35200
172 case 4:
executed 34371 times by 1 test: case 4:
Executed by:
  • libcrypto.so.1.1
34371
173 tmp.tm_hour = n;-
174 break;
executed 34371 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
34371
175 case 5:
executed 34058 times by 1 test: case 5:
Executed by:
  • libcrypto.so.1.1
34058
176 tmp.tm_min = n;-
177 break;
executed 34058 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
34058
178 case 6:
executed 27854 times by 1 test: case 6:
Executed by:
  • libcrypto.so.1.1
27854
179 tmp.tm_sec = n;-
180 break;
executed 27854 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
27854
181 }-
182 }
executed 220017 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
220017
183-
184 /*-
185 * Optional fractional seconds: decimal point followed by one or more-
186 * digits.-
187 */-
188 if (d->type == V_ASN1_GENERALIZEDTIME && a[o] == '.') {
d->type == 24Description
TRUEevaluated 12934 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 20348 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
a[o] == '.'Description
TRUEevaluated 5084 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7850 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5084-20348
189 if (strict)
strictDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5082 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-5082
190 /* RFC 5280 forbids fractional seconds */-
191 goto err;
executed 2 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
2
192 if (++o == l)
++o == lDescription
TRUEevaluated 215 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4867 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
215-4867
193 goto err;
executed 215 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
215
194 i = o;-
195 while ((o < l) && ossl_isdigit(a[o]))
(o < l)Description
TRUEevaluated 22748 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 208 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(ossl_ctype_ch...((a[o]), 0x4))Description
TRUEevaluated 18089 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4659 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
208-22748
196 o++;
executed 18089 times by 1 test: o++;
Executed by:
  • libcrypto.so.1.1
18089
197 /* Must have at least one digit after decimal point */-
198 if (i == o)
i == oDescription
TRUEevaluated 400 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4467 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
400-4467
199 goto err;
executed 400 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
400
200 /* no more bytes to read, but we haven't seen time-zone yet */-
201 if (o == l)
o == lDescription
TRUEevaluated 208 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4259 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
208-4259
202 goto err;
executed 208 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
208
203 }
executed 4259 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4259
204-
205 /*-
206 * 'o' will never point to '\0' at this point, the only chance-
207 * 'o' can point to '\0' is either the subsequent if or the first-
208 * else if is true.-
209 */-
210 if (a[o] == 'Z') {
a[o] == 'Z'Description
TRUEevaluated 27348 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5109 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5109-27348
211 o++;-
212 } else if (!strict && ((a[o] == '+') || (a[o] == '-'))) {
executed 27348 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
!strictDescription
TRUEevaluated 5105 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(a[o] == '+')Description
TRUEevaluated 1286 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(a[o] == '-')Description
TRUEevaluated 3382 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 437 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4-27348
213 int offsign = a[o] == '-' ? 1 : -1;
a[o] == '-'Description
TRUEevaluated 3382 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1286 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1286-3382
214 int offset = 0;-
215-
216 o++;-
217 /*-
218 * if not equal, no need to do subsequent checks-
219 * since the following for-loop will add 'o' by 4-
220 * and the final return statement will check if 'l'-
221 * and 'o' are equal.-
222 */-
223 if (o + 4 != l)
o + 4 != lDescription
TRUEevaluated 439 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4229 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
439-4229
224 goto err;
executed 439 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
439
225 for (i = end; i < end + 2; i++) {
i < end + 2Description
TRUEevaluated 7716 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3259 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3259-7716
226 if (!ossl_isdigit(a[o]))
!(ossl_ctype_c...((a[o]), 0x4))Description
TRUEevaluated 329 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7387 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
329-7387
227 goto err;
executed 329 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
329
228 n = a[o] - '0';-
229 o++;-
230 if (!ossl_isdigit(a[o]))
!(ossl_ctype_c...((a[o]), 0x4))Description
TRUEevaluated 315 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7072 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
315-7072
231 goto err;
executed 315 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
315
232 n = (n * 10) + a[o] - '0';-
233 i2 = (d->type == V_ASN1_UTCTIME) ? i + 1 : i;
(d->type == 23)Description
TRUEevaluated 2848 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4224 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2848-4224
234 if ((n < min[i2]) || (n > max[i2]))
(n < min[i2])Description
TRUEnever evaluated
FALSEevaluated 7072 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(n > max[i2])Description
TRUEevaluated 326 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6746 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7072
235 goto err;
executed 326 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
326
236 /* if tm is NULL, no need to adjust */-
237 if (tm != NULL) {
tm != ((void *)0)Description
TRUEevaluated 6698 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 48 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
48-6698
238 if (i == end)
i == endDescription
TRUEevaluated 3463 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3235 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3235-3463
239 offset = n * 3600;
executed 3463 times by 1 test: offset = n * 3600;
Executed by:
  • libcrypto.so.1.1
3463
240 else if (i == end + 1)
i == end + 1Description
TRUEevaluated 3235 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-3235
241 offset += n * 60;
executed 3235 times by 1 test: offset += n * 60;
Executed by:
  • libcrypto.so.1.1
3235
242 }
executed 6698 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6698
243 o++;-
244 }
executed 6746 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6746
245 if (offset && !OPENSSL_gmtime_adj(&tmp, 0, offset * offsign))
offsetDescription
TRUEevaluated 2602 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 657 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!OPENSSL_gmtim...set * offsign)Description
TRUEevaluated 217 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2385 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
217-2602
246 goto err;
executed 217 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
217
247 } else {
executed 3042 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3042
248 /* not Z, or not +/- in non-strict mode */-
249 goto err;
executed 441 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
441
250 }-
251 if (o == l) {
o == lDescription
TRUEevaluated 29379 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1011 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1011-29379
252 /* success, check if tm should be filled */-
253 if (tm != NULL)
tm != ((void *)0)Description
TRUEevaluated 27430 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1949 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1949-27430
254 *tm = tmp;
executed 27430 times by 1 test: *tm = tmp;
Executed by:
  • libcrypto.so.1.1
27430
255 return 1;
executed 29379 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
29379
256 }-
257 err:
code before this statement executed 1011 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
1011
258 return 0;
executed 14781 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
14781
259}-
260-
261ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type)-
262{-
263 char* p;-
264 ASN1_TIME *tmps = NULL;-
265 const size_t len = 20;-
266-
267 if (type == V_ASN1_UNDEF) {
type == -1Description
TRUEevaluated 8348 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1822 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1822-8348
268 if (is_utc(ts->tm_year))
is_utc(ts->tm_year)Description
TRUEevaluated 8340 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8-8340
269 type = V_ASN1_UTCTIME;
executed 8340 times by 1 test: type = 23;
Executed by:
  • libcrypto.so.1.1
8340
270 else-
271 type = V_ASN1_GENERALIZEDTIME;
executed 8 times by 1 test: type = 24;
Executed by:
  • libcrypto.so.1.1
8
272 } else if (type == V_ASN1_UTCTIME) {
type == 23Description
TRUEnever evaluated
FALSEevaluated 1822 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1822
273 if (!is_utc(ts->tm_year))
!is_utc(ts->tm_year)Description
TRUEnever evaluated
FALSEnever evaluated
0
274 goto err;
never executed: goto err;
0
275 } else if (type != V_ASN1_GENERALIZEDTIME) {
never executed: end of block
type != 24Description
TRUEnever evaluated
FALSEevaluated 1822 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1822
276 goto err;
never executed: goto err;
0
277 }-
278-
279 if (s == NULL)
s == ((void *)0)Description
TRUEevaluated 8303 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1867 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1867-8303
280 tmps = ASN1_STRING_new();
executed 8303 times by 1 test: tmps = ASN1_STRING_new();
Executed by:
  • libcrypto.so.1.1
8303
281 else-
282 tmps = s;
executed 1867 times by 1 test: tmps = s;
Executed by:
  • libcrypto.so.1.1
1867
283 if (tmps == NULL)
tmps == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10170 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10170
284 return NULL;
never executed: return ((void *)0) ;
0
285-
286 if (!ASN1_STRING_set(tmps, NULL, len))
!ASN1_STRING_s...id *)0) , len)Description
TRUEnever evaluated
FALSEevaluated 10170 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10170
287 goto err;
never executed: goto err;
0
288-
289 tmps->type = type;-
290 p = (char*)tmps->data;-
291-
292 if (type == V_ASN1_GENERALIZEDTIME)
type == 24Description
TRUEevaluated 1830 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8340 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1830-8340
293 tmps->length = BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ",
executed 1830 times by 1 test: tmps->length = BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
Executed by:
  • libcrypto.so.1.1
1830
294 ts->tm_year + 1900, ts->tm_mon + 1,
executed 1830 times by 1 test: tmps->length = BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
Executed by:
  • libcrypto.so.1.1
1830
295 ts->tm_mday, ts->tm_hour, ts->tm_min,
executed 1830 times by 1 test: tmps->length = BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
Executed by:
  • libcrypto.so.1.1
1830
296 ts->tm_sec);
executed 1830 times by 1 test: tmps->length = BIO_snprintf(p, len, "%04d%02d%02d%02d%02d%02dZ", ts->tm_year + 1900, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
Executed by:
  • libcrypto.so.1.1
1830
297 else-
298 tmps->length = BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ",
executed 8340 times by 1 test: tmps->length = BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year % 100, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
Executed by:
  • libcrypto.so.1.1
8340
299 ts->tm_year % 100, ts->tm_mon + 1,
executed 8340 times by 1 test: tmps->length = BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year % 100, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
Executed by:
  • libcrypto.so.1.1
8340
300 ts->tm_mday, ts->tm_hour, ts->tm_min,
executed 8340 times by 1 test: tmps->length = BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year % 100, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
Executed by:
  • libcrypto.so.1.1
8340
301 ts->tm_sec);
executed 8340 times by 1 test: tmps->length = BIO_snprintf(p, len, "%02d%02d%02d%02d%02d%02dZ", ts->tm_year % 100, ts->tm_mon + 1, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
Executed by:
  • libcrypto.so.1.1
8340
302-
303#ifdef CHARSET_EBCDIC_not-
304 ebcdic2ascii(tmps->data, tmps->data, tmps->length);-
305#endif-
306 return tmps;
executed 10170 times by 1 test: return tmps;
Executed by:
  • libcrypto.so.1.1
10170
307 err:-
308 if (tmps != s)
tmps != sDescription
TRUEnever evaluated
FALSEnever evaluated
0
309 ASN1_STRING_free(tmps);
never executed: ASN1_STRING_free(tmps);
0
310 return NULL;
never executed: return ((void *)0) ;
0
311}-
312-
313ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)-
314{-
315 return ASN1_TIME_adj(s, t, 0, 0);
executed 111 times by 1 test: return ASN1_TIME_adj(s, t, 0, 0);
Executed by:
  • libcrypto.so.1.1
111
316}-
317-
318ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,-
319 int offset_day, long offset_sec)-
320{-
321 struct tm *ts;-
322 struct tm data;-
323-
324 ts = OPENSSL_gmtime(&t, &data);-
325 if (ts == NULL) {
ts == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8319 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8319
326 ASN1err(ASN1_F_ASN1_TIME_ADJ, ASN1_R_ERROR_GETTING_TIME);-
327 return NULL;
never executed: return ((void *)0) ;
0
328 }-
329 if (offset_day || offset_sec) {
offset_dayDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8302 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
offset_secDescription
TRUEnever evaluated
FALSEevaluated 8302 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8302
330 if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
!OPENSSL_gmtim...y, offset_sec)Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-17
331 return NULL;
never executed: return ((void *)0) ;
0
332 }
executed 17 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
17
333 return asn1_time_from_tm(s, ts, V_ASN1_UNDEF);
executed 8319 times by 1 test: return asn1_time_from_tm(s, ts, -1);
Executed by:
  • libcrypto.so.1.1
8319
334}-
335-
336int ASN1_TIME_check(const ASN1_TIME *t)-
337{-
338 if (t->type == V_ASN1_GENERALIZEDTIME)
t->type == 24Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 36 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
36-56
339 return ASN1_GENERALIZEDTIME_check(t);
executed 56 times by 1 test: return ASN1_GENERALIZEDTIME_check(t);
Executed by:
  • libcrypto.so.1.1
56
340 else if (t->type == V_ASN1_UTCTIME)
t->type == 23Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-36
341 return ASN1_UTCTIME_check(t);
executed 36 times by 1 test: return ASN1_UTCTIME_check(t);
Executed by:
  • libcrypto.so.1.1
36
342 return 0;
never executed: return 0;
0
343}-
344-
345/* Convert an ASN1_TIME structure to GeneralizedTime */-
346ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,-
347 ASN1_GENERALIZEDTIME **out)-
348{-
349 ASN1_GENERALIZEDTIME *ret = NULL;-
350 struct tm tm;-
351-
352 if (!ASN1_TIME_to_tm(t, &tm))
!ASN1_TIME_to_tm(t, &tm)Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-16
353 return NULL;
never executed: return ((void *)0) ;
0
354-
355 if (out != NULL)
out != ((void *)0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4-12
356 ret = *out;
executed 4 times by 1 test: ret = *out;
Executed by:
  • libcrypto.so.1.1
4
357-
358 ret = asn1_time_from_tm(ret, &tm, V_ASN1_GENERALIZEDTIME);-
359-
360 if (out != NULL && ret != NULL)
out != ((void *)0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
ret != ((void *)0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-12
361 *out = ret;
executed 4 times by 1 test: *out = ret;
Executed by:
  • libcrypto.so.1.1
4
362-
363 return ret;
executed 16 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
16
364}-
365-
366int ASN1_TIME_set_string(ASN1_TIME *s, const char *str)-
367{-
368 /* Try UTC, if that fails, try GENERALIZED */-
369 if (ASN1_UTCTIME_set_string(s, str))
ASN1_UTCTIME_s...string(s, str)Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 83 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
25-83
370 return 1;
executed 25 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
25
371 return ASN1_GENERALIZEDTIME_set_string(s, str);
executed 83 times by 1 test: return ASN1_GENERALIZEDTIME_set_string(s, str);
Executed by:
  • libcrypto.so.1.1
83
372}-
373-
374int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str)-
375{-
376 ASN1_TIME t;-
377 struct tm tm;-
378 int rv = 0;-
379-
380 t.length = strlen(str);-
381 t.data = (unsigned char *)str;-
382 t.flags = ASN1_STRING_FLAG_X509_TIME;-
383-
384 t.type = V_ASN1_UTCTIME;-
385-
386 if (!ASN1_TIME_check(&t)) {
!ASN1_TIME_check(&t)Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-17
387 t.type = V_ASN1_GENERALIZEDTIME;-
388 if (!ASN1_TIME_check(&t))
!ASN1_TIME_check(&t)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5-12
389 goto out;
executed 12 times by 1 test: goto out;
Executed by:
  • libcrypto.so.1.1
12
390 }
executed 5 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5
391-
392 /*-
393 * Per RFC 5280 (section 4.1.2.5.), the valid input time-
394 * strings should be encoded with the following rules:-
395 *-
396 * 1. UTC: YYMMDDHHMMSSZ, if YY < 50 (20YY) --> UTC: YYMMDDHHMMSSZ-
397 * 2. UTC: YYMMDDHHMMSSZ, if YY >= 50 (19YY) --> UTC: YYMMDDHHMMSSZ-
398 * 3. G'd: YYYYMMDDHHMMSSZ, if YYYY >= 2050 --> G'd: YYYYMMDDHHMMSSZ-
399 * 4. G'd: YYYYMMDDHHMMSSZ, if YYYY < 2050 --> UTC: YYMMDDHHMMSSZ-
400 *-
401 * Only strings of the 4th rule should be reformatted, but since a-
402 * UTC can only present [1950, 2050), so if the given time string-
403 * is less than 1950 (e.g. 19230419000000Z), we do nothing...-
404 */-
405-
406 if (s != NULL && t.type == V_ASN1_GENERALIZEDTIME) {
s != ((void *)0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
t.type == 24Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-5
407 if (!asn1_time_to_tm(&tm, &t))
!asn1_time_to_tm(&tm, &t)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
408 goto out;
never executed: goto out;
0
409 if (is_utc(tm.tm_year)) {
is_utc(tm.tm_year)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-2
410 t.length -= 2;-
411 /*-
412 * it's OK to let original t.data go since that's assigned-
413 * to a piece of memory allocated outside of this function.-
414 * new t.data would be freed after ASN1_STRING_copy is done.-
415 */-
416 t.data = OPENSSL_zalloc(t.length + 1);-
417 if (t.data == NULL)
t.data == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
418 goto out;
never executed: goto out;
0
419 memcpy(t.data, str + 2, t.length);-
420 t.type = V_ASN1_UTCTIME;-
421 }
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1
422 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3
423-
424 if (s == NULL || ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t))
s == ((void *)0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
ASN1_STRING_co...1_STRING *)&t)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-5
425 rv = 1;
executed 8 times by 1 test: rv = 1;
Executed by:
  • libcrypto.so.1.1
8
426-
427 if (t.data != (unsigned char *)str)
t.data != (unsigned char *)strDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-7
428 OPENSSL_free(t.data);
executed 1 time by 1 test: CRYPTO_free(t.data, __FILE__, 428);
Executed by:
  • libcrypto.so.1.1
1
429out:
code before this statement executed 8 times by 1 test: out:
Executed by:
  • libcrypto.so.1.1
8
430 return rv;
executed 20 times by 1 test: return rv;
Executed by:
  • libcrypto.so.1.1
20
431}-
432-
433int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm)-
434{-
435 if (s == NULL) {
s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 16818 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-16818
436 time_t now_t;-
437-
438 time(&now_t);-
439 memset(tm, 0, sizeof(*tm));-
440 if (OPENSSL_gmtime(&now_t, tm) != NULL)
OPENSSL_gmtime...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
441 return 1;
never executed: return 1;
0
442 return 0;
never executed: return 0;
0
443 }-
444-
445 return asn1_time_to_tm(tm, s);
executed 16818 times by 1 test: return asn1_time_to_tm(tm, s);
Executed by:
  • libcrypto.so.1.1
16818
446}-
447-
448int ASN1_TIME_diff(int *pday, int *psec,-
449 const ASN1_TIME *from, const ASN1_TIME *to)-
450{-
451 struct tm tm_from, tm_to;-
452-
453 if (!ASN1_TIME_to_tm(from, &tm_from))
!ASN1_TIME_to_...rom, &tm_from)Description
TRUEevaluated 53 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8246 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
53-8246
454 return 0;
executed 53 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
53
455 if (!ASN1_TIME_to_tm(to, &tm_to))
!ASN1_TIME_to_tm(to, &tm_to)Description
TRUEnever evaluated
FALSEevaluated 8246 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8246
456 return 0;
never executed: return 0;
0
457 return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to);
executed 8246 times by 1 test: return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to);
Executed by:
  • libcrypto.so.1.1
8246
458}-
459-
460static const char _asn1_mon[12][4] = {-
461 "Jan", "Feb", "Mar", "Apr", "May", "Jun",-
462 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"-
463};-
464-
465int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)-
466{-
467 char *v;-
468 int gmt = 0, l;-
469 struct tm stm;-
470-
471 if (!asn1_time_to_tm(&stm, tm)) {
!asn1_time_to_tm(&stm, tm)Description
TRUEevaluated 14056 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10662 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
10662-14056
472 /* asn1_time_to_tm will check the time type */-
473 goto err;
executed 14056 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
14056
474 }-
475-
476 l = tm->length;-
477 v = (char *)tm->data;-
478 if (v[l - 1] == 'Z')
v[l - 1] == 'Z'Description
TRUEevaluated 7768 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2894 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2894-7768
479 gmt = 1;
executed 7768 times by 1 test: gmt = 1;
Executed by:
  • libcrypto.so.1.1
7768
480-
481 if (tm->type == V_ASN1_GENERALIZEDTIME) {
tm->type == 24Description
TRUEevaluated 4479 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6183 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4479-6183
482 char *f = NULL;-
483 int f_len = 0;-
484-
485 /*-
486 * Try to parse fractional seconds. '14' is the place of-
487 * 'fraction point' in a GeneralizedTime string.-
488 */-
489 if (tm->length > 15 && v[14] == '.') {
tm->length > 15Description
TRUEevaluated 3569 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 910 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
v[14] == '.'Description
TRUEevaluated 2373 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1196 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
910-3569
490 f = &v[14];-
491 f_len = 1;-
492 while (14 + f_len < l && ossl_isdigit(f[f_len]))
14 + f_len < lDescription
TRUEevaluated 14487 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(ossl_ctype_ch...f_len]), 0x4))Description
TRUEevaluated 12114 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2373 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-14487
493 ++f_len;
executed 12114 times by 1 test: ++f_len;
Executed by:
  • libcrypto.so.1.1
12114
494 }
executed 2373 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2373
495-
496 return BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
executed 4479 times by 1 test: return BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec, f_len, f, stm.tm_year + 1900, (gmt ? " GMT" : "")) > 0;
Executed by:
  • libcrypto.so.1.1
4479
497 _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour,
executed 4479 times by 1 test: return BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec, f_len, f, stm.tm_year + 1900, (gmt ? " GMT" : "")) > 0;
Executed by:
  • libcrypto.so.1.1
4479
498 stm.tm_min, stm.tm_sec, f_len, f, stm.tm_year + 1900,
executed 4479 times by 1 test: return BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec, f_len, f, stm.tm_year + 1900, (gmt ? " GMT" : "")) > 0;
Executed by:
  • libcrypto.so.1.1
4479
499 (gmt ? " GMT" : "")) > 0;
executed 4479 times by 1 test: return BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec, f_len, f, stm.tm_year + 1900, (gmt ? " GMT" : "")) > 0;
Executed by:
  • libcrypto.so.1.1
4479
500 } else {-
501 return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s",
executed 6183 times by 1 test: return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec, stm.tm_year + 1900, (gmt ? " GMT" : "")) > 0;
Executed by:
  • libcrypto.so.1.1
6183
502 _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour,
executed 6183 times by 1 test: return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec, stm.tm_year + 1900, (gmt ? " GMT" : "")) > 0;
Executed by:
  • libcrypto.so.1.1
6183
503 stm.tm_min, stm.tm_sec, stm.tm_year + 1900,
executed 6183 times by 1 test: return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec, stm.tm_year + 1900, (gmt ? " GMT" : "")) > 0;
Executed by:
  • libcrypto.so.1.1
6183
504 (gmt ? " GMT" : "")) > 0;
executed 6183 times by 1 test: return BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s", _asn1_mon[stm.tm_mon], stm.tm_mday, stm.tm_hour, stm.tm_min, stm.tm_sec, stm.tm_year + 1900, (gmt ? " GMT" : "")) > 0;
Executed by:
  • libcrypto.so.1.1
6183
505 }-
506 err:-
507 BIO_write(bp, "Bad time value", 14);-
508 return 0;
executed 14056 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
14056
509}-
510-
511int ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t)-
512{-
513 struct tm stm, ttm;-
514 int day, sec;-
515-
516 if (!ASN1_TIME_to_tm(s, &stm))
!ASN1_TIME_to_tm(s, &stm)Description
TRUEnever evaluated
FALSEevaluated 179 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-179
517 return -2;
never executed: return -2;
0
518-
519 if (!OPENSSL_gmtime(&t, &ttm))
!OPENSSL_gmtime(&t, &ttm)Description
TRUEnever evaluated
FALSEevaluated 179 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-179
520 return -2;
never executed: return -2;
0
521-
522 if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm))
!OPENSSL_gmtim...c, &ttm, &stm)Description
TRUEnever evaluated
FALSEevaluated 179 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-179
523 return -2;
never executed: return -2;
0
524-
525 if (day > 0 || sec > 0)
day > 0Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 155 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sec > 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 151 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4-155
526 return 1;
executed 28 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
28
527 if (day < 0 || sec < 0)
day < 0Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 124 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sec < 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 120 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4-124
528 return -1;
executed 31 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
31
529 return 0;
executed 120 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
120
530}-
531-
532int ASN1_TIME_normalize(ASN1_TIME *t)-
533{-
534 struct tm tm;-
535-
536 if (!ASN1_TIME_to_tm(t, &tm))
!ASN1_TIME_to_tm(t, &tm)Description
TRUEnever evaluated
FALSEevaluated 29 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-29
537 return 0;
never executed: return 0;
0
538-
539 return asn1_time_from_tm(t, &tm, V_ASN1_UNDEF) != NULL;
executed 29 times by 1 test: return asn1_time_from_tm(t, &tm, -1) != ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
29
540}-
541-
542int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b)-
543{-
544 int day, sec;-
545-
546 if (!ASN1_TIME_diff(&day, &sec, b, a))
!ASN1_TIME_dif...y, &sec, b, a)Description
TRUEnever evaluated
FALSEevaluated 55 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-55
547 return -2;
never executed: return -2;
0
548 if (day > 0 || sec > 0)
day > 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 51 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sec > 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 47 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4-51
549 return 1;
executed 8 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
8
550 if (day < 0 || sec < 0)
day < 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 39 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
sec < 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 32 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7-39
551 return -1;
executed 15 times by 1 test: return -1;
Executed by:
  • libcrypto.so.1.1
15
552 return 0;
executed 32 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
32
553}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2