Skip to content

Commit 8bcd5ce

Browse files
authored
Merge pull request #34 from Cryptographic-API-Services/#30-move-logic-to-cas-lib
updating aes nonce to use cas-lib
2 parents 1543f8f + c0e6d34 commit 8bcd5ce

File tree

5 files changed

+5
-14
lines changed

5 files changed

+5
-14
lines changed

Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ crate-type = ["cdylib"]
1010
[dependencies]
1111
napi = "2"
1212
napi-derive = "2"
13-
rand = "0.8.5"
14-
rand_chacha = "0.3.1"
15-
rayon = "1.10.0"
1613
csbindgen = "1.9.1"
17-
cas-lib = "0.1.3"
14+
cas-lib = "0.1.6"
1815

1916
[build-dependencies]
2017
napi-build = "1"

index.node

-2.5 KB
Binary file not shown.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{
33
"name": "cas-typescript-sdk",
4-
"version": "1.0.24",
4+
"version": "1.0.25",
55
"description": "",
66
"main": "lib/index.js",
77
"types": "lib/index.d.ts",

src/asymmetric/cas_rsa.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cas_lib::asymmetric::{cas_asymmetric_encryption::{CASRSAEncryption, RSAKeyPairResult}, cas_rsa::CASRSA};
1+
use cas_lib::asymmetric::{cas_asymmetric_encryption::CASRSAEncryption, cas_rsa::CASRSA, types::RSAKeyPairResult};
22
use napi_derive::napi;
33

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

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

2424
#[napi]

src/symmetric/aes.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
use cas_lib::symmetric::{aes::{CASAES128, CASAES256}, cas_symmetric_encryption::CASAESEncryption};
22
use napi_derive::napi;
3-
use rand::{RngCore, SeedableRng};
4-
use rand_chacha::ChaCha20Rng;
53

64
use super::types::CASAesKeyFromX25519SharedSecret;
75

86
#[napi]
97
pub fn aes_nonce() -> Vec<u8> {
10-
let mut rng = ChaCha20Rng::from_entropy();
11-
let mut random_bytes = Vec::with_capacity(12);
12-
random_bytes.resize(12, 0);
13-
rng.fill_bytes(&mut random_bytes);
14-
random_bytes
8+
return <CASAES256 as CASAESEncryption>::generate_nonce();
159
}
1610

1711
#[napi]

0 commit comments

Comments
 (0)