Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ct/ct_vfy.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | typedef enum sct_signature_type_t { | - | ||||||||||||
7 | SIGNATURE_TYPE_NOT_SET = -1, | - | ||||||||||||
8 | SIGNATURE_TYPE_CERT_TIMESTAMP, | - | ||||||||||||
9 | SIGNATURE_TYPE_TREE_HASH | - | ||||||||||||
10 | } SCT_SIGNATURE_TYPE; | - | ||||||||||||
11 | - | |||||||||||||
12 | - | |||||||||||||
13 | - | |||||||||||||
14 | - | |||||||||||||
15 | - | |||||||||||||
16 | static int sct_ctx_update(EVP_MD_CTX *ctx, const SCT_CTX *sctx, const SCT *sct) | - | ||||||||||||
17 | { | - | ||||||||||||
18 | unsigned char tmpbuf[12]; | - | ||||||||||||
19 | unsigned char *p, *der; | - | ||||||||||||
20 | size_t derlen; | - | ||||||||||||
21 | if (sct->entry_type == CT_LOG_ENTRY_TYPE_NOT_SET
| 0-8 | ||||||||||||
22 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
23 | if (sct->entry_type == CT_LOG_ENTRY_TYPE_PRECERT
| 0-8 | ||||||||||||
24 | ((void *)0)
| 0-8 | ||||||||||||
25 | ) | - | ||||||||||||
26 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
27 | - | |||||||||||||
28 | p = tmpbuf; | - | ||||||||||||
29 | *p++ = sct->version; | - | ||||||||||||
30 | *p++ = SIGNATURE_TYPE_CERT_TIMESTAMP; | - | ||||||||||||
31 | (*((p)++)=(unsigned char)(((sct->timestamp)>>56)&0xff), *((p)++)=(unsigned char)(((sct->timestamp)>>48)&0xff), *((p)++)=(unsigned char)(((sct->timestamp)>>40)&0xff), *((p)++)=(unsigned char)(((sct->timestamp)>>32)&0xff), *((p)++)=(unsigned char)(((sct->timestamp)>>24)&0xff), *((p)++)=(unsigned char)(((sct->timestamp)>>16)&0xff), *((p)++)=(unsigned char)(((sct->timestamp)>> 8)&0xff), *((p)++)=(unsigned char)(((sct->timestamp) )&0xff)); | - | ||||||||||||
32 | ((p[0]=(unsigned char)(((sct->entry_type)>> 8)&0xff), p[1]=(unsigned char)(((sct->entry_type) )&0xff)),p+=2); | - | ||||||||||||
33 | - | |||||||||||||
34 | if (!EVP_DigestUpdate(ctx, tmpbuf, p - tmpbuf)
| 0-8 | ||||||||||||
35 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
36 | - | |||||||||||||
37 | if (sct->entry_type == CT_LOG_ENTRY_TYPE_X509
| 0-8 | ||||||||||||
38 | der = sctx->certder; | - | ||||||||||||
39 | derlen = sctx->certderlen; | - | ||||||||||||
40 | } never executed: else {end of block | 0 | ||||||||||||
41 | if (!EVP_DigestUpdate(ctx, sctx->ihash, sctx->ihashlen)
| 0-8 | ||||||||||||
42 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
43 | der = sctx->preder; | - | ||||||||||||
44 | derlen = sctx->prederlen; | - | ||||||||||||
45 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
46 | - | |||||||||||||
47 | - | |||||||||||||
48 | if (der ==
| 0-8 | ||||||||||||
49 | ((void *)0)
| 0-8 | ||||||||||||
50 | ) | - | ||||||||||||
51 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
52 | - | |||||||||||||
53 | - | |||||||||||||
54 | p = tmpbuf; | - | ||||||||||||
55 | ((p[0]=(unsigned char)(((derlen)>>16)&0xff), p[1]=(unsigned char)(((derlen)>> 8)&0xff), p[2]=(unsigned char)(((derlen) )&0xff)),p+=3); | - | ||||||||||||
56 | - | |||||||||||||
57 | if (!EVP_DigestUpdate(ctx, tmpbuf, 3)
| 0-8 | ||||||||||||
58 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
59 | if (!EVP_DigestUpdate(ctx, der, derlen)
| 0-8 | ||||||||||||
60 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
61 | - | |||||||||||||
62 | - | |||||||||||||
63 | p = tmpbuf; | - | ||||||||||||
64 | ((p[0]=(unsigned char)(((sct->ext_len)>> 8)&0xff), p[1]=(unsigned char)(((sct->ext_len) )&0xff)),p+=2); | - | ||||||||||||
65 | if (!EVP_DigestUpdate(ctx, tmpbuf, 2)
| 0-8 | ||||||||||||
66 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
67 | - | |||||||||||||
68 | if (sct->ext_len
| 0-8 | ||||||||||||
69 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
70 | - | |||||||||||||
71 | return executed 8 times by 1 test: 1;return 1; Executed by:
executed 8 times by 1 test: return 1; Executed by:
| 8 | ||||||||||||
72 | } | - | ||||||||||||
73 | - | |||||||||||||
74 | int SCT_CTX_verify(const SCT_CTX *sctx, const SCT *sct) | - | ||||||||||||
75 | { | - | ||||||||||||
76 | EVP_MD_CTX *ctx = | - | ||||||||||||
77 | ((void *)0) | - | ||||||||||||
78 | ; | - | ||||||||||||
79 | int ret = 0; | - | ||||||||||||
80 | - | |||||||||||||
81 | if (!SCT_is_complete(sct)
| 0-9 | ||||||||||||
82 | ((void *)0)
| 0-9 | ||||||||||||
83 | || | - | ||||||||||||
84 | sct->entry_type == CT_LOG_ENTRY_TYPE_NOT_SET
| 0-9 | ||||||||||||
85 | (sct->entry_type == CT_LOG_ENTRY_TYPE_PRECERT
| 0-9 | ||||||||||||
86 | ((void *)0)
| 0-9 | ||||||||||||
87 | )) { | - | ||||||||||||
88 | ERR_put_error(50,(128),(106),__FILE__,104); | - | ||||||||||||
89 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
90 | } | - | ||||||||||||
91 | if (sct->version != SCT_VERSION_V1
| 0-9 | ||||||||||||
92 | ERR_put_error(50,(128),(115),__FILE__,108); | - | ||||||||||||
93 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
94 | } | - | ||||||||||||
95 | if (sct->log_id_len != sctx->pkeyhashlen
| 0-9 | ||||||||||||
96 | memcmp(sct->log_id, sctx->pkeyhash, sctx->pkeyhashlen) != 0
| 0-9 | ||||||||||||
97 | ERR_put_error(50,(128),(114),__FILE__,113); | - | ||||||||||||
98 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
99 | } | - | ||||||||||||
100 | if (sct->timestamp > sctx->epoch_time_in_ms
| 1-8 | ||||||||||||
101 | ERR_put_error(50,(128),(116),__FILE__,117); | - | ||||||||||||
102 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||
103 | } | - | ||||||||||||
104 | - | |||||||||||||
105 | ctx = EVP_MD_CTX_new(); | - | ||||||||||||
106 | if (ctx ==
| 0-8 | ||||||||||||
107 | ((void *)0)
| 0-8 | ||||||||||||
108 | ) | - | ||||||||||||
109 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
110 | - | |||||||||||||
111 | if (!EVP_DigestVerifyInit(ctx,
| 0-8 | ||||||||||||
112 | ((void *)0)
| 0-8 | ||||||||||||
113 | , EVP_sha256(),
| 0-8 | ||||||||||||
114 | ((void *)0)
| 0-8 | ||||||||||||
115 | , sctx->pkey)
| 0-8 | ||||||||||||
116 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
117 | - | |||||||||||||
118 | if (!sct_ctx_update(ctx, sctx, sct)
| 0-8 | ||||||||||||
119 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
120 | - | |||||||||||||
121 | - | |||||||||||||
122 | ret = EVP_DigestVerifyFinal(ctx, sct->sig, sct->sig_len); | - | ||||||||||||
123 | - | |||||||||||||
124 | if (ret == 0
| 0-8 | ||||||||||||
125 | ERR_put_error(50,(128),(107),__FILE__,135); never executed: ERR_put_error(50,(128),(107),__FILE__,135); | 0 | ||||||||||||
126 | - | |||||||||||||
127 | end: code before this statement executed 8 times by 1 test: end: Executed by:
| 8 | ||||||||||||
128 | EVP_MD_CTX_free(ctx); | - | ||||||||||||
129 | return executed 8 times by 1 test: ret;return ret; Executed by:
executed 8 times by 1 test: return ret; Executed by:
| 8 | ||||||||||||
130 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |