Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/a_sign.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | int | - | ||||||||||||||||||
7 | ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, | - | ||||||||||||||||||
8 | ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey, const EVP_MD *type) | - | ||||||||||||||||||
9 | { | - | ||||||||||||||||||
10 | EVP_MD_CTX ctx; | - | ||||||||||||||||||
11 | EVP_MD_CTX_init(&ctx); | - | ||||||||||||||||||
12 | if (!EVP_DigestSignInit(&ctx,
| 0 | ||||||||||||||||||
13 | ((void *)0)
| 0 | ||||||||||||||||||
14 | , type,
| 0 | ||||||||||||||||||
15 | ((void *)0)
| 0 | ||||||||||||||||||
16 | , pkey)
| 0 | ||||||||||||||||||
17 | EVP_MD_CTX_cleanup(&ctx); | - | ||||||||||||||||||
18 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
19 | } | - | ||||||||||||||||||
20 | return never executed: ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, &ctx);return ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, &ctx); never executed: return ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, &ctx); | 0 | ||||||||||||||||||
21 | } | - | ||||||||||||||||||
22 | - | |||||||||||||||||||
23 | - | |||||||||||||||||||
24 | int | - | ||||||||||||||||||
25 | ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, | - | ||||||||||||||||||
26 | ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx) | - | ||||||||||||||||||
27 | { | - | ||||||||||||||||||
28 | const EVP_MD *type; | - | ||||||||||||||||||
29 | EVP_PKEY *pkey; | - | ||||||||||||||||||
30 | unsigned char *buf_in = | - | ||||||||||||||||||
31 | ((void *)0) | - | ||||||||||||||||||
32 | , *buf_out = | - | ||||||||||||||||||
33 | ((void *)0) | - | ||||||||||||||||||
34 | ; | - | ||||||||||||||||||
35 | size_t inl = 0, outl = 0, outll = 0; | - | ||||||||||||||||||
36 | int signid, paramtype; | - | ||||||||||||||||||
37 | int rv; | - | ||||||||||||||||||
38 | - | |||||||||||||||||||
39 | type = EVP_MD_CTX_md(ctx); | - | ||||||||||||||||||
40 | pkey = EVP_PKEY_CTX_get0_pkey(ctx->pctx); | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | if (!type
| 0-2 | ||||||||||||||||||
43 | ERR_put_error(13,(0xfff),(217),__FILE__,156); | - | ||||||||||||||||||
44 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
45 | } | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | if (pkey->ameth->item_sign
| 1 | ||||||||||||||||||
48 | rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2, | - | ||||||||||||||||||
49 | signature); | - | ||||||||||||||||||
50 | if (rv == 1
| 0-1 | ||||||||||||||||||
51 | outl = signature->length; never executed: outl = signature->length; | 0 | ||||||||||||||||||
52 | - | |||||||||||||||||||
53 | - | |||||||||||||||||||
54 | - | |||||||||||||||||||
55 | - | |||||||||||||||||||
56 | - | |||||||||||||||||||
57 | - | |||||||||||||||||||
58 | if (rv <= 0
| 0-1 | ||||||||||||||||||
59 | ERR_put_error(13,(0xfff),(6),__FILE__,172); never executed: ERR_put_error(13,(0xfff),(6),__FILE__,172); | 0 | ||||||||||||||||||
60 | if (rv <= 1
| 0-1 | ||||||||||||||||||
61 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
62 | } executed 1 time by 1 test: elseend of block Executed by:
| 1 | ||||||||||||||||||
63 | rv = 2; executed 1 time by 1 test: rv = 2; Executed by:
| 1 | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | if (rv == 2
| 0-2 | ||||||||||||||||||
66 | if (type->flags & 0x0004
| 0-2 | ||||||||||||||||||
67 | if (!pkey->ameth
| 0-2 | ||||||||||||||||||
68 | !OBJ_find_sigid_by_algs(&signid,
| 0-2 | ||||||||||||||||||
69 | EVP_MD_type(type), pkey->ameth->pkey_id)
| 0-2 | ||||||||||||||||||
70 | ERR_put_error(13,(0xfff),(198),__FILE__,183); | - | ||||||||||||||||||
71 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
72 | } | - | ||||||||||||||||||
73 | } executed 2 times by 1 test: elseend of block Executed by:
| 2 | ||||||||||||||||||
74 | signid = type->pkey_type; never executed: signid = type->pkey_type; | 0 | ||||||||||||||||||
75 | - | |||||||||||||||||||
76 | if (pkey->ameth->pkey_flags & 0x4
| 1 | ||||||||||||||||||
77 | paramtype = 5; executed 1 time by 1 test: paramtype = 5; Executed by:
| 1 | ||||||||||||||||||
78 | else | - | ||||||||||||||||||
79 | paramtype = -1; executed 1 time by 1 test: paramtype = -1; Executed by:
| 1 | ||||||||||||||||||
80 | - | |||||||||||||||||||
81 | if (algor1
| 0-2 | ||||||||||||||||||
82 | X509_ALGOR_set0(algor1, executed 2 times by 1 test: X509_ALGOR_set0(algor1, OBJ_nid2obj(signid), paramtype, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
83 | OBJ_nid2obj(signid), paramtype, executed 2 times by 1 test: X509_ALGOR_set0(algor1, OBJ_nid2obj(signid), paramtype, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
84 | ((void *)0) executed 2 times by 1 test: X509_ALGOR_set0(algor1, OBJ_nid2obj(signid), paramtype, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
85 | ); executed 2 times by 1 test: X509_ALGOR_set0(algor1, OBJ_nid2obj(signid), paramtype, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
86 | if (algor2
| 0-2 | ||||||||||||||||||
87 | X509_ALGOR_set0(algor2, executed 2 times by 1 test: X509_ALGOR_set0(algor2, OBJ_nid2obj(signid), paramtype, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
88 | OBJ_nid2obj(signid), paramtype, executed 2 times by 1 test: X509_ALGOR_set0(algor2, OBJ_nid2obj(signid), paramtype, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
89 | ((void *)0) executed 2 times by 1 test: X509_ALGOR_set0(algor2, OBJ_nid2obj(signid), paramtype, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
90 | ); executed 2 times by 1 test: X509_ALGOR_set0(algor2, OBJ_nid2obj(signid), paramtype, ((void *)0) ); Executed by:
| 2 | ||||||||||||||||||
91 | - | |||||||||||||||||||
92 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
93 | - | |||||||||||||||||||
94 | inl = ASN1_item_i2d(asn, &buf_in, it); | - | ||||||||||||||||||
95 | outll = outl = EVP_PKEY_size(pkey); | - | ||||||||||||||||||
96 | buf_out = malloc(outl); | - | ||||||||||||||||||
97 | if ((
| 0-2 | ||||||||||||||||||
98 | ((void *)0)
| 0-2 | ||||||||||||||||||
99 | )
| 0-2 | ||||||||||||||||||
100 | ((void *)0)
| 0-2 | ||||||||||||||||||
101 | )
| 0-2 | ||||||||||||||||||
102 | outl = 0; | - | ||||||||||||||||||
103 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,208); | - | ||||||||||||||||||
104 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
105 | } | - | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | if (!EVP_DigestUpdate(ctx,buf_in,inl)
| 0-2 | ||||||||||||||||||
108 | !EVP_DigestSignFinal(ctx, buf_out, &outl)
| 0-2 | ||||||||||||||||||
109 | outl = 0; | - | ||||||||||||||||||
110 | ERR_put_error(13,(0xfff),(6),__FILE__,215); | - | ||||||||||||||||||
111 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||
112 | } | - | ||||||||||||||||||
113 | free(signature->data); | - | ||||||||||||||||||
114 | signature->data = buf_out; | - | ||||||||||||||||||
115 | buf_out = | - | ||||||||||||||||||
116 | ((void *)0) | - | ||||||||||||||||||
117 | ; | - | ||||||||||||||||||
118 | signature->length = outl; | - | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | - | |||||||||||||||||||
121 | - | |||||||||||||||||||
122 | signature->flags &= ~(0x08|0x07); | - | ||||||||||||||||||
123 | signature->flags |= 0x08; | - | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | err: code before this statement executed 2 times by 1 test: err: Executed by:
| 2 | ||||||||||||||||||
126 | EVP_MD_CTX_cleanup(ctx); | - | ||||||||||||||||||
127 | freezero((char *)buf_in, inl); | - | ||||||||||||||||||
128 | freezero((char *)buf_out, outll); | - | ||||||||||||||||||
129 | return executed 2 times by 1 test: (outl);return (outl); Executed by:
executed 2 times by 1 test: return (outl); Executed by:
| 2 | ||||||||||||||||||
130 | } | - | ||||||||||||||||||
Switch to Source code | Preprocessed file |