Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating aes nonce to use cas-lib #34

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ crate-type = ["cdylib"]
[dependencies]
napi = "2"
napi-derive = "2"
rand = "0.8.5"
rand_chacha = "0.3.1"
rayon = "1.10.0"
csbindgen = "1.9.1"
cas-lib = "0.1.3"
cas-lib = "0.1.6"

[build-dependencies]
napi-build = "1"
Binary file modified index.node
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{
"name": "cas-typescript-sdk",
"version": "1.0.24",
"version": "1.0.25",
"description": "",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/asymmetric/cas_rsa.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cas_lib::asymmetric::{cas_asymmetric_encryption::{CASRSAEncryption, RSAKeyPairResult}, cas_rsa::CASRSA};
use cas_lib::asymmetric::{cas_asymmetric_encryption::CASRSAEncryption, cas_rsa::CASRSA, types::RSAKeyPairResult};
use napi_derive::napi;

#[napi(constructor)]
Expand All @@ -18,7 +18,7 @@ impl From<RSAKeyPairResult> for CASRSAKeyPairResult {

#[napi]
pub fn generate_rsa_keys(key_size: u32) -> CASRSAKeyPairResult {
return CASRSA::generate_rsa_keys(key_size).into();
return CASRSA::generate_rsa_keys(key_size as usize).into();
}

#[napi]
Expand Down
8 changes: 1 addition & 7 deletions src/symmetric/aes.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
use cas_lib::symmetric::{aes::{CASAES128, CASAES256}, cas_symmetric_encryption::CASAESEncryption};
use napi_derive::napi;
use rand::{RngCore, SeedableRng};
use rand_chacha::ChaCha20Rng;

use super::types::CASAesKeyFromX25519SharedSecret;

#[napi]
pub fn aes_nonce() -> Vec<u8> {
let mut rng = ChaCha20Rng::from_entropy();
let mut random_bytes = Vec::with_capacity(12);
random_bytes.resize(12, 0);
rng.fill_bytes(&mut random_bytes);
random_bytes
return <CASAES256 as CASAESEncryption>::generate_nonce();
}

#[napi]
Expand Down