-
Notifications
You must be signed in to change notification settings - Fork 677
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
Add MIPS little-endian support #1181
Conversation
build.rs x
And disable point_mixed_test on mips64 where the codepath is unused. Conditionally exclude the corresponding C code as well.
nistz256: N0 for p256 is TOBN(0x0, 0x1)
Don't require a specialized implementation of field element addition for each curve; instead share an implementation between RSA and ECC. Refactor the code to avoid needing `elem_sum`.
Use Fiat Crypto for non-x86_64 platforms, like BoringSSL. Continue using the nistz256 code on Windows, differently from BoringSSL. Make *ring* more consistent with BoringSSL.
Assume by default that an operating system does not have an ABI compatible with the PerlAsm sources. Add all the operating systems that we've explicitly added support for to the allowlist. Avoid trying to build or use the PerlAsm code for those targets. On top of this, we can build fallback logic for using Rust (or C) implementations for those targets that aren't compatible with the assembly.
I think we're getting very close to being able to merge this, as I've merged some of the prerequisite work recently. I'm hoping to sort out #1174 and get it merged this weekend. |
PR #1174 is merged, which I think is the last prerequisite to this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading this PR, it seems like a lot can be simplified.
Regarding the ECC stuff, if MIPS won't work without changes to the ECC code, then I guess we should do those changes to the ECC code in a separate PR from this MIPS-specific PR.
@@ -0,0 +1,119 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now have src/aead/chacha/fallback.rs so we don't need this file any more.
@@ -1 +1,2 @@ | |||
ecp_nistz256_table.inl linguist-generated=true | |||
p256-x86_64-table.h linguist-generated=true | |||
p256_table.h linguist-generated=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like all this ECC stuff can be deleted now. I think you can revert all crypto/fipsmodule/ec stuff.
target_arch = "arm", | ||
target_arch = "x86_64", | ||
target_arch = "x86" | ||
))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole function is already guarded by #[cfg(target_arch = "x86_64")]
so this isn't needed.
#[inline] | ||
fn detect_implementation(_cpu: cpu::Features) -> Implementation { | ||
Implementation::Fallback | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing this, change cpu.rs so that you can construct a no-op cpu::Features
on MIPS. In fact, I think I already did that for wasm32, so I think you can just delete all of these changes.
m.limbs.len(), | ||
) | ||
} | ||
limb::limbs_add_assign_mod(&mut a.limbs, &b.limbs, &m.limbs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change is needed for this PR? Otherwise, PLMK why it is.
#[cfg_attr( | ||
not(any(target_arch = "aarch64", target_arch = "arm")), | ||
allow(dead_code) | ||
)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this would be needed in this PR, but not needed already. Maybe this can be removed now?
.private_key_ops | ||
.common | ||
.elem_add(&mut r, &public_key_ops.common.n); | ||
if sig_r_equals_x(self.ops, &r, &x, &z2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this needs to change now. Could you explain?
OK, then let's close this PR and try to build the final PR in #1120 on top of the code that's already there, trying to minimize the changes. Trying to port the code from PR #943 seems kind of unworkable since we don't understand that PR and also for IPR reasons. |
This commit ports the changes from briansmith#1181 into the updated codebase The following command is working: > cross build --target mipsel-unknown-linux-musl But tests are still not working: > cross test --target mipsel-unknown-linux-musl
This is an attempt to add #562 MIPS support, starting with Little Endian platforms.
This includes the merge of several different PRs and fixes to match the latest code in the main branch, such as:
Tests on other platforms (Windows, Linux) still works. There are errors when running on mips, to be fixed yet. So far, Big Endian support is not present, as many of the BoringSSL files don't support it.
Failed tests with `cross test --target mipsel-unknown-linux-musl`