Skip to content

Commit

Permalink
feat(GCP): Implement key generation (#12)
Browse files Browse the repository at this point in the history
Fixes #8.

- [x] refactor
  • Loading branch information
gnarea authored Mar 22, 2023
1 parent 485f082 commit a2b9770
Show file tree
Hide file tree
Showing 10 changed files with 579 additions and 76 deletions.
24 changes: 24 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
"@google-cloud/kms": "^3.5.0",
"@peculiar/webcrypto": "^1.4.2",
"fast-crc32c": "^2.0.0",
"uuid4": "^2.0.3",
"webcrypto-core": "^1.7.6"
},
"devDependencies": {
"@relaycorp/shared-config": "^1.9.3",
"@types/jest": "^28.1.6",
"@types/uuid4": "^2.0.0",
"del-cli": "^5.0.0",
"jest": "^28.1.3",
"jest-extended": "^3.2.4",
Expand Down
8 changes: 8 additions & 0 deletions src/lib/gcp/GcpKmsConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type ProtectionLevel = 'SOFTWARE' | 'HSM';

export interface GcpKmsConfig {
readonly location: string;
readonly keyRing: string;
readonly protectionLevel: ProtectionLevel;
readonly destroyScheduledDurationSeconds?: number;
}
2 changes: 1 addition & 1 deletion src/lib/gcp/GcpKmsRsaPssPrivateKey.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HashingAlgorithm } from '../algorithms';

const HASHING_ALGORITHM: HashingAlgorithm = 'SHA-256';
const KMS_KEY_PATH = 'projects/foo/key/42';
const KMS_PROVIDER = new GcpKmsRsaPssProvider(null as any);
const KMS_PROVIDER = new GcpKmsRsaPssProvider(null as any, null as any);

test('KMS key path should be honored', () => {
const key = new GcpKmsRsaPssPrivateKey(KMS_KEY_PATH, HASHING_ALGORITHM, KMS_PROVIDER);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/gcp/GcpKmsRsaPssPrivateKey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GcpKmsRsaPssProvider } from './GcpKmsRsaPssProvider';
import { RsaPssPrivateKey } from '../PrivateKey';
import { HashingAlgorithm } from '../algorithms.js';
import { HashingAlgorithm } from '../algorithms';

export class GcpKmsRsaPssPrivateKey extends RsaPssPrivateKey {
constructor(
Expand Down
Loading

0 comments on commit a2b9770

Please sign in to comment.