OpenCoverage

obj_dat.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/objects/obj_dat.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2018 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#include <stdio.h>-
11#include "internal/ctype.h"-
12#include <limits.h>-
13#include "internal/cryptlib.h"-
14#include <openssl/lhash.h>-
15#include <openssl/asn1.h>-
16#include "internal/objects.h"-
17#include <openssl/bn.h>-
18#include "internal/asn1_int.h"-
19#include "obj_lcl.h"-
20-
21/* obj_dat.h is generated from objects.h by obj_dat.pl */-
22#include "obj_dat.h"-
23-
24DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn);-
25DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln);-
26DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);-
27-
28#define ADDED_DATA 0-
29#define ADDED_SNAME 1-
30#define ADDED_LNAME 2-
31#define ADDED_NID 3-
32-
33struct added_obj_st {-
34 int type;-
35 ASN1_OBJECT *obj;-
36};-
37-
38static int new_nid = NUM_NID;-
39static LHASH_OF(ADDED_OBJ) *added = NULL;-
40-
41static int sn_cmp(const ASN1_OBJECT *const *a, const unsigned int *b)-
42{-
43 return strcmp((*a)->sn, nid_objs[*b].sn);
executed 5402 times by 1 test: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( (*a)->sn ) && __builtin_constant_p ( nid_objs[*b].sn ) && (__s1_len = __builtin_strlen ( (*a)->sn ), __s2_len = __builtin_strlen ( nid_objs[*b].sn ), (!((size_t)(const void *)(( (*... *) (const char *) ( nid_objs[*b].sn ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( nid_objs[*b].sn ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( (*a)->sn , nid_objs[*b].sn )))); }) ;
Executed by:
  • libcrypto.so.1.1
never executed: __result = (((const unsigned char *) (const char *) ( (*a)->sn ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( nid_objs[*b].sn ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-5402
44}-
45-
46IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, sn);
executed 5402 times by 1 test: return sn_cmp(a,b);
Executed by:
  • libcrypto.so.1.1
executed 554 times by 1 test: return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), sn_cmp_BSEARCH_CMP_FN);
Executed by:
  • libcrypto.so.1.1
554-5402
47-
48static int ln_cmp(const ASN1_OBJECT *const *a, const unsigned int *b)-
49{-
50 return strcmp((*a)->ln, nid_objs[*b].ln);
executed 1906 times by 1 test: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( (*a)->ln ) && __builtin_constant_p ( nid_objs[*b].ln ) && (__s1_len = __builtin_strlen ( (*a)->ln ), __s2_len = __builtin_strlen ( nid_objs[*b].ln ), (!((size_t)(const void *)(( (*... *) (const char *) ( nid_objs[*b].ln ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( nid_objs[*b].ln ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( (*a)->ln , nid_objs[*b].ln )))); }) ;
Executed by:
  • libcrypto.so.1.1
never executed: __result = (((const unsigned char *) (const char *) ( (*a)->ln ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( nid_objs[*b].ln ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-1906
51}-
52-
53IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, ln);
executed 1906 times by 1 test: return ln_cmp(a,b);
Executed by:
  • libcrypto.so.1.1
executed 183 times by 1 test: return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), ln_cmp_BSEARCH_CMP_FN);
Executed by:
  • libcrypto.so.1.1
183-1906
54-
55static unsigned long added_obj_hash(const ADDED_OBJ *ca)-
56{-
57 const ASN1_OBJECT *a;-
58 int i;-
59 unsigned long ret = 0;-
60 unsigned char *p;-
61-
62 a = ca->obj;-
63 switch (ca->type) {-
64 case ADDED_DATA:
executed 368 times by 1 test: case 0:
Executed by:
  • libcrypto.so.1.1
368
65 ret = a->length << 20L;-
66 p = (unsigned char *)a->data;-
67 for (i = 0; i < a->length; i++)
i < a->lengthDescription
TRUEevaluated 1746 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 368 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
368-1746
68 ret ^= p[i] << ((i * 3) % 24);
executed 1746 times by 1 test: ret ^= p[i] << ((i * 3) % 24);
Executed by:
  • libcrypto.so.1.1
1746
69 break;
executed 368 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
368
70 case ADDED_SNAME:
executed 219 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
219
71 ret = OPENSSL_LH_strhash(a->sn);-
72 break;
executed 219 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
219
73 case ADDED_LNAME:
executed 135 times by 1 test: case 2:
Executed by:
  • libcrypto.so.1.1
135
74 ret = OPENSSL_LH_strhash(a->ln);-
75 break;
executed 135 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
135
76 case ADDED_NID:
executed 95 times by 1 test: case 3:
Executed by:
  • libcrypto.so.1.1
95
77 ret = a->nid;-
78 break;
executed 95 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
95
79 default:
never executed: default:
0
80 /* abort(); */-
81 return 0;
never executed: return 0;
0
82 }-
83 ret &= 0x3fffffffL;-
84 ret |= ((unsigned long)ca->type) << 30L;-
85 return ret;
executed 817 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
817
86}-
87-
88static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb)-
89{-
90 ASN1_OBJECT *a, *b;-
91 int i;-
92-
93 i = ca->type - cb->type;-
94 if (i)
iDescription
TRUEnever evaluated
FALSEnever evaluated
0
95 return i;
never executed: return i;
0
96 a = ca->obj;-
97 b = cb->obj;-
98 switch (ca->type) {-
99 case ADDED_DATA:
never executed: case 0:
0
100 i = (a->length - b->length);-
101 if (i)
iDescription
TRUEnever evaluated
FALSEnever evaluated
0
102 return i;
never executed: return i;
0
103 return memcmp(a->data, b->data, (size_t)a->length);
never executed: return memcmp(a->data, b->data, (size_t)a->length);
0
104 case ADDED_SNAME:
never executed: case 1:
0
105 if (a->sn == NULL)
a->sn == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
106 return -1;
never executed: return -1;
0
107 else if (b->sn == NULL)
b->sn == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
108 return 1;
never executed: return 1;
0
109 else-
110 return strcmp(a->sn, b->sn);
never executed: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( a->sn ) && __builtin_constant_p ( b->sn ) && (__s1_len = __builtin_strlen ( a->sn ), __s2_len = __builtin_strlen ( b->sn ), (!((size_t)(const void *)(( a->sn ) + 1) - (size_t)(cons...__result = (((const unsigned char *) (const char *) ( b->sn ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( b->sn ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( a->sn , b->sn )))); }) ;
never executed: __result = (((const unsigned char *) (const char *) ( a->sn ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( b->sn ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
111 case ADDED_LNAME:
never executed: case 2:
0
112 if (a->ln == NULL)
a->ln == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
113 return -1;
never executed: return -1;
0
114 else if (b->ln == NULL)
b->ln == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
115 return 1;
never executed: return 1;
0
116 else-
117 return strcmp(a->ln, b->ln);
never executed: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( a->ln ) && __builtin_constant_p ( b->ln ) && (__s1_len = __builtin_strlen ( a->ln ), __s2_len = __builtin_strlen ( b->ln ), (!((size_t)(const void *)(( a->ln ) + 1) - (size_t)(cons...__result = (((const unsigned char *) (const char *) ( b->ln ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( b->ln ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( a->ln , b->ln )))); }) ;
never executed: __result = (((const unsigned char *) (const char *) ( a->ln ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( b->ln ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
118 case ADDED_NID:
never executed: case 3:
0
119 return a->nid - b->nid;
never executed: return a->nid - b->nid;
0
120 default:
never executed: default:
0
121 /* abort(); */-
122 return 0;
never executed: return 0;
0
123 }-
124}-
125-
126static int init_added(void)-
127{-
128 if (added != NULL)
added != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-61
129 return 1;
never executed: return 1;
0
130 added = lh_ADDED_OBJ_new(added_obj_hash, added_obj_cmp);-
131 return added != NULL;
executed 61 times by 1 test: return added != ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
61
132}-
133-
134static void cleanup1_doall(ADDED_OBJ *a)-
135{-
136 a->obj->nid = 0;-
137 a->obj->flags |= ASN1_OBJECT_FLAG_DYNAMIC |-
138 ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA;-
139}
executed 380 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
380
140-
141static void cleanup2_doall(ADDED_OBJ *a)-
142{-
143 a->obj->nid++;-
144}
executed 380 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
380
145-
146static void cleanup3_doall(ADDED_OBJ *a)-
147{-
148 if (--a->obj->nid == 0)
--a->obj->nid == 0Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 285 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
95-285
149 ASN1_OBJECT_free(a->obj);
executed 95 times by 1 test: ASN1_OBJECT_free(a->obj);
Executed by:
  • libcrypto.so.1.1
95
150 OPENSSL_free(a);-
151}
executed 380 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
380
152-
153void obj_cleanup_int(void)-
154{-
155 if (added == NULL)
added == ((void *)0)Description
TRUEevaluated 2015 times by 12 tests
Evaluated by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
FALSEevaluated 61 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
61-2015
156 return;
executed 2015 times by 12 tests: return;
Executed by:
  • asn1_internal_test
  • chacha_internal_test
  • ctype_internal_test
  • curve448_internal_test
  • libcrypto.so.1.1
  • modes_internal_test
  • poly1305_internal_test
  • rdrand_sanitytest
  • siphash_internal_test
  • sm2_internal_test
  • sm4_internal_test
  • x509_internal_test
2015
157 lh_ADDED_OBJ_set_down_load(added, 0);-
158 lh_ADDED_OBJ_doall(added, cleanup1_doall); /* zero counters */-
159 lh_ADDED_OBJ_doall(added, cleanup2_doall); /* set counters */-
160 lh_ADDED_OBJ_doall(added, cleanup3_doall); /* free objects */-
161 lh_ADDED_OBJ_free(added);-
162 added = NULL;-
163}
executed 61 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
61
164-
165int OBJ_new_nid(int num)-
166{-
167 int i;-
168-
169 i = new_nid;-
170 new_nid += num;-
171 return i;
executed 95 times by 1 test: return i;
Executed by:
  • libcrypto.so.1.1
95
172}-
173-
174int OBJ_add_object(const ASN1_OBJECT *obj)-
175{-
176 ASN1_OBJECT *o;-
177 ADDED_OBJ *ao[4] = { NULL, NULL, NULL, NULL }, *aop;-
178 int i;-
179-
180 if (added == NULL)
added == ((void *)0)Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 34 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
34-61
181 if (!init_added())
!init_added()Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-61
182 return 0;
never executed: return 0;
0
183 if ((o = OBJ_dup(obj)) == NULL)
(o = OBJ_dup(o...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
184 goto err;
never executed: goto err;
0
185 if ((ao[ADDED_NID] = OPENSSL_malloc(sizeof(*ao[0]))) == NULL)
(ao[3] = CRYPT...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
186 goto err2;
never executed: goto err2;
0
187 if ((o->length != 0) && (obj->data != NULL))
(o->length != 0)Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(obj->data != ((void *)0) )Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-95
188 if ((ao[ADDED_DATA] = OPENSSL_malloc(sizeof(*ao[0]))) == NULL)
(ao[0] = CRYPT...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
189 goto err2;
never executed: goto err2;
0
190 if (o->sn != NULL)
o->sn != ((void *)0)Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-95
191 if ((ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(*ao[0]))) == NULL)
(ao[1] = CRYPT...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
192 goto err2;
never executed: goto err2;
0
193 if (o->ln != NULL)
o->ln != ((void *)0)Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-95
194 if ((ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(*ao[0]))) == NULL)
(ao[2] = CRYPT...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
195 goto err2;
never executed: goto err2;
0
196-
197 for (i = ADDED_DATA; i <= ADDED_NID; i++) {
i <= 3Description
TRUEevaluated 380 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
95-380
198 if (ao[i] != NULL) {
ao[i] != ((void *)0)Description
TRUEevaluated 380 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-380
199 ao[i]->type = i;-
200 ao[i]->obj = o;-
201 aop = lh_ADDED_OBJ_insert(added, ao[i]);-
202 /* memory leak, but should not normally matter */-
203 OPENSSL_free(aop);-
204 }
executed 380 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
380
205 }
executed 380 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
380
206 o->flags &=-
207 ~(ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS |-
208 ASN1_OBJECT_FLAG_DYNAMIC_DATA);-
209-
210 return o->nid;
executed 95 times by 1 test: return o->nid;
Executed by:
  • libcrypto.so.1.1
95
211 err2:-
212 OBJerr(OBJ_F_OBJ_ADD_OBJECT, ERR_R_MALLOC_FAILURE);-
213 err:
code before this statement never executed: err:
0
214 for (i = ADDED_DATA; i <= ADDED_NID; i++)
i <= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
215 OPENSSL_free(ao[i]);
never executed: CRYPTO_free(ao[i], __FILE__, 215);
0
216 ASN1_OBJECT_free(o);-
217 return NID_undef;
never executed: return 0;
0
218}-
219-
220ASN1_OBJECT *OBJ_nid2obj(int n)-
221{-
222 ADDED_OBJ ad, *adp;-
223 ASN1_OBJECT ob;-
224-
225 if ((n >= 0) && (n < NUM_NID)) {
(n >= 0)Description
TRUEevaluated 1670817 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(n < 1195)Description
TRUEevaluated 1670817 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1670817
226 if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
(n != 0)Description
TRUEevaluated 736889 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 933928 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(nid_objs[n].nid == 0)Description
TRUEnever evaluated
FALSEevaluated 736889 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-933928
227 OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);-
228 return NULL;
never executed: return ((void *)0) ;
0
229 }-
230 return (ASN1_OBJECT *)&(nid_objs[n]);
executed 1670817 times by 1 test: return (ASN1_OBJECT *)&(nid_objs[n]);
Executed by:
  • libcrypto.so.1.1
1670817
231 } else if (added == NULL)
added == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
232 return NULL;
never executed: return ((void *)0) ;
0
233 else {-
234 ad.type = ADDED_NID;-
235 ad.obj = &ob;-
236 ob.nid = n;-
237 adp = lh_ADDED_OBJ_retrieve(added, &ad);-
238 if (adp != NULL)
adp != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
239 return adp->obj;
never executed: return adp->obj;
0
240 else {-
241 OBJerr(OBJ_F_OBJ_NID2OBJ, OBJ_R_UNKNOWN_NID);-
242 return NULL;
never executed: return ((void *)0) ;
0
243 }-
244 }-
245}-
246-
247const char *OBJ_nid2sn(int n)-
248{-
249 ADDED_OBJ ad, *adp;-
250 ASN1_OBJECT ob;-
251-
252 if ((n >= 0) && (n < NUM_NID)) {
(n >= 0)Description
TRUEevaluated 501718 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(n < 1195)Description
TRUEevaluated 501718 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-501718
253 if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
(n != 0)Description
TRUEevaluated 501718 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(nid_objs[n].nid == 0)Description
TRUEnever evaluated
FALSEevaluated 501718 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-501718
254 OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);-
255 return NULL;
never executed: return ((void *)0) ;
0
256 }-
257 return nid_objs[n].sn;
executed 501718 times by 1 test: return nid_objs[n].sn;
Executed by:
  • libcrypto.so.1.1
501718
258 } else if (added == NULL)
added == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
259 return NULL;
never executed: return ((void *)0) ;
0
260 else {-
261 ad.type = ADDED_NID;-
262 ad.obj = &ob;-
263 ob.nid = n;-
264 adp = lh_ADDED_OBJ_retrieve(added, &ad);-
265 if (adp != NULL)
adp != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
266 return adp->obj->sn;
never executed: return adp->obj->sn;
0
267 else {-
268 OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);-
269 return NULL;
never executed: return ((void *)0) ;
0
270 }-
271 }-
272}-
273-
274const char *OBJ_nid2ln(int n)-
275{-
276 ADDED_OBJ ad, *adp;-
277 ASN1_OBJECT ob;-
278-
279 if ((n >= 0) && (n < NUM_NID)) {
(n >= 0)Description
TRUEevaluated 650357 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(n < 1195)Description
TRUEevaluated 650357 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-650357
280 if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
(n != 0)Description
TRUEevaluated 645927 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4430 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(nid_objs[n].nid == 0)Description
TRUEnever evaluated
FALSEevaluated 645927 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-645927
281 OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID);-
282 return NULL;
never executed: return ((void *)0) ;
0
283 }-
284 return nid_objs[n].ln;
executed 650357 times by 1 test: return nid_objs[n].ln;
Executed by:
  • libcrypto.so.1.1
650357
285 } else if (added == NULL)
added == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
286 return NULL;
never executed: return ((void *)0) ;
0
287 else {-
288 ad.type = ADDED_NID;-
289 ad.obj = &ob;-
290 ob.nid = n;-
291 adp = lh_ADDED_OBJ_retrieve(added, &ad);-
292 if (adp != NULL)
adp != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
293 return adp->obj->ln;
never executed: return adp->obj->ln;
0
294 else {-
295 OBJerr(OBJ_F_OBJ_NID2LN, OBJ_R_UNKNOWN_NID);-
296 return NULL;
never executed: return ((void *)0) ;
0
297 }-
298 }-
299}-
300-
301static int obj_cmp(const ASN1_OBJECT *const *ap, const unsigned int *bp)-
302{-
303 int j;-
304 const ASN1_OBJECT *a = *ap;-
305 const ASN1_OBJECT *b = &nid_objs[*bp];-
306-
307 j = (a->length - b->length);-
308 if (j)
jDescription
TRUEevaluated 5136773 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4911503 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
4911503-5136773
309 return j;
executed 5136773 times by 1 test: return j;
Executed by:
  • libcrypto.so.1.1
5136773
310 if (a->length == 0)
a->length == 0Description
TRUEnever evaluated
FALSEevaluated 4911503 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4911503
311 return 0;
never executed: return 0;
0
312 return memcmp(a->data, b->data, a->length);
executed 4911503 times by 1 test: return memcmp(a->data, b->data, a->length);
Executed by:
  • libcrypto.so.1.1
4911503
313}-
314-
315IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
executed 10048276 times by 1 test: return obj_cmp(a,b);
Executed by:
  • libcrypto.so.1.1
executed 1084412 times by 1 test: return (unsigned int *)OBJ_bsearch_(key, base, num, sizeof(unsigned int), obj_cmp_BSEARCH_CMP_FN);
Executed by:
  • libcrypto.so.1.1
1084412-10048276
316-
317int OBJ_obj2nid(const ASN1_OBJECT *a)-
318{-
319 const unsigned int *op;-
320 ADDED_OBJ ad, *adp;-
321-
322 if (a == NULL)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2723834 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2723834
323 return NID_undef;
never executed: return 0;
0
324 if (a->nid != 0)
a->nid != 0Description
TRUEevaluated 1620959 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1102875 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1102875-1620959
325 return a->nid;
executed 1620959 times by 1 test: return a->nid;
Executed by:
  • libcrypto.so.1.1
1620959
326-
327 if (a->length == 0)
a->length == 0Description
TRUEevaluated 18463 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1084412 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
18463-1084412
328 return NID_undef;
executed 18463 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
18463
329-
330 if (added != NULL) {
added != ((void *)0)Description
TRUEevaluated 273 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1084139 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
273-1084139
331 ad.type = ADDED_DATA;-
332 ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */-
333 adp = lh_ADDED_OBJ_retrieve(added, &ad);-
334 if (adp != NULL)
adp != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 273 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-273
335 return adp->obj->nid;
never executed: return adp->obj->nid;
0
336 }
executed 273 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
273
337 op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);-
338 if (op == NULL)
op == ((void *)0)Description
TRUEevaluated 507315 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 577097 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
507315-577097
339 return NID_undef;
executed 507315 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
507315
340 return nid_objs[*op].nid;
executed 577097 times by 1 test: return nid_objs[*op].nid;
Executed by:
  • libcrypto.so.1.1
577097
341}-
342-
343/*-
344 * Convert an object name into an ASN1_OBJECT if "noname" is not set then-
345 * search for short and long names first. This will convert the "dotted" form-
346 * into an object: unlike OBJ_txt2nid it can be used with any objects, not-
347 * just registered ones.-
348 */-
349-
350ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)-
351{-
352 int nid = NID_undef;-
353 ASN1_OBJECT *op;-
354 unsigned char *buf;-
355 unsigned char *p;-
356 const unsigned char *cp;-
357 int i, j;-
358-
359 if (!no_name) {
!no_nameDescription
TRUEevaluated 89 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
89-95
360 if (((nid = OBJ_sn2nid(s)) != NID_undef) ||
((nid = OBJ_sn2nid(s)) != 0)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 61 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
28-61
361 ((nid = OBJ_ln2nid(s)) != NID_undef))
((nid = OBJ_ln2nid(s)) != 0)Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-61
362 return OBJ_nid2obj(nid);
executed 89 times by 1 test: return OBJ_nid2obj(nid);
Executed by:
  • libcrypto.so.1.1
89
363 }
never executed: end of block
0
364-
365 /* Work out size of content octets */-
366 i = a2d_ASN1_OBJECT(NULL, 0, s, -1);-
367 if (i <= 0) {
i <= 0Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
368 /* Don't clear the error */-
369 /*-
370 * ERR_clear_error();-
371 */-
372 return NULL;
never executed: return ((void *)0) ;
0
373 }-
374 /* Work out total size */-
375 j = ASN1_object_size(0, i, V_ASN1_OBJECT);-
376 if (j < 0)
j < 0Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
377 return NULL;
never executed: return ((void *)0) ;
0
378-
379 if ((buf = OPENSSL_malloc(j)) == NULL) {
(buf = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
380 OBJerr(OBJ_F_OBJ_TXT2OBJ, ERR_R_MALLOC_FAILURE);-
381 return NULL;
never executed: return ((void *)0) ;
0
382 }-
383-
384 p = buf;-
385 /* Write out tag+length */-
386 ASN1_put_object(&p, 0, i, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);-
387 /* Write out contents */-
388 a2d_ASN1_OBJECT(p, i, s, -1);-
389-
390 cp = buf;-
391 op = d2i_ASN1_OBJECT(NULL, &cp, j);-
392 OPENSSL_free(buf);-
393 return op;
executed 95 times by 1 test: return op;
Executed by:
  • libcrypto.so.1.1
95
394}-
395-
396int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)-
397{-
398 int i, n = 0, len, nid, first, use_bn;-
399 BIGNUM *bl;-
400 unsigned long l;-
401 const unsigned char *p;-
402 char tbuf[DECIMAL_SIZE(i) + DECIMAL_SIZE(l) + 2];-
403-
404 /* Ensure that, at every state, |buf| is NUL-terminated. */-
405 if (buf && buf_len > 0)
bufDescription
TRUEevaluated 364647 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
buf_len > 0Description
TRUEevaluated 364647 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-364647
406 buf[0] = '\0';
executed 364647 times by 1 test: buf[0] = '\0';
Executed by:
  • libcrypto.so.1.1
364647
407-
408 if ((a == NULL) || (a->data == NULL))
(a == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 364647 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(a->data == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 364647 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-364647
409 return 0;
never executed: return 0;
0
410-
411 if (!no_name && (nid = OBJ_obj2nid(a)) != NID_undef) {
!no_nameDescription
TRUEevaluated 347468 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 17179 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(nid = OBJ_obj2nid(a)) != 0Description
TRUEevaluated 232788 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 114680 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
17179-347468
412 const char *s;-
413 s = OBJ_nid2ln(nid);-
414 if (s == NULL)
s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 232788 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-232788
415 s = OBJ_nid2sn(nid);
never executed: s = OBJ_nid2sn(nid);
0
416 if (s) {
sDescription
TRUEevaluated 232788 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-232788
417 if (buf)
bufDescription
TRUEevaluated 232788 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-232788
418 OPENSSL_strlcpy(buf, s, buf_len);
executed 232788 times by 1 test: OPENSSL_strlcpy(buf, s, buf_len);
Executed by:
  • libcrypto.so.1.1
232788
419 n = strlen(s);-
420 return n;
executed 232788 times by 1 test: return n;
Executed by:
  • libcrypto.so.1.1
232788
421 }-
422 }
never executed: end of block
0
423-
424 len = a->length;-
425 p = a->data;-
426-
427 first = 1;-
428 bl = NULL;-
429-
430 while (len > 0) {
len > 0Description
TRUEevaluated 365129 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 131859 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
131859-365129
431 l = 0;-
432 use_bn = 0;-
433 for (;;) {-
434 unsigned char c = *p++;-
435 len--;-
436 if ((len == 0) && (c & 0x80))
(len == 0)Description
TRUEevaluated 131859 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 490059 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(c & 0x80)Description
TRUEnever evaluated
FALSEevaluated 131859 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-490059
437 goto err;
never executed: goto err;
0
438 if (use_bn) {
use_bnDescription
TRUEevaluated 98849 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 523069 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
98849-523069
439 if (!BN_add_word(bl, c & 0x7f))
!BN_add_word(bl, c & 0x7f)Description
TRUEnever evaluated
FALSEevaluated 98849 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-98849
440 goto err;
never executed: goto err;
0
441 } else
executed 98849 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
98849
442 l |= c & 0x7f;
executed 523069 times by 1 test: l |= c & 0x7f;
Executed by:
  • libcrypto.so.1.1
523069
443 if (!(c & 0x80))
!(c & 0x80)Description
TRUEevaluated 365129 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 256789 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
256789-365129
444 break;
executed 365129 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
365129
445 if (!use_bn && (l > (ULONG_MAX >> 7L))) {
!use_bnDescription
TRUEevaluated 166759 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 90030 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(l > ( (0x7fff...+ 1UL) >> 7L))Description
TRUEevaluated 8819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 157940 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8819-166759
446 if (bl == NULL && (bl = BN_new()) == NULL)
bl == ((void *)0)Description
TRUEevaluated 4261 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 4558 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(bl = BN_new()) == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4261 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4558
447 goto err;
never executed: goto err;
0
448 if (!BN_set_word(bl, l))
!BN_set_word(bl, l)Description
TRUEnever evaluated
FALSEevaluated 8819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8819
449 goto err;
never executed: goto err;
0
450 use_bn = 1;-
451 }
executed 8819 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
8819
452 if (use_bn) {
use_bnDescription
TRUEevaluated 98849 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 157940 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
98849-157940
453 if (!BN_lshift(bl, bl, 7))
!BN_lshift(bl, bl, 7)Description
TRUEnever evaluated
FALSEevaluated 98849 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-98849
454 goto err;
never executed: goto err;
0
455 } else
executed 98849 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
98849
456 l <<= 7L;
executed 157940 times by 1 test: l <<= 7L;
Executed by:
  • libcrypto.so.1.1
157940
457 }-
458-
459 if (first) {
firstDescription
TRUEevaluated 131859 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 233270 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
131859-233270
460 first = 0;-
461 if (l >= 80) {
l >= 80Description
TRUEevaluated 45144 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 86715 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
45144-86715
462 i = 2;-
463 if (use_bn) {
use_bnDescription
TRUEevaluated 3222 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 41922 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3222-41922
464 if (!BN_sub_word(bl, 80))
!BN_sub_word(bl, 80)Description
TRUEnever evaluated
FALSEevaluated 3222 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3222
465 goto err;
never executed: goto err;
0
466 } else
executed 3222 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3222
467 l -= 80;
executed 41922 times by 1 test: l -= 80;
Executed by:
  • libcrypto.so.1.1
41922
468 } else {-
469 i = (int)(l / 40);-
470 l -= (long)(i * 40);-
471 }
executed 86715 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
86715
472 if (buf && (buf_len > 1)) {
bufDescription
TRUEevaluated 131859 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(buf_len > 1)Description
TRUEevaluated 131859 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-131859
473 *buf++ = i + '0';-
474 *buf = '\0';-
475 buf_len--;-
476 }
executed 131859 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
131859
477 n++;-
478 }
executed 131859 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
131859
479-
480 if (use_bn) {
use_bnDescription
TRUEevaluated 8819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 356310 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8819-356310
481 char *bndec;-
482 bndec = BN_bn2dec(bl);-
483 if (!bndec)
!bndecDescription
TRUEnever evaluated
FALSEevaluated 8819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8819
484 goto err;
never executed: goto err;
0
485 i = strlen(bndec);-
486 if (buf) {
bufDescription
TRUEevaluated 8819 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-8819
487 if (buf_len > 1) {
buf_len > 1Description
TRUEevaluated 6900 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1919 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1919-6900
488 *buf++ = '.';-
489 *buf = '\0';-
490 buf_len--;-
491 }
executed 6900 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6900
492 OPENSSL_strlcpy(buf, bndec, buf_len);-
493 if (i > buf_len) {
i > buf_lenDescription
TRUEevaluated 3062 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5757 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3062-5757
494 buf += buf_len;-
495 buf_len = 0;-
496 } else {
executed 3062 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
3062
497 buf += i;-
498 buf_len -= i;-
499 }
executed 5757 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5757
500 }-
501 n++;-
502 n += i;-
503 OPENSSL_free(bndec);-
504 } else {
executed 8819 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
8819
505 BIO_snprintf(tbuf, sizeof(tbuf), ".%lu", l);-
506 i = strlen(tbuf);-
507 if (buf && (buf_len > 0)) {
bufDescription
TRUEevaluated 356310 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(buf_len > 0)Description
TRUEevaluated 332869 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 23441 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-356310
508 OPENSSL_strlcpy(buf, tbuf, buf_len);-
509 if (i > buf_len) {
i > buf_lenDescription
TRUEevaluated 1171 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 331698 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1171-331698
510 buf += buf_len;-
511 buf_len = 0;-
512 } else {
executed 1171 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1171
513 buf += i;-
514 buf_len -= i;-
515 }
executed 331698 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
331698
516 }-
517 n += i;-
518 l = 0;-
519 }
executed 356310 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
356310
520 }-
521-
522 BN_free(bl);-
523 return n;
executed 131859 times by 1 test: return n;
Executed by:
  • libcrypto.so.1.1
131859
524-
525 err:-
526 BN_free(bl);-
527 return -1;
never executed: return -1;
0
528}-
529-
530int OBJ_txt2nid(const char *s)-
531{-
532 ASN1_OBJECT *obj;-
533 int nid;-
534 obj = OBJ_txt2obj(s, 0);-
535 nid = OBJ_obj2nid(obj);-
536 ASN1_OBJECT_free(obj);-
537 return nid;
executed 65 times by 1 test: return nid;
Executed by:
  • libcrypto.so.1.1
65
538}-
539-
540int OBJ_ln2nid(const char *s)-
541{-
542 ASN1_OBJECT o;-
543 const ASN1_OBJECT *oo = &o;-
544 ADDED_OBJ ad, *adp;-
545 const unsigned int *op;-
546-
547 o.ln = s;-
548 if (added != NULL) {
added != ((void *)0)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 143 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
40-143
549 ad.type = ADDED_LNAME;-
550 ad.obj = &o;-
551 adp = lh_ADDED_OBJ_retrieve(added, &ad);-
552 if (adp != NULL)
adp != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-40
553 return adp->obj->nid;
never executed: return adp->obj->nid;
0
554 }
executed 40 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
40
555 op = OBJ_bsearch_ln(&oo, ln_objs, NUM_LN);-
556 if (op == NULL)
op == ((void *)0)Description
TRUEevaluated 112 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 71 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
71-112
557 return NID_undef;
executed 112 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
112
558 return nid_objs[*op].nid;
executed 71 times by 1 test: return nid_objs[*op].nid;
Executed by:
  • libcrypto.so.1.1
71
559}-
560-
561int OBJ_sn2nid(const char *s)-
562{-
563 ASN1_OBJECT o;-
564 const ASN1_OBJECT *oo = &o;-
565 ADDED_OBJ ad, *adp;-
566 const unsigned int *op;-
567-
568 o.sn = s;-
569 if (added != NULL) {
added != ((void *)0)Description
TRUEevaluated 124 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 430 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
124-430
570 ad.type = ADDED_SNAME;-
571 ad.obj = &o;-
572 adp = lh_ADDED_OBJ_retrieve(added, &ad);-
573 if (adp != NULL)
adp != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 124 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-124
574 return adp->obj->nid;
never executed: return adp->obj->nid;
0
575 }
executed 124 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
124
576 op = OBJ_bsearch_sn(&oo, sn_objs, NUM_SN);-
577 if (op == NULL)
op == ((void *)0)Description
TRUEevaluated 184 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 370 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
184-370
578 return NID_undef;
executed 184 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
184
579 return nid_objs[*op].nid;
executed 370 times by 1 test: return nid_objs[*op].nid;
Executed by:
  • libcrypto.so.1.1
370
580}-
581-
582const void *OBJ_bsearch_(const void *key, const void *base, int num, int size,-
583 int (*cmp) (const void *, const void *))-
584{-
585 return OBJ_bsearch_ex_(key, base, num, size, cmp, 0);
executed 1676430 times by 1 test: return OBJ_bsearch_ex_(key, base, num, size, cmp, 0);
Executed by:
  • libcrypto.so.1.1
1676430
586}-
587-
588const void *OBJ_bsearch_ex_(const void *key, const void *base_, int num,-
589 int size,-
590 int (*cmp) (const void *, const void *),-
591 int flags)-
592{-
593 const char *base = base_;-
594 int l, h, i = 0, c = 0;-
595 const char *p = NULL;-
596-
597 if (num == 0)
num == 0Description
TRUEnever evaluated
FALSEevaluated 1681873 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1681873
598 return NULL;
never executed: return ((void *)0) ;
0
599 l = 0;-
600 h = num;-
601 while (l < h) {
l < hDescription
TRUEevaluated 12512541 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 632437 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
632437-12512541
602 i = (l + h) / 2;-
603 p = &(base[i * size]);-
604 c = (*cmp) (key, p);-
605 if (c < 0)
c < 0Description
TRUEevaluated 7411915 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5100626 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5100626-7411915
606 h = i;
executed 7411915 times by 1 test: h = i;
Executed by:
  • libcrypto.so.1.1
7411915
607 else if (c > 0)
c > 0Description
TRUEevaluated 4051190 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1049436 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1049436-4051190
608 l = i + 1;
executed 4051190 times by 1 test: l = i + 1;
Executed by:
  • libcrypto.so.1.1
4051190
609 else-
610 break;
executed 1049436 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
1049436
611 }-
612#ifdef CHARSET_EBCDIC-
613 /*-
614 * THIS IS A KLUDGE - Because the *_obj is sorted in ASCII order, and I-
615 * don't have perl (yet), we revert to a *LINEAR* search when the object-
616 * wasn't found in the binary search.-
617 */-
618 if (c != 0) {-
619 for (i = 0; i < num; ++i) {-
620 p = &(base[i * size]);-
621 c = (*cmp) (key, p);-
622 if (c == 0 || (c < 0 && (flags & OBJ_BSEARCH_VALUE_ON_NOMATCH)))-
623 return p;-
624 }-
625 }-
626#endif-
627 if (c != 0 && !(flags & OBJ_BSEARCH_VALUE_ON_NOMATCH))
c != 0Description
TRUEevaluated 632437 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1049436 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!(flags & 0x01)Description
TRUEevaluated 632409 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 28 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
28-1049436
628 p = NULL;
executed 632409 times by 1 test: p = ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
632409
629 else if (c == 0 && (flags & OBJ_BSEARCH_FIRST_VALUE_ON_MATCH)) {
c == 0Description
TRUEevaluated 1049436 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 28 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(flags & 0x02)Description
TRUEevaluated 5298 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1044138 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
28-1049436
630 while (i > 0 && (*cmp) (key, &(base[(i - 1) * size])) == 0)
i > 0Description
TRUEevaluated 3374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1924 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(*cmp) (key, &...* size])) == 0Description
TRUEnever evaluated
FALSEevaluated 3374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3374
631 i--;
never executed: i--;
0
632 p = &(base[i * size]);-
633 }
executed 5298 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5298
634 return p;
executed 1681873 times by 1 test: return p;
Executed by:
  • libcrypto.so.1.1
1681873
635}-
636-
637/*-
638 * Parse a BIO sink to create some extra oid's objects.-
639 * Line format:<OID:isdigit or '.']><isspace><SN><isspace><LN>-
640 */-
641int OBJ_create_objects(BIO *in)-
642{-
643 char buf[512];-
644 int i, num = 0;-
645 char *o, *s, *l = NULL;-
646-
647 for (;;) {-
648 s = o = NULL;-
649 i = BIO_gets(in, buf, 512);-
650 if (i <= 0)
i <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
651 return num;
never executed: return num;
0
652 buf[i - 1] = '\0';-
653 if (!ossl_isalnum(buf[0]))
!(ossl_ctype_c... 0x2) | 0x4)))Description
TRUEnever evaluated
FALSEnever evaluated
0
654 return num;
never executed: return num;
0
655 o = s = buf;-
656 while (ossl_isdigit(*s) || *s == '.')
(ossl_ctype_check((*s), 0x4))Description
TRUEnever evaluated
FALSEnever evaluated
*s == '.'Description
TRUEnever evaluated
FALSEnever evaluated
0
657 s++;
never executed: s++;
0
658 if (*s != '\0') {
*s != '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
659 *(s++) = '\0';-
660 while (ossl_isspace(*s))
(ossl_ctype_check((*s), 0x8))Description
TRUEnever evaluated
FALSEnever evaluated
0
661 s++;
never executed: s++;
0
662 if (*s == '\0') {
*s == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
663 s = NULL;-
664 } else {
never executed: end of block
0
665 l = s;-
666 while (*l != '\0' && !ossl_isspace(*l))
*l != '\0'Description
TRUEnever evaluated
FALSEnever evaluated
!(ossl_ctype_check((*l), 0x8))Description
TRUEnever evaluated
FALSEnever evaluated
0
667 l++;
never executed: l++;
0
668 if (*l != '\0') {
*l != '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
669 *(l++) = '\0';-
670 while (ossl_isspace(*l))
(ossl_ctype_check((*l), 0x8))Description
TRUEnever evaluated
FALSEnever evaluated
0
671 l++;
never executed: l++;
0
672 if (*l == '\0') {
*l == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
673 l = NULL;-
674 }
never executed: end of block
0
675 } else {
never executed: end of block
0
676 l = NULL;-
677 }
never executed: end of block
0
678 }-
679 } else {-
680 s = NULL;-
681 }
never executed: end of block
0
682 if (*o == '\0')
*o == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
683 return num;
never executed: return num;
0
684 if (!OBJ_create(o, s, l))
!OBJ_create(o, s, l)Description
TRUEnever evaluated
FALSEnever evaluated
0
685 return num;
never executed: return num;
0
686 num++;-
687 }
never executed: end of block
0
688}
never executed: end of block
0
689-
690int OBJ_create(const char *oid, const char *sn, const char *ln)-
691{-
692 ASN1_OBJECT *tmpoid = NULL;-
693 int ok = 0;-
694-
695 /* Check to see if short or long name already present */-
696 if ((sn != NULL && OBJ_sn2nid(sn) != NID_undef)
sn != ((void *)0)Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
OBJ_sn2nid(sn) != 0Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
697 || (ln != NULL && OBJ_ln2nid(ln) != NID_undef)) {
ln != ((void *)0)Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
OBJ_ln2nid(ln) != 0Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
698 OBJerr(OBJ_F_OBJ_CREATE, OBJ_R_OID_EXISTS);-
699 return 0;
never executed: return 0;
0
700 }-
701-
702 /* Convert numerical OID string to an ASN1_OBJECT structure */-
703 tmpoid = OBJ_txt2obj(oid, 1);-
704 if (tmpoid == NULL)
tmpoid == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
705 return 0;
never executed: return 0;
0
706-
707 /* If NID is not NID_undef then object already exists */-
708 if (OBJ_obj2nid(tmpoid) != NID_undef) {
OBJ_obj2nid(tmpoid) != 0Description
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-95
709 OBJerr(OBJ_F_OBJ_CREATE, OBJ_R_OID_EXISTS);-
710 goto err;
never executed: goto err;
0
711 }-
712-
713 tmpoid->nid = OBJ_new_nid(1);-
714 tmpoid->sn = (char *)sn;-
715 tmpoid->ln = (char *)ln;-
716-
717 ok = OBJ_add_object(tmpoid);-
718-
719 tmpoid->sn = NULL;-
720 tmpoid->ln = NULL;-
721-
722 err:
code before this statement executed 95 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
95
723 ASN1_OBJECT_free(tmpoid);-
724 return ok;
executed 95 times by 1 test: return ok;
Executed by:
  • libcrypto.so.1.1
95
725}-
726-
727size_t OBJ_length(const ASN1_OBJECT *obj)-
728{-
729 if (obj == NULL)
obj == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1567 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1567
730 return 0;
never executed: return 0;
0
731 return obj->length;
executed 1567 times by 1 test: return obj->length;
Executed by:
  • libcrypto.so.1.1
1567
732}-
733-
734const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj)-
735{-
736 if (obj == NULL)
obj == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 45 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-45
737 return NULL;
never executed: return ((void *)0) ;
0
738 return obj->data;
executed 45 times by 1 test: return obj->data;
Executed by:
  • libcrypto.so.1.1
45
739}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2