Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_verify.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature, | - | ||||||||||||
10 | char *data, EVP_PKEY *pkey) | - | ||||||||||||
11 | { | - | ||||||||||||
12 | EVP_MD_CTX *ctx = EVP_MD_CTX_new(); | - | ||||||||||||
13 | const EVP_MD *type; | - | ||||||||||||
14 | unsigned char *p, *buf_in = | - | ||||||||||||
15 | ((void *)0) | - | ||||||||||||
16 | ; | - | ||||||||||||
17 | int ret = -1, i, inl; | - | ||||||||||||
18 | - | |||||||||||||
19 | if (ctx ==
| 0 | ||||||||||||
20 | ((void *)0)
| 0 | ||||||||||||
21 | ) { | - | ||||||||||||
22 | ERR_put_error(13,(137),((1|64)),__FILE__,35); | - | ||||||||||||
23 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
24 | } | - | ||||||||||||
25 | i = OBJ_obj2nid(a->algorithm); | - | ||||||||||||
26 | type = EVP_get_digestbyname(OBJ_nid2sn(i)); | - | ||||||||||||
27 | if (type ==
| 0 | ||||||||||||
28 | ((void *)0)
| 0 | ||||||||||||
29 | ) { | - | ||||||||||||
30 | ERR_put_error(13,(137),(161),__FILE__,41); | - | ||||||||||||
31 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
32 | } | - | ||||||||||||
33 | - | |||||||||||||
34 | if (signature->type == 3
| 0 | ||||||||||||
35 | ERR_put_error(13,(137),(220),__FILE__,46); | - | ||||||||||||
36 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
37 | } | - | ||||||||||||
38 | - | |||||||||||||
39 | inl = i2d(data, | - | ||||||||||||
40 | ((void *)0) | - | ||||||||||||
41 | ); | - | ||||||||||||
42 | buf_in = CRYPTO_malloc((unsigned int)inl, __FILE__, 51); | - | ||||||||||||
43 | if (buf_in ==
| 0 | ||||||||||||
44 | ((void *)0)
| 0 | ||||||||||||
45 | ) { | - | ||||||||||||
46 | ERR_put_error(13,(137),((1|64)),__FILE__,53); | - | ||||||||||||
47 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
48 | } | - | ||||||||||||
49 | p = buf_in; | - | ||||||||||||
50 | - | |||||||||||||
51 | i2d(data, &p); | - | ||||||||||||
52 | ret = EVP_DigestInit_ex(ctx,type,
| 0 | ||||||||||||
53 | ((void *)0)
| 0 | ||||||||||||
54 | )
| 0 | ||||||||||||
55 | && EVP_DigestUpdate(ctx,(unsigned char *)buf_in,inl)
| 0 | ||||||||||||
56 | - | |||||||||||||
57 | CRYPTO_clear_free(buf_in, (unsigned int)inl, __FILE__, 62); | - | ||||||||||||
58 | - | |||||||||||||
59 | if (!ret
| 0 | ||||||||||||
60 | ERR_put_error(13,(137),(6),__FILE__,65); | - | ||||||||||||
61 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
62 | } | - | ||||||||||||
63 | ret = -1; | - | ||||||||||||
64 | - | |||||||||||||
65 | if (EVP_VerifyFinal(ctx, (unsigned char *)signature->data,
| 0 | ||||||||||||
66 | (unsigned int)signature->length, pkey) <= 0
| 0 | ||||||||||||
67 | ERR_put_error(13,(137),(6),__FILE__,72); | - | ||||||||||||
68 | ret = 0; | - | ||||||||||||
69 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
70 | } | - | ||||||||||||
71 | ret = 1; | - | ||||||||||||
72 | err: code before this statement never executed: err: | 0 | ||||||||||||
73 | EVP_MD_CTX_free(ctx); | - | ||||||||||||
74 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||
75 | } | - | ||||||||||||
76 | - | |||||||||||||
77 | - | |||||||||||||
78 | - | |||||||||||||
79 | int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, | - | ||||||||||||
80 | ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey) | - | ||||||||||||
81 | { | - | ||||||||||||
82 | EVP_MD_CTX *ctx = | - | ||||||||||||
83 | ((void *)0) | - | ||||||||||||
84 | ; | - | ||||||||||||
85 | unsigned char *buf_in = | - | ||||||||||||
86 | ((void *)0) | - | ||||||||||||
87 | ; | - | ||||||||||||
88 | int ret = -1, inl = 0; | - | ||||||||||||
89 | - | |||||||||||||
90 | int mdnid, pknid; | - | ||||||||||||
91 | - | |||||||||||||
92 | if (!pkey
| 0-1370 | ||||||||||||
93 | ERR_put_error(13,(197),((3|64)),__FILE__,94); | - | ||||||||||||
94 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
95 | } | - | ||||||||||||
96 | - | |||||||||||||
97 | if (signature->type == 3
| 0-1370 | ||||||||||||
98 | ERR_put_error(13,(197),(220),__FILE__,99); | - | ||||||||||||
99 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
100 | } | - | ||||||||||||
101 | - | |||||||||||||
102 | ctx = EVP_MD_CTX_new(); | - | ||||||||||||
103 | if (ctx ==
| 0-1370 | ||||||||||||
104 | ((void *)0)
| 0-1370 | ||||||||||||
105 | ) { | - | ||||||||||||
106 | ERR_put_error(13,(197),((1|64)),__FILE__,105); | - | ||||||||||||
107 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
108 | } | - | ||||||||||||
109 | - | |||||||||||||
110 | - | |||||||||||||
111 | if (!OBJ_find_sigid_algs(OBJ_obj2nid(a->algorithm), &mdnid, &pknid)
| 0-1370 | ||||||||||||
112 | ERR_put_error(13,(197),(199),__FILE__,111); | - | ||||||||||||
113 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
114 | } | - | ||||||||||||
115 | if (mdnid == 0
| 4-1366 | ||||||||||||
116 | if (!pkey->ameth
| 0-4 | ||||||||||||
117 | ERR_put_error(13,(197),(199),__FILE__,117) | - | ||||||||||||
118 | ; | - | ||||||||||||
119 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
120 | } | - | ||||||||||||
121 | ret = pkey->ameth->item_verify(ctx, it, asn, a, signature, pkey); | - | ||||||||||||
122 | - | |||||||||||||
123 | - | |||||||||||||
124 | - | |||||||||||||
125 | - | |||||||||||||
126 | - | |||||||||||||
127 | if (ret != 2
| 0-4 | ||||||||||||
128 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
129 | ret = -1; | - | ||||||||||||
130 | } executed 4 times by 1 test: else {end of block Executed by:
| 4 | ||||||||||||
131 | const EVP_MD *type; | - | ||||||||||||
132 | type = EVP_get_digestbyname(OBJ_nid2sn(mdnid)); | - | ||||||||||||
133 | if (type ==
| 0-1366 | ||||||||||||
134 | ((void *)0)
| 0-1366 | ||||||||||||
135 | ) { | - | ||||||||||||
136 | ERR_put_error(13,(197),(161),__FILE__,134) | - | ||||||||||||
137 | ; | - | ||||||||||||
138 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
139 | } | - | ||||||||||||
140 | - | |||||||||||||
141 | - | |||||||||||||
142 | if (EVP_PKEY_type(pknid) != pkey->ameth->pkey_id
| 0-1366 | ||||||||||||
143 | ERR_put_error(13,(197),(200),__FILE__,140); | - | ||||||||||||
144 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
145 | } | - | ||||||||||||
146 | - | |||||||||||||
147 | if (!EVP_DigestVerifyInit(ctx,
| 0-1366 | ||||||||||||
148 | ((void *)0)
| 0-1366 | ||||||||||||
149 | , type,
| 0-1366 | ||||||||||||
150 | ((void *)0)
| 0-1366 | ||||||||||||
151 | , pkey)
| 0-1366 | ||||||||||||
152 | ERR_put_error(13,(197),(6),__FILE__,145); | - | ||||||||||||
153 | ret = 0; | - | ||||||||||||
154 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
155 | } | - | ||||||||||||
156 | - | |||||||||||||
157 | } executed 1366 times by 1 test: end of block Executed by:
| 1366 | ||||||||||||
158 | - | |||||||||||||
159 | inl = ASN1_item_i2d(asn, &buf_in, it); | - | ||||||||||||
160 | - | |||||||||||||
161 | if (buf_in ==
| 0-1370 | ||||||||||||
162 | ((void *)0)
| 0-1370 | ||||||||||||
163 | ) { | - | ||||||||||||
164 | ERR_put_error(13,(197),((1|64)),__FILE__,155); | - | ||||||||||||
165 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
166 | } | - | ||||||||||||
167 | - | |||||||||||||
168 | ret = EVP_DigestVerify(ctx, signature->data, (size_t)signature->length, | - | ||||||||||||
169 | buf_in, inl); | - | ||||||||||||
170 | if (ret <= 0
| 25-1345 | ||||||||||||
171 | ERR_put_error(13,(197),(6),__FILE__,162); | - | ||||||||||||
172 | goto executed 25 times by 1 test: err;goto err; Executed by:
executed 25 times by 1 test: goto err; Executed by:
| 25 | ||||||||||||
173 | } | - | ||||||||||||
174 | ret = 1; | - | ||||||||||||
175 | err: code before this statement executed 1345 times by 1 test: err: Executed by:
| 1345 | ||||||||||||
176 | CRYPTO_clear_free(buf_in, (unsigned int)inl, __FILE__, 167); | - | ||||||||||||
177 | EVP_MD_CTX_free(ctx); | - | ||||||||||||
178 | return executed 1370 times by 1 test: ret;return ret; Executed by:
executed 1370 times by 1 test: return ret; Executed by:
| 1370 | ||||||||||||
179 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |