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

signature: Enable Ed25519 support for wasm32 targets. #1440

Merged
merged 1 commit into from
Apr 6, 2022
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 build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const ARM: &str = "arm";

#[rustfmt::skip]
const RING_SRCS: &[(&[&str], &str)] = &[
(&[], "crypto/curve25519/curve25519.c"),
(&[], "crypto/fipsmodule/aes/aes_nohw.c"),
(&[], "crypto/fipsmodule/bn/montgomery.c"),
(&[], "crypto/fipsmodule/bn/montgomery_inv.c"),
Expand All @@ -41,7 +42,6 @@ const RING_SRCS: &[(&[&str], &str)] = &[
(&[], "crypto/poly1305/poly1305.c"),

(&[AARCH64, ARM, X86_64, X86], "crypto/crypto.c"),
(&[AARCH64, ARM, X86_64, X86], "crypto/curve25519/curve25519.c"),
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/ecp_nistz.c"),
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/gfp_p256.c"),
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/gfp_p384.c"),
Expand Down
1 change: 1 addition & 0 deletions src/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ derive_debug_via_id!(Curve);

#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CurveID {
#[cfg(not(target_arch = "wasm32"))]
Curve25519,
P256,
P384,
Expand Down
2 changes: 2 additions & 0 deletions src/ec/curve25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
//! Elliptic curve operations and schemes using Curve25519.

pub mod ed25519;

#[cfg(not(target_arch = "wasm32"))]
pub mod x25519;

mod ops;
Expand Down
1 change: 1 addition & 0 deletions src/ec/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ impl KeyPair {
pub struct Seed {
bytes: [u8; SEED_MAX_BYTES],
curve: &'static Curve,
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
pub(crate) cpu_features: cpu::Features,
}

Expand Down
3 changes: 3 additions & 0 deletions src/ec/suite_b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ pub(crate) fn key_pair_from_bytes(
}

pub mod curve;

#[cfg(not(target_arch = "wasm32"))]
pub mod ecdh;

pub mod ecdsa;

mod ops;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ mod bssl;
mod polyfill;

pub mod aead;

#[cfg(not(target_arch = "wasm32"))]
pub mod agreement;

mod bits;
Expand Down
2 changes: 2 additions & 0 deletions tests/agreement_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

#![cfg(not(target_arch = "wasm32"))]

extern crate alloc;

use ring::{agreement, error, rand, test, test_file};
Expand Down
6 changes: 6 additions & 0 deletions tests/ed25519_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ use ring::{
test, test_file,
};

#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};

#[cfg(target_arch = "wasm32")]
wasm_bindgen_test_configure!(run_in_browser);

/// Test vectors from BoringSSL.
#[test]
fn test_signature_ed25519() {
Expand Down