OpenCoverage

names.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/names.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2016 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/cryptlib.h"-
12#include <openssl/evp.h>-
13#include "internal/objects.h"-
14#include <openssl/x509.h>-
15#include "internal/evp_int.h"-
16-
17int EVP_add_cipher(const EVP_CIPHER *c)-
18{-
19 int r;-
20-
21 if (c == NULL)
c == ((void *)0)Description
TRUEevaluated 15680 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 305992 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
15680-305992
22 return 0;
executed 15680 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
15680
23-
24 r = OBJ_NAME_add(OBJ_nid2sn(c->nid), OBJ_NAME_TYPE_CIPHER_METH,-
25 (const char *)c);-
26 if (r == 0)
r == 0Description
TRUEnever evaluated
FALSEevaluated 305992 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-305992
27 return 0;
never executed: return 0;
0
28 r = OBJ_NAME_add(OBJ_nid2ln(c->nid), OBJ_NAME_TYPE_CIPHER_METH,-
29 (const char *)c);-
30 return r;
executed 305992 times by 1 test: return r;
Executed by:
  • libcrypto.so.1.1
305992
31}-
32-
33int EVP_add_digest(const EVP_MD *md)-
34{-
35 int r;-
36 const char *name;-
37-
38 name = OBJ_nid2sn(md->type);-
39 r = OBJ_NAME_add(name, OBJ_NAME_TYPE_MD_METH, (const char *)md);-
40 if (r == 0)
r == 0Description
TRUEnever evaluated
FALSEevaluated 57024 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-57024
41 return 0;
never executed: return 0;
0
42 r = OBJ_NAME_add(OBJ_nid2ln(md->type), OBJ_NAME_TYPE_MD_METH,-
43 (const char *)md);-
44 if (r == 0)
r == 0Description
TRUEnever evaluated
FALSEevaluated 57024 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-57024
45 return 0;
never executed: return 0;
0
46-
47 if (md->pkey_type && md->type != md->pkey_type) {
md->pkey_typeDescription
TRUEevaluated 47179 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9845 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
md->type != md->pkey_typeDescription
TRUEevaluated 43252 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3927 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3927-47179
48 r = OBJ_NAME_add(OBJ_nid2sn(md->pkey_type),-
49 OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS, name);-
50 if (r == 0)
r == 0Description
TRUEnever evaluated
FALSEevaluated 43252 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-43252
51 return 0;
never executed: return 0;
0
52 r = OBJ_NAME_add(OBJ_nid2ln(md->pkey_type),-
53 OBJ_NAME_TYPE_MD_METH | OBJ_NAME_ALIAS, name);-
54 }
executed 43252 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
43252
55 return r;
executed 57024 times by 1 test: return r;
Executed by:
  • libcrypto.so.1.1
57024
56}-
57-
58const EVP_CIPHER *EVP_get_cipherbyname(const char *name)-
59{-
60 const EVP_CIPHER *cp;-
61-
62 if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 43752 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-43752
63 return NULL;
never executed: return ((void *)0) ;
0
64-
65 cp = (const EVP_CIPHER *)OBJ_NAME_get(name, OBJ_NAME_TYPE_CIPHER_METH);-
66 return cp;
executed 43752 times by 1 test: return cp;
Executed by:
  • libcrypto.so.1.1
43752
67}-
68-
69const EVP_MD *EVP_get_digestbyname(const char *name)-
70{-
71 const EVP_MD *cp;-
72-
73 if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 54731 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-54731
74 return NULL;
never executed: return ((void *)0) ;
0
75-
76 cp = (const EVP_MD *)OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH);-
77 return cp;
executed 54731 times by 1 test: return cp;
Executed by:
  • libcrypto.so.1.1
54731
78}-
79-
80void evp_cleanup_int(void)-
81{-
82 OBJ_NAME_cleanup(OBJ_NAME_TYPE_CIPHER_METH);-
83 OBJ_NAME_cleanup(OBJ_NAME_TYPE_MD_METH);-
84 /*-
85 * The above calls will only clean out the contents of the name hash-
86 * table, but not the hash table itself. The following line does that-
87 * part. -- Richard Levitte-
88 */-
89 OBJ_NAME_cleanup(-1);-
90-
91 EVP_PBE_cleanup();-
92 OBJ_sigid_free();-
93-
94 evp_app_cleanup_int();-
95}
executed 2076 times by 12 tests: end of block
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
2076
96-
97struct doall_cipher {-
98 void *arg;-
99 void (*fn) (const EVP_CIPHER *ciph,-
100 const char *from, const char *to, void *arg);-
101};-
102-
103static void do_all_cipher_fn(const OBJ_NAME *nm, void *arg)-
104{-
105 struct doall_cipher *dc = arg;-
106 if (nm->alias)
nm->aliasDescription
TRUEnever evaluated
FALSEnever evaluated
0
107 dc->fn(NULL, nm->name, nm->data, dc->arg);
never executed: dc->fn( ((void *)0) , nm->name, nm->data, dc->arg);
0
108 else-
109 dc->fn((const EVP_CIPHER *)nm->data, nm->name, NULL, dc->arg);
never executed: dc->fn((const EVP_CIPHER *)nm->data, nm->name, ((void *)0) , dc->arg);
0
110}-
111-
112void EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,-
113 const char *from, const char *to, void *x),-
114 void *arg)-
115{-
116 struct doall_cipher dc;-
117-
118 /* Ignore errors */-
119 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL);-
120-
121 dc.fn = fn;-
122 dc.arg = arg;-
123 OBJ_NAME_do_all(OBJ_NAME_TYPE_CIPHER_METH, do_all_cipher_fn, &dc);-
124}
never executed: end of block
0
125-
126void EVP_CIPHER_do_all_sorted(void (*fn) (const EVP_CIPHER *ciph,-
127 const char *from, const char *to,-
128 void *x), void *arg)-
129{-
130 struct doall_cipher dc;-
131-
132 /* Ignore errors */-
133 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL);-
134-
135 dc.fn = fn;-
136 dc.arg = arg;-
137 OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, do_all_cipher_fn, &dc);-
138}
never executed: end of block
0
139-
140struct doall_md {-
141 void *arg;-
142 void (*fn) (const EVP_MD *ciph,-
143 const char *from, const char *to, void *arg);-
144};-
145-
146static void do_all_md_fn(const OBJ_NAME *nm, void *arg)-
147{-
148 struct doall_md *dc = arg;-
149 if (nm->alias)
nm->aliasDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 dc->fn(NULL, nm->name, nm->data, dc->arg);
never executed: dc->fn( ((void *)0) , nm->name, nm->data, dc->arg);
0
151 else-
152 dc->fn((const EVP_MD *)nm->data, nm->name, NULL, dc->arg);
never executed: dc->fn((const EVP_MD *)nm->data, nm->name, ((void *)0) , dc->arg);
0
153}-
154-
155void EVP_MD_do_all(void (*fn) (const EVP_MD *md,-
156 const char *from, const char *to, void *x),-
157 void *arg)-
158{-
159 struct doall_md dc;-
160-
161 /* Ignore errors */-
162 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL);-
163-
164 dc.fn = fn;-
165 dc.arg = arg;-
166 OBJ_NAME_do_all(OBJ_NAME_TYPE_MD_METH, do_all_md_fn, &dc);-
167}
never executed: end of block
0
168-
169void EVP_MD_do_all_sorted(void (*fn) (const EVP_MD *md,-
170 const char *from, const char *to,-
171 void *x), void *arg)-
172{-
173 struct doall_md dc;-
174-
175 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL);-
176-
177 dc.fn = fn;-
178 dc.arg = arg;-
179 OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, do_all_md_fn, &dc);-
180}
never executed: end of block
0
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2