Skip to content

Commit 203563c

Browse files
feat(cli): Enables experimental ec in KAOs (#457)
Revert "chore(cli): Disables ec-wrapped (#451)" This reverts commit 6713334.
1 parent 9667747 commit 203563c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cli/src/cli.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
tdfSpecVersion,
1717
OpenTDF,
1818
DecoratedStream,
19+
isPublicKeyAlgorithm,
1920
} from '@opentdf/sdk';
2021
import { CLIError, Level, log } from './logger.js';
2122
import { webcrypto } from 'crypto';
@@ -174,6 +175,12 @@ async function parseReadOptions(argv: Partial<mainArgs>): Promise<ReadOptions> {
174175
argv.assertionVerificationKeys
175176
);
176177
}
178+
if (argv.rewrapKeyType?.length) {
179+
if (!isPublicKeyAlgorithm(argv.rewrapKeyType)) {
180+
throw new CLIError('CRITICAL', `Unsupported rewrap key algorithm: [${argv.rewrapKeyType}]`);
181+
}
182+
r.wrappingKeyAlgorithm = argv.rewrapKeyType;
183+
}
177184
if (argv.concurrencyLimit) {
178185
r.concurrencyLimit = argv.concurrencyLimit;
179186
} else {
@@ -272,6 +279,12 @@ async function parseCreateZTDFOptions(argv: Partial<mainArgs>): Promise<CreateZT
272279
if (argv.assertions?.length) {
273280
c.assertionConfigs = await parseAssertionConfig(argv.assertions);
274281
}
282+
if (argv.encapKeyType?.length) {
283+
if (!isPublicKeyAlgorithm(argv.encapKeyType)) {
284+
throw new CLIError('CRITICAL', `Unsupported rewrap key algorithm: [${argv.encapKeyType}]`);
285+
}
286+
c.wrappingKeyAlgorithm = argv.encapKeyType;
287+
}
275288
if (argv.mimeType?.length) {
276289
if (argv.mimeType && /^[a-z]+\/[a-z0-9-+.]+$/.test(argv.mimeType)) {
277290
c.mimeType = argv.mimeType as `${string}/${string}`;
@@ -454,6 +467,13 @@ export const handleArgs = (args: string[]) => {
454467
description: 'Container format',
455468
default: 'nano',
456469
},
470+
encapKeyType: {
471+
alias: 'encapsulation-algorithm',
472+
group: 'Encrypt Options:',
473+
desc: 'Key type for wrapping keys',
474+
type: 'string',
475+
default: 'rsa:2048',
476+
},
457477
policyBinding: {
458478
group: 'Encrypt Options:',
459479
choices: bindingTypes,
@@ -466,6 +486,13 @@ export const handleArgs = (args: string[]) => {
466486
type: 'string',
467487
default: '',
468488
},
489+
rewrapKeyType: {
490+
alias: 'rewrap-encapsulation-algorithm',
491+
group: 'Decrypt Options:',
492+
desc: 'Key type for rewrap',
493+
type: 'string',
494+
default: 'rsa:2048',
495+
},
469496
userId: {
470497
group: 'Encrypt Options:',
471498
type: 'string',

0 commit comments

Comments
 (0)