summaryrefslogtreecommitdiff
path: root/ext/crypto/x25519.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-06-22 23:37:56 +0200
committerGitHub <noreply@github.com>2023-06-22 23:37:56 +0200
commitdda0f1c343bfb3196ce6a7c7e8c2acccfd5c2e5b (patch)
tree10fc273a620949ccf63826363499f8f39056896d /ext/crypto/x25519.rs
parentb319fa7f4965af3d3d576ea528248a31c96a4053 (diff)
refactor(serde_v8): split ZeroCopyBuf into JsBuffer and ToJsBuffer (#19566)
`ZeroCopyBuf` was convenient to use, but sometimes it did hide details that some copies were necessary in certain cases. Also it made it way to easy for the caller to pass around and convert into different values. This commit splits `ZeroCopyBuf` into `JsBuffer` (an array buffer coming from V8) and `ToJsBuffer` (a Rust buffer that will be converted into a V8 array buffer). As a result some magical conversions were removed (they were never used) limiting the API surface and preparing for changes in #19534.
Diffstat (limited to 'ext/crypto/x25519.rs')
-rw-r--r--ext/crypto/x25519.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/crypto/x25519.rs b/ext/crypto/x25519.rs
index 99914e14e..77554129e 100644
--- a/ext/crypto/x25519.rs
+++ b/ext/crypto/x25519.rs
@@ -3,7 +3,7 @@
use curve25519_dalek::montgomery::MontgomeryPoint;
use deno_core::error::AnyError;
use deno_core::op;
-use deno_core::ZeroCopyBuf;
+use deno_core::ToJsBuffer;
use elliptic_curve::pkcs8::PrivateKeyInfo;
use elliptic_curve::subtle::ConstantTimeEq;
use rand::rngs::OsRng;
@@ -101,7 +101,7 @@ pub fn op_crypto_import_pkcs8_x25519(key_data: &[u8], out: &mut [u8]) -> bool {
#[op]
pub fn op_crypto_export_spki_x25519(
pubkey: &[u8],
-) -> Result<ZeroCopyBuf, AnyError> {
+) -> Result<ToJsBuffer, AnyError> {
let key_info = spki::SubjectPublicKeyInfo {
algorithm: spki::AlgorithmIdentifier {
// id-X25519
@@ -116,7 +116,7 @@ pub fn op_crypto_export_spki_x25519(
#[op]
pub fn op_crypto_export_pkcs8_x25519(
pkey: &[u8],
-) -> Result<ZeroCopyBuf, AnyError> {
+) -> Result<ToJsBuffer, AnyError> {
// This should probably use OneAsymmetricKey instead
let pk_info = rsa::pkcs8::PrivateKeyInfo {
public_key: None,