| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/dsa/dsa_asn1.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | static const ASN1_TEMPLATE DSA_SIG_seq_tt[] = { | - | ||||||||||||
| 4 | { (0), (0), | - | ||||||||||||
| 5 | __builtin_offsetof ( | - | ||||||||||||
| 6 | DSA_SIG | - | ||||||||||||
| 7 | , | - | ||||||||||||
| 8 | r | - | ||||||||||||
| 9 | ) | - | ||||||||||||
| 10 | , "r", (&(CBIGNUM_it)) }, | - | ||||||||||||
| 11 | { (0), (0), | - | ||||||||||||
| 12 | __builtin_offsetof ( | - | ||||||||||||
| 13 | DSA_SIG | - | ||||||||||||
| 14 | , | - | ||||||||||||
| 15 | s | - | ||||||||||||
| 16 | ) | - | ||||||||||||
| 17 | , "s", (&(CBIGNUM_it)) } | - | ||||||||||||
| 18 | } ; static const ASN1_ITEM DSA_SIG_it = { 0x1, 16, DSA_SIG_seq_tt, sizeof(DSA_SIG_seq_tt) / sizeof(ASN1_TEMPLATE), | - | ||||||||||||
| 19 | ((void *)0) | - | ||||||||||||
| 20 | , sizeof(DSA_SIG), "DSA_SIG" }; | - | ||||||||||||
| 21 | - | |||||||||||||
| 22 | DSA_SIG *d2i_DSA_SIG(DSA_SIG **a, const unsigned char **in, long len) { return executed 3694 times by 1 test: (DSA_SIG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSA_SIG_it)));return (DSA_SIG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSA_SIG_it)));Executed by:
executed 3694 times by 1 test: } int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **out) { returnreturn (DSA_SIG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSA_SIG_it)));Executed by:
executed 379 times by 1 test: ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSA_SIG_it)));return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSA_SIG_it)));Executed by:
executed 379 times by 1 test: }return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSA_SIG_it)));Executed by:
| 379-3694 | ||||||||||||
| 23 | - | |||||||||||||
| 24 | DSA_SIG *DSA_SIG_new(void) | - | ||||||||||||
| 25 | { | - | ||||||||||||
| 26 | DSA_SIG *sig = CRYPTO_zalloc(sizeof(*sig), __FILE__, 26); | - | ||||||||||||
| 27 | if (sig ==
| 0-371 | ||||||||||||
| 28 | ((void *)0)
| 0-371 | ||||||||||||
| 29 | ) | - | ||||||||||||
| 30 | ERR_put_error(10,(102),((1|64)),__FILE__,28); never executed: ERR_put_error(10,(102),((1|64)),__FILE__,28); | 0 | ||||||||||||
| 31 | return executed 371 times by 1 test: sig;return sig;Executed by:
executed 371 times by 1 test: return sig;Executed by:
| 371 | ||||||||||||
| 32 | } | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | void DSA_SIG_free(DSA_SIG *sig) | - | ||||||||||||
| 35 | { | - | ||||||||||||
| 36 | if (sig ==
| 2-400 | ||||||||||||
| 37 | ((void *)0)
| 2-400 | ||||||||||||
| 38 | ) | - | ||||||||||||
| 39 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||
| 40 | BN_clear_free(sig->r); | - | ||||||||||||
| 41 | BN_clear_free(sig->s); | - | ||||||||||||
| 42 | CRYPTO_free(sig, __FILE__, 38); | - | ||||||||||||
| 43 | } executed 400 times by 1 test: end of blockExecuted by:
| 400 | ||||||||||||
| 44 | - | |||||||||||||
| 45 | void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) | - | ||||||||||||
| 46 | { | - | ||||||||||||
| 47 | if (pr !=
| 0-321 | ||||||||||||
| 48 | ((void *)0)
| 0-321 | ||||||||||||
| 49 | ) | - | ||||||||||||
| 50 | * executed 321 times by 1 test: pr = sig->r;*pr = sig->r;Executed by:
executed 321 times by 1 test: *pr = sig->r;Executed by:
| 321 | ||||||||||||
| 51 | if (ps !=
| 0-321 | ||||||||||||
| 52 | ((void *)0)
| 0-321 | ||||||||||||
| 53 | ) | - | ||||||||||||
| 54 | * executed 321 times by 1 test: ps = sig->s;*ps = sig->s;Executed by:
executed 321 times by 1 test: *ps = sig->s;Executed by:
| 321 | ||||||||||||
| 55 | } executed 321 times by 1 test: end of blockExecuted by:
| 321 | ||||||||||||
| 56 | - | |||||||||||||
| 57 | int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) | - | ||||||||||||
| 58 | { | - | ||||||||||||
| 59 | if (r ==
| 0 | ||||||||||||
| 60 | ((void *)0)
| 0 | ||||||||||||
| 61 | || s ==
| 0 | ||||||||||||
| 62 | ((void *)0)
| 0 | ||||||||||||
| 63 | ) | - | ||||||||||||
| 64 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 65 | BN_clear_free(sig->r); | - | ||||||||||||
| 66 | BN_clear_free(sig->s); | - | ||||||||||||
| 67 | sig->r = r; | - | ||||||||||||
| 68 | sig->s = s; | - | ||||||||||||
| 69 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||
| 70 | } | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | - | |||||||||||||
| 73 | static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, | - | ||||||||||||
| 74 | void *exarg) | - | ||||||||||||
| 75 | { | - | ||||||||||||
| 76 | if (operation == 0
| 15092-30349 | ||||||||||||
| 77 | *pval = (ASN1_VALUE *)DSA_new(); | - | ||||||||||||
| 78 | if (*
| 0-15092 | ||||||||||||
| 79 | ((void *)0)
| 0-15092 | ||||||||||||
| 80 | ) | - | ||||||||||||
| 81 | return executed 15092 times by 1 test: 2;return 2;Executed by:
executed 15092 times by 1 test: return 2;Executed by:
| 15092 | ||||||||||||
| 82 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 83 | } else if (operation == 2
| 10559-19790 | ||||||||||||
| 84 | DSA_free((DSA *)*pval); | - | ||||||||||||
| 85 | *pval = | - | ||||||||||||
| 86 | ((void *)0) | - | ||||||||||||
| 87 | ; | - | ||||||||||||
| 88 | return executed 10559 times by 1 test: 2;return 2;Executed by:
executed 10559 times by 1 test: return 2;Executed by:
| 10559 | ||||||||||||
| 89 | } | - | ||||||||||||
| 90 | return executed 19790 times by 1 test: 1;return 1;Executed by:
executed 19790 times by 1 test: return 1;Executed by:
| 19790 | ||||||||||||
| 91 | } | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | static const ASN1_AUX DSAPrivateKey_aux = { | - | ||||||||||||
| 94 | ((void *)0) | - | ||||||||||||
| 95 | , 0, 0, 0, dsa_cb, 0}; static const ASN1_TEMPLATE DSAPrivateKey_seq_tt[] = { | - | ||||||||||||
| 96 | { ((0x1 << 12)), (0), | - | ||||||||||||
| 97 | __builtin_offsetof ( | - | ||||||||||||
| 98 | DSA | - | ||||||||||||
| 99 | , | - | ||||||||||||
| 100 | version | - | ||||||||||||
| 101 | ) | - | ||||||||||||
| 102 | , "version", (&(INT32_it)) }, | - | ||||||||||||
| 103 | { (0), (0), | - | ||||||||||||
| 104 | __builtin_offsetof ( | - | ||||||||||||
| 105 | DSA | - | ||||||||||||
| 106 | , | - | ||||||||||||
| 107 | p | - | ||||||||||||
| 108 | ) | - | ||||||||||||
| 109 | , "p", (&(BIGNUM_it)) }, | - | ||||||||||||
| 110 | { (0), (0), | - | ||||||||||||
| 111 | __builtin_offsetof ( | - | ||||||||||||
| 112 | DSA | - | ||||||||||||
| 113 | , | - | ||||||||||||
| 114 | q | - | ||||||||||||
| 115 | ) | - | ||||||||||||
| 116 | , "q", (&(BIGNUM_it)) }, | - | ||||||||||||
| 117 | { (0), (0), | - | ||||||||||||
| 118 | __builtin_offsetof ( | - | ||||||||||||
| 119 | DSA | - | ||||||||||||
| 120 | , | - | ||||||||||||
| 121 | g | - | ||||||||||||
| 122 | ) | - | ||||||||||||
| 123 | , "g", (&(BIGNUM_it)) }, | - | ||||||||||||
| 124 | { (0), (0), | - | ||||||||||||
| 125 | __builtin_offsetof ( | - | ||||||||||||
| 126 | DSA | - | ||||||||||||
| 127 | , | - | ||||||||||||
| 128 | pub_key | - | ||||||||||||
| 129 | ) | - | ||||||||||||
| 130 | , "pub_key", (&(BIGNUM_it)) }, | - | ||||||||||||
| 131 | { (0), (0), | - | ||||||||||||
| 132 | __builtin_offsetof ( | - | ||||||||||||
| 133 | DSA | - | ||||||||||||
| 134 | , | - | ||||||||||||
| 135 | priv_key | - | ||||||||||||
| 136 | ) | - | ||||||||||||
| 137 | , "priv_key", (&(CBIGNUM_it)) } | - | ||||||||||||
| 138 | } ; static const ASN1_ITEM DSAPrivateKey_it = { 0x1, 16, DSAPrivateKey_seq_tt, sizeof(DSAPrivateKey_seq_tt) / sizeof(ASN1_TEMPLATE), &DSAPrivateKey_aux, sizeof(DSA), "DSA" }; | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | DSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **in, long len) { return executed 5360 times by 1 test: (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPrivateKey_it)));return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPrivateKey_it)));Executed by:
executed 5360 times by 1 test: } int i2d_DSAPrivateKey(const DSA *a, unsigned char **out) { returnreturn (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPrivateKey_it)));Executed by:
executed 27 times by 1 test: ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPrivateKey_it)));return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPrivateKey_it)));Executed by:
executed 27 times by 1 test: }return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPrivateKey_it)));Executed by:
| 27-5360 | ||||||||||||
| 141 | - | |||||||||||||
| 142 | static const ASN1_AUX DSAparams_aux = { | - | ||||||||||||
| 143 | ((void *)0) | - | ||||||||||||
| 144 | , 0, 0, 0, dsa_cb, 0}; static const ASN1_TEMPLATE DSAparams_seq_tt[] = { | - | ||||||||||||
| 145 | { (0), (0), | - | ||||||||||||
| 146 | __builtin_offsetof ( | - | ||||||||||||
| 147 | DSA | - | ||||||||||||
| 148 | , | - | ||||||||||||
| 149 | p | - | ||||||||||||
| 150 | ) | - | ||||||||||||
| 151 | , "p", (&(BIGNUM_it)) }, | - | ||||||||||||
| 152 | { (0), (0), | - | ||||||||||||
| 153 | __builtin_offsetof ( | - | ||||||||||||
| 154 | DSA | - | ||||||||||||
| 155 | , | - | ||||||||||||
| 156 | q | - | ||||||||||||
| 157 | ) | - | ||||||||||||
| 158 | , "q", (&(BIGNUM_it)) }, | - | ||||||||||||
| 159 | { (0), (0), | - | ||||||||||||
| 160 | __builtin_offsetof ( | - | ||||||||||||
| 161 | DSA | - | ||||||||||||
| 162 | , | - | ||||||||||||
| 163 | g | - | ||||||||||||
| 164 | ) | - | ||||||||||||
| 165 | , "g", (&(BIGNUM_it)) }, | - | ||||||||||||
| 166 | } ; static const ASN1_ITEM DSAparams_it = { 0x1, 16, DSAparams_seq_tt, sizeof(DSAparams_seq_tt) / sizeof(ASN1_TEMPLATE), &DSAparams_aux, sizeof(DSA), "DSA" }; | - | ||||||||||||
| 167 | - | |||||||||||||
| 168 | DSA *d2i_DSAparams(DSA **a, const unsigned char **in, long len) { return executed 7493 times by 1 test: (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAparams_it)));return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAparams_it)));Executed by:
executed 7493 times by 1 test: } int i2d_DSAparams(const DSA *a, unsigned char **out) { returnreturn (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAparams_it)));Executed by:
executed 35 times by 1 test: ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAparams_it)));return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAparams_it)));Executed by:
executed 35 times by 1 test: }return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAparams_it)));Executed by:
| 35-7493 | ||||||||||||
| 169 | - | |||||||||||||
| 170 | static const ASN1_AUX DSAPublicKey_aux = { | - | ||||||||||||
| 171 | ((void *)0) | - | ||||||||||||
| 172 | , 0, 0, 0, dsa_cb, 0}; static const ASN1_TEMPLATE DSAPublicKey_seq_tt[] = { | - | ||||||||||||
| 173 | { (0), (0), | - | ||||||||||||
| 174 | __builtin_offsetof ( | - | ||||||||||||
| 175 | DSA | - | ||||||||||||
| 176 | , | - | ||||||||||||
| 177 | pub_key | - | ||||||||||||
| 178 | ) | - | ||||||||||||
| 179 | , "pub_key", (&(BIGNUM_it)) }, | - | ||||||||||||
| 180 | { (0), (0), | - | ||||||||||||
| 181 | __builtin_offsetof ( | - | ||||||||||||
| 182 | DSA | - | ||||||||||||
| 183 | , | - | ||||||||||||
| 184 | p | - | ||||||||||||
| 185 | ) | - | ||||||||||||
| 186 | , "p", (&(BIGNUM_it)) }, | - | ||||||||||||
| 187 | { (0), (0), | - | ||||||||||||
| 188 | __builtin_offsetof ( | - | ||||||||||||
| 189 | DSA | - | ||||||||||||
| 190 | , | - | ||||||||||||
| 191 | q | - | ||||||||||||
| 192 | ) | - | ||||||||||||
| 193 | , "q", (&(BIGNUM_it)) }, | - | ||||||||||||
| 194 | { (0), (0), | - | ||||||||||||
| 195 | __builtin_offsetof ( | - | ||||||||||||
| 196 | DSA | - | ||||||||||||
| 197 | , | - | ||||||||||||
| 198 | g | - | ||||||||||||
| 199 | ) | - | ||||||||||||
| 200 | , "g", (&(BIGNUM_it)) } | - | ||||||||||||
| 201 | } ; static const ASN1_ITEM DSAPublicKey_it = { 0x1, 16, DSAPublicKey_seq_tt, sizeof(DSAPublicKey_seq_tt) / sizeof(ASN1_TEMPLATE), &DSAPublicKey_aux, sizeof(DSA), "DSA" }; | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | DSA *d2i_DSAPublicKey(DSA **a, const unsigned char **in, long len) { return executed 3323 times by 1 test: (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPublicKey_it)));return (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPublicKey_it)));Executed by:
executed 3323 times by 1 test: } int i2d_DSAPublicKey(const DSA *a, unsigned char **out) { returnreturn (DSA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (&(DSAPublicKey_it)));Executed by:
executed 3 times by 1 test: ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPublicKey_it)));return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPublicKey_it)));Executed by:
executed 3 times by 1 test: }return ASN1_item_i2d((ASN1_VALUE *)a, out, (&(DSAPublicKey_it)));Executed by:
| 3-3323 | ||||||||||||
| 204 | - | |||||||||||||
| 205 | DSA *DSAparams_dup(DSA *dsa) | - | ||||||||||||
| 206 | { | - | ||||||||||||
| 207 | return never executed: ASN1_item_dup((&(DSAparams_it)), dsa);return ASN1_item_dup((&(DSAparams_it)), dsa);never executed: return ASN1_item_dup((&(DSAparams_it)), dsa); | 0 | ||||||||||||
| 208 | } | - | ||||||||||||
| 209 | - | |||||||||||||
| 210 | int DSA_sign(int type, const unsigned char *dgst, int dlen, | - | ||||||||||||
| 211 | unsigned char *sig, unsigned int *siglen, DSA *dsa) | - | ||||||||||||
| 212 | { | - | ||||||||||||
| 213 | DSA_SIG *s; | - | ||||||||||||
| 214 | - | |||||||||||||
| 215 | s = DSA_do_sign(dgst, dlen, dsa); | - | ||||||||||||
| 216 | if (s ==
| 0-64 | ||||||||||||
| 217 | ((void *)0)
| 0-64 | ||||||||||||
| 218 | ) { | - | ||||||||||||
| 219 | *siglen = 0; | - | ||||||||||||
| 220 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 221 | } | - | ||||||||||||
| 222 | *siglen = i2d_DSA_SIG(s, &sig); | - | ||||||||||||
| 223 | DSA_SIG_free(s); | - | ||||||||||||
| 224 | return executed 64 times by 1 test: 1;return 1;Executed by:
executed 64 times by 1 test: return 1;Executed by:
| 64 | ||||||||||||
| 225 | } | - | ||||||||||||
| 226 | int DSA_verify(int type, const unsigned char *dgst, int dgst_len, | - | ||||||||||||
| 227 | const unsigned char *sigbuf, int siglen, DSA *dsa) | - | ||||||||||||
| 228 | { | - | ||||||||||||
| 229 | DSA_SIG *s; | - | ||||||||||||
| 230 | const unsigned char *p = sigbuf; | - | ||||||||||||
| 231 | unsigned char *der = | - | ||||||||||||
| 232 | ((void *)0) | - | ||||||||||||
| 233 | ; | - | ||||||||||||
| 234 | int derlen = -1; | - | ||||||||||||
| 235 | int ret = -1; | - | ||||||||||||
| 236 | - | |||||||||||||
| 237 | s = DSA_SIG_new(); | - | ||||||||||||
| 238 | if (s ==
| 0-307 | ||||||||||||
| 239 | ((void *)0)
| 0-307 | ||||||||||||
| 240 | ) | - | ||||||||||||
| 241 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||
| 242 | if (d2i_DSA_SIG(&s, &p, siglen) ==
| 2-305 | ||||||||||||
| 243 | ((void *)0)
| 2-305 | ||||||||||||
| 244 | ) | - | ||||||||||||
| 245 | goto executed 2 times by 1 test: err;goto err;Executed by:
executed 2 times by 1 test: goto err;Executed by:
| 2 | ||||||||||||
| 246 | - | |||||||||||||
| 247 | derlen = i2d_DSA_SIG(s, &der); | - | ||||||||||||
| 248 | if (derlen != siglen
| 1-302 | ||||||||||||
| 249 | goto executed 4 times by 1 test: err;goto err;Executed by:
executed 4 times by 1 test: goto err;Executed by:
| 4 | ||||||||||||
| 250 | ret = DSA_do_verify(dgst, dgst_len, s, dsa); | - | ||||||||||||
| 251 | err: code before this statement executed 301 times by 1 test: err:Executed by:
| 301 | ||||||||||||
| 252 | CRYPTO_clear_free(der, derlen, __FILE__, 152); | - | ||||||||||||
| 253 | DSA_SIG_free(s); | - | ||||||||||||
| 254 | return executed 307 times by 1 test: ret;return ret;Executed by:
executed 307 times by 1 test: return ret;Executed by:
| 307 | ||||||||||||
| 255 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |