Skip to content

Commit 2186b42

Browse files
authored
Merge pull request #15 from Cryptographic-API-Services/pre-release
Function Name Matching For C# SDK
2 parents 7410b23 + 5e7cdd5 commit 2186b42

16 files changed

+46
-46
lines changed

index.node

0 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

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

src-ts/hashers/hasher-base.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface IHasherBase {
2-
hash_512(dataToHash: number[]): number[];
3-
verify_512(dataToHash: number[], dataToVerify: number[]): boolean;
4-
hash_256(dataToHash: number[]): number[];
5-
verify_256(dataToHash: number[], dataToVerify: number[]): boolean;
2+
hash512(dataToHash: number[]): number[];
3+
verify512(dataToHash: number[], dataToVerify: number[]): boolean;
4+
hash256(dataToHash: number[]): number[];
5+
verify256(dataToHash: number[], dataToVerify: number[]): boolean;
66
}

src-ts/hashers/sha-wrapper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { sha256, sha256Verify, sha512, sha512Verify } from "../../index";
22
import { IHasherBase } from "./hasher-base";
33

44
export class SHAWrapper implements IHasherBase {
5-
hash_512(dataToHash: number[]): number[] {
5+
hash512(dataToHash: number[]): number[] {
66
if (!dataToHash || dataToHash.length === 0) {
77
throw new Error("You must provide an allocated array of data");
88
}
99
return sha512(dataToHash);
1010
}
1111

12-
verify_512(dataToHash: number[], dataToVerify: number[]): boolean {
12+
verify512(dataToHash: number[], dataToVerify: number[]): boolean {
1313
if (!dataToHash || dataToHash.length === 0) {
1414
throw new Error("You must provide an allocated array of data");
1515
}
@@ -19,14 +19,14 @@ export class SHAWrapper implements IHasherBase {
1919
return sha512Verify(dataToHash, dataToVerify);
2020
}
2121

22-
hash_256(dataToHash: number[]): number[] {
22+
hash256(dataToHash: number[]): number[] {
2323
if (!dataToHash || dataToHash.length === 0) {
2424
throw new Error("You must provide an allocated array of data");
2525
}
2626
return sha256(dataToHash);
2727
}
2828

29-
verify_256(dataToHash: number[], dataToVerify: number[]): boolean {
29+
verify256(dataToHash: number[], dataToVerify: number[]): boolean {
3030
if (!dataToHash || dataToHash.length === 0) {
3131
throw new Error("You must provide an allocated array of data");
3232
}

src-ts/hybrid/types/aes-rsa-hybrid-initializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class AESRSAHybridInitializer {
1515
this.aesType = aesType;
1616
let aesWrapper = new AESWrapper();
1717
this.aesKey = (aesType === 128) ? aesWrapper.aes128Key() : aesWrapper.aes256Key();
18-
this.aesNonce = aesWrapper.aesNonce();
18+
this.aesNonce = aesWrapper.generateAESNonce();
1919
if (rsaSize !== 1028 && rsaSize !== 2048 && rsaSize !== 4096) {
2020
throw new Error("You must provide an appropriate RSA Key pair size to generate a hybrid initalizer");
2121
}

src-ts/key_exchange/x25519.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class X25519Wrapper {
55
return x25519GenerateSecretAndPublicKey();
66
}
77

8-
public diffieHellman(secretKey: Array<number>, publicKey: Array<number>) {
8+
public generateSharedSecret(secretKey: Array<number>, publicKey: Array<number>) {
99
return x25519DiffieHellman(secretKey, publicKey);
1010
}
1111
}

src-ts/password-hashers/argon2-wrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class Argon2Wrapper implements IPasswordHasherBase {
99
return argon2Hash(password);
1010
}
1111

12-
public verifyPassword(hashedPassword: string, passwordToVerify: string): boolean {
12+
public verify(hashedPassword: string, passwordToVerify: string): boolean {
1313
if (!hashedPassword || !passwordToVerify) {
1414
throw new Error("You must provide a hashed password and a plaintext password to verify with Argon2");
1515
}

src-ts/password-hashers/bcrypt-wrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class BCryptWrapper implements IPasswordHasherBase {
99
return bcryptHash(password);
1010
}
1111

12-
public verifyPassword(
12+
public verify(
1313
hashedPassword: string,
1414
passwordToVerify: string,
1515
): boolean {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export interface IPasswordHasherBase {
22
hashPassword(password: string): string;
3-
verifyPassword(hashedPassword: string, passwordToVerify: string): boolean;
3+
verify(hashedPassword: string, passwordToVerify: string): boolean;
44
}

src-ts/password-hashers/scrypt-wrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ScryptWrapper implements IPasswordHasherBase {
1010
return scryptHash(password);
1111
}
1212

13-
public verifyPassword(hashedPassword: string, passwordToVerify: string): boolean {
13+
public verify(hashedPassword: string, passwordToVerify: string): boolean {
1414
if (!hashedPassword || !passwordToVerify) {
1515
throw new Error("You must provide a hashed password and a plaintext password to verify with Scrypt");
1616
}

src-ts/symmetric/aes-wrapper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class AESWrapper {
2020
return aes256Key();
2121
}
2222

23-
public aesNonce(): Array<number> {
23+
public generateAESNonce(): Array<number> {
2424
return aesNonce();
2525
}
2626

@@ -40,11 +40,11 @@ export class AESWrapper {
4040
return aes256Decrypt(aesKey, nonce, ciphertext);
4141
}
4242

43-
public aes256KeyFromX25519SharedSecret(shared_secret: Array<number>): AesKeyFromX25519SharedSecret {
43+
public aes256KeyNonceX25519DiffieHellman(shared_secret: Array<number>): AesKeyFromX25519SharedSecret {
4444
return aes256KeyFromX25519SharedSecret(shared_secret);
4545
}
4646

47-
public aes128KeyFromX25519SharedSecret(shared_secret: Array<number>): AesKeyFromX25519SharedSecret {
47+
public aes128KeyNonceX25519DiffieHellman(shared_secret: Array<number>): AesKeyFromX25519SharedSecret {
4848
return aes128KeyFromX25519SharedSecret(shared_secret);
4949
}
5050
}

test-ts/hasher.test.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("SHA512 Tests", () => {
77
const tohashed: string = "This is my array to hash";
88
const encoder = new TextEncoder();
99
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
10-
const hashed = wrapper.hash_512(tohashBytes);
10+
const hashed = wrapper.hash512(tohashBytes);
1111
assert.notEqual(tohashBytes, hashed);
1212
});
1313

@@ -16,9 +16,9 @@ describe("SHA512 Tests", () => {
1616
const tohashed: string = "This is my array to hash";
1717
const encoder = new TextEncoder();
1818
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
19-
const hashed = wrapper.hash_512(tohashBytes);
19+
const hashed = wrapper.hash512(tohashBytes);
2020
const toVerifyBytes: Array<number> = Array.from(encoder.encode(tohashed));
21-
const verified = wrapper.verify_512(hashed, toVerifyBytes);
21+
const verified = wrapper.verify512(hashed, toVerifyBytes);
2222
assert.equal(true, verified);
2323
});
2424

@@ -27,10 +27,10 @@ describe("SHA512 Tests", () => {
2727
const tohashed: string = "This is my array to hash";
2828
const encoder = new TextEncoder();
2929
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
30-
const hashed = wrapper.hash_512(tohashBytes);
30+
const hashed = wrapper.hash512(tohashBytes);
3131
const toVerify = "This Is Not The Same";
3232
const toVerifyBytes: Array<number> = Array.from(encoder.encode(toVerify));
33-
const verified = wrapper.verify_512(hashed, toVerifyBytes);
33+
const verified = wrapper.verify512(hashed, toVerifyBytes);
3434
assert.equal(false, verified);
3535
});
3636
});
@@ -42,7 +42,7 @@ describe("SHA256 Tests", () => {
4242
const tohashed: string = "This is my array to hash";
4343
const encoder = new TextEncoder();
4444
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
45-
const hashed = wrapper.hash_256(tohashBytes);
45+
const hashed = wrapper.hash256(tohashBytes);
4646
assert.notEqual(tohashBytes, hashed);
4747
});
4848

@@ -51,9 +51,9 @@ describe("SHA256 Tests", () => {
5151
const tohashed: string = "This is my array to hash";
5252
const encoder = new TextEncoder();
5353
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
54-
const hashed = wrapper.hash_256(tohashBytes);
54+
const hashed = wrapper.hash256(tohashBytes);
5555
const toVerifyBytes: Array<number> = Array.from(encoder.encode(tohashed));
56-
const verified = wrapper.verify_256(hashed, toVerifyBytes);
56+
const verified = wrapper.verify256(hashed, toVerifyBytes);
5757
assert.equal(true, verified);
5858
});
5959

@@ -62,10 +62,10 @@ describe("SHA256 Tests", () => {
6262
const tohashed: string = "This is my array to hash";
6363
const encoder = new TextEncoder();
6464
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
65-
const hashed = wrapper.hash_256(tohashBytes);
65+
const hashed = wrapper.hash256(tohashBytes);
6666
const toVerify = "This Is Not The Same";
6767
const toVerifyBytes: Array<number> = Array.from(encoder.encode(toVerify));
68-
const verified = wrapper.verify_256(hashed, toVerifyBytes);
68+
const verified = wrapper.verify256(hashed, toVerifyBytes);
6969
assert.equal(false, verified);
7070
});
7171
});

test-ts/insecure-channel.test.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ describe("Insecure Channel Tests", () => {
1111
const alice_keys: X25519SecretPublicKeyResult = x25519Wrapper.generateSecretAndPublicKey();
1212
const bob_keys: X25519SecretPublicKeyResult = x25519Wrapper.generateSecretAndPublicKey();
1313

14-
const alice_shared_secret = x25519Wrapper.diffieHellman(alice_keys.secretKey, bob_keys.publicKey);
15-
const bob_shared_secret = x25519Wrapper.diffieHellman(bob_keys.secretKey, alice_keys.publicKey);
14+
const alice_shared_secret = x25519Wrapper.generateSharedSecret(alice_keys.secretKey, bob_keys.publicKey);
15+
const bob_shared_secret = x25519Wrapper.generateSharedSecret(bob_keys.secretKey, alice_keys.publicKey);
1616

17-
const alice_aes_key = aesWrapper.aes256KeyFromX25519SharedSecret(alice_shared_secret);
18-
const bob_aes_key = aesWrapper.aes256KeyFromX25519SharedSecret(bob_shared_secret);
17+
const alice_aes_key = aesWrapper.aes256KeyNonceX25519DiffieHellman(alice_shared_secret);
18+
const bob_aes_key = aesWrapper.aes256KeyNonceX25519DiffieHellman(bob_shared_secret);
1919

2020
const tohashed: string = "This is my encrypt text";
2121
const encoder = new TextEncoder();
@@ -33,11 +33,11 @@ describe("Insecure Channel Tests", () => {
3333
const alice_keys: X25519SecretPublicKeyResult = x25519Wrapper.generateSecretAndPublicKey();
3434
const bob_keys: X25519SecretPublicKeyResult = x25519Wrapper.generateSecretAndPublicKey();
3535

36-
const alice_shared_secret = x25519Wrapper.diffieHellman(alice_keys.secretKey, bob_keys.publicKey);
37-
const bob_shared_secret = x25519Wrapper.diffieHellman(bob_keys.secretKey, alice_keys.publicKey);
36+
const alice_shared_secret = x25519Wrapper.generateSharedSecret(alice_keys.secretKey, bob_keys.publicKey);
37+
const bob_shared_secret = x25519Wrapper.generateSharedSecret(bob_keys.secretKey, alice_keys.publicKey);
3838

39-
const alice_aes_key = aesWrapper.aes128KeyFromX25519SharedSecret(alice_shared_secret);
40-
const bob_aes_key = aesWrapper.aes128KeyFromX25519SharedSecret(bob_shared_secret);
39+
const alice_aes_key = aesWrapper.aes128KeyNonceX25519DiffieHellman(alice_shared_secret);
40+
const bob_aes_key = aesWrapper.aes128KeyNonceX25519DiffieHellman(bob_shared_secret);
4141

4242
const tohashed: string = "This is my encrypt text";
4343
const encoder = new TextEncoder();

test-ts/key-exchange-test.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ describe("X25519 Key Exchange", () => {
88
const alice = wrapper.generateSecretAndPublicKey();
99
const bob = wrapper.generateSecretAndPublicKey();
1010

11-
const alice_shared_secret = wrapper.diffieHellman(
11+
const alice_shared_secret = wrapper.generateSharedSecret(
1212
alice.secretKey,
1313
bob.publicKey,
1414
);
15-
const bob_shared_secret = wrapper.diffieHellman(
15+
const bob_shared_secret = wrapper.generateSharedSecret(
1616
bob.secretKey,
1717
alice.publicKey,
1818
);

test-ts/password-hasher-test.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ describe("Bcrypt Tests", () => {
1818
const hasher: BCryptWrapper = new BCryptWrapper();
1919
const password: string = "NotThisPassword!@";
2020
const hashedPassword: string = hasher.hashPassword(password);
21-
const isValid: boolean = hasher.verifyPassword(hashedPassword, password);
21+
const isValid: boolean = hasher.verify(hashedPassword, password);
2222
expect(isValid).to.equal(true);
2323
});
2424

2525
it("verify fail", () => {
2626
const hasher: BCryptWrapper = new BCryptWrapper();
2727
const password: string = "NotThisPassword!@";
2828
const hashedPassword: string = hasher.hashPassword(password);
29-
const isValid: boolean = hasher.verifyPassword(
29+
const isValid: boolean = hasher.verify(
3030
hashedPassword,
3131
"ThesePasswordsDoNotMatch",
3232
);
@@ -50,7 +50,7 @@ describe("Scrypt Tests", () => {
5050
);
5151
const password: string = "ScryptRocks1231231";
5252
const hashed: string = hasher.hashPassword(password);
53-
const verified: boolean = hasher.verifyPassword(hashed, password);
53+
const verified: boolean = hasher.verify(hashed, password);
5454
assert.isTrue(verified);
5555
});
5656

@@ -60,7 +60,7 @@ describe("Scrypt Tests", () => {
6060
);
6161
const password: string = "ScryptRocksSomeGarbageText";
6262
const hashed: string = hasher.hashPassword(password);
63-
const verified: boolean = hasher.verifyPassword(
63+
const verified: boolean = hasher.verify(
6464
hashed,
6565
"make this fail, its not the same",
6666
);
@@ -84,7 +84,7 @@ describe("Argon2 Tests", () => {
8484
);
8585
const password: string = "ScryptRocks1231231";
8686
const hashed: string = hasher.hashPassword(password);
87-
const verified: boolean = hasher.verifyPassword(hashed, password);
87+
const verified: boolean = hasher.verify(hashed, password);
8888
assert.isTrue(verified);
8989
});
9090

@@ -94,7 +94,7 @@ describe("Argon2 Tests", () => {
9494
);
9595
const password: string = "ScryptRocksSomeGarbageText";
9696
const hashed: string = hasher.hashPassword(password);
97-
const verified: boolean = hasher.verifyPassword(
97+
const verified: boolean = hasher.verify(
9898
hashed,
9999
"make this fail, its not the same",
100100
);

test-ts/symmetric.test.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe("Symmetric Tests", () => {
66
it("aes 128 encrypt and decrypt equals", () => {
77
const aesWrapper: AESWrapper = new AESWrapper();
88
const aesKey = aesWrapper.aes128Key();
9-
const aesNonce = aesWrapper.aesNonce();
9+
const aesNonce = aesWrapper.generateAESNonce();
1010
const tohashed: string = "This is my array to encrypt";
1111
const encoder = new TextEncoder();
1212
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));
@@ -19,7 +19,7 @@ describe("Symmetric Tests", () => {
1919
it("aes 256 encrypt and decrypt equals", () => {
2020
const aesWrapper: AESWrapper = new AESWrapper();
2121
const aesKey = aesWrapper.aes256Key();
22-
const aesNonce = aesWrapper.aesNonce();
22+
const aesNonce = aesWrapper.generateAESNonce();
2323
const tohashed: string = "This is my array to encrypt";
2424
const encoder = new TextEncoder();
2525
const tohashBytes: Array<number> = Array.from(encoder.encode(tohashed));

0 commit comments

Comments
 (0)