OpenCoverage

dsa_asn1.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/dsa/dsa_asn1.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3static const ASN1_TEMPLATE DSA_SIG_seq_tt[] = {-
4 { (0), (0), -
5 __builtin_offsetof (-
6 DSA_SIG-
7 , -
8 r-
9 )-
10 , "r", (&(CBIGNUM_it)) },-
11 { (0), (0), -
12 __builtin_offsetof (-
13 DSA_SIG-
14 , -
15 s-
16 )-
17 , "s", (&(CBIGNUM_it)) }-
18} ; static const ASN1_ITEM DSA_SIG_it = { 0x1, 16, DSA_SIG_seq_tt, sizeof(DSA_SIG_seq_tt) / sizeof(ASN1_TEMPLATE), -
19 ((void *)0)-
20 , sizeof(DSA_SIG), "DSA_SIG" };-
21-
22DSA_SIG *d2i_DSA_SIG(DSA_SIG **a, const unsigned char **in, long len) { return
executed 3694 times by 1 test: return (DSA_SIG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSA_SIG_it)));
Executed by:
  • libcrypto.so.1.1
(DSA_SIG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSA_SIG_it)));
executed 3694 times by 1 test: return (DSA_SIG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSA_SIG_it)));
Executed by:
  • libcrypto.so.1.1
} int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **out) { return
executed 379 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSA_SIG_it)));
Executed by:
  • libcrypto.so.1.1
ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSA_SIG_it)));
executed 379 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSA_SIG_it)));
Executed by:
  • libcrypto.so.1.1
}
379-3694
23-
24DSA_SIG *DSA_SIG_new(void)-
25{-
26 DSA_SIG *sig = CRYPTO_zalloc(sizeof(*sig), __FILE__, 26);-
27 if (sig ==
sig == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 371 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-371
28 ((void *)0)
sig == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 371 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-371
29 )-
30 ERR_put_error(10,(102),((1|64)),__FILE__,28);
never executed: ERR_put_error(10,(102),((1|64)),__FILE__,28);
0
31 return
executed 371 times by 1 test: return sig;
Executed by:
  • libcrypto.so.1.1
sig;
executed 371 times by 1 test: return sig;
Executed by:
  • libcrypto.so.1.1
371
32}-
33-
34void DSA_SIG_free(DSA_SIG *sig)-
35{-
36 if (sig ==
sig == ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 400 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-400
37 ((void *)0)
sig == ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 400 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-400
38 )-
39 return;
executed 2 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
2
40 BN_clear_free(sig->r);-
41 BN_clear_free(sig->s);-
42 CRYPTO_free(sig, __FILE__, 38);-
43}
executed 400 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
400
44-
45void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)-
46{-
47 if (pr !=
pr != ((void *)0)Description
TRUEevaluated 321 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-321
48 ((void *)0)
pr != ((void *)0)Description
TRUEevaluated 321 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-321
49 )-
50 *
executed 321 times by 1 test: *pr = sig->r;
Executed by:
  • libcrypto.so.1.1
pr = sig->r;
executed 321 times by 1 test: *pr = sig->r;
Executed by:
  • libcrypto.so.1.1
321
51 if (ps !=
ps != ((void *)0)Description
TRUEevaluated 321 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-321
52 ((void *)0)
ps != ((void *)0)Description
TRUEevaluated 321 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-321
53 )-
54 *
executed 321 times by 1 test: *ps = sig->s;
Executed by:
  • libcrypto.so.1.1
ps = sig->s;
executed 321 times by 1 test: *ps = sig->s;
Executed by:
  • libcrypto.so.1.1
321
55}
executed 321 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
321
56-
57int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s)-
58{-
59 if (r ==
r == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
60 ((void *)0)
r == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
61 || s ==
s == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
62 ((void *)0)
s == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
63 )-
64 return
never executed: return 0;
0;
never executed: return 0;
0
65 BN_clear_free(sig->r);-
66 BN_clear_free(sig->s);-
67 sig->r = r;-
68 sig->s = s;-
69 return
never executed: return 1;
1;
never executed: return 1;
0
70}-
71-
72-
73static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,-
74 void *exarg)-
75{-
76 if (operation == 0
operation == 0Description
TRUEevaluated 15092 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 30349 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
15092-30349
77 *pval = (ASN1_VALUE *)DSA_new();-
78 if (*
*pval != ((void *)0)Description
TRUEevaluated 15092 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
pval !=
*pval != ((void *)0)Description
TRUEevaluated 15092 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-15092
79 ((void *)0)
*pval != ((void *)0)Description
TRUEevaluated 15092 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-15092
80 )-
81 return
executed 15092 times by 1 test: return 2;
Executed by:
  • libcrypto.so.1.1
2;
executed 15092 times by 1 test: return 2;
Executed by:
  • libcrypto.so.1.1
15092
82 return
never executed: return 0;
0;
never executed: return 0;
0
83 } else if (operation == 2
operation == 2Description
TRUEevaluated 10559 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 19790 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
10559-19790
84 DSA_free((DSA *)*pval);-
85 *pval = -
86 ((void *)0)-
87 ;-
88 return
executed 10559 times by 1 test: return 2;
Executed by:
  • libcrypto.so.1.1
2;
executed 10559 times by 1 test: return 2;
Executed by:
  • libcrypto.so.1.1
10559
89 }-
90 return
executed 19790 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 19790 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
19790
91}-
92-
93static const ASN1_AUX DSAPrivateKey_aux = {-
94((void *)0)-
95, 0, 0, 0, dsa_cb, 0}; static const ASN1_TEMPLATE DSAPrivateKey_seq_tt[] = {-
96 { ((0x1 << 12)), (0), -
97 __builtin_offsetof (-
98 DSA-
99 , -
100 version-
101 )-
102 , "version", (&(INT32_it)) },-
103 { (0), (0), -
104 __builtin_offsetof (-
105 DSA-
106 , -
107 p-
108 )-
109 , "p", (&(BIGNUM_it)) },-
110 { (0), (0), -
111 __builtin_offsetof (-
112 DSA-
113 , -
114 q-
115 )-
116 , "q", (&(BIGNUM_it)) },-
117 { (0), (0), -
118 __builtin_offsetof (-
119 DSA-
120 , -
121 g-
122 )-
123 , "g", (&(BIGNUM_it)) },-
124 { (0), (0), -
125 __builtin_offsetof (-
126 DSA-
127 , -
128 pub_key-
129 )-
130 , "pub_key", (&(BIGNUM_it)) },-
131 { (0), (0), -
132 __builtin_offsetof (-
133 DSA-
134 , -
135 priv_key-
136 )-
137 , "priv_key", (&(CBIGNUM_it)) }-
138} ; static const ASN1_ITEM DSAPrivateKey_it = { 0x1, 16, DSAPrivateKey_seq_tt, sizeof(DSAPrivateKey_seq_tt) / sizeof(ASN1_TEMPLATE), &DSAPrivateKey_aux, sizeof(DSA), "DSA" };-
139-
140DSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **in, long len) { return
executed 5360 times by 1 test: return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPrivateKey_it)));
Executed by:
  • libcrypto.so.1.1
(DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPrivateKey_it)));
executed 5360 times by 1 test: return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPrivateKey_it)));
Executed by:
  • libcrypto.so.1.1
} int i2d_DSAPrivateKey(const DSA *a, unsigned char **out) { return
executed 27 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPrivateKey_it)));
Executed by:
  • libcrypto.so.1.1
ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPrivateKey_it)));
executed 27 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPrivateKey_it)));
Executed by:
  • libcrypto.so.1.1
}
27-5360
141-
142static const ASN1_AUX DSAparams_aux = {-
143((void *)0)-
144, 0, 0, 0, dsa_cb, 0}; static const ASN1_TEMPLATE DSAparams_seq_tt[] = {-
145 { (0), (0), -
146 __builtin_offsetof (-
147 DSA-
148 , -
149 p-
150 )-
151 , "p", (&(BIGNUM_it)) },-
152 { (0), (0), -
153 __builtin_offsetof (-
154 DSA-
155 , -
156 q-
157 )-
158 , "q", (&(BIGNUM_it)) },-
159 { (0), (0), -
160 __builtin_offsetof (-
161 DSA-
162 , -
163 g-
164 )-
165 , "g", (&(BIGNUM_it)) },-
166} ; static const ASN1_ITEM DSAparams_it = { 0x1, 16, DSAparams_seq_tt, sizeof(DSAparams_seq_tt) / sizeof(ASN1_TEMPLATE), &DSAparams_aux, sizeof(DSA), "DSA" };-
167-
168DSA *d2i_DSAparams(DSA **a, const unsigned char **in, long len) { return
executed 7493 times by 1 test: return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAparams_it)));
Executed by:
  • libcrypto.so.1.1
(DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAparams_it)));
executed 7493 times by 1 test: return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAparams_it)));
Executed by:
  • libcrypto.so.1.1
} int i2d_DSAparams(const DSA *a, unsigned char **out) { return
executed 35 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAparams_it)));
Executed by:
  • libcrypto.so.1.1
ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAparams_it)));
executed 35 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAparams_it)));
Executed by:
  • libcrypto.so.1.1
}
35-7493
169-
170static const ASN1_AUX DSAPublicKey_aux = {-
171((void *)0)-
172, 0, 0, 0, dsa_cb, 0}; static const ASN1_TEMPLATE DSAPublicKey_seq_tt[] = {-
173 { (0), (0), -
174 __builtin_offsetof (-
175 DSA-
176 , -
177 pub_key-
178 )-
179 , "pub_key", (&(BIGNUM_it)) },-
180 { (0), (0), -
181 __builtin_offsetof (-
182 DSA-
183 , -
184 p-
185 )-
186 , "p", (&(BIGNUM_it)) },-
187 { (0), (0), -
188 __builtin_offsetof (-
189 DSA-
190 , -
191 q-
192 )-
193 , "q", (&(BIGNUM_it)) },-
194 { (0), (0), -
195 __builtin_offsetof (-
196 DSA-
197 , -
198 g-
199 )-
200 , "g", (&(BIGNUM_it)) }-
201} ; static const ASN1_ITEM DSAPublicKey_it = { 0x1, 16, DSAPublicKey_seq_tt, sizeof(DSAPublicKey_seq_tt) / sizeof(ASN1_TEMPLATE), &DSAPublicKey_aux, sizeof(DSA), "DSA" };-
202-
203DSA *d2i_DSAPublicKey(DSA **a, const unsigned char **in, long len) { return
executed 3323 times by 1 test: return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPublicKey_it)));
Executed by:
  • libcrypto.so.1.1
(DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPublicKey_it)));
executed 3323 times by 1 test: return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPublicKey_it)));
Executed by:
  • libcrypto.so.1.1
} int i2d_DSAPublicKey(const DSA *a, unsigned char **out) { return
executed 3 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPublicKey_it)));
Executed by:
  • libcrypto.so.1.1
ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPublicKey_it)));
executed 3 times by 1 test: return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPublicKey_it)));
Executed by:
  • libcrypto.so.1.1
}
3-3323
204-
205DSA *DSAparams_dup(DSA *dsa)-
206{-
207 return
never executed: return ASN1_item_dup((&(DSAparams_it)), dsa);
ASN1_item_dup((&(DSAparams_it)), dsa);
never executed: return ASN1_item_dup((&(DSAparams_it)), dsa);
0
208}-
209-
210int DSA_sign(int type, const unsigned char *dgst, int dlen,-
211 unsigned char *sig, unsigned int *siglen, DSA *dsa)-
212{-
213 DSA_SIG *s;-
214-
215 s = DSA_do_sign(dgst, dlen, dsa);-
216 if (s ==
s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-64
217 ((void *)0)
s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-64
218 ) {-
219 *siglen = 0;-
220 return
never executed: return 0;
0;
never executed: return 0;
0
221 }-
222 *siglen = i2d_DSA_SIG(s, &sig);-
223 DSA_SIG_free(s);-
224 return
executed 64 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 64 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
64
225}-
226int DSA_verify(int type, const unsigned char *dgst, int dgst_len,-
227 const unsigned char *sigbuf, int siglen, DSA *dsa)-
228{-
229 DSA_SIG *s;-
230 const unsigned char *p = sigbuf;-
231 unsigned char *der = -
232 ((void *)0)-
233 ;-
234 int derlen = -1;-
235 int ret = -1;-
236-
237 s = DSA_SIG_new();-
238 if (s ==
s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 307 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-307
239 ((void *)0)
s == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 307 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-307
240 )-
241 return
never executed: return ret;
ret;
never executed: return ret;
0
242 if (d2i_DSA_SIG(&s, &p, siglen) ==
d2i_DSA_SIG(&s...== ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 305 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-305
243 ((void *)0)
d2i_DSA_SIG(&s...== ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 305 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-305
244 )-
245 goto
executed 2 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 2 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
2
246-
247 derlen = i2d_DSA_SIG(s, &der);-
248 if (derlen != siglen
derlen != siglenDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 302 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| memcmp(sigbuf, der, derlen)
memcmp(sigbuf, der, derlen)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 301 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
1-302
249 goto
executed 4 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
err;
executed 4 times by 1 test: goto err;
Executed by:
  • libcrypto.so.1.1
4
250 ret = DSA_do_verify(dgst, dgst_len, s, dsa);-
251 err:
code before this statement executed 301 times by 1 test: err:
Executed by:
  • libcrypto.so.1.1
301
252 CRYPTO_clear_free(der, derlen, __FILE__, 152);-
253 DSA_SIG_free(s);-
254 return
executed 307 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 307 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
307
255}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2