Skip to content

Commit f6263d9

Browse files
author
Surkov, Kirill
committed
Enable rsa for wasm32-unknown-unknown targets
1 parent 6dcfe73 commit f6263d9

File tree

5 files changed

+221
-32
lines changed

5 files changed

+221
-32
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

identity/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ zeroize = { version = "1.8", optional = true }
3131
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
3232
ring = { workspace = true, features = ["alloc", "std"], optional = true }
3333

34+
[target.wasm32-unknown-unknown.dependencies]
35+
ring = { workspace = true, features = ["alloc", "std", "wasm32_unknown_unknown_js"], optional = true }
36+
3437
[features]
3538
secp256k1 = ["dep:k256", "dep:asn1_der", "dep:sha2", "dep:hkdf", "dep:zeroize"]
3639
ecdsa = ["dep:p256", "dep:zeroize", "dep:sec1", "dep:sha2", "dep:hkdf"]

identity/src/error.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ impl DecodingError {
7676
}
7777
}
7878

79-
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
79+
#[cfg(all(
80+
feature = "rsa",
81+
any(
82+
not(target_arch = "wasm32"),
83+
all(target_arch = "wasm32", target_os = "unknown")
84+
)
85+
))]
8086
pub(crate) fn encoding_unsupported(key_type: &'static str) -> Self {
8187
Self {
8288
msg: format!("encoding {key_type} key to Protobuf is unsupported"),
@@ -106,15 +112,27 @@ pub struct SigningError {
106112

107113
/// An error during encoding of key material.
108114
impl SigningError {
109-
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
115+
#[cfg(all(
116+
feature = "rsa",
117+
any(
118+
not(target_arch = "wasm32"),
119+
all(target_arch = "wasm32", target_os = "unknown")
120+
)
121+
))]
110122
pub(crate) fn new<S: ToString>(msg: S) -> Self {
111123
Self {
112124
msg: msg.to_string(),
113125
source: None,
114126
}
115127
}
116128

117-
#[cfg(all(feature = "rsa", not(target_arch = "wasm32")))]
129+
#[cfg(all(
130+
feature = "rsa",
131+
any(
132+
not(target_arch = "wasm32"),
133+
all(target_arch = "wasm32", target_os = "unknown")
134+
)
135+
))]
118136
pub(crate) fn source(self, source: impl Error + Send + Sync + 'static) -> Self {
119137
Self {
120138
source: Some(Box::new(source)),

0 commit comments

Comments
 (0)