Skip to content

Commit

Permalink
feat(web-client): add Diffie-Hellman key agreement
Browse files Browse the repository at this point in the history
  • Loading branch information
jdvlio committed Aug 29, 2022
1 parent b8ff054 commit 0dce201
Show file tree
Hide file tree
Showing 11 changed files with 389 additions and 1 deletion.
101 changes: 101 additions & 0 deletions web-client/package-lock.json

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

1 change: 1 addition & 0 deletions web-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@ngneat/until-destroy": "^9.2.1",
"@sentry/angular": "^6.19.7",
"@sentry/capacitor": "^0.6.1",
"@stablelib/x25519": "^1.0.3",
"@zxing/browser": "^0.1.1",
"@zxing/library": "^0.19.1",
"@zxing/ngx-scanner": "~3.5.0",
Expand Down
33 changes: 33 additions & 0 deletions web-client/patches/@stablelib+binary+1.0.1.patch
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"
}
33 changes: 33 additions & 0 deletions web-client/patches/@stablelib+bytes+1.0.1.patch
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"
}
33 changes: 33 additions & 0 deletions web-client/patches/@stablelib+int+1.0.1.patch
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"
}
33 changes: 33 additions & 0 deletions web-client/patches/@stablelib+keyagreement+1.0.1.patch
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"
}
29 changes: 29 additions & 0 deletions web-client/patches/@stablelib+random+1.0.1.patch
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"
}
33 changes: 33 additions & 0 deletions web-client/patches/@stablelib+wipe+1.0.1.patch
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"
}
16 changes: 16 additions & 0 deletions web-client/patches/@stablelib+x25519+1.0.2.patch
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"
}
16 changes: 16 additions & 0 deletions web-client/src/schema/crypto.spec.ts
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);
})
})
Loading

0 comments on commit 0dce201

Please sign in to comment.