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

Updating Crypto to use WebCrypto API and to replace RSA with ECC #446

Merged
merged 68 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5013208
feat: introducing webcrypto to keys domain
CMCDragonkai Oct 7, 2022
be886b5
bench: restructured benchmarks and acquired results for the new
CMCDragonkai Oct 7, 2022
f72b932
feat: beginning libsodium migration
CMCDragonkai Oct 7, 2022
f9ea850
feat: benching after libsodium
CMCDragonkai Oct 9, 2022
9ebf876
fix: replacing `KeyManager` usage with `KeyRing`.
tegefaulkes Oct 10, 2022
bc83a95
fix: `CertIdEncoded` is now a lowercase base16 string
tegefaulkes Oct 11, 2022
80fe433
tests: updating tests
CMCDragonkai Oct 11, 2022
22cd35c
feat: added keyring benchmarks
CMCDragonkai Oct 11, 2022
bcd9c37
feat: added worker overhead benchmarks
CMCDragonkai Oct 11, 2022
5805d74
feat: `KeyRing` worker changes
CMCDragonkai Oct 11, 2022
b4a08f0
tests: fixing tests
tegefaulkes Oct 12, 2022
09115c6
fix: fully removing `setupGlobalKeypair`
tegefaulkes Oct 12, 2022
532e662
feat: generating certificate can be done in the worker now
CMCDragonkai Oct 12, 2022
d15e82f
fix: updated agent status tests and bin command
tegefaulkes Oct 12, 2022
8c4c5ff
tests: added more `CertManager` tests
tegefaulkes Oct 12, 2022
3dc3ff8
feat: CertManager now auto-renews on startup
CMCDragonkai Oct 12, 2022
785fc23
tests: removed all scaffolding and useless packages
CMCDragonkai Oct 12, 2022
022357a
tests: certificate manager tests and PEM tests
CMCDragonkai Oct 12, 2022
365f721
feat: CertManager now renews with existing keypair
CMCDragonkai Oct 13, 2022
ec54799
fix: re-enabling `CertManager` tests
tegefaulkes Oct 13, 2022
d466fcf
fix: Adding `KeyRing` password hashing overrides to tests
tegefaulkes Oct 13, 2022
ec087b0
feat: CertManager now locks when renewing or resetting,
CMCDragonkai Oct 13, 2022
1db1d4f
fix: small fix to network utils
tegefaulkes Oct 13, 2022
d4c859e
fix: renamed error names to be clearer
CMCDragonkai Oct 13, 2022
16fb848
fix: cleaned up polykey worker module to have only keys related funct…
CMCDragonkai Oct 13, 2022
879d919
feat: `VaultManager` constructs and maintains a separate `DB` for the…
tegefaulkes Oct 13, 2022
1c960bd
feat: all ID generators now use `keys/utils/random.ts` for the random…
CMCDragonkai Oct 13, 2022
c1a4f59
tests: cert manager fast check tests and now timing
CMCDragonkai Oct 13, 2022
3471bfc
fix: small fix to claim utils
tegefaulkes Oct 13, 2022
86e38a2
fix: removed old `KeyManager` and keys utils
tegefaulkes Oct 13, 2022
7c0b02e
fix: mem locking error for nodes domain
tegefaulkes Oct 13, 2022
84c8ce9
fix: adding `keyRingConfig` overrides to tests across the board
tegefaulkes Oct 13, 2022
b7281f9
feat: `CertManager` changes
CMCDragonkai Oct 14, 2022
10b39cb
fix: renamed `memoryLocked` to `strictMemoryLock`
tegefaulkes Oct 14, 2022
589f70d
fix: nodes domain getting `PublicKey` from `NodeId` and not through c…
tegefaulkes Oct 14, 2022
314951a
feat: `keys encrypt` and `keys verify` bin commands now take a public…
tegefaulkes Oct 14, 2022
735931e
feat: updating `keys privateKey`, `keys publicKey` and `keys keyPair`
tegefaulkes Oct 14, 2022
013f0e5
test: updating `CertManager` tests
CMCDragonkai Oct 14, 2022
73b9262
fix: split `keys root` into `keys private`, `keys public` and `keys p…
tegefaulkes Oct 17, 2022
0102c74
fix: updated client `keysKeyPair.test.ts` and added `keysPublicKey.te…
tegefaulkes Oct 17, 2022
dde2620
fix: no need to change the name of `keysKeyPairRenew` and `keysKeyPai…
tegefaulkes Oct 17, 2022
3b5a26c
fix: updated `agent start` and `bootstrap` bin commands
tegefaulkes Oct 17, 2022
f48b430
fix: removing old parameters and apply `KeyRing` config overrides for…
tegefaulkes Oct 17, 2022
fad9a6f
fix: updating `AgentChildProcessInput` type
tegefaulkes Oct 17, 2022
9b65a1d
fix: fixed up `keys private` and `keys keypair` to take a new passwor…
tegefaulkes Oct 17, 2022
997d31d
tests: general test fixes
tegefaulkes Oct 17, 2022
5137cee
feat: general rework
CMCDragonkai Oct 15, 2022
7ab3b12
Feat: updating tokens and claims
CMCDragonkai Oct 26, 2022
47bfd04
fix: fixed up buffer locking/unlocking and tests for keys
CMCDragonkai Nov 2, 2022
25bdb60
tests: expanding tests for claims
CMCDragonkai Nov 2, 2022
c4a4ff4
fix: cleaning up claims errors
CMCDragonkai Nov 2, 2022
24000ce
feat: refactoring `gestaltGraph`
CMCDragonkai Nov 3, 2022
eb08bd6
tests: updating `GestaltGraph.test.ts`
tegefaulkes Nov 14, 2022
4bc0738
feat: refactoring `Discovery`
tegefaulkes Nov 14, 2022
b6dc66e
feat: fixing up build issues
tegefaulkes Nov 15, 2022
4285a3c
feat: refactoring claim processes
tegefaulkes Nov 15, 2022
652c5de
fix: fixing sessions tokens
tegefaulkes Nov 16, 2022
a78b4de
fix: notification fixes
tegefaulkes Nov 17, 2022
c70cd08
tests: small fixes for nodeManager tests
tegefaulkes Nov 21, 2022
4af0eee
fix: TLS verification
tegefaulkes Nov 21, 2022
4af9169
fix: session tokens are working now
tegefaulkes Nov 21, 2022
b399b1a
tests: fixing up tests and clean up
tegefaulkes Nov 21, 2022
d71f690
build: update `lint` and `lintfix` script
tegefaulkes Dec 7, 2022
48cefcd
dep: updating typescript versions
tegefaulkes Dec 7, 2022
644dbc1
fix: small type fix
tegefaulkes Dec 7, 2022
b84d634
dep: updated `@matrixai/errors`
tegefaulkes Dec 7, 2022
9321f6c
tests: disabled failing `Vaultmanager` test
tegefaulkes Dec 8, 2022
c68a01d
fix: removed unneeded copy from postbuild script
tegefaulkes Dec 8, 2022
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
4 changes: 2 additions & 2 deletions benches/suites/keys/key_generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ async function main() {
b.add('generate root asymmetric keypair', () => {
generate.generateKeyPair();
}),
b.add('generate deterministic root keypair', () => {
generate.generateDeterministicKeyPair(code);
b.add('generate deterministic root keypair', async () => {
await generate.generateDeterministicKeyPair(code);
}),
b.add('generate 256 bit symmetric key', () => {
generate.generateKey();
Expand Down
6 changes: 3 additions & 3 deletions benches/suites/keys/keyring_lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main() {
keysPath: `${dataDir}/keys`,
password: 'password',
logger,
fresh: true
fresh: true,
});
await keyRing.stop();
};
Expand All @@ -36,13 +36,13 @@ async function main() {
const keyRing = await KeyRing.createKeyRing({
keysPath: `${dataDir}/keys`,
password: 'password',
logger
logger,
});
await keyRing.stop();
return async () => {
// Due to password hashing this is intended to be slow
await keyRing.start({
password: 'password'
password: 'password',
});
await keyRing.stop();
};
Expand Down
8 changes: 4 additions & 4 deletions benches/suites/keys/password_hashing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ async function main() {
'password',
undefined,
password.passwordOpsLimits.min,
password.passwordMemLimits.min
password.passwordMemLimits.min,
);
}),
b.add('password hashing - interactive', () => {
password.hashPassword(
'password',
undefined,
password.passwordOpsLimits.interactive,
password.passwordMemLimits.interactive
password.passwordMemLimits.interactive,
);
}),
b.add('password hashing - moderate', () => {
password.hashPassword(
'password',
undefined,
password.passwordOpsLimits.moderate,
password.passwordMemLimits.moderate
password.passwordMemLimits.moderate,
);
}),
b.add('password hashing - sensitive', () => {
password.hashPassword(
'password',
undefined,
password.passwordOpsLimits.sensitive,
password.passwordMemLimits.sensitive
password.passwordMemLimits.sensitive,
);
}),
...suiteCommon,
Expand Down
27 changes: 15 additions & 12 deletions benches/suites/keys/x509.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,21 @@ async function main() {
x509.certFromASN1(certASN1);
};
}),
b.add('certificate serialization & deserialization to ASN1 buffer', async () => {
const cert = await x509.generateCertificate({
certId: certIdGenerator(),
subjectKeyPair,
issuerPrivateKey: issuerKeyPair.privateKey,
duration: 1000,
});
return () => {
const certASN1 = x509.certToASN1(cert);
x509.certFromASN1(certASN1);
};
}),
b.add(
'certificate serialization & deserialization to ASN1 buffer',
async () => {
const cert = await x509.generateCertificate({
certId: certIdGenerator(),
subjectKeyPair,
issuerPrivateKey: issuerKeyPair.privateKey,
duration: 1000,
});
return () => {
const certASN1 = x509.certToASN1(cert);
x509.certFromASN1(certASN1);
};
},
),
...suiteCommon,
);
return summary;
Expand Down
9 changes: 7 additions & 2 deletions benches/suites/workers/worker_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ async function main() {
const logger = new Logger(`worker_overhead bench`, LogLevel.WARN, [
new StreamHandler(),
]);
const workerManager = await workersUtils.createWorkerManager({ cores, logger });
const workerManager = await workersUtils.createWorkerManager({
cores,
logger,
});
let summary: Summary;
try {
summary = await b.suite(
Expand Down Expand Up @@ -56,7 +59,9 @@ async function main() {
issuerPrivateKey: subjectKeyPair.privateKey.buffer,
duration: 1000,
});
return keysUtils.certFromASN1(Buffer.from(result) as CertificateASN1)!;
return keysUtils.certFromASN1(
Buffer.from(result) as CertificateASN1,
)!;
});
};
}),
Expand Down
7 changes: 4 additions & 3 deletions benches/suites/workers/worker_overhead.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import b from 'benny';
import crypto from 'crypto';
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
import * as workersUtils from '@/workers/utils';
import { summaryName, suiteCommon } from '../../utils';
Expand All @@ -9,10 +8,12 @@ async function main() {
const logger = new Logger(`worker_overhead bench`, LogLevel.WARN, [
new StreamHandler(),
]);
const workerManager = await workersUtils.createWorkerManager({ cores, logger });
const workerManager = await workersUtils.createWorkerManager({
cores,
logger,
});
// 1 MiB worth of data is the ballpark range of data to be worth parallelising
// 1 KiB of data is still too small
const bytes = crypto.randomBytes(1024 * 1024);
const summary = await b.suite(
summaryName(__filename),
b.add('call overhead', async () => {
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"ts-node": "ts-node",
"ts-node-inspect": "node --require ts-node/register --inspect",
"test": "jest",
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,ts,json}'",
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,ts,json}' --fix",
"lint": "eslint '{src,tests,scripts}/**/*.{js,ts,json}' 'benches/**/*.ts'",
"lintfix": "eslint '{src,tests,scripts}/**/*.{js,ts,json}' 'benches/**/*.ts' --fix",
tegefaulkes marked this conversation as resolved.
Show resolved Hide resolved
"lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +",
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src",
"bench": "shx rm -rf ./benches/results && ts-node ./benches",
Expand All @@ -82,10 +82,10 @@
"@matrixai/async-cancellable": "^1.0.2",
"@matrixai/async-init": "^1.8.2",
"@matrixai/async-locks": "^3.2.0",
"@matrixai/db": "^5.0.3",
"@matrixai/errors": "^1.1.5",
"@matrixai/db": "^5.1.0",
"@matrixai/errors": "^1.1.6",
"@matrixai/id": "^3.3.3",
"@matrixai/logger": "^3.0.0",
"@matrixai/logger": "^3.1.0",
"@matrixai/resources": "^1.1.4",
"@matrixai/timer": "^1.0.0",
"@matrixai/workers": "^1.3.6",
Expand Down
Loading