Skip to content

Commit

Permalink
Use immutable buffers in SubtleCrypto methods (#3797)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-seppanen authored Jan 23, 2024
1 parent 64e4a25 commit 1942791
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* Stabilize `ClipboardEvent`.
[#3791](https://github.com/rustwasm/wasm-bindgen/pull/3791)

* Use immutable buffers in `SubtleCrypto` methods.
[#3797](https://github.com/rustwasm/wasm-bindgen/pull/3797)

## [0.2.90](https://github.com/rustwasm/wasm-bindgen/compare/0.2.89...0.2.90)

Released 2024-01-06
Expand Down
40 changes: 20 additions & 20 deletions crates/web-sys/src/features/gen_SubtleCrypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &::js_sys::Object,
key: &CryptoKey,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = decrypt)]
Expand All @@ -62,7 +62,7 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &str,
key: &CryptoKey,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = deriveBits)]
Expand Down Expand Up @@ -181,7 +181,7 @@ extern "C" {
pub fn digest_with_object_and_u8_array(
this: &SubtleCrypto,
algorithm: &::js_sys::Object,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = digest)]
#[doc = "The `digest()` method."]
Expand All @@ -192,7 +192,7 @@ extern "C" {
pub fn digest_with_str_and_u8_array(
this: &SubtleCrypto,
algorithm: &str,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = encrypt)]
Expand Down Expand Up @@ -231,7 +231,7 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &::js_sys::Object,
key: &CryptoKey,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = encrypt)]
Expand All @@ -244,7 +244,7 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &str,
key: &CryptoKey,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = exportKey)]
Expand Down Expand Up @@ -347,7 +347,7 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &::js_sys::Object,
key: &CryptoKey,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = sign)]
Expand All @@ -360,7 +360,7 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &str,
key: &CryptoKey,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = unwrapKey)]
Expand Down Expand Up @@ -389,7 +389,7 @@ extern "C" {
pub fn unwrap_key_with_u8_array_and_object_and_object(
this: &SubtleCrypto,
format: &str,
wrapped_key: &mut [u8],
wrapped_key: &[u8],
unwrapping_key: &CryptoKey,
unwrap_algorithm: &::js_sys::Object,
unwrapped_key_algorithm: &::js_sys::Object,
Expand Down Expand Up @@ -423,7 +423,7 @@ extern "C" {
pub fn unwrap_key_with_u8_array_and_str_and_object(
this: &SubtleCrypto,
format: &str,
wrapped_key: &mut [u8],
wrapped_key: &[u8],
unwrapping_key: &CryptoKey,
unwrap_algorithm: &str,
unwrapped_key_algorithm: &::js_sys::Object,
Expand Down Expand Up @@ -457,7 +457,7 @@ extern "C" {
pub fn unwrap_key_with_u8_array_and_object_and_str(
this: &SubtleCrypto,
format: &str,
wrapped_key: &mut [u8],
wrapped_key: &[u8],
unwrapping_key: &CryptoKey,
unwrap_algorithm: &::js_sys::Object,
unwrapped_key_algorithm: &str,
Expand Down Expand Up @@ -491,7 +491,7 @@ extern "C" {
pub fn unwrap_key_with_u8_array_and_str_and_str(
this: &SubtleCrypto,
format: &str,
wrapped_key: &mut [u8],
wrapped_key: &[u8],
unwrapping_key: &CryptoKey,
unwrap_algorithm: &str,
unwrapped_key_algorithm: &str,
Expand Down Expand Up @@ -537,7 +537,7 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &::js_sys::Object,
key: &CryptoKey,
signature: &mut [u8],
signature: &[u8],
data: &::js_sys::Object,
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
Expand All @@ -551,7 +551,7 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &str,
key: &CryptoKey,
signature: &mut [u8],
signature: &[u8],
data: &::js_sys::Object,
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
Expand All @@ -566,7 +566,7 @@ extern "C" {
algorithm: &::js_sys::Object,
key: &CryptoKey,
signature: &::js_sys::Object,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = verify)]
Expand All @@ -580,7 +580,7 @@ extern "C" {
algorithm: &str,
key: &CryptoKey,
signature: &::js_sys::Object,
data: &mut [u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = verify)]
Expand All @@ -593,8 +593,8 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &::js_sys::Object,
key: &CryptoKey,
signature: &mut [u8],
data: &mut [u8],
signature: &[u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = verify)]
Expand All @@ -607,8 +607,8 @@ extern "C" {
this: &SubtleCrypto,
algorithm: &str,
key: &CryptoKey,
signature: &mut [u8],
data: &mut [u8],
signature: &[u8],
data: &[u8],
) -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "CryptoKey")]
# [wasm_bindgen (catch , method , structural , js_class = "SubtleCrypto" , js_name = wrapKey)]
Expand Down
7 changes: 7 additions & 0 deletions crates/webidl/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ pub(crate) static IMMUTABLE_SLICE_WHITELIST: Lazy<BTreeSet<&'static str>> = Lazy
"FontFace", // TODO: Add another type's functions here. Leave a comment header with the type name
// FileSystemSyncAccessHandle and FileSystemWritableFileStream
"write",
// SubtleCrypto
"encrypt",
"decrypt",
"digest",
"sign",
"unwrapKey",
"verify",
])
});

Expand Down

0 comments on commit 1942791

Please sign in to comment.