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

#38 removing hybrid and removing RSA encrypt and decrypt #41

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/main-pr-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-pr-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ path = "src/lib.rs"
crate-type = ["cdylib"]

[dependencies]
napi = "2"
napi-derive = "2"
napi = "2.16.13"
napi-derive = "2.16.12"
csbindgen = "1.9.1"
cas-lib = "0.1.6"
cas-lib = "0.2.2"

[build-dependencies]
napi-build = "1"
104 changes: 51 additions & 53 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,78 @@

/* auto-generated by NAPI-RS */

export function argon2Hash(password: string): string
export function argon2HashThreadPool(password: string): string
export function argon2Verify(hashedPassword: string, passwordToVerify: string): boolean
export function argon2VerifyThreadpool(hashedPassword: string, passwordToVerify: string): boolean
export function bcryptHash(passwordToHash: string): string
export function bcryptHashThreadpool(passwordToHash: string): string
export function bcryptVerify(hashedPassword: string, passwordToVerify: string): boolean
export function bcryptVerifyThreadpool(passwordToHash: string, passwordToVerify: string): boolean
export function scryptHash(passwordToHash: string): string
export function scryptVerify(hashedPassword: string, passwordToVerify: string): boolean
export function scryptHashThreadpool(passwordToHash: string): string
export function scryptVerifyThreadpool(hashedPassword: string, passwordToVerify: string): boolean
export function sha512(dataToHash: Array<number>): Array<number>
export function sha512Verify(dataToHash: Array<number>, dataToVerify: Array<number>): boolean
export function sha256(dataToHash: Array<number>): Array<number>
export function sha256Verify(dataToHash: Array<number>, dataToVerify: Array<number>): boolean
export function x25519GenerateSecretAndPublicKey(): CASx25519SecretPublicKeyResult
export function x25519DiffieHellman(mySecretKey: Array<number>, usersPublicKey: Array<number>): Array<number>
export function aesNonce(): Array<number>
export function aes128Key(): Array<number>
export function aes256Key(): Array<number>
export function aes128Encrypt(aesKey: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
export function aes128Decrypt(aesKey: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
export function aes256Encrypt(aesKey: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
export function aes256Decrypt(aesKey: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
export function aes256KeyFromX25519SharedSecret(sharedSecret: Array<number>): CASAesKeyFromX25519SharedSecret
export function aes128KeyFromX25519SharedSecret(sharedSecret: Array<number>): CASAesKeyFromX25519SharedSecret
export function generateRsaKeys(keySize: number): CasrsaKeyPairResult
export function encryptPlaintextRsa(publicKey: string, plaintext: Array<number>): Array<number>
export function decryptCiphertextRsa(privateKey: string, ciphertext: Array<number>): Array<number>
export function signRsa(privateKey: string, hash: Array<number>): Array<number>
export function verifyRsa(publicKey: string, hash: Array<number>, signature: Array<number>): boolean
export function sha512RsaDigitalSignature(rsaKeySize: number, dataToSign: Array<number>): CASRSADigitalSignatureResult
export function sha512RsaVerifyDigitalSignature(publicKey: string, dataToVerify: Array<number>, signature: Array<number>): boolean
export function sha256RsaDigitalSignature(rsaKeySize: number, dataToSign: Array<number>): CASRSADigitalSignatureResult
export function sha256RsaVerifyDigitalSignature(publicKey: string, dataToVerify: Array<number>, signature: Array<number>): boolean
export function sha512Ed25519DigitalSignature(dataToSign: Array<number>): CASSHAED25519DalekDigitalSignatureResult
export function sha512Ed25519DigitalSignatureVerify(publicKey: Array<number>, dataToVerify: Array<number>, signature: Array<number>): boolean
export function sha256Ed25519DigitalSignature(dataToSign: Array<number>): CASSHAED25519DalekDigitalSignatureResult
export function sha256Ed25519DigitalSignatureVerify(publicKey: Array<number>, dataToVerify: Array<number>, signature: Array<number>): boolean
export function ascon128KeyGenerate(): Array<number>
export function ascon128NonceGenerate(): Array<number>
export function ascon128Encrypt(key: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
export function ascon128Decrypt(key: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
export function hmacSign(key: Array<number>, message: Array<number>): Array<number>
export function hmacSignThreadpool(key: Array<number>, message: Array<number>): Array<number>
export function hmacVerify(key: Array<number>, message: Array<number>, signature: Array<number>): boolean
export function hmacVerifyThreadpool(key: Array<number>, message: Array<number>, signature: Array<number>): boolean
export declare function argon2Hash(password: string): string
export declare function argon2HashThreadPool(password: string): string
export declare function argon2Verify(hashedPassword: string, passwordToVerify: string): boolean
export declare function argon2VerifyThreadpool(hashedPassword: string, passwordToVerify: string): boolean
export declare function bcryptHash(passwordToHash: string): string
export declare function bcryptHashThreadpool(passwordToHash: string): string
export declare function bcryptVerify(hashedPassword: string, passwordToVerify: string): boolean
export declare function bcryptVerifyThreadpool(passwordToHash: string, passwordToVerify: string): boolean
export declare function scryptHash(passwordToHash: string): string
export declare function scryptVerify(hashedPassword: string, passwordToVerify: string): boolean
export declare function scryptHashThreadpool(passwordToHash: string): string
export declare function scryptVerifyThreadpool(hashedPassword: string, passwordToVerify: string): boolean
export declare function sha512(dataToHash: Array<number>): Array<number>
export declare function sha512Verify(dataToHash: Array<number>, dataToVerify: Array<number>): boolean
export declare function sha256(dataToHash: Array<number>): Array<number>
export declare function sha256Verify(dataToHash: Array<number>, dataToVerify: Array<number>): boolean
export declare function x25519GenerateSecretAndPublicKey(): CASx25519SecretPublicKeyResult
export declare function x25519DiffieHellman(mySecretKey: Array<number>, usersPublicKey: Array<number>): Array<number>
export declare function aesNonce(): Array<number>
export declare function aes128Key(): Array<number>
export declare function aes256Key(): Array<number>
export declare function aes128Encrypt(aesKey: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
export declare function aes128Decrypt(aesKey: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
export declare function aes256Encrypt(aesKey: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
export declare function aes256Decrypt(aesKey: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
export declare function aes256KeyFromX25519SharedSecret(sharedSecret: Array<number>): CASAesKeyFromX25519SharedSecret
export declare function aes128KeyFromX25519SharedSecret(sharedSecret: Array<number>): CASAesKeyFromX25519SharedSecret
export declare function generateRsaKeys(keySize: number): CasrsaKeyPairResult
export declare function signRsa(privateKey: string, hash: Array<number>): Array<number>
export declare function verifyRsa(publicKey: string, hash: Array<number>, signature: Array<number>): boolean
export declare function sha512RsaDigitalSignature(rsaKeySize: number, dataToSign: Array<number>): CASRSADigitalSignatureResult
export declare function sha512RsaVerifyDigitalSignature(publicKey: string, dataToVerify: Array<number>, signature: Array<number>): boolean
export declare function sha256RsaDigitalSignature(rsaKeySize: number, dataToSign: Array<number>): CASRSADigitalSignatureResult
export declare function sha256RsaVerifyDigitalSignature(publicKey: string, dataToVerify: Array<number>, signature: Array<number>): boolean
export declare function sha512Ed25519DigitalSignature(dataToSign: Array<number>): CASSHAED25519DalekDigitalSignatureResult
export declare function sha512Ed25519DigitalSignatureVerify(publicKey: Array<number>, dataToVerify: Array<number>, signature: Array<number>): boolean
export declare function sha256Ed25519DigitalSignature(dataToSign: Array<number>): CASSHAED25519DalekDigitalSignatureResult
export declare function sha256Ed25519DigitalSignatureVerify(publicKey: Array<number>, dataToVerify: Array<number>, signature: Array<number>): boolean
export declare function ascon128KeyGenerate(): Array<number>
export declare function ascon128NonceGenerate(): Array<number>
export declare function ascon128Encrypt(key: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
export declare function ascon128Decrypt(key: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
export declare function hmacSign(key: Array<number>, message: Array<number>): Array<number>
export declare function hmacSignThreadpool(key: Array<number>, message: Array<number>): Array<number>
export declare function hmacVerify(key: Array<number>, message: Array<number>, signature: Array<number>): boolean
export declare function hmacVerifyThreadpool(key: Array<number>, message: Array<number>, signature: Array<number>): boolean
export type CASx25519SecretPublicKeyResult = CaSx25519SecretPublicKeyResult
export class CaSx25519SecretPublicKeyResult {
export declare class CaSx25519SecretPublicKeyResult {
publicKey: Array<number>
secretKey: Array<number>
constructor(publicKey: Array<number>, secretKey: Array<number>)
}
export type CASAesKeyFromX25519SharedSecret = CasAesKeyFromX25519SharedSecret
export class CasAesKeyFromX25519SharedSecret {
export declare class CasAesKeyFromX25519SharedSecret {
aesKey: Array<number>
aesNonce: Array<number>
constructor(aesKey: Array<number>, aesNonce: Array<number>)
}
export type CASRSAKeyPairResult = CasrsaKeyPairResult
export class CasrsaKeyPairResult {
export declare class CasrsaKeyPairResult {
privateKey: string
publicKey: string
constructor(privateKey: string, publicKey: string)
}
export type CASSHAED25519DalekDigitalSignatureResult = Casshaed25519DalekDigitalSignatureResult
export class Casshaed25519DalekDigitalSignatureResult {
export declare class Casshaed25519DalekDigitalSignatureResult {
publicKey: Array<number>
signature: Array<number>
constructor(publicKey: Array<number>, signature: Array<number>)
}
export type CASRSADigitalSignatureResult = CasrsaDigitalSignatureResult
export class CasrsaDigitalSignatureResult {
export declare class CasrsaDigitalSignatureResult {
publicKey: string
privateKey: string
signature: Array<number>
Expand Down
Binary file modified index.node
100644 → 100755
Binary file not shown.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

{
"name": "cas-typescript-sdk",
"version": "1.0.26",
"version": "1.0.27",
"description": "",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "cargo test && npm run build && mocha -r ts-node/register ./test-ts/**/*.ts --timeout 20000 --recursive",
"node:test": "mocha -r ts-node/register ./test-ts/**/*.ts --timeout 20000 --recursive",
"rust:test": "cargo test",
"build": "npm run build:rust && rm -rf lib && tsc",
"build": "npm run build:rust && tsc",
"build:rust": "napi build --release",
"prepare": "npm run build"
},
Expand Down
29 changes: 1 addition & 28 deletions src-ts/asymmetric/RSAWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CASRSAKeyPairResult, decryptCiphertextRsa, encryptPlaintextRsa, generateRsaKeys, signRsa, verifyRsa } from "../../index";
import { CASRSAKeyPairResult, generateRsaKeys, signRsa, verifyRsa } from "../../index";

export class RSAWrapper {

Expand All @@ -21,33 +21,6 @@ export class RSAWrapper {
* @returns Array<number>
*/

public encrypt(publicKey: string, plaintext: Array<number>): Array<number> {
if (!publicKey) {
throw new Error("You must provide a public key to encrypt with RSA");
}
if (!plaintext || plaintext.length === 0) {
throw new Error("You must provide an array of plaintext bytes to encrypt with RSA");
}
return encryptPlaintextRsa(publicKey, plaintext);
}

/**
* Decrypts a ciphertext with an RSA private key.
* @param privateKey
* @param ciphertext
* @returns Array<number>
*/

public decrypt(privateKey: string, ciphertext: Array<number>): Array<number> {
if (!privateKey) {
throw new Error("You must provide a private key to encrypt with RSA");
}
if (!ciphertext || ciphertext.length === 0) {
throw new Error("You must provide an array of ciphertext bytes to encrypt with RSA");
}
return decryptCiphertextRsa(privateKey, ciphertext);
}

/**
* Signs a byte array with an RSA private key for verification.
* @param privateKey
Expand Down
76 changes: 0 additions & 76 deletions src-ts/hybrid/hybrid-encryption-wrapper.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src-ts/hybrid/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src-ts/hybrid/types/aes-rsa-hybird-encrypt-result.ts

This file was deleted.

29 changes: 0 additions & 29 deletions src-ts/hybrid/types/aes-rsa-hybrid-initializer.ts

This file was deleted.

1 change: 0 additions & 1 deletion src-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export * from "./hashers/index";
export * from "./key_exchange/index";
export * from "./symmetric/index";
export * from "./asymmetric/index";
export * from "./hybrid/index";
export * from "./digital-signature";
export * from "./sponges/index";
export * from "./message/index";
Loading
Loading