| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/dsa/dsa_ameth.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | static int | - | ||||||||||||||||||||||||
| 7 | dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | - | ||||||||||||||||||||||||
| 8 | { | - | ||||||||||||||||||||||||
| 9 | const unsigned char *p, *pm; | - | ||||||||||||||||||||||||
| 10 | int pklen, pmlen; | - | ||||||||||||||||||||||||
| 11 | int ptype; | - | ||||||||||||||||||||||||
| 12 | const void *pval; | - | ||||||||||||||||||||||||
| 13 | const ASN1_STRING *pstr; | - | ||||||||||||||||||||||||
| 14 | X509_ALGOR *palg; | - | ||||||||||||||||||||||||
| 15 | ASN1_INTEGER *public_key = | - | ||||||||||||||||||||||||
| 16 | ((void *)0) | - | ||||||||||||||||||||||||
| 17 | ; | - | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | DSA *dsa = | - | ||||||||||||||||||||||||
| 20 | ((void *)0) | - | ||||||||||||||||||||||||
| 21 | ; | - | ||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||
| 23 | if (!X509_PUBKEY_get0_param(
| 0-2 | ||||||||||||||||||||||||
| 24 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 25 | , &p, &pklen, &palg, pubkey)
| 0-2 | ||||||||||||||||||||||||
| 26 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 27 | X509_ALGOR_get0( | - | ||||||||||||||||||||||||
| 28 | ((void *)0) | - | ||||||||||||||||||||||||
| 29 | , &ptype, &pval, palg); | - | ||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||
| 31 | if (ptype == 16
| 0-2 | ||||||||||||||||||||||||
| 32 | pstr = pval; | - | ||||||||||||||||||||||||
| 33 | pm = pstr->data; | - | ||||||||||||||||||||||||
| 34 | pmlen = pstr->length; | - | ||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||
| 36 | if (!(dsa = d2i_DSAparams(
| 0-2 | ||||||||||||||||||||||||
| 37 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 38 | , &pm, pmlen))
| 0-2 | ||||||||||||||||||||||||
| 39 | ERR_put_error(10,(0xfff),(104),__FILE__,95); | - | ||||||||||||||||||||||||
| 40 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 41 | } | - | ||||||||||||||||||||||||
| 42 | } executed 2 times by 1 test: else if (ptype == 5end of blockExecuted by:
| 0-2 | ||||||||||||||||||||||||
| 43 | if (!(dsa = DSA_new())
| 0 | ||||||||||||||||||||||||
| 44 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,100); | - | ||||||||||||||||||||||||
| 45 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 46 | } | - | ||||||||||||||||||||||||
| 47 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 48 | ERR_put_error(10,(0xfff),(105),__FILE__,104); | - | ||||||||||||||||||||||||
| 49 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 50 | } | - | ||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | if (!(public_key=d2i_ASN1_INTEGER(
| 0-2 | ||||||||||||||||||||||||
| 53 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 54 | , &p, pklen))
| 0-2 | ||||||||||||||||||||||||
| 55 | ERR_put_error(10,(0xfff),(104),__FILE__,109); | - | ||||||||||||||||||||||||
| 56 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 57 | } | - | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key,
| 0-2 | ||||||||||||||||||||||||
| 60 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 61 | ))
| 0-2 | ||||||||||||||||||||||||
| 62 | ERR_put_error(10,(0xfff),(108),__FILE__,114); | - | ||||||||||||||||||||||||
| 63 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 64 | } | - | ||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | ASN1_INTEGER_free(public_key); | - | ||||||||||||||||||||||||
| 67 | EVP_PKEY_assign((pkey),116, (char *)(dsa)); | - | ||||||||||||||||||||||||
| 68 | return executed 2 times by 1 test: 1;return 1;Executed by:
executed 2 times by 1 test: return 1;Executed by:
| 2 | ||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | err: | - | ||||||||||||||||||||||||
| 71 | if (public_key
| 0 | ||||||||||||||||||||||||
| 72 | ASN1_INTEGER_free(public_key); never executed: ASN1_INTEGER_free(public_key); | 0 | ||||||||||||||||||||||||
| 73 | DSA_free(dsa); | - | ||||||||||||||||||||||||
| 74 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 75 | } | - | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | static int | - | ||||||||||||||||||||||||
| 78 | dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) | - | ||||||||||||||||||||||||
| 79 | { | - | ||||||||||||||||||||||||
| 80 | DSA *dsa; | - | ||||||||||||||||||||||||
| 81 | void *pval = | - | ||||||||||||||||||||||||
| 82 | ((void *)0) | - | ||||||||||||||||||||||||
| 83 | ; | - | ||||||||||||||||||||||||
| 84 | int ptype; | - | ||||||||||||||||||||||||
| 85 | unsigned char *penc = | - | ||||||||||||||||||||||||
| 86 | ((void *)0) | - | ||||||||||||||||||||||||
| 87 | ; | - | ||||||||||||||||||||||||
| 88 | int penclen; | - | ||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | dsa = pkey->pkey.dsa; | - | ||||||||||||||||||||||||
| 91 | if (pkey->save_parameters
| 0-2 | ||||||||||||||||||||||||
| 92 | ASN1_STRING *str; | - | ||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | str = ASN1_STRING_new(); | - | ||||||||||||||||||||||||
| 95 | if (str ==
| 0-2 | ||||||||||||||||||||||||
| 96 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 97 | ) { | - | ||||||||||||||||||||||||
| 98 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,144); | - | ||||||||||||||||||||||||
| 99 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 100 | } | - | ||||||||||||||||||||||||
| 101 | str->length = i2d_DSAparams(dsa, &str->data); | - | ||||||||||||||||||||||||
| 102 | if (str->length <= 0
| 0-2 | ||||||||||||||||||||||||
| 103 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,149); | - | ||||||||||||||||||||||||
| 104 | ASN1_STRING_free(str); | - | ||||||||||||||||||||||||
| 105 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 106 | } | - | ||||||||||||||||||||||||
| 107 | pval = str; | - | ||||||||||||||||||||||||
| 108 | ptype = 16; | - | ||||||||||||||||||||||||
| 109 | } executed 2 times by 1 test: elseend of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 110 | ptype = -1; never executed: ptype = -1; | 0 | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | dsa->write_params = 0; | - | ||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | penclen = i2d_DSAPublicKey(dsa, &penc); | - | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | if (penclen <= 0
| 0-2 | ||||||||||||||||||||||||
| 117 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,163); | - | ||||||||||||||||||||||||
| 118 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 119 | } | - | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(116), ptype, pval,
| 0-2 | ||||||||||||||||||||||||
| 122 | penc, penclen)
| 0-2 | ||||||||||||||||||||||||
| 123 | return executed 2 times by 1 test: 1;return 1;Executed by:
executed 2 times by 1 test: return 1;Executed by:
| 2 | ||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||||||||
| 126 | free(penc); | - | ||||||||||||||||||||||||
| 127 | ASN1_STRING_free(pval); | - | ||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 130 | } | - | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | static int | - | ||||||||||||||||||||||||
| 136 | dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) | - | ||||||||||||||||||||||||
| 137 | { | - | ||||||||||||||||||||||||
| 138 | const unsigned char *p, *pm; | - | ||||||||||||||||||||||||
| 139 | int pklen, pmlen; | - | ||||||||||||||||||||||||
| 140 | int ptype; | - | ||||||||||||||||||||||||
| 141 | const void *pval; | - | ||||||||||||||||||||||||
| 142 | const ASN1_STRING *pstr; | - | ||||||||||||||||||||||||
| 143 | const X509_ALGOR *palg; | - | ||||||||||||||||||||||||
| 144 | ASN1_INTEGER *privkey = | - | ||||||||||||||||||||||||
| 145 | ((void *)0) | - | ||||||||||||||||||||||||
| 146 | ; | - | ||||||||||||||||||||||||
| 147 | BN_CTX *ctx = | - | ||||||||||||||||||||||||
| 148 | ((void *)0) | - | ||||||||||||||||||||||||
| 149 | ; | - | ||||||||||||||||||||||||
| 150 | DSA *dsa = | - | ||||||||||||||||||||||||
| 151 | ((void *)0) | - | ||||||||||||||||||||||||
| 152 | ; | - | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | int ret = 0; | - | ||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||
| 156 | if (!PKCS8_pkey_get0(
| 0 | ||||||||||||||||||||||||
| 157 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 158 | , &p, &pklen, &palg, p8)
| 0 | ||||||||||||||||||||||||
| 159 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 160 | X509_ALGOR_get0( | - | ||||||||||||||||||||||||
| 161 | ((void *)0) | - | ||||||||||||||||||||||||
| 162 | , &ptype, &pval, palg); | - | ||||||||||||||||||||||||
| 163 | if (ptype != 16
| 0 | ||||||||||||||||||||||||
| 164 | goto never executed: decerr;goto decerr;never executed: goto decerr; | 0 | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | if ((
| 0 | ||||||||||||||||||||||||
| 167 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 168 | , &p, pklen)) ==
| 0 | ||||||||||||||||||||||||
| 169 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 170 | ) | - | ||||||||||||||||||||||||
| 171 | goto never executed: decerr;goto decerr;never executed: goto decerr; | 0 | ||||||||||||||||||||||||
| 172 | if (privkey->type == (2 | 0x100)
| 0 | ||||||||||||||||||||||||
| 173 | goto never executed: decerr;goto decerr;never executed: goto decerr; | 0 | ||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||
| 175 | pstr = pval; | - | ||||||||||||||||||||||||
| 176 | pm = pstr->data; | - | ||||||||||||||||||||||||
| 177 | pmlen = pstr->length; | - | ||||||||||||||||||||||||
| 178 | if (!(dsa = d2i_DSAparams(
| 0 | ||||||||||||||||||||||||
| 179 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 180 | , &pm, pmlen))
| 0 | ||||||||||||||||||||||||
| 181 | goto never executed: decerr;goto decerr;never executed: goto decerr; | 0 | ||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey,
| 0 | ||||||||||||||||||||||||
| 184 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 185 | ))
| 0 | ||||||||||||||||||||||||
| 186 | ERR_put_error(10,(0xfff),(109),__FILE__,214); | - | ||||||||||||||||||||||||
| 187 | goto never executed: dsaerr;goto dsaerr;never executed: goto dsaerr; | 0 | ||||||||||||||||||||||||
| 188 | } | - | ||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||
| 190 | if (!(dsa->pub_key = BN_new())
| 0 | ||||||||||||||||||||||||
| 191 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,219); | - | ||||||||||||||||||||||||
| 192 | goto never executed: dsaerr;goto dsaerr;never executed: goto dsaerr; | 0 | ||||||||||||||||||||||||
| 193 | } | - | ||||||||||||||||||||||||
| 194 | if (!(ctx = BN_CTX_new())
| 0 | ||||||||||||||||||||||||
| 195 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,223); | - | ||||||||||||||||||||||||
| 196 | goto never executed: dsaerr;goto dsaerr;never executed: goto dsaerr; | 0 | ||||||||||||||||||||||||
| 197 | } | - | ||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||
| 199 | if (!BN_mod_exp_ct(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)
| 0 | ||||||||||||||||||||||||
| 200 | ERR_put_error(10,(0xfff),(109),__FILE__,228); | - | ||||||||||||||||||||||||
| 201 | goto never executed: dsaerr;goto dsaerr;never executed: goto dsaerr; | 0 | ||||||||||||||||||||||||
| 202 | } | - | ||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||
| 204 | if (!EVP_PKEY_assign((pkey),116, (char *)(dsa))
| 0 | ||||||||||||||||||||||||
| 205 | goto never executed: decerr;goto decerr;never executed: goto decerr; | 0 | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | ret = 1; | - | ||||||||||||||||||||||||
| 208 | goto never executed: done;goto done;never executed: goto done; | 0 | ||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||
| 210 | decerr: | - | ||||||||||||||||||||||||
| 211 | ERR_put_error(10,(0xfff),(104),__FILE__,239); | - | ||||||||||||||||||||||||
| 212 | dsaerr: code before this statement never executed: dsaerr: | 0 | ||||||||||||||||||||||||
| 213 | DSA_free(dsa); | - | ||||||||||||||||||||||||
| 214 | done: code before this statement never executed: done: | 0 | ||||||||||||||||||||||||
| 215 | BN_CTX_free(ctx); | - | ||||||||||||||||||||||||
| 216 | ASN1_INTEGER_free(privkey); | - | ||||||||||||||||||||||||
| 217 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 218 | } | - | ||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | static int | - | ||||||||||||||||||||||||
| 221 | dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) | - | ||||||||||||||||||||||||
| 222 | { | - | ||||||||||||||||||||||||
| 223 | ASN1_STRING *params = | - | ||||||||||||||||||||||||
| 224 | ((void *)0) | - | ||||||||||||||||||||||||
| 225 | ; | - | ||||||||||||||||||||||||
| 226 | ASN1_INTEGER *prkey = | - | ||||||||||||||||||||||||
| 227 | ((void *)0) | - | ||||||||||||||||||||||||
| 228 | ; | - | ||||||||||||||||||||||||
| 229 | unsigned char *dp = | - | ||||||||||||||||||||||||
| 230 | ((void *)0) | - | ||||||||||||||||||||||||
| 231 | ; | - | ||||||||||||||||||||||||
| 232 | int dplen; | - | ||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||
| 234 | params = ASN1_STRING_new(); | - | ||||||||||||||||||||||||
| 235 | if (!params
| 0-1 | ||||||||||||||||||||||||
| 236 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,258); | - | ||||||||||||||||||||||||
| 237 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 238 | } | - | ||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | params->length = i2d_DSAparams(pkey->pkey.dsa, ¶ms->data); | - | ||||||||||||||||||||||||
| 241 | if (params->length <= 0
| 0-1 | ||||||||||||||||||||||||
| 242 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,264); | - | ||||||||||||||||||||||||
| 243 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 244 | } | - | ||||||||||||||||||||||||
| 245 | params->type = 16; | - | ||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||
| 248 | prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, | - | ||||||||||||||||||||||||
| 249 | ((void *)0) | - | ||||||||||||||||||||||||
| 250 | ); | - | ||||||||||||||||||||||||
| 251 | if (!prkey
| 0-1 | ||||||||||||||||||||||||
| 252 | ERR_put_error(10,(0xfff),(109),__FILE__,272); | - | ||||||||||||||||||||||||
| 253 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 254 | } | - | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | dplen = i2d_ASN1_INTEGER(prkey, &dp); | - | ||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | ASN1_INTEGER_free(prkey); | - | ||||||||||||||||||||||||
| 259 | prkey = | - | ||||||||||||||||||||||||
| 260 | ((void *)0) | - | ||||||||||||||||||||||||
| 261 | ; | - | ||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||
| 263 | if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(116), 0, 16,
| 0-1 | ||||||||||||||||||||||||
| 264 | params, dp, dplen)
| 0-1 | ||||||||||||||||||||||||
| 265 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | return executed 1 time by 1 test: 1;return 1;Executed by:
executed 1 time by 1 test: return 1;Executed by:
| 1 | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | err: | - | ||||||||||||||||||||||||
| 270 | free(dp); | - | ||||||||||||||||||||||||
| 271 | ASN1_STRING_free(params); | - | ||||||||||||||||||||||||
| 272 | ASN1_INTEGER_free(prkey); | - | ||||||||||||||||||||||||
| 273 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 274 | } | - | ||||||||||||||||||||||||
| 275 | - | |||||||||||||||||||||||||
| 276 | static int | - | ||||||||||||||||||||||||
| 277 | int_dsa_size(const EVP_PKEY *pkey) | - | ||||||||||||||||||||||||
| 278 | { | - | ||||||||||||||||||||||||
| 279 | return executed 2 times by 1 test: DSA_size(pkey->pkey.dsa);return DSA_size(pkey->pkey.dsa);Executed by:
executed 2 times by 1 test: return DSA_size(pkey->pkey.dsa);Executed by:
| 2 | ||||||||||||||||||||||||
| 280 | } | - | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | static int | - | ||||||||||||||||||||||||
| 283 | dsa_bits(const EVP_PKEY *pkey) | - | ||||||||||||||||||||||||
| 284 | { | - | ||||||||||||||||||||||||
| 285 | return executed 1 time by 1 test: BN_num_bits(pkey->pkey.dsa->p);return BN_num_bits(pkey->pkey.dsa->p);Executed by:
executed 1 time by 1 test: return BN_num_bits(pkey->pkey.dsa->p);Executed by:
| 1 | ||||||||||||||||||||||||
| 286 | } | - | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | static int | - | ||||||||||||||||||||||||
| 289 | dsa_missing_parameters(const EVP_PKEY *pkey) | - | ||||||||||||||||||||||||
| 290 | { | - | ||||||||||||||||||||||||
| 291 | DSA *dsa; | - | ||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | dsa = pkey->pkey.dsa; | - | ||||||||||||||||||||||||
| 294 | if (dsa->p ==
| 0-1 | ||||||||||||||||||||||||
| 295 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 296 | || dsa->q ==
| 0-1 | ||||||||||||||||||||||||
| 297 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 298 | || dsa->g ==
| 0-1 | ||||||||||||||||||||||||
| 299 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 300 | ) | - | ||||||||||||||||||||||||
| 301 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 302 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||||||||
| 303 | } | - | ||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | static int | - | ||||||||||||||||||||||||
| 306 | dsa_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) | - | ||||||||||||||||||||||||
| 307 | { | - | ||||||||||||||||||||||||
| 308 | BIGNUM *a; | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | if ((
| 0-1 | ||||||||||||||||||||||||
| 311 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 312 | ) | - | ||||||||||||||||||||||||
| 313 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 314 | BN_free(to->pkey.dsa->p); | - | ||||||||||||||||||||||||
| 315 | to->pkey.dsa->p = a; | - | ||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | if ((
| 0-1 | ||||||||||||||||||||||||
| 318 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 319 | ) | - | ||||||||||||||||||||||||
| 320 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 321 | BN_free(to->pkey.dsa->q); | - | ||||||||||||||||||||||||
| 322 | to->pkey.dsa->q = a; | - | ||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||
| 324 | if ((
| 0-1 | ||||||||||||||||||||||||
| 325 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 326 | ) | - | ||||||||||||||||||||||||
| 327 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 328 | BN_free(to->pkey.dsa->g); | - | ||||||||||||||||||||||||
| 329 | to->pkey.dsa->g = a; | - | ||||||||||||||||||||||||
| 330 | return executed 1 time by 1 test: 1;return 1;Executed by:
executed 1 time by 1 test: return 1;Executed by:
| 1 | ||||||||||||||||||||||||
| 331 | } | - | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | static int | - | ||||||||||||||||||||||||
| 334 | dsa_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) | - | ||||||||||||||||||||||||
| 335 | { | - | ||||||||||||||||||||||||
| 336 | if (BN_cmp(a->pkey.dsa->p, b->pkey.dsa->p)
| 0 | ||||||||||||||||||||||||
| 337 | BN_cmp(a->pkey.dsa->q, b->pkey.dsa->q)
| 0 | ||||||||||||||||||||||||
| 338 | BN_cmp(a->pkey.dsa->g, b->pkey.dsa->g)
| 0 | ||||||||||||||||||||||||
| 339 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 340 | else | - | ||||||||||||||||||||||||
| 341 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 342 | } | - | ||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | static int | - | ||||||||||||||||||||||||
| 345 | dsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) | - | ||||||||||||||||||||||||
| 346 | { | - | ||||||||||||||||||||||||
| 347 | if (BN_cmp(b->pkey.dsa->pub_key, a->pkey.dsa->pub_key) != 0
| 0 | ||||||||||||||||||||||||
| 348 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 349 | else | - | ||||||||||||||||||||||||
| 350 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 351 | } | - | ||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | static void | - | ||||||||||||||||||||||||
| 354 | int_dsa_free(EVP_PKEY *pkey) | - | ||||||||||||||||||||||||
| 355 | { | - | ||||||||||||||||||||||||
| 356 | DSA_free(pkey->pkey.dsa); | - | ||||||||||||||||||||||||
| 357 | } executed 5 times by 2 tests: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | static void | - | ||||||||||||||||||||||||
| 360 | update_buflen(const BIGNUM *b, size_t *pbuflen) | - | ||||||||||||||||||||||||
| 361 | { | - | ||||||||||||||||||||||||
| 362 | size_t i; | - | ||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||
| 364 | if (!b
| 3-9 | ||||||||||||||||||||||||
| 365 | return; executed 3 times by 2 tests: return;Executed by:
| 3 | ||||||||||||||||||||||||
| 366 | if (*
| 3-6 | ||||||||||||||||||||||||
| 367 | * executed 3 times by 2 tests: pbuflen = i;*pbuflen = i;Executed by:
executed 3 times by 2 tests: *pbuflen = i;Executed by:
| 3 | ||||||||||||||||||||||||
| 368 | } executed 9 times by 2 tests: end of blockExecuted by:
| 9 | ||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||
| 370 | static int | - | ||||||||||||||||||||||||
| 371 | do_dsa_print(BIO *bp, const DSA *x, int off, int ptype) | - | ||||||||||||||||||||||||
| 372 | { | - | ||||||||||||||||||||||||
| 373 | unsigned char *m = | - | ||||||||||||||||||||||||
| 374 | ((void *)0) | - | ||||||||||||||||||||||||
| 375 | ; | - | ||||||||||||||||||||||||
| 376 | int ret = 0; | - | ||||||||||||||||||||||||
| 377 | size_t buf_len = 0; | - | ||||||||||||||||||||||||
| 378 | const char *ktype = | - | ||||||||||||||||||||||||
| 379 | ((void *)0) | - | ||||||||||||||||||||||||
| 380 | ; | - | ||||||||||||||||||||||||
| 381 | const BIGNUM *priv_key, *pub_key; | - | ||||||||||||||||||||||||
| 382 | - | |||||||||||||||||||||||||
| 383 | if (ptype == 2
| 1 | ||||||||||||||||||||||||
| 384 | priv_key = x->priv_key; executed 1 time by 1 test: priv_key = x->priv_key;Executed by:
| 1 | ||||||||||||||||||||||||
| 385 | else | - | ||||||||||||||||||||||||
| 386 | priv_key = executed 1 time by 1 test: priv_key = ((void *)0) ;Executed by:
| 1 | ||||||||||||||||||||||||
| 387 | ((void *)0) executed 1 time by 1 test: priv_key = ((void *)0) ;Executed by:
| 1 | ||||||||||||||||||||||||
| 388 | ; executed 1 time by 1 test: priv_key = ((void *)0) ;Executed by:
| 1 | ||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | if (ptype > 0
| 0-2 | ||||||||||||||||||||||||
| 391 | pub_key = x->pub_key; executed 2 times by 2 tests: pub_key = x->pub_key;Executed by:
| 2 | ||||||||||||||||||||||||
| 392 | else | - | ||||||||||||||||||||||||
| 393 | pub_key = never executed: pub_key = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 394 | ((void *)0) never executed: pub_key = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 395 | ; never executed: pub_key = ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||
| 397 | if (ptype == 2
| 1 | ||||||||||||||||||||||||
| 398 | ktype = "Private-Key"; executed 1 time by 1 test: ktype = "Private-Key";Executed by:
| 1 | ||||||||||||||||||||||||
| 399 | else if (ptype == 1
| 0-1 | ||||||||||||||||||||||||
| 400 | ktype = "Public-Key"; executed 1 time by 1 test: ktype = "Public-Key";Executed by:
| 1 | ||||||||||||||||||||||||
| 401 | else | - | ||||||||||||||||||||||||
| 402 | ktype = "DSA-Parameters"; never executed: ktype = "DSA-Parameters"; | 0 | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | update_buflen(x->p, &buf_len); | - | ||||||||||||||||||||||||
| 405 | update_buflen(x->q, &buf_len); | - | ||||||||||||||||||||||||
| 406 | update_buflen(x->g, &buf_len); | - | ||||||||||||||||||||||||
| 407 | update_buflen(priv_key, &buf_len); | - | ||||||||||||||||||||||||
| 408 | update_buflen(pub_key, &buf_len); | - | ||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||
| 410 | m = malloc(buf_len + 10); | - | ||||||||||||||||||||||||
| 411 | if (m ==
| 0-2 | ||||||||||||||||||||||||
| 412 | ((void *)0)
| 0-2 | ||||||||||||||||||||||||
| 413 | ) { | - | ||||||||||||||||||||||||
| 414 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,410); | - | ||||||||||||||||||||||||
| 415 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 416 | } | - | ||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||
| 418 | if (priv_key
| 0-2 | ||||||||||||||||||||||||
| 419 | if (!BIO_indent(bp, off, 128)
| 0 | ||||||||||||||||||||||||
| 420 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 421 | if (BIO_printf(bp, "%s: (%d bit)\n", ktype,
| 0 | ||||||||||||||||||||||||
| 422 | BN_num_bits(x->p)) <= 0
| 0 | ||||||||||||||||||||||||
| 423 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 424 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | if (!ASN1_bn_print(bp, "priv:", priv_key, m, off)
| 0-2 | ||||||||||||||||||||||||
| 427 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 428 | if (!ASN1_bn_print(bp, "pub: ", pub_key, m, off)
| 0-2 | ||||||||||||||||||||||||
| 429 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 430 | if (!ASN1_bn_print(bp, "P: ", x->p, m, off)
| 0-2 | ||||||||||||||||||||||||
| 431 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 432 | if (!ASN1_bn_print(bp, "Q: ", x->q, m, off)
| 0-2 | ||||||||||||||||||||||||
| 433 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 434 | if (!ASN1_bn_print(bp, "G: ", x->g, m, off)
| 0-2 | ||||||||||||||||||||||||
| 435 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 436 | ret = 1; | - | ||||||||||||||||||||||||
| 437 | err: code before this statement executed 2 times by 2 tests: err:Executed by:
| 2 | ||||||||||||||||||||||||
| 438 | free(m); | - | ||||||||||||||||||||||||
| 439 | return executed 2 times by 2 tests: (ret);return(ret);Executed by:
executed 2 times by 2 tests: return(ret);Executed by:
| 2 | ||||||||||||||||||||||||
| 440 | } | - | ||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | static int | - | ||||||||||||||||||||||||
| 443 | dsa_param_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) | - | ||||||||||||||||||||||||
| 444 | { | - | ||||||||||||||||||||||||
| 445 | DSA *dsa; | - | ||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||
| 447 | if (!(dsa = d2i_DSAparams(
| 0-1 | ||||||||||||||||||||||||
| 448 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 449 | , pder, derlen))
| 0-1 | ||||||||||||||||||||||||
| 450 | ERR_put_error(10,(0xfff),(10),__FILE__,444); | - | ||||||||||||||||||||||||
| 451 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 452 | } | - | ||||||||||||||||||||||||
| 453 | EVP_PKEY_assign((pkey),116, (char *)(dsa)); | - | ||||||||||||||||||||||||
| 454 | return executed 1 time by 1 test: 1;return 1;Executed by:
executed 1 time by 1 test: return 1;Executed by:
| 1 | ||||||||||||||||||||||||
| 455 | } | - | ||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | static int | - | ||||||||||||||||||||||||
| 458 | dsa_param_encode(const EVP_PKEY *pkey, unsigned char **pder) | - | ||||||||||||||||||||||||
| 459 | { | - | ||||||||||||||||||||||||
| 460 | return never executed: i2d_DSAparams(pkey->pkey.dsa, pder);return i2d_DSAparams(pkey->pkey.dsa, pder);never executed: return i2d_DSAparams(pkey->pkey.dsa, pder); | 0 | ||||||||||||||||||||||||
| 461 | } | - | ||||||||||||||||||||||||
| 462 | - | |||||||||||||||||||||||||
| 463 | static int | - | ||||||||||||||||||||||||
| 464 | dsa_param_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) | - | ||||||||||||||||||||||||
| 465 | { | - | ||||||||||||||||||||||||
| 466 | return never executed: do_dsa_print(bp, pkey->pkey.dsa, indent, 0);return do_dsa_print(bp, pkey->pkey.dsa, indent, 0);never executed: return do_dsa_print(bp, pkey->pkey.dsa, indent, 0); | 0 | ||||||||||||||||||||||||
| 467 | } | - | ||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||
| 469 | static int | - | ||||||||||||||||||||||||
| 470 | dsa_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) | - | ||||||||||||||||||||||||
| 471 | { | - | ||||||||||||||||||||||||
| 472 | return executed 1 time by 1 test: do_dsa_print(bp, pkey->pkey.dsa, indent, 1);return do_dsa_print(bp, pkey->pkey.dsa, indent, 1);Executed by:
executed 1 time by 1 test: return do_dsa_print(bp, pkey->pkey.dsa, indent, 1);Executed by:
| 1 | ||||||||||||||||||||||||
| 473 | } | - | ||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||
| 475 | static int | - | ||||||||||||||||||||||||
| 476 | dsa_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) | - | ||||||||||||||||||||||||
| 477 | { | - | ||||||||||||||||||||||||
| 478 | return executed 1 time by 1 test: do_dsa_print(bp, pkey->pkey.dsa, indent, 2);return do_dsa_print(bp, pkey->pkey.dsa, indent, 2);Executed by:
executed 1 time by 1 test: return do_dsa_print(bp, pkey->pkey.dsa, indent, 2);Executed by:
| 1 | ||||||||||||||||||||||||
| 479 | } | - | ||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | static int | - | ||||||||||||||||||||||||
| 482 | old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) | - | ||||||||||||||||||||||||
| 483 | { | - | ||||||||||||||||||||||||
| 484 | DSA *dsa; | - | ||||||||||||||||||||||||
| 485 | BN_CTX *ctx = | - | ||||||||||||||||||||||||
| 486 | ((void *)0) | - | ||||||||||||||||||||||||
| 487 | ; | - | ||||||||||||||||||||||||
| 488 | BIGNUM *j, *p1, *newp1; | - | ||||||||||||||||||||||||
| 489 | - | |||||||||||||||||||||||||
| 490 | if (!(dsa = d2i_DSAPrivateKey(
| 0 | ||||||||||||||||||||||||
| 491 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 492 | , pder, derlen))
| 0 | ||||||||||||||||||||||||
| 493 | ERR_put_error(10,(0xfff),(10),__FILE__,483); | - | ||||||||||||||||||||||||
| 494 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 495 | } | - | ||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||
| 497 | ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||
| 498 | if (ctx ==
| 0 | ||||||||||||||||||||||||
| 499 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 500 | ) | - | ||||||||||||||||||||||||
| 501 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | - | |||||||||||||||||||||||||
| 507 | j = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 508 | p1 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 509 | newp1 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 510 | if (j ==
| 0 | ||||||||||||||||||||||||
| 511 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 512 | || p1 ==
| 0 | ||||||||||||||||||||||||
| 513 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 514 | || newp1 ==
| 0 | ||||||||||||||||||||||||
| 515 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 516 | ) | - | ||||||||||||||||||||||||
| 517 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | if (BN_sub(p1, dsa->p, BN_value_one()) == 0
| 0 | ||||||||||||||||||||||||
| 520 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | if (BN_div_ct(j,
| 0 | ||||||||||||||||||||||||
| 523 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 524 | , p1, dsa->q, ctx) == 0
| 0 | ||||||||||||||||||||||||
| 525 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 526 | - | |||||||||||||||||||||||||
| 527 | if (BN_mul(newp1, dsa->q, j, ctx) == 0
| 0 | ||||||||||||||||||||||||
| 528 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 529 | if (BN_cmp(newp1, p1) != 0
| 0 | ||||||||||||||||||||||||
| 530 | ERR_put_error(10,(0xfff),(102),__FILE__,510); | - | ||||||||||||||||||||||||
| 531 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 532 | } | - | ||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | if (BN_is_prime_ex(dsa->q, 0, ctx,
| 0 | ||||||||||||||||||||||||
| 539 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 540 | ) == 0
| 0 | ||||||||||||||||||||||||
| 541 | ERR_put_error(10,(0xfff),(102),__FILE__,519); | - | ||||||||||||||||||||||||
| 542 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 543 | } | - | ||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||
| 545 | BN_CTX_free(ctx); | - | ||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||
| 547 | EVP_PKEY_assign((pkey),116, (char *)(dsa)); | - | ||||||||||||||||||||||||
| 548 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | err: | - | ||||||||||||||||||||||||
| 551 | BN_CTX_free(ctx); | - | ||||||||||||||||||||||||
| 552 | DSA_free(dsa); | - | ||||||||||||||||||||||||
| 553 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 554 | } | - | ||||||||||||||||||||||||
| 555 | - | |||||||||||||||||||||||||
| 556 | static int | - | ||||||||||||||||||||||||
| 557 | old_dsa_priv_encode(const EVP_PKEY *pkey, unsigned char **pder) | - | ||||||||||||||||||||||||
| 558 | { | - | ||||||||||||||||||||||||
| 559 | return never executed: i2d_DSAPrivateKey(pkey->pkey.dsa, pder);return i2d_DSAPrivateKey(pkey->pkey.dsa, pder);never executed: return i2d_DSAPrivateKey(pkey->pkey.dsa, pder); | 0 | ||||||||||||||||||||||||
| 560 | } | - | ||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||
| 562 | static int | - | ||||||||||||||||||||||||
| 563 | dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg, const ASN1_STRING *sig, | - | ||||||||||||||||||||||||
| 564 | int indent, ASN1_PCTX *pctx) | - | ||||||||||||||||||||||||
| 565 | { | - | ||||||||||||||||||||||||
| 566 | DSA_SIG *dsa_sig; | - | ||||||||||||||||||||||||
| 567 | const unsigned char *p; | - | ||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||
| 569 | if (!sig
| 1 | ||||||||||||||||||||||||
| 570 | if (BIO_puts(bp, "\n") <= 0
| 0-1 | ||||||||||||||||||||||||
| 571 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 572 | else | - | ||||||||||||||||||||||||
| 573 | return executed 1 time by 1 test: 1;return 1;Executed by:
executed 1 time by 1 test: return 1;Executed by:
| 1 | ||||||||||||||||||||||||
| 574 | } | - | ||||||||||||||||||||||||
| 575 | p = sig->data; | - | ||||||||||||||||||||||||
| 576 | dsa_sig = d2i_DSA_SIG( | - | ||||||||||||||||||||||||
| 577 | ((void *)0) | - | ||||||||||||||||||||||||
| 578 | , &p, sig->length); | - | ||||||||||||||||||||||||
| 579 | if (dsa_sig
| 0-1 | ||||||||||||||||||||||||
| 580 | int rv = 0; | - | ||||||||||||||||||||||||
| 581 | size_t buf_len = 0; | - | ||||||||||||||||||||||||
| 582 | unsigned char *m = | - | ||||||||||||||||||||||||
| 583 | ((void *)0) | - | ||||||||||||||||||||||||
| 584 | ; | - | ||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||
| 586 | update_buflen(dsa_sig->r, &buf_len); | - | ||||||||||||||||||||||||
| 587 | update_buflen(dsa_sig->s, &buf_len); | - | ||||||||||||||||||||||||
| 588 | m = malloc(buf_len + 10); | - | ||||||||||||||||||||||||
| 589 | if (m ==
| 0-1 | ||||||||||||||||||||||||
| 590 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 591 | ) { | - | ||||||||||||||||||||||||
| 592 | ERR_put_error(10,(0xfff),((1|64)),__FILE__,564); | - | ||||||||||||||||||||||||
| 593 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 594 | } | - | ||||||||||||||||||||||||
| 595 | - | |||||||||||||||||||||||||
| 596 | if (BIO_write(bp, "\n", 1) != 1
| 0-1 | ||||||||||||||||||||||||
| 597 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||
| 599 | if (!ASN1_bn_print(bp, "r: ", dsa_sig->r, m, indent)
| 0-1 | ||||||||||||||||||||||||
| 600 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 601 | if (!ASN1_bn_print(bp, "s: ", dsa_sig->s, m, indent)
| 0-1 | ||||||||||||||||||||||||
| 602 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 603 | rv = 1; | - | ||||||||||||||||||||||||
| 604 | err: code before this statement executed 1 time by 1 test: err:Executed by:
| 1 | ||||||||||||||||||||||||
| 605 | free(m); | - | ||||||||||||||||||||||||
| 606 | DSA_SIG_free(dsa_sig); | - | ||||||||||||||||||||||||
| 607 | return executed 1 time by 1 test: rv;return rv;Executed by:
executed 1 time by 1 test: return rv;Executed by:
| 1 | ||||||||||||||||||||||||
| 608 | } | - | ||||||||||||||||||||||||
| 609 | return never executed: X509_signature_dump(bp, sig, indent);return X509_signature_dump(bp, sig, indent);never executed: return X509_signature_dump(bp, sig, indent); | 0 | ||||||||||||||||||||||||
| 610 | } | - | ||||||||||||||||||||||||
| 611 | - | |||||||||||||||||||||||||
| 612 | static int | - | ||||||||||||||||||||||||
| 613 | dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | - | ||||||||||||||||||||||||
| 614 | { | - | ||||||||||||||||||||||||
| 615 | switch (op) { | - | ||||||||||||||||||||||||
| 616 | case never executed: 0x1:case 0x1:never executed: case 0x1: | 0 | ||||||||||||||||||||||||
| 617 | if (arg1 == 0
| 0 | ||||||||||||||||||||||||
| 618 | int snid, hnid; | - | ||||||||||||||||||||||||
| 619 | X509_ALGOR *alg1, *alg2; | - | ||||||||||||||||||||||||
| 620 | - | |||||||||||||||||||||||||
| 621 | PKCS7_SIGNER_INFO_get0_algs(arg2, | - | ||||||||||||||||||||||||
| 622 | ((void *)0) | - | ||||||||||||||||||||||||
| 623 | , &alg1, &alg2); | - | ||||||||||||||||||||||||
| 624 | if (alg1 ==
| 0 | ||||||||||||||||||||||||
| 625 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 626 | || alg1->algorithm ==
| 0 | ||||||||||||||||||||||||
| 627 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 628 | ) | - | ||||||||||||||||||||||||
| 629 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 630 | hnid = OBJ_obj2nid(alg1->algorithm); | - | ||||||||||||||||||||||||
| 631 | if (hnid == 0
| 0 | ||||||||||||||||||||||||
| 632 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 633 | if (!OBJ_find_sigid_by_algs(&snid, hnid,
| 0 | ||||||||||||||||||||||||
| 634 | EVP_PKEY_id(pkey))
| 0 | ||||||||||||||||||||||||
| 635 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 636 | X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), -1, | - | ||||||||||||||||||||||||
| 637 | 0); | - | ||||||||||||||||||||||||
| 638 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 639 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 640 | - | |||||||||||||||||||||||||
| 641 | case never executed: 0x3:case 0x3:never executed: case 0x3: | 0 | ||||||||||||||||||||||||
| 642 | *(int *)arg2 = 64; | - | ||||||||||||||||||||||||
| 643 | return never executed: 2;return 2;never executed: return 2; | 0 | ||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||
| 645 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||
| 646 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||||||||
| 647 | } | - | ||||||||||||||||||||||||
| 648 | } | - | ||||||||||||||||||||||||
| 649 | - | |||||||||||||||||||||||||
| 650 | - | |||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = { | - | ||||||||||||||||||||||||
| 653 | { | - | ||||||||||||||||||||||||
| 654 | .pkey_id = 66, | - | ||||||||||||||||||||||||
| 655 | .pkey_base_id = 116, | - | ||||||||||||||||||||||||
| 656 | .pkey_flags = 0x1 | - | ||||||||||||||||||||||||
| 657 | }, | - | ||||||||||||||||||||||||
| 658 | - | |||||||||||||||||||||||||
| 659 | { | - | ||||||||||||||||||||||||
| 660 | .pkey_id = 67, | - | ||||||||||||||||||||||||
| 661 | .pkey_base_id = 116, | - | ||||||||||||||||||||||||
| 662 | .pkey_flags = 0x1 | - | ||||||||||||||||||||||||
| 663 | }, | - | ||||||||||||||||||||||||
| 664 | - | |||||||||||||||||||||||||
| 665 | { | - | ||||||||||||||||||||||||
| 666 | .pkey_id = 70, | - | ||||||||||||||||||||||||
| 667 | .pkey_base_id = 116, | - | ||||||||||||||||||||||||
| 668 | .pkey_flags = 0x1 | - | ||||||||||||||||||||||||
| 669 | }, | - | ||||||||||||||||||||||||
| 670 | - | |||||||||||||||||||||||||
| 671 | { | - | ||||||||||||||||||||||||
| 672 | .pkey_id = 113, | - | ||||||||||||||||||||||||
| 673 | .pkey_base_id = 116, | - | ||||||||||||||||||||||||
| 674 | .pkey_flags = 0x1 | - | ||||||||||||||||||||||||
| 675 | }, | - | ||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | { | - | ||||||||||||||||||||||||
| 678 | .pkey_id = 116, | - | ||||||||||||||||||||||||
| 679 | .pkey_base_id = 116, | - | ||||||||||||||||||||||||
| 680 | - | |||||||||||||||||||||||||
| 681 | .pem_str = "DSA", | - | ||||||||||||||||||||||||
| 682 | .info = "OpenSSL DSA method", | - | ||||||||||||||||||||||||
| 683 | - | |||||||||||||||||||||||||
| 684 | .pub_decode = dsa_pub_decode, | - | ||||||||||||||||||||||||
| 685 | .pub_encode = dsa_pub_encode, | - | ||||||||||||||||||||||||
| 686 | .pub_cmp = dsa_pub_cmp, | - | ||||||||||||||||||||||||
| 687 | .pub_print = dsa_pub_print, | - | ||||||||||||||||||||||||
| 688 | - | |||||||||||||||||||||||||
| 689 | .priv_decode = dsa_priv_decode, | - | ||||||||||||||||||||||||
| 690 | .priv_encode = dsa_priv_encode, | - | ||||||||||||||||||||||||
| 691 | .priv_print = dsa_priv_print, | - | ||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | .pkey_size = int_dsa_size, | - | ||||||||||||||||||||||||
| 694 | .pkey_bits = dsa_bits, | - | ||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||
| 696 | .param_decode = dsa_param_decode, | - | ||||||||||||||||||||||||
| 697 | .param_encode = dsa_param_encode, | - | ||||||||||||||||||||||||
| 698 | .param_missing = dsa_missing_parameters, | - | ||||||||||||||||||||||||
| 699 | .param_copy = dsa_copy_parameters, | - | ||||||||||||||||||||||||
| 700 | .param_cmp = dsa_cmp_parameters, | - | ||||||||||||||||||||||||
| 701 | .param_print = dsa_param_print, | - | ||||||||||||||||||||||||
| 702 | .sig_print = dsa_sig_print, | - | ||||||||||||||||||||||||
| 703 | - | |||||||||||||||||||||||||
| 704 | .pkey_free = int_dsa_free, | - | ||||||||||||||||||||||||
| 705 | .pkey_ctrl = dsa_pkey_ctrl, | - | ||||||||||||||||||||||||
| 706 | .old_priv_decode = old_dsa_priv_decode, | - | ||||||||||||||||||||||||
| 707 | .old_priv_encode = old_dsa_priv_encode | - | ||||||||||||||||||||||||
| 708 | } | - | ||||||||||||||||||||||||
| 709 | }; | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |