Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use _alt versions on ARM #4

Merged
merged 3 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "thirdparty/s2n-bignum"]
path = thirdparty/s2n-bignum
url = https://github.com/awslabs/s2n-bignum.git
url = https://github.com/ctz/s2n-bignum.git
[submodule "thirdparty/wycheproof"]
path = thirdparty/wycheproof
url = https://github.com/C2SP/wycheproof.git
28 changes: 16 additions & 12 deletions admin/parse-asm/driver.p256.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,13 @@

# aarch64
with open(
"../../thirdparty/s2n-bignum/arm/p256/bignum_montsqr_p256.S"
"../../thirdparty/s2n-bignum/arm/p256/bignum_montsqr_p256_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/bignum_montsqr_p256.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"bignum_montsqr_p256",
"bignum_montsqr_p256_alt",
parameter_map=[
("inout", "x0", "z.as_mut_ptr() => _"),
("inout", "x1", "x.as_ptr() => _"),
Expand All @@ -360,13 +360,13 @@
parse_file(input, d)

with open(
"../../thirdparty/s2n-bignum/arm/p256/bignum_montmul_p256.S"
"../../thirdparty/s2n-bignum/arm/p256/bignum_montmul_p256_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/bignum_montmul_p256.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"bignum_montmul_p256",
"bignum_montmul_p256_alt",
parameter_map=[
("inout", "x0", "z.as_mut_ptr() => _"),
("inout", "x1", "x.as_ptr() => _"),
Expand Down Expand Up @@ -579,12 +579,12 @@
)
parse_file(input, d)

with open("../../thirdparty/s2n-bignum/arm/p256/p256_montjadd.S") as input, open(
"../../graviola/src/low/aarch64/p256_montjadd.rs", "w"
) as output:
with open(
"../../thirdparty/s2n-bignum/arm/p256/p256_montjadd_alt.S"
) as input, open("../../graviola/src/low/aarch64/p256_montjadd.rs", "w") as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"p256_montjadd",
"p256_montjadd_alt",
parameter_map=[
("inout", "x0", "p3.as_mut_ptr() => _"),
("inout", "x1", "p1.as_ptr() => _"),
Expand All @@ -594,12 +594,14 @@
)
parse_file(input, d)

with open("../../thirdparty/s2n-bignum/arm/p256/p256_montjmixadd.S") as input, open(
with open(
"../../thirdparty/s2n-bignum/arm/p256/p256_montjmixadd_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/p256_montjmixadd.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"p256_montjmixadd",
"p256_montjmixadd_alt",
parameter_map=[
("inout", "x0", "p3.as_mut_ptr() => _"),
("inout", "x1", "p1.as_ptr() => _"),
Expand All @@ -609,12 +611,14 @@
)
parse_file(input, d)

with open("../../thirdparty/s2n-bignum/arm/p256/p256_montjdouble.S") as input, open(
with open(
"../../thirdparty/s2n-bignum/arm/p256/p256_montjdouble_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/p256_montjdouble.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"p256_montjdouble",
"p256_montjdouble_alt",
parameter_map=[
("inout", "x0", "p3.as_mut_ptr() => _"),
("inout", "x1", "p1.as_ptr() => _"),
Expand Down
22 changes: 12 additions & 10 deletions admin/parse-asm/driver.p384.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@

# aarch64
with open(
"../../thirdparty/s2n-bignum/arm/p384/bignum_montsqr_p384.S"
"../../thirdparty/s2n-bignum/arm/p384/bignum_montsqr_p384_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/bignum_montsqr_p384.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"bignum_montsqr_p384",
"bignum_montsqr_p384_alt",
parameter_map=[
("inout", "x0", "z.as_mut_ptr() => _"),
("inout", "x1", "x.as_ptr() => _"),
Expand All @@ -175,13 +175,13 @@
parse_file(input, d)

with open(
"../../thirdparty/s2n-bignum/arm/p384/bignum_montmul_p384.S"
"../../thirdparty/s2n-bignum/arm/p384/bignum_montmul_p384_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/bignum_montmul_p384.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"bignum_montmul_p384",
"bignum_montmul_p384_alt",
parameter_map=[
("inout", "x0", "z.as_mut_ptr() => _"),
("inout", "x1", "x.as_ptr() => _"),
Expand Down Expand Up @@ -282,12 +282,12 @@
)
parse_file(input, d)

with open("../../thirdparty/s2n-bignum/arm/p384/p384_montjadd.S") as input, open(
"../../graviola/src/low/aarch64/p384_montjadd.rs", "w"
) as output:
with open(
"../../thirdparty/s2n-bignum/arm/p384/p384_montjadd_alt.S"
) as input, open("../../graviola/src/low/aarch64/p384_montjadd.rs", "w") as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"p384_montjadd",
"p384_montjadd_alt",
parameter_map=[
("inout", "x0", "p3.as_mut_ptr() => _"),
("inout", "x1", "p1.as_ptr() => _"),
Expand All @@ -297,12 +297,14 @@
)
parse_file(input, d)

with open("../../thirdparty/s2n-bignum/arm/p384/p384_montjdouble.S") as input, open(
with open(
"../../thirdparty/s2n-bignum/arm/p384/p384_montjdouble_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/p384_montjdouble.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"p384_montjdouble",
"p384_montjdouble_alt",
parameter_map=[
("inout", "x0", "p3.as_mut_ptr() => _"),
("inout", "x1", "p1.as_ptr() => _"),
Expand Down
14 changes: 7 additions & 7 deletions admin/parse-asm/driver.x25519.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
parse_file(input, d)

with open(
"../../thirdparty/s2n-bignum/arm/curve25519/curve25519_x25519.S"
"../../thirdparty/s2n-bignum/arm/curve25519/curve25519_x25519_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/curve25519_x25519.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.emit_rust_function(
"curve25519_x25519",
"curve25519_x25519_alt",
parameter_map=[
("inout", "x0", "res.as_mut_ptr() => _"),
("inout", "x1", "scalar.as_ptr() => _"),
Expand All @@ -60,16 +60,16 @@
parse_file(input, d)

with open(
"../../thirdparty/s2n-bignum/arm/curve25519/curve25519_x25519base.S"
"../../thirdparty/s2n-bignum/arm/curve25519/curve25519_x25519base_alt.S"
) as input, open(
"../../graviola/src/low/aarch64/curve25519_x25519base.rs", "w"
) as output:
d = RustDriver(output, Architecture_aarch64)
d.add_const_symbol("curve25519_x25519base_edwards25519_0g")
d.add_const_symbol("curve25519_x25519base_edwards25519_8g")
d.add_const_symbol("curve25519_x25519base_edwards25519_gtable")
d.add_const_symbol("curve25519_x25519base_alt_edwards25519_0g")
d.add_const_symbol("curve25519_x25519base_alt_edwards25519_8g")
d.add_const_symbol("curve25519_x25519base_alt_edwards25519_gtable")
d.emit_rust_function(
"curve25519_x25519base",
"curve25519_x25519base_alt",
parameter_map=[
("inout", "x0", "res.as_mut_ptr() => _"),
("inout", "x1", "scalar.as_ptr() => _"),
Expand Down
2 changes: 2 additions & 0 deletions admin/parse-asm/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def parse_file(f, visit):
elif l.startswith("//"):
visit(Type.COMMENT, l[2:])
elif l.startswith("#define "):
if "//" in l:
l, _ = l.split("//", maxsplit=1)
_def, name, val = l.split(maxsplit=2)
if len(tokenise(name)) != 1:
# needs full tokenisation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::low::macros::*;
// (uint64_t *z, uint64_t *table, uint64_t height, uint64_t idx);
//
// Initial version written by Hanno Becker
// Standard ARM ABI: X0 = z, X1 = table, X2 = height, X4 = idx
// Standard ARM ABI: X0 = z, X1 = table, X2 = height, X3 = idx
// ----------------------------------------------------------------------------

// *****************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::low::macros::*;
// (uint64_t *z, uint64_t *table, uint64_t height, uint64_t idx);
//
// Initial version written by Hanno Becker
// Standard ARM ABI: X0 = z, X1 = table, X2 = height, X4 = idx
// Standard ARM ABI: X0 = z, X1 = table, X2 = height, X3 = idx
// ----------------------------------------------------------------------------

// *****************************************************
Expand Down
Loading