Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_mpi.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | int BN_bn2mpi(const BIGNUM *a, unsigned char *d) | - | ||||||||||||
3 | { | - | ||||||||||||
4 | int bits; | - | ||||||||||||
5 | int num = 0; | - | ||||||||||||
6 | int ext = 0; | - | ||||||||||||
7 | long l; | - | ||||||||||||
8 | - | |||||||||||||
9 | bits = BN_num_bits(a); | - | ||||||||||||
10 | num = (bits + 7) / 8; | - | ||||||||||||
11 | if (bits > 0
| 2-10 | ||||||||||||
12 | ext = ((bits & 0x07) == 0); | - | ||||||||||||
13 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||
14 | if (d ==
| 6 | ||||||||||||
15 | ((void *)0)
| 6 | ||||||||||||
16 | ) | - | ||||||||||||
17 | return executed 6 times by 1 test: (num + 4 + ext);return (num + 4 + ext); Executed by:
executed 6 times by 1 test: return (num + 4 + ext); Executed by:
| 6 | ||||||||||||
18 | - | |||||||||||||
19 | l = num + ext; | - | ||||||||||||
20 | d[0] = (unsigned char)(l >> 24) & 0xff; | - | ||||||||||||
21 | d[1] = (unsigned char)(l >> 16) & 0xff; | - | ||||||||||||
22 | d[2] = (unsigned char)(l >> 8) & 0xff; | - | ||||||||||||
23 | d[3] = (unsigned char)(l) & 0xff; | - | ||||||||||||
24 | if (ext
| 1-5 | ||||||||||||
25 | d[4] = 0; executed 1 time by 1 test: d[4] = 0; Executed by:
| 1 | ||||||||||||
26 | num = BN_bn2bin(a, &(d[4 + ext])); | - | ||||||||||||
27 | if (a->neg
| 2-4 | ||||||||||||
28 | d[4] |= 0x80; executed 2 times by 1 test: d[4] |= 0x80; Executed by:
| 2 | ||||||||||||
29 | return executed 6 times by 1 test: (num + 4 + ext);return (num + 4 + ext); Executed by:
executed 6 times by 1 test: return (num + 4 + ext); Executed by:
| 6 | ||||||||||||
30 | } | - | ||||||||||||
31 | - | |||||||||||||
32 | BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *ain) | - | ||||||||||||
33 | { | - | ||||||||||||
34 | long len; | - | ||||||||||||
35 | int neg = 0; | - | ||||||||||||
36 | BIGNUM *a = | - | ||||||||||||
37 | ((void *)0) | - | ||||||||||||
38 | ; | - | ||||||||||||
39 | - | |||||||||||||
40 | if (n < 4
| 0-6 | ||||||||||||
41 | ERR_put_error(3,(112),(106),__FILE__,49); | - | ||||||||||||
42 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
43 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
44 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
45 | } | - | ||||||||||||
46 | len = ((long)d[0] << 24) | ((long)d[1] << 16) | ((int)d[2] << 8) | (int) | - | ||||||||||||
47 | d[3]; | - | ||||||||||||
48 | if ((
| 0-6 | ||||||||||||
49 | ERR_put_error(3,(112),(104),__FILE__,55); | - | ||||||||||||
50 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
51 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
52 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
53 | } | - | ||||||||||||
54 | - | |||||||||||||
55 | if (ain ==
| 0-6 | ||||||||||||
56 | ((void *)0)
| 0-6 | ||||||||||||
57 | ) | - | ||||||||||||
58 | a = BN_new(); executed 6 times by 1 test: a = BN_new(); Executed by:
| 6 | ||||||||||||
59 | else | - | ||||||||||||
60 | a = ain; never executed: a = ain; | 0 | ||||||||||||
61 | - | |||||||||||||
62 | if (a ==
| 0-6 | ||||||||||||
63 | ((void *)0)
| 0-6 | ||||||||||||
64 | ) | - | ||||||||||||
65 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
66 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
67 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
68 | - | |||||||||||||
69 | if (len == 0
| 1-5 | ||||||||||||
70 | a->neg = 0; | - | ||||||||||||
71 | a->top = 0; | - | ||||||||||||
72 | return executed 1 time by 1 test: a;return a; Executed by:
executed 1 time by 1 test: return a; Executed by:
| 1 | ||||||||||||
73 | } | - | ||||||||||||
74 | d += 4; | - | ||||||||||||
75 | if ((*
| 2-3 | ||||||||||||
76 | neg = 1; executed 2 times by 1 test: neg = 1; Executed by:
| 2 | ||||||||||||
77 | if (BN_bin2bn(d, (int)len, a) ==
| 0-5 | ||||||||||||
78 | ((void *)0)
| 0-5 | ||||||||||||
79 | ) { | - | ||||||||||||
80 | if (ain ==
| 0 | ||||||||||||
81 | ((void *)0)
| 0 | ||||||||||||
82 | ) | - | ||||||||||||
83 | BN_free(a); never executed: BN_free(a); | 0 | ||||||||||||
84 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
85 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
86 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
87 | } | - | ||||||||||||
88 | a->neg = neg; | - | ||||||||||||
89 | if (neg
| 2-3 | ||||||||||||
90 | BN_clear_bit(a, BN_num_bits(a) - 1); | - | ||||||||||||
91 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
92 | ; | - | ||||||||||||
93 | return executed 5 times by 1 test: a;return a; Executed by:
executed 5 times by 1 test: return a; Executed by:
| 5 | ||||||||||||
94 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |