| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/x_bignum.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
| 3 | static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
| 4 | - | |||||||||||||
| 5 | static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, | - | ||||||||||||
| 6 | const ASN1_ITEM *it); | - | ||||||||||||
| 7 | static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, | - | ||||||||||||
| 8 | int utype, char *free_cont, const ASN1_ITEM *it); | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | static ASN1_PRIMITIVE_FUNCS bignum_pf = { | - | ||||||||||||
| 11 | - | |||||||||||||
| 12 | ((void *)0) | - | ||||||||||||
| 13 | , | - | ||||||||||||
| 14 | 0, | - | ||||||||||||
| 15 | bn_new, | - | ||||||||||||
| 16 | bn_free, | - | ||||||||||||
| 17 | 0, | - | ||||||||||||
| 18 | bn_c2i, | - | ||||||||||||
| 19 | bn_i2c | - | ||||||||||||
| 20 | }; | - | ||||||||||||
| 21 | - | |||||||||||||
| 22 | const ASN1_ITEM BIGNUM_it = { | - | ||||||||||||
| 23 | .itype = 0x0, | - | ||||||||||||
| 24 | .utype = 2, | - | ||||||||||||
| 25 | .templates = | - | ||||||||||||
| 26 | ((void *)0) | - | ||||||||||||
| 27 | , | - | ||||||||||||
| 28 | .tcount = 0, | - | ||||||||||||
| 29 | .funcs = &bignum_pf, | - | ||||||||||||
| 30 | .size = 0, | - | ||||||||||||
| 31 | .sname = "BIGNUM", | - | ||||||||||||
| 32 | }; | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | const ASN1_ITEM CBIGNUM_it = { | - | ||||||||||||
| 35 | .itype = 0x0, | - | ||||||||||||
| 36 | .utype = 2, | - | ||||||||||||
| 37 | .templates = | - | ||||||||||||
| 38 | ((void *)0) | - | ||||||||||||
| 39 | , | - | ||||||||||||
| 40 | .tcount = 0, | - | ||||||||||||
| 41 | .funcs = &bignum_pf, | - | ||||||||||||
| 42 | .size = 0, | - | ||||||||||||
| 43 | .sname = "BIGNUM", | - | ||||||||||||
| 44 | }; | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | static int | - | ||||||||||||
| 47 | bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
| 48 | { | - | ||||||||||||
| 49 | *pval = (ASN1_VALUE *)BN_new(); | - | ||||||||||||
| 50 | if (*
| 0-2403 | ||||||||||||
| 51 | return executed 2403 times by 7 tests: 1;return 1;Executed by:
executed 2403 times by 7 tests: return 1;Executed by:
| 2403 | ||||||||||||
| 52 | else | - | ||||||||||||
| 53 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 54 | } | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | static void | - | ||||||||||||
| 57 | bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
| 58 | { | - | ||||||||||||
| 59 | if (*
| 0-1216 | ||||||||||||
| 60 | ((void *)0)
| 0-1216 | ||||||||||||
| 61 | ) | - | ||||||||||||
| 62 | return; never executed: return; | 0 | ||||||||||||
| 63 | BN_clear_free((BIGNUM *)*pval); | - | ||||||||||||
| 64 | *pval = | - | ||||||||||||
| 65 | ((void *)0) | - | ||||||||||||
| 66 | ; | - | ||||||||||||
| 67 | } executed 1216 times by 1 test: end of blockExecuted by:
| 1216 | ||||||||||||
| 68 | - | |||||||||||||
| 69 | static int | - | ||||||||||||
| 70 | bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const ASN1_ITEM *it) | - | ||||||||||||
| 71 | { | - | ||||||||||||
| 72 | BIGNUM *bn; | - | ||||||||||||
| 73 | int pad, len; | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | if (*
| 0-5650 | ||||||||||||
| 76 | ((void *)0)
| 0-5650 | ||||||||||||
| 77 | ) | - | ||||||||||||
| 78 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||
| 79 | bn = (BIGNUM *)*pval; | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | if (BN_num_bits(bn) & 0x7
| 1931-3719 | ||||||||||||
| 82 | pad = 0; executed 3719 times by 3 tests: pad = 0;Executed by:
| 3719 | ||||||||||||
| 83 | else | - | ||||||||||||
| 84 | pad = 1; executed 1931 times by 4 tests: pad = 1;Executed by:
| 1931 | ||||||||||||
| 85 | if (cont
| 1528-4122 | ||||||||||||
| 86 | if (pad
| 517-1011 | ||||||||||||
| 87 | * executed 517 times by 4 tests: cont++ = 0;*cont++ = 0;Executed by:
executed 517 times by 4 tests: *cont++ = 0;Executed by:
| 517 | ||||||||||||
| 88 | len = BN_bn2bin(bn, cont); | - | ||||||||||||
| 89 | } executed 1528 times by 4 tests: elseend of blockExecuted by:
| 1528 | ||||||||||||
| 90 | len = ((BN_num_bits(bn)+7)/8); executed 4122 times by 4 tests: len = ((BN_num_bits(bn)+7)/8);Executed by:
| 4122 | ||||||||||||
| 91 | return executed 5650 times by 4 tests: pad + len;return pad + len;Executed by:
executed 5650 times by 4 tests: return pad + len;Executed by:
| 5650 | ||||||||||||
| 92 | } | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | static int | - | ||||||||||||
| 95 | bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, | - | ||||||||||||
| 96 | char *free_cont, const ASN1_ITEM *it) | - | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 | BIGNUM *bn; | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | if (*
| 912-1187 | ||||||||||||
| 101 | ((void *)0)
| 912-1187 | ||||||||||||
| 102 | ) { | - | ||||||||||||
| 103 | if (bn_new(pval, it) == 0
| 0-1187 | ||||||||||||
| 104 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 105 | } executed 1187 times by 6 tests: end of blockExecuted by:
| 1187 | ||||||||||||
| 106 | bn = (BIGNUM *)*pval; | - | ||||||||||||
| 107 | if (!BN_bin2bn(cont, len, bn)
| 0-2099 | ||||||||||||
| 108 | bn_free(pval, it); | - | ||||||||||||
| 109 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 110 | } | - | ||||||||||||
| 111 | return executed 2099 times by 7 tests: 1;return 1;Executed by:
executed 2099 times by 7 tests: return 1;Executed by:
| 2099 | ||||||||||||
| 112 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |