| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509/x509_set.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | int X509_set_version(X509 *x, long version) | - | ||||||||||||
| 3 | { | - | ||||||||||||
| 4 | if (x ==
| 0-518 | ||||||||||||
| 5 | ((void *)0)
| 0-518 | ||||||||||||
| 6 | ) | - | ||||||||||||
| 7 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 8 | if (version == 0
| 0-518 | ||||||||||||
| 9 | ASN1_INTEGER_free(x->cert_info.version); | - | ||||||||||||
| 10 | x->cert_info.version = | - | ||||||||||||
| 11 | ((void *)0) | - | ||||||||||||
| 12 | ; | - | ||||||||||||
| 13 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||
| 14 | } | - | ||||||||||||
| 15 | if (x->cert_info.version ==
| 0-518 | ||||||||||||
| 16 | ((void *)0)
| 0-518 | ||||||||||||
| 17 | ) { | - | ||||||||||||
| 18 | if ((
| 0-518 | ||||||||||||
| 19 | ((void *)0)
| 0-518 | ||||||||||||
| 20 | ) | - | ||||||||||||
| 21 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 22 | } executed 518 times by 1 test: end of blockExecuted by:
| 518 | ||||||||||||
| 23 | return executed 518 times by 1 test: ASN1_INTEGER_set(x->cert_info.version, version);return ASN1_INTEGER_set(x->cert_info.version, version);Executed by:
executed 518 times by 1 test: return ASN1_INTEGER_set(x->cert_info.version, version);Executed by:
| 518 | ||||||||||||
| 24 | } | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) | - | ||||||||||||
| 27 | { | - | ||||||||||||
| 28 | ASN1_INTEGER *in; | - | ||||||||||||
| 29 | - | |||||||||||||
| 30 | if (x ==
| 0-11 | ||||||||||||
| 31 | ((void *)0)
| 0-11 | ||||||||||||
| 32 | ) | - | ||||||||||||
| 33 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 34 | in = &x->cert_info.serialNumber; | - | ||||||||||||
| 35 | if (in != serial
| 0-11 | ||||||||||||
| 36 | return executed 11 times by 1 test: ASN1_STRING_copy(in, serial);return ASN1_STRING_copy(in, serial);Executed by:
executed 11 times by 1 test: return ASN1_STRING_copy(in, serial);Executed by:
| 11 | ||||||||||||
| 37 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||
| 38 | } | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | int X509_set_issuer_name(X509 *x, X509_NAME *name) | - | ||||||||||||
| 41 | { | - | ||||||||||||
| 42 | if (x ==
| 0-15 | ||||||||||||
| 43 | ((void *)0)
| 0-15 | ||||||||||||
| 44 | ) | - | ||||||||||||
| 45 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 46 | return executed 15 times by 1 test: X509_NAME_set(&x->cert_info.issuer, name);return X509_NAME_set(&x->cert_info.issuer, name);Executed by:
executed 15 times by 1 test: return X509_NAME_set(&x->cert_info.issuer, name);Executed by:
| 15 | ||||||||||||
| 47 | } | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | int X509_set_subject_name(X509 *x, X509_NAME *name) | - | ||||||||||||
| 50 | { | - | ||||||||||||
| 51 | if (x ==
| 0-417 | ||||||||||||
| 52 | ((void *)0)
| 0-417 | ||||||||||||
| 53 | ) | - | ||||||||||||
| 54 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 55 | return executed 417 times by 1 test: X509_NAME_set(&x->cert_info.subject, name);return X509_NAME_set(&x->cert_info.subject, name);Executed by:
executed 417 times by 1 test: return X509_NAME_set(&x->cert_info.subject, name);Executed by:
| 417 | ||||||||||||
| 56 | } | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm) | - | ||||||||||||
| 59 | { | - | ||||||||||||
| 60 | ASN1_TIME *in; | - | ||||||||||||
| 61 | in = *ptm; | - | ||||||||||||
| 62 | if (in != tm
| 0 | ||||||||||||
| 63 | in = ASN1_STRING_dup(tm); | - | ||||||||||||
| 64 | if (in !=
| 0 | ||||||||||||
| 65 | ((void *)0)
| 0 | ||||||||||||
| 66 | ) { | - | ||||||||||||
| 67 | ASN1_TIME_free(*ptm); | - | ||||||||||||
| 68 | *ptm = in; | - | ||||||||||||
| 69 | } never executed: end of block | 0 | ||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||
| 71 | return never executed: (in != return (in != ((void *)0) );never executed: return (in != ((void *)0) ); | 0 | ||||||||||||
| 72 | ((void *)0) never executed: return (in != ((void *)0) ); | 0 | ||||||||||||
| 73 | ); never executed: return (in != ((void *)0) ); | 0 | ||||||||||||
| 74 | } | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm) | - | ||||||||||||
| 77 | { | - | ||||||||||||
| 78 | if (x ==
| 0 | ||||||||||||
| 79 | ((void *)0)
| 0 | ||||||||||||
| 80 | ) | - | ||||||||||||
| 81 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 82 | return never executed: x509_set1_time(&x->cert_info.validity.notBefore, tm);return x509_set1_time(&x->cert_info.validity.notBefore, tm);never executed: return x509_set1_time(&x->cert_info.validity.notBefore, tm); | 0 | ||||||||||||
| 83 | } | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm) | - | ||||||||||||
| 86 | { | - | ||||||||||||
| 87 | if (x ==
| 0 | ||||||||||||
| 88 | ((void *)0)
| 0 | ||||||||||||
| 89 | ) | - | ||||||||||||
| 90 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 91 | return never executed: x509_set1_time(&x->cert_info.validity.notAfter, tm);return x509_set1_time(&x->cert_info.validity.notAfter, tm);never executed: return x509_set1_time(&x->cert_info.validity.notAfter, tm); | 0 | ||||||||||||
| 92 | } | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | int X509_set_pubkey(X509 *x, EVP_PKEY *pkey) | - | ||||||||||||
| 95 | { | - | ||||||||||||
| 96 | if (x ==
| 0-10 | ||||||||||||
| 97 | ((void *)0)
| 0-10 | ||||||||||||
| 98 | ) | - | ||||||||||||
| 99 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 100 | return executed 10 times by 1 test: X509_PUBKEY_set(&(x->cert_info.key), pkey);return X509_PUBKEY_set(&(x->cert_info.key), pkey);Executed by:
executed 10 times by 1 test: return X509_PUBKEY_set(&(x->cert_info.key), pkey);Executed by:
| 10 | ||||||||||||
| 101 | } | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | int X509_up_ref(X509 *x) | - | ||||||||||||
| 104 | { | - | ||||||||||||
| 105 | int i; | - | ||||||||||||
| 106 | - | |||||||||||||
| 107 | if (CRYPTO_UP_REF(&x->references, &i, x->lock) <= 0
| 0-35269 | ||||||||||||
| 108 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 109 | - | |||||||||||||
| 110 | ; | - | ||||||||||||
| 111 | ; | - | ||||||||||||
| 112 | return executed 35269 times by 1 test: ((return ((i > 1) ? 1 : 0);Executed by:
executed 35269 times by 1 test: return ((i > 1) ? 1 : 0);Executed by:
| 0-35269 | ||||||||||||
| 113 | } | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | long X509_get_version(const X509 *x) | - | ||||||||||||
| 116 | { | - | ||||||||||||
| 117 | return executed 13990 times by 1 test: ASN1_INTEGER_get(x->cert_info.version);return ASN1_INTEGER_get(x->cert_info.version);Executed by:
executed 13990 times by 1 test: return ASN1_INTEGER_get(x->cert_info.version);Executed by:
| 13990 | ||||||||||||
| 118 | } | - | ||||||||||||
| 119 | - | |||||||||||||
| 120 | const ASN1_TIME *X509_get0_notBefore(const X509 *x) | - | ||||||||||||
| 121 | { | - | ||||||||||||
| 122 | return executed 5637 times by 1 test: x->cert_info.validity.notBefore;return x->cert_info.validity.notBefore;Executed by:
executed 5637 times by 1 test: return x->cert_info.validity.notBefore;Executed by:
| 5637 | ||||||||||||
| 123 | } | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | const ASN1_TIME *X509_get0_notAfter(const X509 *x) | - | ||||||||||||
| 126 | { | - | ||||||||||||
| 127 | return executed 5399 times by 1 test: x->cert_info.validity.notAfter;return x->cert_info.validity.notAfter;Executed by:
executed 5399 times by 1 test: return x->cert_info.validity.notAfter;Executed by:
| 5399 | ||||||||||||
| 128 | } | - | ||||||||||||
| 129 | - | |||||||||||||
| 130 | ASN1_TIME *X509_getm_notBefore(const X509 *x) | - | ||||||||||||
| 131 | { | - | ||||||||||||
| 132 | return executed 15 times by 1 test: x->cert_info.validity.notBefore;return x->cert_info.validity.notBefore;Executed by:
executed 15 times by 1 test: return x->cert_info.validity.notBefore;Executed by:
| 15 | ||||||||||||
| 133 | } | - | ||||||||||||
| 134 | - | |||||||||||||
| 135 | ASN1_TIME *X509_getm_notAfter(const X509 *x) | - | ||||||||||||
| 136 | { | - | ||||||||||||
| 137 | return executed 15 times by 1 test: x->cert_info.validity.notAfter;return x->cert_info.validity.notAfter;Executed by:
executed 15 times by 1 test: return x->cert_info.validity.notAfter;Executed by:
| 15 | ||||||||||||
| 138 | } | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | int X509_get_signature_type(const X509 *x) | - | ||||||||||||
| 141 | { | - | ||||||||||||
| 142 | return never executed: EVP_PKEY_type(OBJ_obj2nid(x->sig_alg.algorithm));return EVP_PKEY_type(OBJ_obj2nid(x->sig_alg.algorithm));never executed: return EVP_PKEY_type(OBJ_obj2nid(x->sig_alg.algorithm)); | 0 | ||||||||||||
| 143 | } | - | ||||||||||||
| 144 | - | |||||||||||||
| 145 | X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x) | - | ||||||||||||
| 146 | { | - | ||||||||||||
| 147 | return executed 1373 times by 1 test: x->cert_info.key;return x->cert_info.key;Executed by:
executed 1373 times by 1 test: return x->cert_info.key;Executed by:
| 1373 | ||||||||||||
| 148 | } | - | ||||||||||||
| 149 | - | |||||||||||||
| 150 | const struct stack_st_X509_EXTENSION *X509_get0_extensions(const X509 *x) | - | ||||||||||||
| 151 | { | - | ||||||||||||
| 152 | return executed 1348 times by 1 test: x->cert_info.extensions;return x->cert_info.extensions;Executed by:
executed 1348 times by 1 test: return x->cert_info.extensions;Executed by:
| 1348 | ||||||||||||
| 153 | } | - | ||||||||||||
| 154 | - | |||||||||||||
| 155 | void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid, | - | ||||||||||||
| 156 | const ASN1_BIT_STRING **psuid) | - | ||||||||||||
| 157 | { | - | ||||||||||||
| 158 | if (piuid !=
| 0-1346 | ||||||||||||
| 159 | ((void *)0)
| 0-1346 | ||||||||||||
| 160 | ) | - | ||||||||||||
| 161 | * executed 1346 times by 1 test: piuid = x->cert_info.issuerUID;*piuid = x->cert_info.issuerUID;Executed by:
executed 1346 times by 1 test: *piuid = x->cert_info.issuerUID;Executed by:
| 1346 | ||||||||||||
| 162 | if (psuid !=
| 0-1346 | ||||||||||||
| 163 | ((void *)0)
| 0-1346 | ||||||||||||
| 164 | ) | - | ||||||||||||
| 165 | * executed 1346 times by 1 test: psuid = x->cert_info.subjectUID;*psuid = x->cert_info.subjectUID;Executed by:
executed 1346 times by 1 test: *psuid = x->cert_info.subjectUID;Executed by:
| 1346 | ||||||||||||
| 166 | } executed 1346 times by 1 test: end of blockExecuted by:
| 1346 | ||||||||||||
| 167 | - | |||||||||||||
| 168 | const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x) | - | ||||||||||||
| 169 | { | - | ||||||||||||
| 170 | return executed 1489 times by 1 test: &x->cert_info.signature;return &x->cert_info.signature;Executed by:
executed 1489 times by 1 test: return &x->cert_info.signature;Executed by:
| 1489 | ||||||||||||
| 171 | } | - | ||||||||||||
| 172 | - | |||||||||||||
| 173 | int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid, | - | ||||||||||||
| 174 | int *secbits, uint32_t *flags) | - | ||||||||||||
| 175 | { | - | ||||||||||||
| 176 | if (mdnid !=
| 1138-12007 | ||||||||||||
| 177 | ((void *)0)
| 1138-12007 | ||||||||||||
| 178 | ) | - | ||||||||||||
| 179 | * executed 12007 times by 1 test: mdnid = siginf->mdnid;*mdnid = siginf->mdnid;Executed by:
executed 12007 times by 1 test: *mdnid = siginf->mdnid;Executed by:
| 12007 | ||||||||||||
| 180 | if (pknid !=
| 1138-12007 | ||||||||||||
| 181 | ((void *)0)
| 1138-12007 | ||||||||||||
| 182 | ) | - | ||||||||||||
| 183 | * executed 12007 times by 1 test: pknid = siginf->pknid;*pknid = siginf->pknid;Executed by:
executed 12007 times by 1 test: *pknid = siginf->pknid;Executed by:
| 12007 | ||||||||||||
| 184 | if (secbits !=
| 1643-11502 | ||||||||||||
| 185 | ((void *)0)
| 1643-11502 | ||||||||||||
| 186 | ) | - | ||||||||||||
| 187 | * executed 11502 times by 1 test: secbits = siginf->secbits;*secbits = siginf->secbits;Executed by:
executed 11502 times by 1 test: *secbits = siginf->secbits;Executed by:
| 11502 | ||||||||||||
| 188 | if (flags !=
| 0-13145 | ||||||||||||
| 189 | ((void *)0)
| 0-13145 | ||||||||||||
| 190 | ) | - | ||||||||||||
| 191 | * never executed: flags = siginf->flags;*flags = siginf->flags;never executed: *flags = siginf->flags; | 0 | ||||||||||||
| 192 | return executed 13145 times by 1 test: (siginf->flags & 0x1) != 0;return (siginf->flags & 0x1) != 0;Executed by:
executed 13145 times by 1 test: return (siginf->flags & 0x1) != 0;Executed by:
| 13145 | ||||||||||||
| 193 | } | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid, | - | ||||||||||||
| 196 | int secbits, uint32_t flags) | - | ||||||||||||
| 197 | { | - | ||||||||||||
| 198 | siginf->mdnid = mdnid; | - | ||||||||||||
| 199 | siginf->pknid = pknid; | - | ||||||||||||
| 200 | siginf->secbits = secbits; | - | ||||||||||||
| 201 | siginf->flags = flags; | - | ||||||||||||
| 202 | } executed 15 times by 1 test: end of blockExecuted by:
| 15 | ||||||||||||
| 203 | - | |||||||||||||
| 204 | int X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits, | - | ||||||||||||
| 205 | uint32_t *flags) | - | ||||||||||||
| 206 | { | - | ||||||||||||
| 207 | X509_check_purpose(x, -1, -1); | - | ||||||||||||
| 208 | return executed 13145 times by 1 test: X509_SIG_INFO_get(&x->siginf, mdnid, pknid, secbits, flags);return X509_SIG_INFO_get(&x->siginf, mdnid, pknid, secbits, flags);Executed by:
executed 13145 times by 1 test: return X509_SIG_INFO_get(&x->siginf, mdnid, pknid, secbits, flags);Executed by:
| 13145 | ||||||||||||
| 209 | } | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | static void x509_sig_info_init(X509_SIG_INFO *siginf, const X509_ALGOR *alg, | - | ||||||||||||
| 212 | const ASN1_STRING *sig) | - | ||||||||||||
| 213 | { | - | ||||||||||||
| 214 | int pknid, mdnid; | - | ||||||||||||
| 215 | const EVP_MD *md; | - | ||||||||||||
| 216 | - | |||||||||||||
| 217 | siginf->mdnid = 0; | - | ||||||||||||
| 218 | siginf->pknid = 0; | - | ||||||||||||
| 219 | siginf->secbits = -1; | - | ||||||||||||
| 220 | siginf->flags = 0; | - | ||||||||||||
| 221 | if (!OBJ_find_sigid_algs(OBJ_obj2nid(alg->algorithm), &mdnid, &pknid)
| 204-12297 | ||||||||||||
| 222 | || pknid == 0
| 0-12297 | ||||||||||||
| 223 | return; executed 204 times by 1 test: return;Executed by:
| 204 | ||||||||||||
| 224 | siginf->pknid = pknid; | - | ||||||||||||
| 225 | if (mdnid == 0
| 55-12242 | ||||||||||||
| 226 | - | |||||||||||||
| 227 | const EVP_PKEY_ASN1_METHOD *ameth = EVP_PKEY_asn1_find( | - | ||||||||||||
| 228 | ((void *)0) | - | ||||||||||||
| 229 | , pknid); | - | ||||||||||||
| 230 | if (ameth ==
| 0-55 | ||||||||||||
| 231 | ((void *)0)
| 0-55 | ||||||||||||
| 232 | || ameth->siginf_set ==
| 1-54 | ||||||||||||
| 233 | ((void *)0)
| 1-54 | ||||||||||||
| 234 | - | |||||||||||||
| 235 | || ameth->siginf_set(siginf, alg, sig) == 0
| 15-39 | ||||||||||||
| 236 | return; executed 40 times by 1 test: return;Executed by:
| 40 | ||||||||||||
| 237 | siginf->flags |= 0x1; | - | ||||||||||||
| 238 | return; executed 15 times by 1 test: return;Executed by:
| 15 | ||||||||||||
| 239 | } | - | ||||||||||||
| 240 | siginf->flags |= 0x1; | - | ||||||||||||
| 241 | siginf->mdnid = mdnid; | - | ||||||||||||
| 242 | md = EVP_get_digestbyname(OBJ_nid2sn(mdnid)); | - | ||||||||||||
| 243 | if (md ==
| 8-12234 | ||||||||||||
| 244 | ((void *)0)
| 8-12234 | ||||||||||||
| 245 | ) | - | ||||||||||||
| 246 | return; executed 8 times by 1 test: return;Executed by:
| 8 | ||||||||||||
| 247 | - | |||||||||||||
| 248 | siginf->secbits = EVP_MD_size(md) * 4; | - | ||||||||||||
| 249 | switch (mdnid) { | - | ||||||||||||
| 250 | case executed 2265 times by 1 test: 64:case 64:Executed by:
executed 2265 times by 1 test: case 64:Executed by:
| 2265 | ||||||||||||
| 251 | case executed 9920 times by 1 test: 672:case 672:Executed by:
executed 9920 times by 1 test: case 672:Executed by:
| 9920 | ||||||||||||
| 252 | case executed 5 times by 1 test: 673:case 673:Executed by:
executed 5 times by 1 test: case 673:Executed by:
| 5 | ||||||||||||
| 253 | case executed 8 times by 1 test: 674:case 674:Executed by:
executed 8 times by 1 test: case 674:Executed by:
| 8 | ||||||||||||
| 254 | siginf->flags |= 0x2; | - | ||||||||||||
| 255 | } executed 12198 times by 1 test: end of blockExecuted by:
| 12198 | ||||||||||||
| 256 | } executed 12234 times by 1 test: end of blockExecuted by:
| 12234 | ||||||||||||
| 257 | - | |||||||||||||
| 258 | void x509_init_sig_info(X509 *x) | - | ||||||||||||
| 259 | { | - | ||||||||||||
| 260 | x509_sig_info_init(&x->siginf, &x->sig_alg, &x->signature); | - | ||||||||||||
| 261 | } executed 12501 times by 1 test: end of blockExecuted by:
| 12501 | ||||||||||||
| Switch to Source code | Preprocessed file |