summaryrefslogtreecommitdiff
path: root/ext/crypto/lib.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-03-14 23:14:15 +0530
committerGitHub <noreply@github.com>2022-03-14 18:44:15 +0100
commitb4e42953e1d243f2eda20e5be6b845d60b7bf688 (patch)
tree10b3bfff165f9c04f9174c7c399d44b9b724c3b3 /ext/crypto/lib.rs
parent4e3ed37037a2aa1edeac260dc3463a81d9cf9b88 (diff)
feat(core): codegen ops (#13861)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
Diffstat (limited to 'ext/crypto/lib.rs')
-rw-r--r--ext/crypto/lib.rs41
1 files changed, 23 insertions, 18 deletions
diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs
index 69381e139..3b33830d3 100644
--- a/ext/crypto/lib.rs
+++ b/ext/crypto/lib.rs
@@ -9,8 +9,8 @@ use deno_core::error::not_supported;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::include_js_files;
-use deno_core::op_async;
-use deno_core::op_sync;
+use deno_core::op;
+
use deno_core::Extension;
use deno_core::OpState;
use deno_core::ZeroCopyBuf;
@@ -88,22 +88,19 @@ pub fn init(maybe_seed: Option<u64>) -> Extension {
"01_webidl.js",
))
.ops(vec![
- (
- "op_crypto_get_random_values",
- op_sync(op_crypto_get_random_values),
- ),
- ("op_crypto_generate_key", op_async(op_crypto_generate_key)),
- ("op_crypto_sign_key", op_async(op_crypto_sign_key)),
- ("op_crypto_verify_key", op_async(op_crypto_verify_key)),
- ("op_crypto_derive_bits", op_async(op_crypto_derive_bits)),
- ("op_crypto_import_key", op_sync(op_crypto_import_key)),
- ("op_crypto_export_key", op_sync(op_crypto_export_key)),
- ("op_crypto_encrypt", op_async(op_crypto_encrypt)),
- ("op_crypto_decrypt", op_async(op_crypto_decrypt)),
- ("op_crypto_subtle_digest", op_async(op_crypto_subtle_digest)),
- ("op_crypto_random_uuid", op_sync(op_crypto_random_uuid)),
- ("op_crypto_wrap_key", op_sync(op_crypto_wrap_key)),
- ("op_crypto_unwrap_key", op_sync(op_crypto_unwrap_key)),
+ op_crypto_get_random_values::decl(),
+ op_crypto_generate_key::decl(),
+ op_crypto_sign_key::decl(),
+ op_crypto_verify_key::decl(),
+ op_crypto_derive_bits::decl(),
+ op_crypto_import_key::decl(),
+ op_crypto_export_key::decl(),
+ op_crypto_encrypt::decl(),
+ op_crypto_decrypt::decl(),
+ op_crypto_subtle_digest::decl(),
+ op_crypto_random_uuid::decl(),
+ op_crypto_wrap_key::decl(),
+ op_crypto_unwrap_key::decl(),
])
.state(move |state| {
if let Some(seed) = maybe_seed {
@@ -114,6 +111,7 @@ pub fn init(maybe_seed: Option<u64>) -> Extension {
.build()
}
+#[op]
pub fn op_crypto_get_random_values(
state: &mut OpState,
mut zero_copy: ZeroCopyBuf,
@@ -170,6 +168,7 @@ pub struct SignArg {
named_curve: Option<CryptoNamedCurve>,
}
+#[op]
pub async fn op_crypto_sign_key(
_state: Rc<RefCell<OpState>>,
args: SignArg,
@@ -324,6 +323,7 @@ pub struct VerifyArg {
named_curve: Option<CryptoNamedCurve>,
}
+#[op]
pub async fn op_crypto_verify_key(
_state: Rc<RefCell<OpState>>,
args: VerifyArg,
@@ -484,6 +484,7 @@ pub struct DeriveKeyArg {
info: Option<ZeroCopyBuf>,
}
+#[op]
pub async fn op_crypto_derive_bits(
_state: Rc<RefCell<OpState>>,
args: DeriveKeyArg,
@@ -789,6 +790,7 @@ impl<'a> TryFrom<rsa::pkcs8::der::asn1::Any<'a>>
}
}
+#[op]
pub fn op_crypto_random_uuid(
state: &mut OpState,
_: (),
@@ -808,6 +810,7 @@ pub fn op_crypto_random_uuid(
Ok(uuid.to_string())
}
+#[op]
pub async fn op_crypto_subtle_digest(
_state: Rc<RefCell<OpState>>,
algorithm: CryptoHash,
@@ -831,6 +834,7 @@ pub struct WrapUnwrapKeyArg {
algorithm: Algorithm,
}
+#[op]
pub fn op_crypto_wrap_key(
_state: &mut OpState,
args: WrapUnwrapKeyArg,
@@ -860,6 +864,7 @@ pub fn op_crypto_wrap_key(
}
}
+#[op]
pub fn op_crypto_unwrap_key(
_state: &mut OpState,
args: WrapUnwrapKeyArg,