Skip to content

Commit

Permalink
Optimize ArrayBuffer arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
nabetti1720 committed Nov 25, 2024
1 parent 2a9a2ab commit 51af5db
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions modules/llrt_crypto/src/subtle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub async fn subtle_decrypt<'js>(
let algorithm = extract_algorithm_object(&ctx, &algorithm)?;

let bytes = decrypt(&ctx, &algorithm, key.as_bytes(), data.as_bytes())?;
ArrayBuffer::new(ctx, bytes.as_slice())
ArrayBuffer::new(ctx, bytes)
}

pub async fn subtle_derive_bits<'js>(
Expand All @@ -127,7 +127,7 @@ pub async fn subtle_derive_bits<'js>(
let derive_algorithm = extract_derive_algorithm(&ctx, &algorithm)?;

let bytes = derive_bits(&ctx, &derive_algorithm, base_key.as_bytes(), length)?;
ArrayBuffer::new(ctx, bytes.as_slice())
ArrayBuffer::new(ctx, bytes)
}

pub async fn subtle_digest<'js>(
Expand All @@ -146,7 +146,7 @@ pub async fn subtle_digest<'js>(
};

let bytes = digest(&ctx, &algorithm, data.as_bytes())?;
ArrayBuffer::new(ctx, bytes.as_slice())
ArrayBuffer::new(ctx, bytes)
}

pub async fn subtle_encrypt<'js>(
Expand All @@ -158,7 +158,7 @@ pub async fn subtle_encrypt<'js>(
let algorithm = extract_algorithm_object(&ctx, &algorithm)?;

let bytes = encrypt(&ctx, &algorithm, key.as_bytes(), data.as_bytes())?;
ArrayBuffer::new(ctx, bytes.as_slice())
ArrayBuffer::new(ctx, bytes)
}

pub async fn subtle_generate_key<'js>(
Expand All @@ -170,7 +170,7 @@ pub async fn subtle_generate_key<'js>(
let key_gen_algorithm = extract_generate_key_algorithm(&ctx, &algorithm)?;

let bytes = generate_key(&ctx, &key_gen_algorithm)?;
ArrayBuffer::new(ctx, bytes.as_slice())
ArrayBuffer::new(ctx, bytes)
}

pub async fn subtle_sign<'js>(
Expand All @@ -182,7 +182,7 @@ pub async fn subtle_sign<'js>(
let algorithm = extract_sign_verify_algorithm(&ctx, &algorithm)?;

let bytes = sign(&ctx, &algorithm, key.as_bytes(), data.as_bytes())?;
ArrayBuffer::new(ctx, bytes.as_slice())
ArrayBuffer::new(ctx, bytes)
}

pub async fn subtle_verify<'js>(
Expand Down

0 comments on commit 51af5db

Please sign in to comment.