| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | | - |
| 50 | | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | | - |
| 55 | | - |
| 56 | | - |
| 57 | | - |
| 58 | | - |
| 59 | #include <stdio.h> | - |
| 60 | | - |
| 61 | #include <openssl/bn.h> | - |
| 62 | #include <openssl/dh.h> | - |
| 63 | | - |
| 64 | | - |
| 65 | | - |
| 66 | | - |
| 67 | | - |
| 68 | | - |
| 69 | | - |
| 70 | | - |
| 71 | | - |
| 72 | | - |
| 73 | | - |
| 74 | int | - |
| 75 | DH_check(const DH *dh, int *ret) | - |
| 76 | { | - |
| 77 | int ok = 0; | - |
| 78 | BN_CTX *ctx = NULL; | - |
| 79 | BN_ULONG l; | - |
| 80 | BIGNUM *q = NULL; | - |
| 81 | | - |
| 82 | *ret = 0; | - |
| 83 | ctx = BN_CTX_new(); | - |
| 84 | if (ctx == NULL)| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| 0-1 |
| 85 | goto err; never executed: goto err; | 0 |
| 86 | q = BN_new(); | - |
| 87 | if (q == NULL)| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| 0-1 |
| 88 | goto err; never executed: goto err; | 0 |
| 89 | | - |
| 90 | if (BN_is_word(dh->g, DH_GENERATOR_2)) {| TRUE | evaluated 1 time by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-1 |
| 91 | l = BN_mod_word(dh->p, 24); | - |
| 92 | if (l == (BN_ULONG)-1)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 93 | goto err; never executed: goto err; | 0 |
| 94 | if (l != 11)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 95 | *ret |= DH_NOT_SUITABLE_GENERATOR; never executed: *ret |= 0x08; | 0 |
| 96 | } else if (BN_is_word(dh->g, DH_GENERATOR_5)) { never executed: end of block | TRUE | evaluated 1 time by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 1 time by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | evaluated 1 time by 1 test | | FALSE | never evaluated |
| 0-1 |
| 97 | l = BN_mod_word(dh->p, 10); | - |
| 98 | if (l == (BN_ULONG)-1)| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| 0-1 |
| 99 | goto err; never executed: goto err; | 0 |
| 100 | if (l != 3 && l != 7)| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-1 |
| 101 | *ret |= DH_NOT_SUITABLE_GENERATOR; never executed: *ret |= 0x08; | 0 |
| 102 | } elseexecuted 1 time by 1 test: end of block | 1 |
| 103 | *ret |= DH_UNABLE_TO_CHECK_GENERATOR; never executed: *ret |= 0x04; | 0 |
| 104 | | - |
| 105 | if (!BN_is_prime_ex(dh->p, BN_prime_checks, ctx, NULL))| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| 0-1 |
| 106 | *ret |= DH_CHECK_P_NOT_PRIME; never executed: *ret |= 0x01; | 0 |
| 107 | else { | - |
| 108 | if (!BN_rshift1(q, dh->p))| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| 0-1 |
| 109 | goto err; never executed: goto err; | 0 |
| 110 | if (!BN_is_prime_ex(q, BN_prime_checks, ctx, NULL))| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| 0-1 |
| 111 | *ret |= DH_CHECK_P_NOT_SAFE_PRIME; never executed: *ret |= 0x02; | 0 |
| 112 | }executed 1 time by 1 test: end of block | 1 |
| 113 | ok = 1; | - |
| 114 | err:code before this statement executed 1 time by 1 test: err: | 1 |
| 115 | BN_CTX_free(ctx); | - |
| 116 | BN_free(q); | - |
| 117 | return ok;executed 1 time by 1 test: return ok; | 1 |
| 118 | } | - |
| 119 | | - |
| 120 | int | - |
| 121 | DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) | - |
| 122 | { | - |
| 123 | BIGNUM *q = NULL; | - |
| 124 | | - |
| 125 | *ret = 0; | - |
| 126 | q = BN_new(); | - |
| 127 | if (q == NULL)| TRUE | never evaluated | | FALSE | evaluated 60 times by 3 tests |
| 0-60 |
| 128 | return 0; never executed: return 0; | 0 |
| 129 | BN_set_word(q, 1); | - |
| 130 | if (BN_cmp(pub_key, q) <= 0)| TRUE | never evaluated | | FALSE | evaluated 60 times by 3 tests |
| 0-60 |
| 131 | *ret |= DH_CHECK_PUBKEY_TOO_SMALL; never executed: *ret |= 0x01; | 0 |
| 132 | BN_copy(q, dh->p); | - |
| 133 | BN_sub_word(q, 1); | - |
| 134 | if (BN_cmp(pub_key, q) >= 0)| TRUE | never evaluated | | FALSE | evaluated 60 times by 3 tests |
| 0-60 |
| 135 | *ret |= DH_CHECK_PUBKEY_TOO_LARGE; never executed: *ret |= 0x02; | 0 |
| 136 | | - |
| 137 | BN_free(q); | - |
| 138 | return 1;executed 60 times by 3 tests: return 1; | 60 |
| 139 | } | - |
| | |