-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from formosa-crypto/feature/curve25519
curve25519: mulx .s size ++ refactor to isolate loads
- Loading branch information
Showing
17 changed files
with
391 additions
and
275 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/crypto_scalarmult/curve25519/amd64/common/51/decode_u5.jinc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
inline fn __decode_u_coordinate5(reg u64[4] t) -> reg u64[5] | ||
{ | ||
reg u64[5] u; | ||
reg u64 mask; | ||
|
||
mask = 0x7ffffffffffff; | ||
|
||
//u[0] = t[0] & mask; // 51; 13 left | ||
u[0] = t[0]; | ||
u[0] &= mask; | ||
|
||
//u[1] = (t[1] << 13) || (t[0] >> 51) & mask; // 38; 26 left | ||
u[1] = t[1]; | ||
u[1] <<= 13; | ||
t[0] >>= 51; | ||
u[1] |= t[0]; | ||
u[1] &= mask; | ||
|
||
//u[2] = (t[2] << 26) || (t[1] >> 38) & mask; // 25; 39 left | ||
u[2] = t[2]; | ||
u[2] <<= 26; | ||
t[1] >>= 38; | ||
u[2] |= t[1]; | ||
u[2] &= mask; | ||
|
||
//u[3] = (t[3] << 39) || (t[2] >> 25) & mask; // 12; '52' left | ||
u[3] = t[3]; | ||
u[3] <<= 39; | ||
t[2] >>= 25; | ||
u[3] |= t[2]; | ||
u[3] &= mask; | ||
|
||
//u[4] = (t[3] >> 12) & mask; | ||
u[4] = t[3]; | ||
u[4] >>= 12; | ||
u[4] &= mask; | ||
|
||
return u; | ||
} | ||
|
||
inline fn __decode_u_coordinate_base5() -> reg u64[5] | ||
{ | ||
reg u64[5] u; | ||
|
||
u[0] = 9; | ||
u[1] = 0; | ||
u[2] = 0; | ||
u[3] = 0; | ||
u[4] = 0; | ||
|
||
return u; | ||
} | ||
|
56 changes: 56 additions & 0 deletions
56
src/crypto_scalarmult/curve25519/amd64/common/51/init_points5.jinc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
inline fn __init_points5( | ||
reg u64[5] initr) | ||
-> | ||
stack u64[5], | ||
reg u64[5], | ||
stack u64[5], | ||
stack u64[5] | ||
{ | ||
inline int i; | ||
stack u64[5] x2 x3 z3; | ||
reg u64[5] z2r; | ||
reg u64 z; | ||
|
||
?{}, z = #set0(); | ||
|
||
x2[0] = 1; | ||
z2r[0] = 0; | ||
x3 = #copy(initr); | ||
z3[0] = 1; | ||
|
||
for i=1 to 5 | ||
{ x2[i] = z; | ||
z2r[i] = z; | ||
z3[i] = z; | ||
} | ||
|
||
// (1, 0, init, 1) | ||
return x2, z2r, x3, z3; | ||
} | ||
|
||
inline fn __init_points5_x3() | ||
-> | ||
stack u64[5], | ||
reg u64[5], | ||
stack u64[5] | ||
{ | ||
inline int i; | ||
stack u64[5] f1s f3s; | ||
reg u64[5] f2; | ||
reg u64 z; | ||
|
||
?{}, z = #set0(); | ||
|
||
f1s[0] = 1; | ||
f2[0] = 1; | ||
f3s[0] = 1; | ||
|
||
for i=1 to 5 | ||
{ f1s[i] = z; | ||
f2[i] = z; | ||
f3s[i] = z; | ||
} | ||
|
||
return f1s, f2, f3s; | ||
} | ||
|
113 changes: 0 additions & 113 deletions
113
src/crypto_scalarmult/curve25519/amd64/common/51/load5.jinc
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/crypto_scalarmult/curve25519/amd64/common/64/decode_u4.jinc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
inline fn __decode_u_coordinate4(reg u64[4] u) -> reg u64[4] | ||
{ | ||
u[3] &= 0x7fffffffffffffff; | ||
return u; | ||
} | ||
|
||
inline fn __decode_u_coordinate_base4() -> reg u64[4] | ||
{ | ||
reg u64[4] u; | ||
|
||
u[0] = 9; | ||
u[1] = 0; | ||
u[2] = 0; | ||
u[3] = 0; | ||
|
||
return u; | ||
} | ||
|
24 changes: 0 additions & 24 deletions
24
...ult/curve25519/amd64/common/64/load4.jinc → ...ve25519/amd64/common/64/init_points4.jinc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/crypto_scalarmult/curve25519/amd64/common/decode_scalar.jinc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
inline fn __decode_scalar(reg u64[4] k) -> stack u8[32] | ||
{ | ||
inline int i; | ||
stack u8[32] ks; | ||
|
||
for i=0 to 4 | ||
{ ks[u64 i] = k[i]; } | ||
|
||
ks[0] &= 0xf8; | ||
ks[31] &= 0x7f; | ||
ks[31] |= 0x40; | ||
|
||
return ks; | ||
} | ||
|
||
inline fn __decode_scalar_shl1(reg u64[4] k) -> stack u64[4] | ||
{ | ||
stack u64[4] ks; | ||
|
||
k[3] <<= 1; | ||
k[0] &= 0xfffffffffffffff8; | ||
k[3] |= 0x8000000000000000; | ||
|
||
ks = #copy(k); | ||
|
||
return ks; | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
src/crypto_scalarmult/curve25519/amd64/common/load_store4.jinc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
inline fn __load4(reg u64 p) -> reg u64[4] | ||
{ | ||
inline int i; | ||
reg u64[4] a; | ||
|
||
for i=0 to 4 | ||
{ a[i] = [p + 8*i]; } | ||
|
||
return a; | ||
} | ||
|
||
inline fn __store4(reg u64 p, reg u64[4] a) | ||
{ | ||
inline int i; | ||
|
||
for i=0 to 4 | ||
{ [p + 8*i] = a[i]; } | ||
} | ||
|
Oops, something went wrong.