Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ts/ts_req_utils.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||
2 | * Copyright 2006-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/objects.h> | - | ||||||
13 | #include <openssl/x509v3.h> | - | ||||||
14 | #include <openssl/ts.h> | - | ||||||
15 | #include "ts_lcl.h" | - | ||||||
16 | - | |||||||
17 | int TS_REQ_set_version(TS_REQ *a, long version) | - | ||||||
18 | { | - | ||||||
19 | return ASN1_INTEGER_set(a->version, version); never executed: return ASN1_INTEGER_set(a->version, version); | 0 | ||||||
20 | } | - | ||||||
21 | - | |||||||
22 | long TS_REQ_get_version(const TS_REQ *a) | - | ||||||
23 | { | - | ||||||
24 | return ASN1_INTEGER_get(a->version); executed 446 times by 1 test: return ASN1_INTEGER_get(a->version); Executed by:
| 446 | ||||||
25 | } | - | ||||||
26 | - | |||||||
27 | int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint) | - | ||||||
28 | { | - | ||||||
29 | TS_MSG_IMPRINT *new_msg_imprint; | - | ||||||
30 | - | |||||||
31 | if (a->msg_imprint == msg_imprint)
| 0 | ||||||
32 | return 1; never executed: return 1; | 0 | ||||||
33 | new_msg_imprint = TS_MSG_IMPRINT_dup(msg_imprint); | - | ||||||
34 | if (new_msg_imprint == NULL) {
| 0 | ||||||
35 | TSerr(TS_F_TS_REQ_SET_MSG_IMPRINT, ERR_R_MALLOC_FAILURE); | - | ||||||
36 | return 0; never executed: return 0; | 0 | ||||||
37 | } | - | ||||||
38 | TS_MSG_IMPRINT_free(a->msg_imprint); | - | ||||||
39 | a->msg_imprint = new_msg_imprint; | - | ||||||
40 | return 1; never executed: return 1; | 0 | ||||||
41 | } | - | ||||||
42 | - | |||||||
43 | TS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a) | - | ||||||
44 | { | - | ||||||
45 | return a->msg_imprint; never executed: return a->msg_imprint; | 0 | ||||||
46 | } | - | ||||||
47 | - | |||||||
48 | int TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg) | - | ||||||
49 | { | - | ||||||
50 | X509_ALGOR *new_alg; | - | ||||||
51 | - | |||||||
52 | if (a->hash_algo == alg)
| 0 | ||||||
53 | return 1; never executed: return 1; | 0 | ||||||
54 | new_alg = X509_ALGOR_dup(alg); | - | ||||||
55 | if (new_alg == NULL) {
| 0 | ||||||
56 | TSerr(TS_F_TS_MSG_IMPRINT_SET_ALGO, ERR_R_MALLOC_FAILURE); | - | ||||||
57 | return 0; never executed: return 0; | 0 | ||||||
58 | } | - | ||||||
59 | X509_ALGOR_free(a->hash_algo); | - | ||||||
60 | a->hash_algo = new_alg; | - | ||||||
61 | return 1; never executed: return 1; | 0 | ||||||
62 | } | - | ||||||
63 | - | |||||||
64 | X509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a) | - | ||||||
65 | { | - | ||||||
66 | return a->hash_algo; never executed: return a->hash_algo; | 0 | ||||||
67 | } | - | ||||||
68 | - | |||||||
69 | int TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len) | - | ||||||
70 | { | - | ||||||
71 | return ASN1_OCTET_STRING_set(a->hashed_msg, d, len); never executed: return ASN1_OCTET_STRING_set(a->hashed_msg, d, len); | 0 | ||||||
72 | } | - | ||||||
73 | - | |||||||
74 | ASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a) | - | ||||||
75 | { | - | ||||||
76 | return a->hashed_msg; never executed: return a->hashed_msg; | 0 | ||||||
77 | } | - | ||||||
78 | - | |||||||
79 | int TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy) | - | ||||||
80 | { | - | ||||||
81 | ASN1_OBJECT *new_policy; | - | ||||||
82 | - | |||||||
83 | if (a->policy_id == policy)
| 0 | ||||||
84 | return 1; never executed: return 1; | 0 | ||||||
85 | new_policy = OBJ_dup(policy); | - | ||||||
86 | if (new_policy == NULL) {
| 0 | ||||||
87 | TSerr(TS_F_TS_REQ_SET_POLICY_ID, ERR_R_MALLOC_FAILURE); | - | ||||||
88 | return 0; never executed: return 0; | 0 | ||||||
89 | } | - | ||||||
90 | ASN1_OBJECT_free(a->policy_id); | - | ||||||
91 | a->policy_id = new_policy; | - | ||||||
92 | return 1; never executed: return 1; | 0 | ||||||
93 | } | - | ||||||
94 | - | |||||||
95 | ASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a) | - | ||||||
96 | { | - | ||||||
97 | return a->policy_id; executed 446 times by 1 test: return a->policy_id; Executed by:
| 446 | ||||||
98 | } | - | ||||||
99 | - | |||||||
100 | int TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce) | - | ||||||
101 | { | - | ||||||
102 | ASN1_INTEGER *new_nonce; | - | ||||||
103 | - | |||||||
104 | if (a->nonce == nonce)
| 0 | ||||||
105 | return 1; never executed: return 1; | 0 | ||||||
106 | new_nonce = ASN1_INTEGER_dup(nonce); | - | ||||||
107 | if (new_nonce == NULL) {
| 0 | ||||||
108 | TSerr(TS_F_TS_REQ_SET_NONCE, ERR_R_MALLOC_FAILURE); | - | ||||||
109 | return 0; never executed: return 0; | 0 | ||||||
110 | } | - | ||||||
111 | ASN1_INTEGER_free(a->nonce); | - | ||||||
112 | a->nonce = new_nonce; | - | ||||||
113 | return 1; never executed: return 1; | 0 | ||||||
114 | } | - | ||||||
115 | - | |||||||
116 | const ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a) | - | ||||||
117 | { | - | ||||||
118 | return a->nonce; never executed: return a->nonce; | 0 | ||||||
119 | } | - | ||||||
120 | - | |||||||
121 | int TS_REQ_set_cert_req(TS_REQ *a, int cert_req) | - | ||||||
122 | { | - | ||||||
123 | a->cert_req = cert_req ? 0xFF : 0x00;
| 0 | ||||||
124 | return 1; never executed: return 1; | 0 | ||||||
125 | } | - | ||||||
126 | - | |||||||
127 | int TS_REQ_get_cert_req(const TS_REQ *a) | - | ||||||
128 | { | - | ||||||
129 | return a->cert_req ? 1 : 0; never executed: return a->cert_req ? 1 : 0;
| 0 | ||||||
130 | } | - | ||||||
131 | - | |||||||
132 | STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a) | - | ||||||
133 | { | - | ||||||
134 | return a->extensions; never executed: return a->extensions; | 0 | ||||||
135 | } | - | ||||||
136 | - | |||||||
137 | void TS_REQ_ext_free(TS_REQ *a) | - | ||||||
138 | { | - | ||||||
139 | if (!a)
| 0 | ||||||
140 | return; never executed: return; | 0 | ||||||
141 | sk_X509_EXTENSION_pop_free(a->extensions, X509_EXTENSION_free); | - | ||||||
142 | a->extensions = NULL; | - | ||||||
143 | } never executed: end of block | 0 | ||||||
144 | - | |||||||
145 | int TS_REQ_get_ext_count(TS_REQ *a) | - | ||||||
146 | { | - | ||||||
147 | return X509v3_get_ext_count(a->extensions); never executed: return X509v3_get_ext_count(a->extensions); | 0 | ||||||
148 | } | - | ||||||
149 | - | |||||||
150 | int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos) | - | ||||||
151 | { | - | ||||||
152 | return X509v3_get_ext_by_NID(a->extensions, nid, lastpos); never executed: return X509v3_get_ext_by_NID(a->extensions, nid, lastpos); | 0 | ||||||
153 | } | - | ||||||
154 | - | |||||||
155 | int TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos) | - | ||||||
156 | { | - | ||||||
157 | return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos); never executed: return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos); | 0 | ||||||
158 | } | - | ||||||
159 | - | |||||||
160 | int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos) | - | ||||||
161 | { | - | ||||||
162 | return X509v3_get_ext_by_critical(a->extensions, crit, lastpos); never executed: return X509v3_get_ext_by_critical(a->extensions, crit, lastpos); | 0 | ||||||
163 | } | - | ||||||
164 | - | |||||||
165 | X509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc) | - | ||||||
166 | { | - | ||||||
167 | return X509v3_get_ext(a->extensions, loc); never executed: return X509v3_get_ext(a->extensions, loc); | 0 | ||||||
168 | } | - | ||||||
169 | - | |||||||
170 | X509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc) | - | ||||||
171 | { | - | ||||||
172 | return X509v3_delete_ext(a->extensions, loc); never executed: return X509v3_delete_ext(a->extensions, loc); | 0 | ||||||
173 | } | - | ||||||
174 | - | |||||||
175 | int TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc) | - | ||||||
176 | { | - | ||||||
177 | return X509v3_add_ext(&a->extensions, ex, loc) != NULL; never executed: return X509v3_add_ext(&a->extensions, ex, loc) != ((void *)0) ; | 0 | ||||||
178 | } | - | ||||||
179 | - | |||||||
180 | void *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx) | - | ||||||
181 | { | - | ||||||
182 | return X509V3_get_d2i(a->extensions, nid, crit, idx); never executed: return X509V3_get_d2i(a->extensions, nid, crit, idx); | 0 | ||||||
183 | } | - | ||||||
Source code | Switch to Preprocessed file |