-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web-client): add Diffie-Hellman key agreement
- Loading branch information
Showing
11 changed files
with
389 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/node_modules/@stablelib/binary/tsconfig.json b/node_modules/@stablelib/binary/tsconfig.json | ||
index 81435d2..4082f16 100644 | ||
--- a/node_modules/@stablelib/binary/tsconfig.json | ||
+++ b/node_modules/@stablelib/binary/tsconfig.json | ||
@@ -1,27 +1,3 @@ | ||
{ | ||
- "compilerOptions": { | ||
- "target": "es5", | ||
- "module": "commonjs", | ||
- "strict": true, | ||
- "noUnusedParameters": true, | ||
- "noImplicitReturns": true, | ||
- "noUnusedLocals": true, | ||
- "removeComments": false, | ||
- "preserveConstEnums": true, | ||
- "moduleResolution": "node", | ||
- "newLine": "LF", | ||
- "sourceMap": true, | ||
- "declaration": true, | ||
- "outDir": "lib", | ||
- "lib": [ | ||
- "es5", | ||
- "es2015.promise", | ||
- "dom", | ||
- "scripthost" | ||
- ] | ||
- }, | ||
- "exclude": [ | ||
- "node_modules", | ||
- "lib" | ||
- ] | ||
+ "extends": "../../tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/node_modules/@stablelib/bytes/tsconfig.json b/node_modules/@stablelib/bytes/tsconfig.json | ||
index 81435d2..4082f16 100644 | ||
--- a/node_modules/@stablelib/bytes/tsconfig.json | ||
+++ b/node_modules/@stablelib/bytes/tsconfig.json | ||
@@ -1,27 +1,3 @@ | ||
{ | ||
- "compilerOptions": { | ||
- "target": "es5", | ||
- "module": "commonjs", | ||
- "strict": true, | ||
- "noUnusedParameters": true, | ||
- "noImplicitReturns": true, | ||
- "noUnusedLocals": true, | ||
- "removeComments": false, | ||
- "preserveConstEnums": true, | ||
- "moduleResolution": "node", | ||
- "newLine": "LF", | ||
- "sourceMap": true, | ||
- "declaration": true, | ||
- "outDir": "lib", | ||
- "lib": [ | ||
- "es5", | ||
- "es2015.promise", | ||
- "dom", | ||
- "scripthost" | ||
- ] | ||
- }, | ||
- "exclude": [ | ||
- "node_modules", | ||
- "lib" | ||
- ] | ||
+ "extends": "../../tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/node_modules/@stablelib/int/tsconfig.json b/node_modules/@stablelib/int/tsconfig.json | ||
index 81435d2..4082f16 100644 | ||
--- a/node_modules/@stablelib/int/tsconfig.json | ||
+++ b/node_modules/@stablelib/int/tsconfig.json | ||
@@ -1,27 +1,3 @@ | ||
{ | ||
- "compilerOptions": { | ||
- "target": "es5", | ||
- "module": "commonjs", | ||
- "strict": true, | ||
- "noUnusedParameters": true, | ||
- "noImplicitReturns": true, | ||
- "noUnusedLocals": true, | ||
- "removeComments": false, | ||
- "preserveConstEnums": true, | ||
- "moduleResolution": "node", | ||
- "newLine": "LF", | ||
- "sourceMap": true, | ||
- "declaration": true, | ||
- "outDir": "lib", | ||
- "lib": [ | ||
- "es5", | ||
- "es2015.promise", | ||
- "dom", | ||
- "scripthost" | ||
- ] | ||
- }, | ||
- "exclude": [ | ||
- "node_modules", | ||
- "lib" | ||
- ] | ||
+ "extends": "../../tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/node_modules/@stablelib/keyagreement/tsconfig.json b/node_modules/@stablelib/keyagreement/tsconfig.json | ||
index 81435d2..4082f16 100644 | ||
--- a/node_modules/@stablelib/keyagreement/tsconfig.json | ||
+++ b/node_modules/@stablelib/keyagreement/tsconfig.json | ||
@@ -1,27 +1,3 @@ | ||
{ | ||
- "compilerOptions": { | ||
- "target": "es5", | ||
- "module": "commonjs", | ||
- "strict": true, | ||
- "noUnusedParameters": true, | ||
- "noImplicitReturns": true, | ||
- "noUnusedLocals": true, | ||
- "removeComments": false, | ||
- "preserveConstEnums": true, | ||
- "moduleResolution": "node", | ||
- "newLine": "LF", | ||
- "sourceMap": true, | ||
- "declaration": true, | ||
- "outDir": "lib", | ||
- "lib": [ | ||
- "es5", | ||
- "es2015.promise", | ||
- "dom", | ||
- "scripthost" | ||
- ] | ||
- }, | ||
- "exclude": [ | ||
- "node_modules", | ||
- "lib" | ||
- ] | ||
+ "extends": "../../tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
diff --git a/node_modules/@stablelib/random/source/browser.ts b/node_modules/@stablelib/random/source/browser.ts | ||
index b25887b..a016ebb 100644 | ||
--- a/node_modules/@stablelib/random/source/browser.ts | ||
+++ b/node_modules/@stablelib/random/source/browser.ts | ||
@@ -16,7 +16,7 @@ export class BrowserRandomSource implements RandomSource { | ||
? (self.crypto || (self as { msCrypto?: any }).msCrypto) // IE11 has msCrypto | ||
: null; | ||
|
||
- if (browserCrypto && browserCrypto.getRandomValues !== undefined) { | ||
+ if (browserCrypto && browserCrypto.getRandomValues) { | ||
this._crypto = browserCrypto; | ||
this.isAvailable = true; | ||
this.isInstantiated = true; | ||
diff --git a/node_modules/@stablelib/random/tsconfig.json b/node_modules/@stablelib/random/tsconfig.json | ||
index 5d5a801..4082f16 100644 | ||
--- a/node_modules/@stablelib/random/tsconfig.json | ||
+++ b/node_modules/@stablelib/random/tsconfig.json | ||
@@ -1,10 +1,3 @@ | ||
{ | ||
- "extends": "../../configs/tsconfig.json", | ||
- "compilerOptions": { | ||
- "outDir": "lib", | ||
- }, | ||
- "exclude": [ | ||
- "node_modules", | ||
- "lib" | ||
- ] | ||
+ "extends": "../../tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/node_modules/@stablelib/wipe/tsconfig.json b/node_modules/@stablelib/wipe/tsconfig.json | ||
index 81435d2..4082f16 100644 | ||
--- a/node_modules/@stablelib/wipe/tsconfig.json | ||
+++ b/node_modules/@stablelib/wipe/tsconfig.json | ||
@@ -1,27 +1,3 @@ | ||
{ | ||
- "compilerOptions": { | ||
- "target": "es5", | ||
- "module": "commonjs", | ||
- "strict": true, | ||
- "noUnusedParameters": true, | ||
- "noImplicitReturns": true, | ||
- "noUnusedLocals": true, | ||
- "removeComments": false, | ||
- "preserveConstEnums": true, | ||
- "moduleResolution": "node", | ||
- "newLine": "LF", | ||
- "sourceMap": true, | ||
- "declaration": true, | ||
- "outDir": "lib", | ||
- "lib": [ | ||
- "es5", | ||
- "es2015.promise", | ||
- "dom", | ||
- "scripthost" | ||
- ] | ||
- }, | ||
- "exclude": [ | ||
- "node_modules", | ||
- "lib" | ||
- ] | ||
+ "extends": "../../tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
diff --git a/node_modules/@stablelib/x25519/tsconfig.json b/node_modules/@stablelib/x25519/tsconfig.json | ||
index 5d5a801..4082f16 100644 | ||
--- a/node_modules/@stablelib/x25519/tsconfig.json | ||
+++ b/node_modules/@stablelib/x25519/tsconfig.json | ||
@@ -1,10 +1,3 @@ | ||
{ | ||
- "extends": "../../configs/tsconfig.json", | ||
- "compilerOptions": { | ||
- "outDir": "lib", | ||
- }, | ||
- "exclude": [ | ||
- "node_modules", | ||
- "lib" | ||
- ] | ||
+ "extends": "../../tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { X25519KeyAgreement } from '@stablelib/x25519/lib/keyagreement'; | ||
import { DiffieHellman, PublicKey, SharedSecret } from './crypto'; | ||
|
||
describe("DiffieHellman", () => { | ||
it("successfully established a shared secret", () => { | ||
const clientSide = DiffieHellman.from_seed(Uint8Array.from(Array(32).fill(111))); | ||
const serverSide = new X25519KeyAgreement(Uint8Array.from(Array(32).fill(222))); | ||
|
||
const clientPk: PublicKey = clientSide.x25519_public_key(); | ||
const serverSecret: SharedSecret = serverSide.finish(clientPk).getSharedKey(); | ||
|
||
const serverPk: PublicKey = serverSide.offer(); | ||
const clientSecret: SharedSecret = clientSide.diffie_hellman(serverPk); | ||
expect(clientSecret).toEqual(serverSecret); | ||
}) | ||
}) |
Oops, something went wrong.