Skip to content

Commit 5ccf6f5

Browse files
Update tdf.ts
1 parent 5742ee8 commit 5ccf6f5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/tdf3/src/tdf.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,20 +674,23 @@ async function unwrapKey({
674674
const url = `${keySplitInfo.url}/v2/rewrap`;
675675
let ephemeralEncryptionKeysRaw: AnyKeyPair;
676676
let ephemeralEncryptionKeys: PemKeyPair;
677+
let algorithm: string;
677678
if (wrappingKeyAlgorithm === 'ec:secp256r1') {
678679
ephemeralEncryptionKeysRaw = await generateKeyPair();
679680
ephemeralEncryptionKeys = await cryptoService.cryptoToPemPair(ephemeralEncryptionKeysRaw);
681+
algorithm = 'ES256';
680682
} else if (wrappingKeyAlgorithm === 'rsa:2048' || !wrappingKeyAlgorithm) {
681683
ephemeralEncryptionKeysRaw = await cryptoService.generateKeyPair();
682684
ephemeralEncryptionKeys = await cryptoService.cryptoToPemPair(ephemeralEncryptionKeysRaw);
685+
algorithm = 'RS256';
683686
} else {
684687
throw new ConfigurationError(`Unsupported wrapping key algorithm [${wrappingKeyAlgorithm}]`);
685688
}
686689

687690
const clientPublicKey = ephemeralEncryptionKeys.publicKey;
688691

689692
const requestBodyStr = JSON.stringify({
690-
algorithm: 'RS256',
693+
algorithm,
691694
keyAccess: keySplitInfo,
692695
policy: manifest.encryptionInformation.policy,
693696
clientPublicKey,

0 commit comments

Comments
 (0)