Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/ed25519.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | static void get_hram(unsigned char *hram, const unsigned char *sm, const unsigned char *pk, unsigned char *playground, unsigned long long smlen) | - | ||||||
4 | { | - | ||||||
5 | unsigned long long i; | - | ||||||
6 | - | |||||||
7 | for (i = 0;i < 32
executed 447584 times by 2 tests: playground[i] = sm[i]; Executed by:
| 13987-447584 | ||||||
8 | for (i = 32;i < 64
executed 447584 times by 2 tests: playground[i] = pk[i-32]; Executed by:
| 13987-447584 | ||||||
9 | for (i = 64;i < smlen
executed 4495939 times by 2 tests: playground[i] = sm[i]; Executed by:
| 13987-4495939 | ||||||
10 | - | |||||||
11 | crypto_hash_sha512(hram,playground,smlen); | - | ||||||
12 | } executed 13987 times by 2 tests: end of block Executed by:
| 13987 | ||||||
13 | - | |||||||
14 | - | |||||||
15 | int crypto_sign_ed25519_keypair( | - | ||||||
16 | unsigned char *pk, | - | ||||||
17 | unsigned char *sk | - | ||||||
18 | ) | - | ||||||
19 | { | - | ||||||
20 | crypto_sign_ed25519_ref_sc25519 scsk; | - | ||||||
21 | crypto_sign_ed25519_ref_ge25519 gepk; | - | ||||||
22 | unsigned char extsk[64]; | - | ||||||
23 | int i; | - | ||||||
24 | - | |||||||
25 | arc4random_buf((sk), (32)); | - | ||||||
26 | crypto_hash_sha512(extsk, sk, 32); | - | ||||||
27 | extsk[0] &= 248; | - | ||||||
28 | extsk[31] &= 127; | - | ||||||
29 | extsk[31] |= 64; | - | ||||||
30 | - | |||||||
31 | crypto_sign_ed25519_ref_sc25519_from32bytes(&scsk,extsk); | - | ||||||
32 | - | |||||||
33 | crypto_sign_ed25519_ref_scalarmult_base(&gepk, &scsk); | - | ||||||
34 | crypto_sign_ed25519_ref_pack(pk, &gepk); | - | ||||||
35 | for(i=0;i<32
| 13-416 | ||||||
36 | sk[32 + i] = pk[i]; executed 416 times by 3 tests: sk[32 + i] = pk[i]; Executed by:
| 416 | ||||||
37 | return executed 13 times by 3 tests: 0;return 0; Executed by:
executed 13 times by 3 tests: return 0; Executed by:
| 13 | ||||||
38 | } | - | ||||||
39 | - | |||||||
40 | int crypto_sign_ed25519( | - | ||||||
41 | unsigned char *sm,unsigned long long *smlen, | - | ||||||
42 | const unsigned char *m,unsigned long long mlen, | - | ||||||
43 | const unsigned char *sk | - | ||||||
44 | ) | - | ||||||
45 | { | - | ||||||
46 | crypto_sign_ed25519_ref_sc25519 sck, scs, scsk; | - | ||||||
47 | crypto_sign_ed25519_ref_ge25519 ger; | - | ||||||
48 | unsigned char r[32]; | - | ||||||
49 | unsigned char s[32]; | - | ||||||
50 | unsigned char extsk[64]; | - | ||||||
51 | unsigned long long i; | - | ||||||
52 | unsigned char hmg[64U]; | - | ||||||
53 | unsigned char hram[64U]; | - | ||||||
54 | - | |||||||
55 | crypto_hash_sha512(extsk, sk, 32); | - | ||||||
56 | extsk[0] &= 248; | - | ||||||
57 | extsk[31] &= 127; | - | ||||||
58 | extsk[31] |= 64; | - | ||||||
59 | - | |||||||
60 | *smlen = mlen+64; | - | ||||||
61 | for(i=0;i<mlen
| 65-12296 | ||||||
62 | sm[64 + i] = m[i]; executed 12296 times by 2 tests: sm[64 + i] = m[i]; Executed by:
| 12296 | ||||||
63 | for(i=0;i<32
| 65-2080 | ||||||
64 | sm[32 + i] = extsk[32+i]; executed 2080 times by 2 tests: sm[32 + i] = extsk[32+i]; Executed by:
| 2080 | ||||||
65 | - | |||||||
66 | crypto_hash_sha512(hmg, sm+32, mlen+32); | - | ||||||
67 | - | |||||||
68 | - | |||||||
69 | crypto_sign_ed25519_ref_sc25519_from64bytes(&sck, hmg); | - | ||||||
70 | crypto_sign_ed25519_ref_scalarmult_base(&ger, &sck); | - | ||||||
71 | crypto_sign_ed25519_ref_pack(r, &ger); | - | ||||||
72 | - | |||||||
73 | - | |||||||
74 | for(i=0;i<32
| 65-2080 | ||||||
75 | sm[i] = r[i]; executed 2080 times by 2 tests: sm[i] = r[i]; Executed by:
| 2080 | ||||||
76 | - | |||||||
77 | get_hram(hram, sm, sk+32, sm, mlen+64); | - | ||||||
78 | - | |||||||
79 | crypto_sign_ed25519_ref_sc25519_from64bytes(&scs, hram); | - | ||||||
80 | crypto_sign_ed25519_ref_sc25519_from32bytes(&scsk, extsk); | - | ||||||
81 | crypto_sign_ed25519_ref_sc25519_mul(&scs, &scs, &scsk); | - | ||||||
82 | - | |||||||
83 | crypto_sign_ed25519_ref_sc25519_add(&scs, &scs, &sck); | - | ||||||
84 | - | |||||||
85 | crypto_sign_ed25519_ref_sc25519_to32bytes(s,&scs); | - | ||||||
86 | for(i=0;i<32
| 65-2080 | ||||||
87 | sm[32 + i] = s[i]; executed 2080 times by 2 tests: sm[32 + i] = s[i]; Executed by:
| 2080 | ||||||
88 | - | |||||||
89 | return executed 65 times by 2 tests: 0;return 0; Executed by:
executed 65 times by 2 tests: return 0; Executed by:
| 65 | ||||||
90 | } | - | ||||||
91 | - | |||||||
92 | int crypto_sign_ed25519_open( | - | ||||||
93 | unsigned char *m,unsigned long long *mlen, | - | ||||||
94 | const unsigned char *sm,unsigned long long smlen, | - | ||||||
95 | const unsigned char *pk | - | ||||||
96 | ) | - | ||||||
97 | { | - | ||||||
98 | unsigned int i; | - | ||||||
99 | int ret; | - | ||||||
100 | unsigned char t2[32]; | - | ||||||
101 | crypto_sign_ed25519_ref_ge25519 get1, get2; | - | ||||||
102 | crypto_sign_ed25519_ref_sc25519 schram, scs; | - | ||||||
103 | unsigned char hram[64U]; | - | ||||||
104 | - | |||||||
105 | *mlen = (unsigned long long) -1; | - | ||||||
106 | if (smlen < 64
never executed: -1;return -1; never executed: return -1; | 0-14399 | ||||||
107 | - | |||||||
108 | if (crypto_sign_ed25519_ref_unpackneg_vartime(&get1, pk)
executed 477 times by 1 test: -1;return -1; Executed by:
executed 477 times by 1 test: return -1; Executed by:
| 477-13922 | ||||||
109 | - | |||||||
110 | get_hram(hram,sm,pk,m,smlen); | - | ||||||
111 | - | |||||||
112 | crypto_sign_ed25519_ref_sc25519_from64bytes(&schram, hram); | - | ||||||
113 | - | |||||||
114 | crypto_sign_ed25519_ref_sc25519_from32bytes(&scs, sm+32); | - | ||||||
115 | - | |||||||
116 | crypto_sign_ed25519_ref_double_scalarmult_vartime(&get2, &get1, &schram, &crypto_sign_ed25519_ref_ge25519_base, &scs); | - | ||||||
117 | crypto_sign_ed25519_ref_pack(t2, &get2); | - | ||||||
118 | - | |||||||
119 | ret = crypto_verify_32(sm, t2); | - | ||||||
120 | - | |||||||
121 | if (!ret
| 75-13847 | ||||||
122 | { | - | ||||||
123 | for(i=0;i<smlen-64
| 75-16198 | ||||||
124 | m[i] = sm[i + 64]; executed 16198 times by 2 tests: m[i] = sm[i + 64]; Executed by:
| 16198 | ||||||
125 | *mlen = smlen-64; | - | ||||||
126 | } executed 75 times by 2 tests: end of block Executed by:
| 75 | ||||||
127 | else | - | ||||||
128 | { | - | ||||||
129 | for(i=0;i<smlen-64
| 13847-4467445 | ||||||
130 | m[i] = 0; executed 4467445 times by 1 test: m[i] = 0; Executed by:
| 4467445 | ||||||
131 | } executed 13847 times by 1 test: end of block Executed by:
| 13847 | ||||||
132 | return executed 13922 times by 2 tests: ret;return ret; Executed by:
executed 13922 times by 2 tests: return ret; Executed by:
| 13922 | ||||||
133 | } | - | ||||||
Switch to Source code | Preprocessed file |