| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/dsa/dsa_lib.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||||||||||||||
| 2 | * Copyright 1995-2018 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 "internal/refcount.h" | - | ||||||||||||||||||||||||
| 13 | #include <openssl/bn.h> | - | ||||||||||||||||||||||||
| 14 | #include "dsa_locl.h" | - | ||||||||||||||||||||||||
| 15 | #include <openssl/asn1.h> | - | ||||||||||||||||||||||||
| 16 | #include <openssl/engine.h> | - | ||||||||||||||||||||||||
| 17 | #include <openssl/dh.h> | - | ||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||
| 19 | DSA *DSA_new(void) | - | ||||||||||||||||||||||||
| 20 | { | - | ||||||||||||||||||||||||
| 21 | return DSA_new_method(NULL); executed 15144 times by 1 test: return DSA_new_method( ((void *)0) );Executed by:
| 15144 | ||||||||||||||||||||||||
| 22 | } | - | ||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | int DSA_set_method(DSA *dsa, const DSA_METHOD *meth) | - | ||||||||||||||||||||||||
| 25 | { | - | ||||||||||||||||||||||||
| 26 | /* | - | ||||||||||||||||||||||||
| 27 | * NB: The caller is specifically setting a method, so it's not up to us | - | ||||||||||||||||||||||||
| 28 | * to deal with which ENGINE it comes from. | - | ||||||||||||||||||||||||
| 29 | */ | - | ||||||||||||||||||||||||
| 30 | const DSA_METHOD *mtmp; | - | ||||||||||||||||||||||||
| 31 | mtmp = dsa->meth; | - | ||||||||||||||||||||||||
| 32 | if (mtmp->finish)
| 0 | ||||||||||||||||||||||||
| 33 | mtmp->finish(dsa); never executed: mtmp->finish(dsa); | 0 | ||||||||||||||||||||||||
| 34 | #ifndef OPENSSL_NO_ENGINE | - | ||||||||||||||||||||||||
| 35 | ENGINE_finish(dsa->engine); | - | ||||||||||||||||||||||||
| 36 | dsa->engine = NULL; | - | ||||||||||||||||||||||||
| 37 | #endif | - | ||||||||||||||||||||||||
| 38 | dsa->meth = meth; | - | ||||||||||||||||||||||||
| 39 | if (meth->init)
| 0 | ||||||||||||||||||||||||
| 40 | meth->init(dsa); never executed: meth->init(dsa); | 0 | ||||||||||||||||||||||||
| 41 | return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
| 42 | } | - | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | const DSA_METHOD *DSA_get_method(DSA *d) | - | ||||||||||||||||||||||||
| 45 | { | - | ||||||||||||||||||||||||
| 46 | return d->meth; never executed: return d->meth; | 0 | ||||||||||||||||||||||||
| 47 | } | - | ||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | DSA *DSA_new_method(ENGINE *engine) | - | ||||||||||||||||||||||||
| 50 | { | - | ||||||||||||||||||||||||
| 51 | DSA *ret = OPENSSL_zalloc(sizeof(*ret)); | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | if (ret == NULL) {
| 0-15144 | ||||||||||||||||||||||||
| 54 | DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE); | - | ||||||||||||||||||||||||
| 55 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 56 | } | - | ||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||
| 58 | ret->references = 1; | - | ||||||||||||||||||||||||
| 59 | ret->lock = CRYPTO_THREAD_lock_new(); | - | ||||||||||||||||||||||||
| 60 | if (ret->lock == NULL) {
| 0-15144 | ||||||||||||||||||||||||
| 61 | DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE); | - | ||||||||||||||||||||||||
| 62 | OPENSSL_free(ret); | - | ||||||||||||||||||||||||
| 63 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 64 | } | - | ||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | ret->meth = DSA_get_default_method(); | - | ||||||||||||||||||||||||
| 67 | #ifndef OPENSSL_NO_ENGINE | - | ||||||||||||||||||||||||
| 68 | ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW; /* early default init */ | - | ||||||||||||||||||||||||
| 69 | if (engine) {
| 0-15144 | ||||||||||||||||||||||||
| 70 | if (!ENGINE_init(engine)) {
| 0 | ||||||||||||||||||||||||
| 71 | DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB); | - | ||||||||||||||||||||||||
| 72 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 73 | } | - | ||||||||||||||||||||||||
| 74 | ret->engine = engine; | - | ||||||||||||||||||||||||
| 75 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 76 | ret->engine = ENGINE_get_default_DSA(); executed 15144 times by 1 test: ret->engine = ENGINE_get_default_DSA();Executed by:
| 15144 | ||||||||||||||||||||||||
| 77 | if (ret->engine) {
| 0-15144 | ||||||||||||||||||||||||
| 78 | ret->meth = ENGINE_get_DSA(ret->engine); | - | ||||||||||||||||||||||||
| 79 | if (ret->meth == NULL) {
| 0 | ||||||||||||||||||||||||
| 80 | DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB); | - | ||||||||||||||||||||||||
| 81 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 82 | } | - | ||||||||||||||||||||||||
| 83 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 84 | #endif | - | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW; | - | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data))
| 0-15144 | ||||||||||||||||||||||||
| 89 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
| 0-15144 | ||||||||||||||||||||||||
| 92 | DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_INIT_FAIL); | - | ||||||||||||||||||||||||
| 93 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 94 | } | - | ||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | return ret; executed 15144 times by 1 test: return ret;Executed by:
| 15144 | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | err: | - | ||||||||||||||||||||||||
| 99 | DSA_free(ret); | - | ||||||||||||||||||||||||
| 100 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 101 | } | - | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | void DSA_free(DSA *r) | - | ||||||||||||||||||||||||
| 104 | { | - | ||||||||||||||||||||||||
| 105 | int i; | - | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | if (r == NULL)
| 3658-17014 | ||||||||||||||||||||||||
| 108 | return; executed 3658 times by 1 test: return;Executed by:
| 3658 | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | CRYPTO_DOWN_REF(&r->references, &i, r->lock); | - | ||||||||||||||||||||||||
| 111 | REF_PRINT_COUNT("DSA", r); | - | ||||||||||||||||||||||||
| 112 | if (i > 0)
| 1870-15144 | ||||||||||||||||||||||||
| 113 | return; executed 1870 times by 1 test: return;Executed by:
| 1870 | ||||||||||||||||||||||||
| 114 | REF_ASSERT_ISNT(i < 0); | - | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | if (r->meth != NULL && r->meth->finish != NULL)
| 0-15144 | ||||||||||||||||||||||||
| 117 | r->meth->finish(r); executed 15144 times by 1 test: r->meth->finish(r);Executed by:
| 15144 | ||||||||||||||||||||||||
| 118 | #ifndef OPENSSL_NO_ENGINE | - | ||||||||||||||||||||||||
| 119 | ENGINE_finish(r->engine); | - | ||||||||||||||||||||||||
| 120 | #endif | - | ||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||
| 122 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); | - | ||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | CRYPTO_THREAD_lock_free(r->lock); | - | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | BN_clear_free(r->p); | - | ||||||||||||||||||||||||
| 127 | BN_clear_free(r->q); | - | ||||||||||||||||||||||||
| 128 | BN_clear_free(r->g); | - | ||||||||||||||||||||||||
| 129 | BN_clear_free(r->pub_key); | - | ||||||||||||||||||||||||
| 130 | BN_clear_free(r->priv_key); | - | ||||||||||||||||||||||||
| 131 | OPENSSL_free(r); | - | ||||||||||||||||||||||||
| 132 | } executed 15144 times by 1 test: end of blockExecuted by:
| 15144 | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | int DSA_up_ref(DSA *r) | - | ||||||||||||||||||||||||
| 135 | { | - | ||||||||||||||||||||||||
| 136 | int i; | - | ||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||
| 138 | if (CRYPTO_UP_REF(&r->references, &i, r->lock) <= 0)
| 0-1870 | ||||||||||||||||||||||||
| 139 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | REF_PRINT_COUNT("DSA", r); | - | ||||||||||||||||||||||||
| 142 | REF_ASSERT_ISNT(i < 2); | - | ||||||||||||||||||||||||
| 143 | return ((i > 1) ? 1 : 0); executed 1870 times by 1 test: return ((i > 1) ? 1 : 0);Executed by:
| 0-1870 | ||||||||||||||||||||||||
| 144 | } | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | int DSA_size(const DSA *r) | - | ||||||||||||||||||||||||
| 147 | { | - | ||||||||||||||||||||||||
| 148 | int ret, i; | - | ||||||||||||||||||||||||
| 149 | ASN1_INTEGER bs; | - | ||||||||||||||||||||||||
| 150 | unsigned char buf[4]; /* 4 bytes looks really small. However, | - | ||||||||||||||||||||||||
| 151 | * i2d_ASN1_INTEGER() will not look beyond | - | ||||||||||||||||||||||||
| 152 | * the first byte, as long as the second | - | ||||||||||||||||||||||||
| 153 | * parameter is NULL. */ | - | ||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||
| 155 | i = BN_num_bits(r->q); | - | ||||||||||||||||||||||||
| 156 | bs.length = (i + 7) / 8; | - | ||||||||||||||||||||||||
| 157 | bs.data = buf; | - | ||||||||||||||||||||||||
| 158 | bs.type = V_ASN1_INTEGER; | - | ||||||||||||||||||||||||
| 159 | /* If the top bit is set the asn1 encoding is 1 larger. */ | - | ||||||||||||||||||||||||
| 160 | buf[0] = 0xff; | - | ||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | i = i2d_ASN1_INTEGER(&bs, NULL); | - | ||||||||||||||||||||||||
| 163 | i += i; /* r and s */ | - | ||||||||||||||||||||||||
| 164 | ret = ASN1_object_size(1, i, V_ASN1_SEQUENCE); | - | ||||||||||||||||||||||||
| 165 | return ret; executed 368 times by 1 test: return ret;Executed by:
| 368 | ||||||||||||||||||||||||
| 166 | } | - | ||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | int DSA_set_ex_data(DSA *d, int idx, void *arg) | - | ||||||||||||||||||||||||
| 169 | { | - | ||||||||||||||||||||||||
| 170 | return CRYPTO_set_ex_data(&d->ex_data, idx, arg); never executed: return CRYPTO_set_ex_data(&d->ex_data, idx, arg); | 0 | ||||||||||||||||||||||||
| 171 | } | - | ||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||
| 173 | void *DSA_get_ex_data(DSA *d, int idx) | - | ||||||||||||||||||||||||
| 174 | { | - | ||||||||||||||||||||||||
| 175 | return CRYPTO_get_ex_data(&d->ex_data, idx); never executed: return CRYPTO_get_ex_data(&d->ex_data, idx); | 0 | ||||||||||||||||||||||||
| 176 | } | - | ||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | int DSA_security_bits(const DSA *d) | - | ||||||||||||||||||||||||
| 179 | { | - | ||||||||||||||||||||||||
| 180 | if (d->p && d->q)
| 0-2017 | ||||||||||||||||||||||||
| 181 | return BN_security_bits(BN_num_bits(d->p), BN_num_bits(d->q)); executed 2017 times by 1 test: return BN_security_bits(BN_num_bits(d->p), BN_num_bits(d->q));Executed by:
| 2017 | ||||||||||||||||||||||||
| 182 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
| 183 | } | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | #ifndef OPENSSL_NO_DH | - | ||||||||||||||||||||||||
| 186 | DH *DSA_dup_DH(const DSA *r) | - | ||||||||||||||||||||||||
| 187 | { | - | ||||||||||||||||||||||||
| 188 | /* | - | ||||||||||||||||||||||||
| 189 | * DSA has p, q, g, optional pub_key, optional priv_key. DH has p, | - | ||||||||||||||||||||||||
| 190 | * optional length, g, optional pub_key, optional priv_key, optional q. | - | ||||||||||||||||||||||||
| 191 | */ | - | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | DH *ret = NULL; | - | ||||||||||||||||||||||||
| 194 | BIGNUM *p = NULL, *q = NULL, *g = NULL, *pub_key = NULL, *priv_key = NULL; | - | ||||||||||||||||||||||||
| 195 | - | |||||||||||||||||||||||||
| 196 | if (r == NULL)
| 0 | ||||||||||||||||||||||||
| 197 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 198 | ret = DH_new(); | - | ||||||||||||||||||||||||
| 199 | if (ret == NULL)
| 0 | ||||||||||||||||||||||||
| 200 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 201 | if (r->p != NULL || r->g != NULL || r->q != NULL) {
| 0 | ||||||||||||||||||||||||
| 202 | if (r->p == NULL || r->g == NULL || r->q == NULL) {
| 0 | ||||||||||||||||||||||||
| 203 | /* Shouldn't happen */ | - | ||||||||||||||||||||||||
| 204 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 205 | } | - | ||||||||||||||||||||||||
| 206 | p = BN_dup(r->p); | - | ||||||||||||||||||||||||
| 207 | g = BN_dup(r->g); | - | ||||||||||||||||||||||||
| 208 | q = BN_dup(r->q); | - | ||||||||||||||||||||||||
| 209 | if (p == NULL || g == NULL || q == NULL || !DH_set0_pqg(ret, p, q, g))
| 0 | ||||||||||||||||||||||||
| 210 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 211 | p = g = q = NULL; | - | ||||||||||||||||||||||||
| 212 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | if (r->pub_key != NULL) {
| 0 | ||||||||||||||||||||||||
| 215 | pub_key = BN_dup(r->pub_key); | - | ||||||||||||||||||||||||
| 216 | if (pub_key == NULL)
| 0 | ||||||||||||||||||||||||
| 217 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 218 | if (r->priv_key != NULL) {
| 0 | ||||||||||||||||||||||||
| 219 | priv_key = BN_dup(r->priv_key); | - | ||||||||||||||||||||||||
| 220 | if (priv_key == NULL)
| 0 | ||||||||||||||||||||||||
| 221 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 222 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 223 | if (!DH_set0_key(ret, pub_key, priv_key))
| 0 | ||||||||||||||||||||||||
| 224 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 225 | } else if (r->priv_key != NULL) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 226 | /* Shouldn't happen */ | - | ||||||||||||||||||||||||
| 227 | goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
| 228 | } | - | ||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||
| 232 | err: | - | ||||||||||||||||||||||||
| 233 | BN_free(p); | - | ||||||||||||||||||||||||
| 234 | BN_free(g); | - | ||||||||||||||||||||||||
| 235 | BN_free(q); | - | ||||||||||||||||||||||||
| 236 | BN_free(pub_key); | - | ||||||||||||||||||||||||
| 237 | BN_free(priv_key); | - | ||||||||||||||||||||||||
| 238 | DH_free(ret); | - | ||||||||||||||||||||||||
| 239 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 240 | } | - | ||||||||||||||||||||||||
| 241 | #endif | - | ||||||||||||||||||||||||
| 242 | - | |||||||||||||||||||||||||
| 243 | void DSA_get0_pqg(const DSA *d, | - | ||||||||||||||||||||||||
| 244 | const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) | - | ||||||||||||||||||||||||
| 245 | { | - | ||||||||||||||||||||||||
| 246 | if (p != NULL)
| 0-10 | ||||||||||||||||||||||||
| 247 | *p = d->p; executed 10 times by 1 test: *p = d->p;Executed by:
| 10 | ||||||||||||||||||||||||
| 248 | if (q != NULL)
| 1-9 | ||||||||||||||||||||||||
| 249 | *q = d->q; executed 9 times by 1 test: *q = d->q;Executed by:
| 9 | ||||||||||||||||||||||||
| 250 | if (g != NULL)
| 1-9 | ||||||||||||||||||||||||
| 251 | *g = d->g; executed 9 times by 1 test: *g = d->g;Executed by:
| 9 | ||||||||||||||||||||||||
| 252 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||
| 254 | int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) | - | ||||||||||||||||||||||||
| 255 | { | - | ||||||||||||||||||||||||
| 256 | /* If the fields p, q and g in d are NULL, the corresponding input | - | ||||||||||||||||||||||||
| 257 | * parameters MUST be non-NULL. | - | ||||||||||||||||||||||||
| 258 | */ | - | ||||||||||||||||||||||||
| 259 | if ((d->p == NULL && p == NULL)
| 0-4 | ||||||||||||||||||||||||
| 260 | || (d->q == NULL && q == NULL)
| 0-4 | ||||||||||||||||||||||||
| 261 | || (d->g == NULL && g == NULL))
| 0-4 | ||||||||||||||||||||||||
| 262 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 263 | - | |||||||||||||||||||||||||
| 264 | if (p != NULL) {
| 0-4 | ||||||||||||||||||||||||
| 265 | BN_free(d->p); | - | ||||||||||||||||||||||||
| 266 | d->p = p; | - | ||||||||||||||||||||||||
| 267 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 268 | if (q != NULL) {
| 0-4 | ||||||||||||||||||||||||
| 269 | BN_free(d->q); | - | ||||||||||||||||||||||||
| 270 | d->q = q; | - | ||||||||||||||||||||||||
| 271 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 272 | if (g != NULL) {
| 0-4 | ||||||||||||||||||||||||
| 273 | BN_free(d->g); | - | ||||||||||||||||||||||||
| 274 | d->g = g; | - | ||||||||||||||||||||||||
| 275 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||
| 277 | return 1; executed 4 times by 1 test: return 1;Executed by:
| 4 | ||||||||||||||||||||||||
| 278 | } | - | ||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | void DSA_get0_key(const DSA *d, | - | ||||||||||||||||||||||||
| 281 | const BIGNUM **pub_key, const BIGNUM **priv_key) | - | ||||||||||||||||||||||||
| 282 | { | - | ||||||||||||||||||||||||
| 283 | if (pub_key != NULL)
| 0-8 | ||||||||||||||||||||||||
| 284 | *pub_key = d->pub_key; executed 8 times by 1 test: *pub_key = d->pub_key;Executed by:
| 8 | ||||||||||||||||||||||||
| 285 | if (priv_key != NULL)
| 0-8 | ||||||||||||||||||||||||
| 286 | *priv_key = d->priv_key; executed 8 times by 1 test: *priv_key = d->priv_key;Executed by:
| 8 | ||||||||||||||||||||||||
| 287 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key) | - | ||||||||||||||||||||||||
| 290 | { | - | ||||||||||||||||||||||||
| 291 | /* If the field pub_key in d is NULL, the corresponding input | - | ||||||||||||||||||||||||
| 292 | * parameters MUST be non-NULL. The priv_key field may | - | ||||||||||||||||||||||||
| 293 | * be left NULL. | - | ||||||||||||||||||||||||
| 294 | */ | - | ||||||||||||||||||||||||
| 295 | if (d->pub_key == NULL && pub_key == NULL)
| 0-3 | ||||||||||||||||||||||||
| 296 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | if (pub_key != NULL) {
| 0-3 | ||||||||||||||||||||||||
| 299 | BN_free(d->pub_key); | - | ||||||||||||||||||||||||
| 300 | d->pub_key = pub_key; | - | ||||||||||||||||||||||||
| 301 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||
| 302 | if (priv_key != NULL) {
| 0-3 | ||||||||||||||||||||||||
| 303 | BN_free(d->priv_key); | - | ||||||||||||||||||||||||
| 304 | d->priv_key = priv_key; | - | ||||||||||||||||||||||||
| 305 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||
| 307 | return 1; executed 3 times by 1 test: return 1;Executed by:
| 3 | ||||||||||||||||||||||||
| 308 | } | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | const BIGNUM *DSA_get0_p(const DSA *d) | - | ||||||||||||||||||||||||
| 311 | { | - | ||||||||||||||||||||||||
| 312 | return d->p; never executed: return d->p; | 0 | ||||||||||||||||||||||||
| 313 | } | - | ||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||
| 315 | const BIGNUM *DSA_get0_q(const DSA *d) | - | ||||||||||||||||||||||||
| 316 | { | - | ||||||||||||||||||||||||
| 317 | return d->q; executed 6 times by 1 test: return d->q;Executed by:
| 6 | ||||||||||||||||||||||||
| 318 | } | - | ||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | const BIGNUM *DSA_get0_g(const DSA *d) | - | ||||||||||||||||||||||||
| 321 | { | - | ||||||||||||||||||||||||
| 322 | return d->g; never executed: return d->g; | 0 | ||||||||||||||||||||||||
| 323 | } | - | ||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||
| 325 | const BIGNUM *DSA_get0_pub_key(const DSA *d) | - | ||||||||||||||||||||||||
| 326 | { | - | ||||||||||||||||||||||||
| 327 | return d->pub_key; never executed: return d->pub_key; | 0 | ||||||||||||||||||||||||
| 328 | } | - | ||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||
| 330 | const BIGNUM *DSA_get0_priv_key(const DSA *d) | - | ||||||||||||||||||||||||
| 331 | { | - | ||||||||||||||||||||||||
| 332 | return d->priv_key; never executed: return d->priv_key; | 0 | ||||||||||||||||||||||||
| 333 | } | - | ||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | void DSA_clear_flags(DSA *d, int flags) | - | ||||||||||||||||||||||||
| 336 | { | - | ||||||||||||||||||||||||
| 337 | d->flags &= ~flags; | - | ||||||||||||||||||||||||
| 338 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | int DSA_test_flags(const DSA *d, int flags) | - | ||||||||||||||||||||||||
| 341 | { | - | ||||||||||||||||||||||||
| 342 | return d->flags & flags; never executed: return d->flags & flags; | 0 | ||||||||||||||||||||||||
| 343 | } | - | ||||||||||||||||||||||||
| 344 | - | |||||||||||||||||||||||||
| 345 | void DSA_set_flags(DSA *d, int flags) | - | ||||||||||||||||||||||||
| 346 | { | - | ||||||||||||||||||||||||
| 347 | d->flags |= flags; | - | ||||||||||||||||||||||||
| 348 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||
| 350 | ENGINE *DSA_get0_engine(DSA *d) | - | ||||||||||||||||||||||||
| 351 | { | - | ||||||||||||||||||||||||
| 352 | return d->engine; never executed: return d->engine; | 0 | ||||||||||||||||||||||||
| 353 | } | - | ||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||
| 355 | int DSA_bits(const DSA *dsa) | - | ||||||||||||||||||||||||
| 356 | { | - | ||||||||||||||||||||||||
| 357 | return BN_num_bits(dsa->p); executed 18 times by 1 test: return BN_num_bits(dsa->p);Executed by:
| 18 | ||||||||||||||||||||||||
| 358 | } | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |