@@ -16,6 +16,7 @@ import {
16
16
tdfSpecVersion ,
17
17
OpenTDF ,
18
18
DecoratedStream ,
19
+ isPublicKeyAlgorithm ,
19
20
} from '@opentdf/sdk' ;
20
21
import { CLIError , Level , log } from './logger.js' ;
21
22
import { webcrypto } from 'crypto' ;
@@ -174,6 +175,12 @@ async function parseReadOptions(argv: Partial<mainArgs>): Promise<ReadOptions> {
174
175
argv . assertionVerificationKeys
175
176
) ;
176
177
}
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
+ }
177
184
if ( argv . concurrencyLimit ) {
178
185
r . concurrencyLimit = argv . concurrencyLimit ;
179
186
} else {
@@ -272,6 +279,12 @@ async function parseCreateZTDFOptions(argv: Partial<mainArgs>): Promise<CreateZT
272
279
if ( argv . assertions ?. length ) {
273
280
c . assertionConfigs = await parseAssertionConfig ( argv . assertions ) ;
274
281
}
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
+ }
275
288
if ( argv . mimeType ?. length ) {
276
289
if ( argv . mimeType && / ^ [ a - z ] + \/ [ a - z 0 - 9 - + .] + $ / . test ( argv . mimeType ) ) {
277
290
c . mimeType = argv . mimeType as `${string } /${string } `;
@@ -454,6 +467,13 @@ export const handleArgs = (args: string[]) => {
454
467
description : 'Container format' ,
455
468
default : 'nano' ,
456
469
} ,
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
+ } ,
457
477
policyBinding : {
458
478
group : 'Encrypt Options:' ,
459
479
choices : bindingTypes ,
@@ -466,6 +486,13 @@ export const handleArgs = (args: string[]) => {
466
486
type : 'string' ,
467
487
default : '' ,
468
488
} ,
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
+ } ,
469
496
userId : {
470
497
group : 'Encrypt Options:' ,
471
498
type : 'string' ,
0 commit comments