cas-typescript-sdk 1.0.39 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +1 -1
- package/index.d.ts +11 -12
- package/index.node +0 -0
- package/lib/digital-signature/digital-siganture-sha-512.d.ts +1 -15
- package/lib/digital-signature/digital-siganture-sha-512.js +0 -30
- package/lib/digital-signature/digital-signature-base.d.ts +1 -3
- package/lib/digital-signature/digital-signaturte-sha-256.d.ts +1 -15
- package/lib/digital-signature/digital-signaturte-sha-256.js +0 -30
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/signature/ed25519-wrapper.d.ts +22 -0
- package/lib/signature/ed25519-wrapper.js +32 -0
- package/lib/signature/index.d.ts +2 -0
- package/lib/signature/index.js +5 -0
- package/lib/symmetric/aes-wrapper.d.ts +2 -3
- package/lib/symmetric/index.d.ts +1 -2
- package/package.json +4 -4
- package/src/asymmetric/cas_ed25519.rs +35 -0
- package/src/lib.rs +1 -3
- package/src/symmetric/aes.rs +2 -4
- package/src-ts/digital-signature/digital-siganture-sha-512.ts +1 -34
- package/src-ts/digital-signature/digital-signature-base.ts +0 -2
- package/src-ts/digital-signature/digital-signaturte-sha-256.ts +1 -33
- package/src-ts/index.ts +2 -1
- package/src-ts/signature/ed25519-wrapper.ts +36 -0
- package/src-ts/signature/index.ts +3 -0
- package/src-ts/symmetric/aes-wrapper.ts +2 -3
- package/src-ts/symmetric/index.ts +1 -2
- package/test-ts/digital-signature.test.spec.ts +16 -39
- package/test-ts/insecure-channel.test.spec.ts +8 -4
- package/test-ts/symmetric.test.spec.ts +8 -4
- package/src/digital_signature/sha_256_ed25519.rs +0 -37
- package/src/digital_signature/sha_512_ed25519.rs +0 -43
- package/src/symmetric/types.rs +0 -27
package/Cargo.toml
CHANGED
package/index.d.ts
CHANGED
|
@@ -26,19 +26,18 @@ export declare function aes128Encrypt(aesKey: Array<number>, nonce: Array<number
|
|
|
26
26
|
export declare function aes128Decrypt(aesKey: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
|
|
27
27
|
export declare function aes256Encrypt(aesKey: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
|
|
28
28
|
export declare function aes256Decrypt(aesKey: Array<number>, nonce: Array<number>, ciphertext: Array<number>): Array<number>
|
|
29
|
-
export declare function aes256KeyFromX25519SharedSecret(sharedSecret: Array<number>):
|
|
30
|
-
export declare function aes128KeyFromX25519SharedSecret(sharedSecret: Array<number>):
|
|
29
|
+
export declare function aes256KeyFromX25519SharedSecret(sharedSecret: Array<number>): Array<number>
|
|
30
|
+
export declare function aes128KeyFromX25519SharedSecret(sharedSecret: Array<number>): Array<number>
|
|
31
31
|
export declare function generateRsaKeys(keySize: number): CasrsaKeyPairResult
|
|
32
32
|
export declare function signRsa(privateKey: string, hash: Array<number>): Array<number>
|
|
33
33
|
export declare function verifyRsa(publicKey: string, hash: Array<number>, signature: Array<number>): boolean
|
|
34
|
+
export declare function generateEd25519Keys(): Cased25519KeyPairResult
|
|
35
|
+
export declare function signEd25519(privateKey: Array<number>, message: Array<number>): Array<number>
|
|
36
|
+
export declare function verifyEd25519(publicKey: Array<number>, message: Array<number>, signature: Array<number>): boolean
|
|
34
37
|
export declare function sha512RsaDigitalSignature(rsaKeySize: number, dataToSign: Array<number>): CASRSADigitalSignatureResult
|
|
35
38
|
export declare function sha512RsaVerifyDigitalSignature(publicKey: string, dataToVerify: Array<number>, signature: Array<number>): boolean
|
|
36
39
|
export declare function sha256RsaDigitalSignature(rsaKeySize: number, dataToSign: Array<number>): CASRSADigitalSignatureResult
|
|
37
40
|
export declare function sha256RsaVerifyDigitalSignature(publicKey: string, dataToVerify: Array<number>, signature: Array<number>): boolean
|
|
38
|
-
export declare function sha512Ed25519DigitalSignature(dataToSign: Array<number>): CASSHAED25519DalekDigitalSignatureResult
|
|
39
|
-
export declare function sha512Ed25519DigitalSignatureVerify(publicKey: Array<number>, dataToVerify: Array<number>, signature: Array<number>): boolean
|
|
40
|
-
export declare function sha256Ed25519DigitalSignature(dataToSign: Array<number>): CASSHAED25519DalekDigitalSignatureResult
|
|
41
|
-
export declare function sha256Ed25519DigitalSignatureVerify(publicKey: Array<number>, dataToVerify: Array<number>, signature: Array<number>): boolean
|
|
42
41
|
export declare function ascon128KeyGenerate(): Array<number>
|
|
43
42
|
export declare function ascon128NonceGenerate(): Array<number>
|
|
44
43
|
export declare function ascon128Encrypt(key: Array<number>, nonce: Array<number>, plaintext: Array<number>): Array<number>
|
|
@@ -51,18 +50,18 @@ export declare class CaSx25519SecretPublicKeyResult {
|
|
|
51
50
|
secretKey: Array<number>
|
|
52
51
|
constructor(publicKey: Array<number>, secretKey: Array<number>)
|
|
53
52
|
}
|
|
54
|
-
export type CASAesKeyFromX25519SharedSecret = CasAesKeyFromX25519SharedSecret
|
|
55
|
-
export declare class CasAesKeyFromX25519SharedSecret {
|
|
56
|
-
aesKey: Array<number>
|
|
57
|
-
aesNonce: Array<number>
|
|
58
|
-
constructor(aesKey: Array<number>, aesNonce: Array<number>)
|
|
59
|
-
}
|
|
60
53
|
export type CASRSAKeyPairResult = CasrsaKeyPairResult
|
|
61
54
|
export declare class CasrsaKeyPairResult {
|
|
62
55
|
privateKey: string
|
|
63
56
|
publicKey: string
|
|
64
57
|
constructor(privateKey: string, publicKey: string)
|
|
65
58
|
}
|
|
59
|
+
export type CASED25519KeyPairResult = Cased25519KeyPairResult
|
|
60
|
+
export declare class Cased25519KeyPairResult {
|
|
61
|
+
privateKey: Array<number>
|
|
62
|
+
publicKey: Array<number>
|
|
63
|
+
constructor(privateKey: Array<number>, publicKey: Array<number>)
|
|
64
|
+
}
|
|
66
65
|
export type CASSHAED25519DalekDigitalSignatureResult = Casshaed25519DalekDigitalSignatureResult
|
|
67
66
|
export declare class Casshaed25519DalekDigitalSignatureResult {
|
|
68
67
|
publicKey: Array<number>
|
package/index.node
CHANGED
|
Binary file
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
import { CASRSADigitalSignatureResult
|
|
1
|
+
import { CASRSADigitalSignatureResult } from "../../index";
|
|
2
2
|
import { IDigitalSignature } from "./digital-signature-base";
|
|
3
3
|
export declare class DigitalSignatureSHA512Wrapper implements IDigitalSignature {
|
|
4
|
-
/**
|
|
5
|
-
* Creates an ED25519 siganture from an array of bytes with SHA3-512.
|
|
6
|
-
* @param dataToSign
|
|
7
|
-
* @returns CASSHAED25519DalekDigitalSignatureResult
|
|
8
|
-
*/
|
|
9
|
-
createED25519(dataToSign: number[]): CASSHAED25519DalekDigitalSignatureResult;
|
|
10
|
-
/**
|
|
11
|
-
* Verifies an ED25519 signature with the public key generated from running createED25519() with SHA3-512
|
|
12
|
-
* @param publicKey
|
|
13
|
-
* @param dataToVerify
|
|
14
|
-
* @param signature
|
|
15
|
-
* @returns boolean
|
|
16
|
-
*/
|
|
17
|
-
verifyED25519(publicKey: number[], dataToVerify: number[], signature: number[]): boolean;
|
|
18
4
|
/**
|
|
19
5
|
* Generates and RSA digital signature with SHA3-512
|
|
20
6
|
* @param rsa_key_size
|
|
@@ -3,36 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DigitalSignatureSHA512Wrapper = void 0;
|
|
4
4
|
const index_1 = require("../../index");
|
|
5
5
|
class DigitalSignatureSHA512Wrapper {
|
|
6
|
-
/**
|
|
7
|
-
* Creates an ED25519 siganture from an array of bytes with SHA3-512.
|
|
8
|
-
* @param dataToSign
|
|
9
|
-
* @returns CASSHAED25519DalekDigitalSignatureResult
|
|
10
|
-
*/
|
|
11
|
-
createED25519(dataToSign) {
|
|
12
|
-
if (dataToSign?.length === 0) {
|
|
13
|
-
throw new Error("Must provide allocated data to sign");
|
|
14
|
-
}
|
|
15
|
-
return (0, index_1.sha512Ed25519DigitalSignature)(dataToSign);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Verifies an ED25519 signature with the public key generated from running createED25519() with SHA3-512
|
|
19
|
-
* @param publicKey
|
|
20
|
-
* @param dataToVerify
|
|
21
|
-
* @param signature
|
|
22
|
-
* @returns boolean
|
|
23
|
-
*/
|
|
24
|
-
verifyED25519(publicKey, dataToVerify, signature) {
|
|
25
|
-
if (!publicKey) {
|
|
26
|
-
throw new Error("You must provide a public key for verify with ED25519");
|
|
27
|
-
}
|
|
28
|
-
if (dataToVerify?.length === 0) {
|
|
29
|
-
throw new Error("Must provide allocated data to verify");
|
|
30
|
-
}
|
|
31
|
-
if (signature?.length === 0) {
|
|
32
|
-
throw new Error("Must provide allocated signature to verify");
|
|
33
|
-
}
|
|
34
|
-
return (0, index_1.sha512Ed25519DigitalSignatureVerify)(publicKey, dataToVerify, signature);
|
|
35
|
-
}
|
|
36
6
|
/**
|
|
37
7
|
* Generates and RSA digital signature with SHA3-512
|
|
38
8
|
* @param rsa_key_size
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { CASRSADigitalSignatureResult
|
|
1
|
+
import { CASRSADigitalSignatureResult } from "../../index";
|
|
2
2
|
export interface IDigitalSignature {
|
|
3
3
|
createRsa(rsa_key_size: number, data_to_sign: Array<number>): CASRSADigitalSignatureResult;
|
|
4
4
|
verifyRSa(public_key: string, data_to_verify: Array<number>, signature: Array<number>): boolean;
|
|
5
|
-
createED25519(dataToSign: Array<number>): CASSHAED25519DalekDigitalSignatureResult;
|
|
6
|
-
verifyED25519(publicKey: Array<number>, dataToVerify: Array<number>, signature: Array<number>): boolean;
|
|
7
5
|
}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
import { CASRSADigitalSignatureResult
|
|
1
|
+
import { CASRSADigitalSignatureResult } from "../../index";
|
|
2
2
|
import { IDigitalSignature } from "./digital-signature-base";
|
|
3
3
|
export declare class DigitalSignatureSHA256Wrapper implements IDigitalSignature {
|
|
4
|
-
/**
|
|
5
|
-
* Creates an ED25519 siganture from an array of bytes with SHA3-512.
|
|
6
|
-
* @param dataToSign
|
|
7
|
-
* @returns SHAED25519DalekDigitalSignatureResult
|
|
8
|
-
*/
|
|
9
|
-
createED25519(dataToSign: number[]): CASSHAED25519DalekDigitalSignatureResult;
|
|
10
|
-
/**
|
|
11
|
-
* Verifies an ED25519 signature with the public key generated from running createED25519() with SHA3-512
|
|
12
|
-
* @param publicKey
|
|
13
|
-
* @param dataToVerify
|
|
14
|
-
* @param signature
|
|
15
|
-
* @returns boolean
|
|
16
|
-
*/
|
|
17
|
-
verifyED25519(publicKey: number[], dataToVerify: number[], signature: number[]): boolean;
|
|
18
4
|
/**
|
|
19
5
|
* Generates and RSA digital signature with SHA3-512
|
|
20
6
|
* @param rsa_key_size
|
|
@@ -3,36 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DigitalSignatureSHA256Wrapper = void 0;
|
|
4
4
|
const index_1 = require("../../index");
|
|
5
5
|
class DigitalSignatureSHA256Wrapper {
|
|
6
|
-
/**
|
|
7
|
-
* Creates an ED25519 siganture from an array of bytes with SHA3-512.
|
|
8
|
-
* @param dataToSign
|
|
9
|
-
* @returns SHAED25519DalekDigitalSignatureResult
|
|
10
|
-
*/
|
|
11
|
-
createED25519(dataToSign) {
|
|
12
|
-
if (dataToSign?.length === 0) {
|
|
13
|
-
throw new Error("Must provide allocated data to sign");
|
|
14
|
-
}
|
|
15
|
-
return (0, index_1.sha256Ed25519DigitalSignature)(dataToSign);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Verifies an ED25519 signature with the public key generated from running createED25519() with SHA3-512
|
|
19
|
-
* @param publicKey
|
|
20
|
-
* @param dataToVerify
|
|
21
|
-
* @param signature
|
|
22
|
-
* @returns boolean
|
|
23
|
-
*/
|
|
24
|
-
verifyED25519(publicKey, dataToVerify, signature) {
|
|
25
|
-
if (!publicKey) {
|
|
26
|
-
throw new Error("You must provide a public key for verify with ED25519");
|
|
27
|
-
}
|
|
28
|
-
if (dataToVerify?.length === 0) {
|
|
29
|
-
throw new Error("Must provide allocated data to verify");
|
|
30
|
-
}
|
|
31
|
-
if (signature?.length === 0) {
|
|
32
|
-
throw new Error("Must provide allocated signature to verify");
|
|
33
|
-
}
|
|
34
|
-
return (0, index_1.sha256Ed25519DigitalSignatureVerify)(publicKey, dataToVerify, signature);
|
|
35
|
-
}
|
|
36
6
|
/**
|
|
37
7
|
* Generates and RSA digital signature with SHA3-512
|
|
38
8
|
* @param rsa_key_size
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -22,3 +22,4 @@ __exportStar(require("./asymmetric/index"), exports);
|
|
|
22
22
|
__exportStar(require("./digital-signature"), exports);
|
|
23
23
|
__exportStar(require("./sponges/index"), exports);
|
|
24
24
|
__exportStar(require("./message/index"), exports);
|
|
25
|
+
__exportStar(require("./signature/index"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Cased25519KeyPairResult } from "../../index";
|
|
2
|
+
export declare class Ed25519Wrapper {
|
|
3
|
+
/**
|
|
4
|
+
* Generates a new Ed25519 key pair
|
|
5
|
+
*/
|
|
6
|
+
getKeyPair(): Cased25519KeyPairResult;
|
|
7
|
+
/**
|
|
8
|
+
* Signs a message with the given Ed25519 private key
|
|
9
|
+
* @param privateKey The private key to sign the message with
|
|
10
|
+
* @param message The message to sign
|
|
11
|
+
* @returns The signature
|
|
12
|
+
*/
|
|
13
|
+
signMessage(privateKey: number[], message: number[]): number[];
|
|
14
|
+
/**
|
|
15
|
+
* Verifies a signature for a message with the given Ed25519 public key
|
|
16
|
+
* @param publicKey The public key to verify the signature with
|
|
17
|
+
* @param message The signed message
|
|
18
|
+
* @param signature The signature to verify
|
|
19
|
+
* @returns True if the signature is valid, false otherwise
|
|
20
|
+
*/
|
|
21
|
+
verifyMessage(publicKey: number[], message: number[], signature: number[]): boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ed25519Wrapper = void 0;
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
|
+
class Ed25519Wrapper {
|
|
6
|
+
/**
|
|
7
|
+
* Generates a new Ed25519 key pair
|
|
8
|
+
*/
|
|
9
|
+
getKeyPair() {
|
|
10
|
+
return (0, index_1.generateEd25519Keys)();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Signs a message with the given Ed25519 private key
|
|
14
|
+
* @param privateKey The private key to sign the message with
|
|
15
|
+
* @param message The message to sign
|
|
16
|
+
* @returns The signature
|
|
17
|
+
*/
|
|
18
|
+
signMessage(privateKey, message) {
|
|
19
|
+
return (0, index_1.signEd25519)(privateKey, message);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Verifies a signature for a message with the given Ed25519 public key
|
|
23
|
+
* @param publicKey The public key to verify the signature with
|
|
24
|
+
* @param message The signed message
|
|
25
|
+
* @param signature The signature to verify
|
|
26
|
+
* @returns True if the signature is valid, false otherwise
|
|
27
|
+
*/
|
|
28
|
+
verifyMessage(publicKey, message, signature) {
|
|
29
|
+
return (0, index_1.verifyEd25519)(publicKey, message, signature);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.Ed25519Wrapper = Ed25519Wrapper;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ed25519Wrapper = void 0;
|
|
4
|
+
const ed25519_wrapper_1 = require("./ed25519-wrapper");
|
|
5
|
+
Object.defineProperty(exports, "Ed25519Wrapper", { enumerable: true, get: function () { return ed25519_wrapper_1.Ed25519Wrapper; } });
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CASAesKeyFromX25519SharedSecret } from "../../index";
|
|
2
1
|
export declare class AESWrapper {
|
|
3
2
|
/**
|
|
4
3
|
* @description Generates a 128 bit AES key
|
|
@@ -52,11 +51,11 @@ export declare class AESWrapper {
|
|
|
52
51
|
* @param shared_secret
|
|
53
52
|
* @returns
|
|
54
53
|
*/
|
|
55
|
-
aes256KeyNonceX25519DiffieHellman(shared_secret: Array<number>):
|
|
54
|
+
aes256KeyNonceX25519DiffieHellman(shared_secret: Array<number>): number[];
|
|
56
55
|
/**
|
|
57
56
|
* Derives an AES-128 key from a X25519 Diffie Hellman shared secret.
|
|
58
57
|
* @param shared_secret
|
|
59
58
|
* @returns
|
|
60
59
|
*/
|
|
61
|
-
aes128KeyNonceX25519DiffieHellman(shared_secret: Array<number>):
|
|
60
|
+
aes128KeyNonceX25519DiffieHellman(shared_secret: Array<number>): number[];
|
|
62
61
|
}
|
package/lib/symmetric/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cas-typescript-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@napi-rs/cli": "^2.18.4",
|
|
32
|
-
"rimraf": "^6.0.1"
|
|
32
|
+
"rimraf": "^6.0.1",
|
|
33
|
+
"typescript": "^5.8.3"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/chai": "^4.3.20",
|
|
@@ -37,7 +38,6 @@
|
|
|
37
38
|
"@types/node-fetch": "^2.6.12",
|
|
38
39
|
"chai": "^4.5.0",
|
|
39
40
|
"mocha": "^10.8.2",
|
|
40
|
-
"ts-node": "^10.9.2"
|
|
41
|
-
"typescript": "^5.8.3"
|
|
41
|
+
"ts-node": "^10.9.2"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
use cas_lib::signatures::cas_ed25519::{Ed25519ByteKeyPair, Ed25519ByteSignature};
|
|
3
|
+
use cas_lib::signatures::ed25519::{get_ed25519_key_pair, ed25519_sign_with_key_pair, ed25519_verify_with_public_key};
|
|
4
|
+
use napi_derive::napi;
|
|
5
|
+
|
|
6
|
+
#[napi(constructor)]
|
|
7
|
+
pub struct CASED25519KeyPairResult {
|
|
8
|
+
pub private_key: Vec<u8>,
|
|
9
|
+
pub public_key: Vec<u8>,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
impl From<Ed25519ByteKeyPair> for CASED25519KeyPairResult {
|
|
13
|
+
fn from(result: Ed25519ByteKeyPair) -> Self {
|
|
14
|
+
CASED25519KeyPairResult {
|
|
15
|
+
private_key: result.key_pair,
|
|
16
|
+
public_key: result.public_key
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#[napi]
|
|
22
|
+
pub fn generate_ed25519_keys() -> CASED25519KeyPairResult {
|
|
23
|
+
return get_ed25519_key_pair().into();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#[napi]
|
|
27
|
+
pub fn sign_ed25519(private_key: Vec<u8>, message: Vec<u8>) -> Vec<u8> {
|
|
28
|
+
let signature = ed25519_sign_with_key_pair(private_key, message);
|
|
29
|
+
signature.signature // assuming Ed25519ByteSignature has a field named `signature: Vec<u8>`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[napi]
|
|
33
|
+
pub fn verify_ed25519(public_key: Vec<u8>, message: Vec<u8>, signature: Vec<u8>) -> bool {
|
|
34
|
+
return ed25519_verify_with_public_key(public_key, signature, message);
|
|
35
|
+
}
|
package/src/lib.rs
CHANGED
|
@@ -20,18 +20,16 @@ mod key_exchange {
|
|
|
20
20
|
|
|
21
21
|
mod symmetric {
|
|
22
22
|
pub mod aes;
|
|
23
|
-
mod types;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
mod asymmetric {
|
|
27
26
|
pub mod cas_rsa;
|
|
27
|
+
pub mod cas_ed25519;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
mod digital_signature {
|
|
31
31
|
pub mod sha_512_rsa;
|
|
32
32
|
pub mod sha_256_rsa;
|
|
33
|
-
pub mod sha_512_ed25519;
|
|
34
|
-
pub mod sha_256_ed25519;
|
|
35
33
|
mod types;
|
|
36
34
|
}
|
|
37
35
|
|
package/src/symmetric/aes.rs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
use cas_lib::symmetric::{aes::{CASAES128, CASAES256}, cas_symmetric_encryption::{CASAES128Encryption, CASAES256Encryption}};
|
|
2
2
|
use napi_derive::napi;
|
|
3
3
|
|
|
4
|
-
use super::types::CASAesKeyFromX25519SharedSecret;
|
|
5
|
-
|
|
6
4
|
#[napi]
|
|
7
5
|
pub fn aes_nonce() -> Vec<u8> {
|
|
8
6
|
return <CASAES256 as CASAES256Encryption>::generate_nonce().to_vec();
|
|
@@ -41,14 +39,14 @@ pub fn aes256_decrypt(aes_key: Vec<u8>, nonce: Vec<u8>, ciphertext: Vec<u8>) ->
|
|
|
41
39
|
#[napi]
|
|
42
40
|
pub fn aes_256_key_from_x25519_shared_secret(
|
|
43
41
|
shared_secret: Vec<u8>,
|
|
44
|
-
) ->
|
|
42
|
+
) -> Vec<u8> {
|
|
45
43
|
return <CASAES256 as CASAES256Encryption>::key_from_x25519_shared_secret(shared_secret).into();
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
#[napi]
|
|
49
47
|
pub fn aes_128_key_from_x25519_shared_secret(
|
|
50
48
|
shared_secret: Vec<u8>,
|
|
51
|
-
) ->
|
|
49
|
+
) -> Vec<u8> {
|
|
52
50
|
return <CASAES128 as CASAES128Encryption>::key_from_x25519_shared_secret(shared_secret).into();
|
|
53
51
|
}
|
|
54
52
|
|
|
@@ -1,40 +1,7 @@
|
|
|
1
|
-
import { CASRSADigitalSignatureResult, CASSHAED25519DalekDigitalSignatureResult,
|
|
1
|
+
import { CASRSADigitalSignatureResult, CASSHAED25519DalekDigitalSignatureResult, sha512RsaDigitalSignature, sha512RsaVerifyDigitalSignature } from "../../index";
|
|
2
2
|
import { IDigitalSignature } from "./digital-signature-base";
|
|
3
3
|
|
|
4
4
|
export class DigitalSignatureSHA512Wrapper implements IDigitalSignature {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates an ED25519 siganture from an array of bytes with SHA3-512.
|
|
8
|
-
* @param dataToSign
|
|
9
|
-
* @returns CASSHAED25519DalekDigitalSignatureResult
|
|
10
|
-
*/
|
|
11
|
-
createED25519(dataToSign: number[]): CASSHAED25519DalekDigitalSignatureResult {
|
|
12
|
-
if (dataToSign?.length === 0) {
|
|
13
|
-
throw new Error("Must provide allocated data to sign");
|
|
14
|
-
}
|
|
15
|
-
return sha512Ed25519DigitalSignature(dataToSign);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Verifies an ED25519 signature with the public key generated from running createED25519() with SHA3-512
|
|
20
|
-
* @param publicKey
|
|
21
|
-
* @param dataToVerify
|
|
22
|
-
* @param signature
|
|
23
|
-
* @returns boolean
|
|
24
|
-
*/
|
|
25
|
-
verifyED25519(publicKey: number[], dataToVerify: number[], signature: number[]): boolean {
|
|
26
|
-
if (!publicKey) {
|
|
27
|
-
throw new Error("You must provide a public key for verify with ED25519");
|
|
28
|
-
}
|
|
29
|
-
if (dataToVerify?.length === 0) {
|
|
30
|
-
throw new Error("Must provide allocated data to verify");
|
|
31
|
-
}
|
|
32
|
-
if (signature?.length === 0) {
|
|
33
|
-
throw new Error("Must provide allocated signature to verify");
|
|
34
|
-
}
|
|
35
|
-
return sha512Ed25519DigitalSignatureVerify(publicKey, dataToVerify, signature);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
5
|
/**
|
|
39
6
|
* Generates and RSA digital signature with SHA3-512
|
|
40
7
|
* @param rsa_key_size
|
|
@@ -3,6 +3,4 @@ import { CASRSADigitalSignatureResult, CASSHAED25519DalekDigitalSignatureResult
|
|
|
3
3
|
export interface IDigitalSignature {
|
|
4
4
|
createRsa(rsa_key_size: number, data_to_sign: Array<number>): CASRSADigitalSignatureResult;
|
|
5
5
|
verifyRSa(public_key: string, data_to_verify: Array<number>, signature: Array<number>): boolean;
|
|
6
|
-
createED25519(dataToSign: Array<number>): CASSHAED25519DalekDigitalSignatureResult;
|
|
7
|
-
verifyED25519(publicKey: Array<number>, dataToVerify: Array<number>, signature: Array<number>): boolean;
|
|
8
6
|
}
|
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
import { CASRSADigitalSignatureResult,
|
|
1
|
+
import { CASRSADigitalSignatureResult, sha256RsaDigitalSignature, sha256RsaVerifyDigitalSignature } from "../../index";
|
|
2
2
|
import { IDigitalSignature } from "./digital-signature-base";
|
|
3
3
|
|
|
4
4
|
export class DigitalSignatureSHA256Wrapper implements IDigitalSignature {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates an ED25519 siganture from an array of bytes with SHA3-512.
|
|
8
|
-
* @param dataToSign
|
|
9
|
-
* @returns SHAED25519DalekDigitalSignatureResult
|
|
10
|
-
*/
|
|
11
|
-
createED25519(dataToSign: number[]): CASSHAED25519DalekDigitalSignatureResult {
|
|
12
|
-
if (dataToSign?.length === 0) {
|
|
13
|
-
throw new Error("Must provide allocated data to sign");
|
|
14
|
-
}
|
|
15
|
-
return sha256Ed25519DigitalSignature(dataToSign);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Verifies an ED25519 signature with the public key generated from running createED25519() with SHA3-512
|
|
20
|
-
* @param publicKey
|
|
21
|
-
* @param dataToVerify
|
|
22
|
-
* @param signature
|
|
23
|
-
* @returns boolean
|
|
24
|
-
*/
|
|
25
|
-
verifyED25519(publicKey: number[], dataToVerify: number[], signature: number[]): boolean {
|
|
26
|
-
if (!publicKey) {
|
|
27
|
-
throw new Error("You must provide a public key for verify with ED25519");
|
|
28
|
-
}
|
|
29
|
-
if (dataToVerify?.length === 0) {
|
|
30
|
-
throw new Error("Must provide allocated data to verify");
|
|
31
|
-
}
|
|
32
|
-
if (signature?.length === 0) {
|
|
33
|
-
throw new Error("Must provide allocated signature to verify");
|
|
34
|
-
}
|
|
35
|
-
return sha256Ed25519DigitalSignatureVerify(publicKey, dataToVerify, signature);
|
|
36
|
-
}
|
|
37
5
|
|
|
38
6
|
/**
|
|
39
7
|
* Generates and RSA digital signature with SHA3-512
|
package/src-ts/index.ts
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Cased25519KeyPairResult,
|
|
3
|
+
generateEd25519Keys,
|
|
4
|
+
signEd25519,
|
|
5
|
+
verifyEd25519,
|
|
6
|
+
} from "../../index";
|
|
7
|
+
|
|
8
|
+
export class Ed25519Wrapper {
|
|
9
|
+
/**
|
|
10
|
+
* Generates a new Ed25519 key pair
|
|
11
|
+
*/
|
|
12
|
+
public getKeyPair(): Cased25519KeyPairResult {
|
|
13
|
+
return generateEd25519Keys();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Signs a message with the given Ed25519 private key
|
|
18
|
+
* @param privateKey The private key to sign the message with
|
|
19
|
+
* @param message The message to sign
|
|
20
|
+
* @returns The signature
|
|
21
|
+
*/
|
|
22
|
+
public signMessage(privateKey: number[], message: number[]): number[] {
|
|
23
|
+
return signEd25519(privateKey, message);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Verifies a signature for a message with the given Ed25519 public key
|
|
28
|
+
* @param publicKey The public key to verify the signature with
|
|
29
|
+
* @param message The signed message
|
|
30
|
+
* @param signature The signature to verify
|
|
31
|
+
* @returns True if the signature is valid, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
public verifyMessage(publicKey: number[], message: number[], signature: number[]): boolean {
|
|
34
|
+
return verifyEd25519(publicKey, message, signature);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CASAesKeyFromX25519SharedSecret,
|
|
3
2
|
aes128Decrypt,
|
|
4
3
|
aes128Encrypt,
|
|
5
4
|
aes128Key,
|
|
@@ -87,7 +86,7 @@ export class AESWrapper {
|
|
|
87
86
|
* @param shared_secret
|
|
88
87
|
* @returns
|
|
89
88
|
*/
|
|
90
|
-
public aes256KeyNonceX25519DiffieHellman(shared_secret: Array<number>):
|
|
89
|
+
public aes256KeyNonceX25519DiffieHellman(shared_secret: Array<number>): number[] {
|
|
91
90
|
return aes256KeyFromX25519SharedSecret(shared_secret);
|
|
92
91
|
}
|
|
93
92
|
|
|
@@ -96,7 +95,7 @@ export class AESWrapper {
|
|
|
96
95
|
* @param shared_secret
|
|
97
96
|
* @returns
|
|
98
97
|
*/
|
|
99
|
-
public aes128KeyNonceX25519DiffieHellman(shared_secret: Array<number>):
|
|
98
|
+
public aes128KeyNonceX25519DiffieHellman(shared_secret: Array<number>): number[] {
|
|
100
99
|
return aes128KeyFromX25519SharedSecret(shared_secret);
|
|
101
100
|
}
|
|
102
101
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assert } from "chai";
|
|
2
2
|
import { DigitalSignatureFactory, DigitalSignatureType } from "../src-ts/digital-signature/digital-signature-factory";
|
|
3
3
|
import { CASRSADigitalSignatureResult } from "../index";
|
|
4
|
+
import { Ed25519Wrapper } from "../src-ts/signature/ed25519-wrapper";
|
|
4
5
|
|
|
5
6
|
describe("Digital Signature", () => {
|
|
6
7
|
it("SHA 512 RSA pass", () => {
|
|
@@ -47,47 +48,23 @@ describe("Digital Signature", () => {
|
|
|
47
48
|
assert.equal(verify, false);
|
|
48
49
|
});
|
|
49
50
|
|
|
50
|
-
it("SHA 512 ED25519 pass", () => {
|
|
51
|
-
const shaDsWrapper = DigitalSignatureFactory.get(DigitalSignatureType.SHA512)
|
|
52
|
-
const toHash: string = "This is my array to encrypt";
|
|
53
|
-
const encoder = new TextEncoder();
|
|
54
|
-
const toHashBytes: Array<number> = Array.from(encoder.encode(toHash));
|
|
55
|
-
const dsResult = shaDsWrapper.createED25519(toHashBytes);
|
|
56
|
-
const verify = shaDsWrapper.verifyED25519(dsResult.publicKey, toHashBytes, dsResult.signature);
|
|
57
|
-
assert.equal(verify, true);
|
|
58
|
-
});
|
|
59
51
|
|
|
60
|
-
it("
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const dsResult = shaDsWrapper.createED25519(toHashBytes);
|
|
68
|
-
const verify = shaDsWrapper.verifyED25519(dsResult.publicKey, badBytes, dsResult.signature);
|
|
69
|
-
assert.equal(verify, false);
|
|
52
|
+
it("ED25519 Sign and Verify", () => {
|
|
53
|
+
const ed25519 = new Ed25519Wrapper();
|
|
54
|
+
const keyPair = ed25519.getKeyPair();
|
|
55
|
+
const message = Array.from(new TextEncoder().encode("This is a test message"));
|
|
56
|
+
const signature = ed25519.signMessage(keyPair.privateKey, message);
|
|
57
|
+
const isValid = ed25519.verifyMessage(keyPair.publicKey, message, signature);
|
|
58
|
+
assert.equal(isValid, true);
|
|
70
59
|
});
|
|
71
60
|
|
|
72
|
-
it("
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
assert.equal(
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("SHA 256 ED25519 fails", () => {
|
|
83
|
-
const shaDsWrapper = DigitalSignatureFactory.get(DigitalSignatureType.SHA256)
|
|
84
|
-
const toHash: string = "This is my array to encrypt";
|
|
85
|
-
const notOriginal: string = "This is not a fun time";
|
|
86
|
-
const encoder = new TextEncoder();
|
|
87
|
-
const toHashBytes: Array<number> = Array.from(encoder.encode(toHash));
|
|
88
|
-
const badBytes: Array<number> = Array.from(encoder.encode(notOriginal));
|
|
89
|
-
const dsResult = shaDsWrapper.createED25519(toHashBytes);
|
|
90
|
-
const verify = shaDsWrapper.verifyED25519(dsResult.publicKey, badBytes, dsResult.signature);
|
|
91
|
-
assert.equal(verify, false);
|
|
61
|
+
it("ED25519 Verify Fails with Wrong Message", () => {
|
|
62
|
+
const ed25519 = new Ed25519Wrapper();
|
|
63
|
+
const keyPair = ed25519.getKeyPair();
|
|
64
|
+
const message = Array.from(new TextEncoder().encode("This is a test message"));
|
|
65
|
+
const wrongMessage = Array.from(new TextEncoder().encode("This is a different message"));
|
|
66
|
+
const signature = ed25519.signMessage(keyPair.privateKey, message);
|
|
67
|
+
const isValid = ed25519.verifyMessage(keyPair.publicKey, wrongMessage, signature);
|
|
68
|
+
assert.equal(isValid, false);
|
|
92
69
|
});
|
|
93
70
|
});
|
|
@@ -21,8 +21,10 @@ describe("Insecure Channel Tests", () => {
|
|
|
21
21
|
const encoder = new TextEncoder();
|
|
22
22
|
const toEncrypt: Array<number> = Array.from(encoder.encode(tohashed));
|
|
23
23
|
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const nonce = aesWrapper.generateAESNonce();
|
|
25
|
+
|
|
26
|
+
const encrypted = aesWrapper.aes256Encrypt(alice_aes_key, nonce, toEncrypt);
|
|
27
|
+
const decrypted = aesWrapper.aes256Decrypt(bob_aes_key, nonce, encrypted);
|
|
26
28
|
let result = areEqual(decrypted, toEncrypt);
|
|
27
29
|
assert.isTrue(result);
|
|
28
30
|
});
|
|
@@ -43,8 +45,10 @@ describe("Insecure Channel Tests", () => {
|
|
|
43
45
|
const encoder = new TextEncoder();
|
|
44
46
|
const toEncrypt: Array<number> = Array.from(encoder.encode(tohashed));
|
|
45
47
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
+
const nonce = aesWrapper.generateAESNonce();
|
|
49
|
+
|
|
50
|
+
const encrypted = aesWrapper.aes128Encrypt(alice_aes_key, nonce, toEncrypt);
|
|
51
|
+
const decrypted = aesWrapper.aes128Decrypt(bob_aes_key, nonce, encrypted);
|
|
48
52
|
let result = areEqual(decrypted, toEncrypt);
|
|
49
53
|
assert.isTrue(result);
|
|
50
54
|
});
|
|
@@ -42,12 +42,14 @@ describe("Symmetric Tests", () => {
|
|
|
42
42
|
const aliceAesKey = aesWrapper.aes256KeyNonceX25519DiffieHellman(aliceSharedSecret);
|
|
43
43
|
const bobAesKey = aesWrapper.aes256KeyNonceX25519DiffieHellman(bobSharedSecret);
|
|
44
44
|
|
|
45
|
+
const nonce = aesWrapper.generateAESNonce();
|
|
46
|
+
|
|
45
47
|
const tohashed: string = "This is my array to encrypt";
|
|
46
48
|
const encoder = new TextEncoder();
|
|
47
49
|
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
|
|
48
50
|
|
|
49
|
-
const aliceCiphertext = aesWrapper.aes256Encrypt(aliceAesKey
|
|
50
|
-
const bobPlaintext = aesWrapper.aes256Decrypt(bobAesKey
|
|
51
|
+
const aliceCiphertext = aesWrapper.aes256Encrypt(aliceAesKey, nonce, tohashBytes);
|
|
52
|
+
const bobPlaintext = aesWrapper.aes256Decrypt(bobAesKey, nonce, aliceCiphertext);
|
|
51
53
|
|
|
52
54
|
var result = areEqual(bobPlaintext, tohashBytes);
|
|
53
55
|
assert.isTrue(result);
|
|
@@ -69,8 +71,10 @@ describe("Symmetric Tests", () => {
|
|
|
69
71
|
const encoder = new TextEncoder();
|
|
70
72
|
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
|
|
71
73
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
+
const nonce = aesWrapper.generateAESNonce();
|
|
75
|
+
|
|
76
|
+
const aliceCiphertext = aesWrapper.aes128Encrypt(aliceAesKey, nonce, tohashBytes);
|
|
77
|
+
const bobPlaintext = aesWrapper.aes128Decrypt(bobAesKey, nonce, aliceCiphertext);
|
|
74
78
|
|
|
75
79
|
var result = areEqual(bobPlaintext, tohashBytes);
|
|
76
80
|
assert.isTrue(result);
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
use cas_lib::digital_signature::{cas_digital_signature_rsa::ED25519DigitalSignature, sha_256_ed25519::SHA256ED25519DigitalSignature};
|
|
2
|
-
use napi_derive::napi;
|
|
3
|
-
|
|
4
|
-
use super::types::CASSHAED25519DalekDigitalSignatureResult;
|
|
5
|
-
|
|
6
|
-
#[napi]
|
|
7
|
-
pub fn sha_256_ed25519_digital_signature(data_to_sign: Vec<u8>) -> CASSHAED25519DalekDigitalSignatureResult {
|
|
8
|
-
return <SHA256ED25519DigitalSignature as ED25519DigitalSignature>::digital_signature_ed25519(data_to_sign).into();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
#[napi]
|
|
12
|
-
pub fn sha_256_ed25519_digital_signature_verify(public_key: Vec<u8>, data_to_verify: Vec<u8>, signature: Vec<u8>) -> bool {
|
|
13
|
-
if public_key.len() != 32 || signature.len() != 64 {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
SHA256ED25519DigitalSignature::digital_signature_ed25519_verify(public_key, data_to_verify, signature)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
#[test]
|
|
21
|
-
fn sha_256_ed25519_test() {
|
|
22
|
-
let key_size: u32 = 1024;
|
|
23
|
-
let data_to_sign = b"GetTheseBytes".to_vec();
|
|
24
|
-
let signature_result: CASSHAED25519DalekDigitalSignatureResult = SHA256ED25519DigitalSignature::digital_signature_ed25519(data_to_sign.clone()).into();
|
|
25
|
-
let is_verified: bool = SHA256ED25519DigitalSignature::digital_signature_ed25519_verify(signature_result.public_key, data_to_sign, signature_result.signature);
|
|
26
|
-
assert_eq!(is_verified, true);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#[test]
|
|
30
|
-
fn sha_512_ed25519_test_fail() {
|
|
31
|
-
let key_size: u32 = 1024;
|
|
32
|
-
let data_to_sign = b"GetTheseBytes".to_vec();
|
|
33
|
-
let signature_result: CASSHAED25519DalekDigitalSignatureResult = SHA256ED25519DigitalSignature::digital_signature_ed25519(data_to_sign.clone()).into();
|
|
34
|
-
let not_original_data = b"NOtTHoseBytes".to_vec();
|
|
35
|
-
let is_verified: bool = SHA256ED25519DigitalSignature::digital_signature_ed25519_verify(signature_result.public_key, not_original_data, signature_result.signature);
|
|
36
|
-
assert_eq!(is_verified, false);
|
|
37
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
use cas_lib::digital_signature::{cas_digital_signature_rsa::{ED25519DigitalSignature, SHAED25519DalekDigitalSignatureResult}, sha_512_ed25519::SHA512ED25519DigitalSignature};
|
|
2
|
-
|
|
3
|
-
use napi_derive::napi;
|
|
4
|
-
|
|
5
|
-
use super::types::CASSHAED25519DalekDigitalSignatureResult;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
#[napi]
|
|
9
|
-
pub fn sha_512_ed25519_digital_signature(data_to_sign: Vec<u8>) -> CASSHAED25519DalekDigitalSignatureResult {
|
|
10
|
-
return <SHA512ED25519DigitalSignature as ED25519DigitalSignature>::digital_signature_ed25519(data_to_sign).into();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
#[napi]
|
|
14
|
-
pub fn sha_512_ed25519_digital_signature_verify(public_key: Vec<u8>, data_to_verify: Vec<u8>, signature: Vec<u8>) -> bool {
|
|
15
|
-
return <SHA512ED25519DigitalSignature as ED25519DigitalSignature>::digital_signature_ed25519_verify(
|
|
16
|
-
public_key,
|
|
17
|
-
data_to_verify,
|
|
18
|
-
signature,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
#[test]
|
|
23
|
-
fn sha_512_ed25519_test() {
|
|
24
|
-
let key_size: u32 = 1024;
|
|
25
|
-
let data_to_sign = b"GetTheseBytes".to_vec();
|
|
26
|
-
let signature_result: SHAED25519DalekDigitalSignatureResult = <SHA512ED25519DigitalSignature as ED25519DigitalSignature>::digital_signature_ed25519(data_to_sign.clone());
|
|
27
|
-
let is_verified: bool = SHA512ED25519DigitalSignature::digital_signature_ed25519_verify(signature_result.public_key, data_to_sign, signature_result.signature);
|
|
28
|
-
assert_eq!(is_verified, true);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
#[test]
|
|
32
|
-
fn sha_512_ed25519_test_fail() {
|
|
33
|
-
let key_size: u32 = 1024;
|
|
34
|
-
let data_to_sign = b"GetTheseBytes".to_vec();
|
|
35
|
-
let signature_result: CASSHAED25519DalekDigitalSignatureResult = <SHA512ED25519DigitalSignature as ED25519DigitalSignature>::digital_signature_ed25519(data_to_sign.clone()).into();
|
|
36
|
-
let not_original_data = b"NOtTHoseBytes".to_vec();
|
|
37
|
-
let is_verified: bool = SHA512ED25519DigitalSignature::digital_signature_ed25519_verify(
|
|
38
|
-
signature_result.public_key,
|
|
39
|
-
not_original_data,
|
|
40
|
-
signature_result.signature,
|
|
41
|
-
);
|
|
42
|
-
assert_eq!(is_verified, false);
|
|
43
|
-
}
|
package/src/symmetric/types.rs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
use cas_lib::symmetric::cas_symmetric_encryption::{Aes128KeyFromX25519SharedSecret, Aes256KeyFromX25519SharedSecret};
|
|
3
|
-
use napi_derive::napi;
|
|
4
|
-
|
|
5
|
-
#[napi(constructor)]
|
|
6
|
-
pub struct CASAesKeyFromX25519SharedSecret {
|
|
7
|
-
pub aes_key: Vec<u8>,
|
|
8
|
-
pub aes_nonce: Vec<u8>,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
impl From<Aes128KeyFromX25519SharedSecret> for CASAesKeyFromX25519SharedSecret {
|
|
12
|
-
fn from(value: Aes128KeyFromX25519SharedSecret) -> Self {
|
|
13
|
-
CASAesKeyFromX25519SharedSecret {
|
|
14
|
-
aes_key: value.aes_key.to_vec(),
|
|
15
|
-
aes_nonce: value.aes_nonce.to_vec()
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
impl From<Aes256KeyFromX25519SharedSecret> for CASAesKeyFromX25519SharedSecret {
|
|
21
|
-
fn from(value: Aes256KeyFromX25519SharedSecret) -> Self {
|
|
22
|
-
CASAesKeyFromX25519SharedSecret {
|
|
23
|
-
aes_key: value.aes_key.to_vec(),
|
|
24
|
-
aes_nonce: value.aes_nonce.to_vec()
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|