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

Enable ed25519 to be built in wasm target with wasm32_c gate #1176

Closed
wants to merge 1 commit into from
Closed
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 @@ -44,7 +44,7 @@ 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"),
(&[], "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
18 changes: 18 additions & 0 deletions tests/ed25519_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ use ring::{
test, test_file,
};

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

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

/// Test vectors from BoringSSL.
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
fn test_signature_ed25519() {
test::run(test_file!("ed25519_tests.txt"), |section, test_case| {
assert_eq!(section, "");
Expand Down Expand Up @@ -63,6 +71,8 @@ fn test_signature_ed25519() {

/// Test vectors from BoringSSL.
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
fn test_signature_ed25519_verify() {
test::run(
test_file!("ed25519_verify_tests.txt"),
Expand Down Expand Up @@ -96,6 +106,8 @@ fn test_signature_verification(
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
fn test_ed25519_from_seed_and_public_key_misuse() {
const PRIVATE_KEY: &[u8] = include_bytes!("ed25519_test_private_key.bin");
const PUBLIC_KEY: &[u8] = include_bytes!("ed25519_test_public_key.bin");
Expand All @@ -113,6 +125,8 @@ fn test_ed25519_from_seed_and_public_key_misuse() {
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
fn test_ed25519_from_pkcs8_unchecked() {
// Just test that we can parse the input.
test::run(
Expand All @@ -135,6 +149,8 @@ fn test_ed25519_from_pkcs8_unchecked() {
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
fn test_ed25519_from_pkcs8() {
// Just test that we can parse the input.
test::run(
Expand All @@ -157,6 +173,8 @@ fn test_ed25519_from_pkcs8() {
}

#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
#[cfg(any(not(target_arch = "wasm32"), feature = "wasm32_c"))]
fn ed25519_test_public_key_coverage() {
const PRIVATE_KEY: &[u8] = include_bytes!("ed25519_test_private_key.p8");
const PUBLIC_KEY: &[u8] = include_bytes!("ed25519_test_public_key.der");
Expand Down