Skip to content

Commit f7b5d8c

Browse files
authored
chore(kms): support ML-DSA keys for keySpec (#35991)
### Issue # (if applicable) Closes #35990 ### Reason for this change To support ML-DSA keys for KeySpec. ### Description of changes - Add ML-DSA keys validation rule ### Description of how you validated changes Added both unit tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 962a804 commit f7b5d8c

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

packages/aws-cdk-lib/aws-kms/lib/key.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ export class Key extends KeyBase {
819819
KeySpec.HMAC_256,
820820
KeySpec.HMAC_384,
821821
KeySpec.HMAC_512,
822+
KeySpec.ML_DSA_44,
823+
KeySpec.ML_DSA_65,
824+
KeySpec.ML_DSA_87,
822825
],
823826
[KeyUsage.SIGN_VERIFY]: [
824827
KeySpec.SYMMETRIC_DEFAULT,
@@ -837,6 +840,9 @@ export class Key extends KeyBase {
837840
KeySpec.ECC_SECG_P256K1,
838841
KeySpec.SYMMETRIC_DEFAULT,
839842
KeySpec.SM2,
843+
KeySpec.ML_DSA_44,
844+
KeySpec.ML_DSA_65,
845+
KeySpec.ML_DSA_87,
840846
],
841847
[KeyUsage.KEY_AGREEMENT]: [
842848
KeySpec.SYMMETRIC_DEFAULT,
@@ -848,6 +854,9 @@ export class Key extends KeyBase {
848854
KeySpec.HMAC_256,
849855
KeySpec.HMAC_384,
850856
KeySpec.HMAC_512,
857+
KeySpec.ML_DSA_44,
858+
KeySpec.ML_DSA_65,
859+
KeySpec.ML_DSA_87,
851860
],
852861
};
853862
const keySpec = props.keySpec ?? KeySpec.SYMMETRIC_DEFAULT;

packages/aws-cdk-lib/aws-kms/test/key.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,38 @@ describe('SM2', () => {
14151415
});
14161416
});
14171417

1418+
describe('ML-DSA', () => {
1419+
let stack: cdk.Stack;
1420+
1421+
beforeEach(() => {
1422+
stack = new cdk.Stack();
1423+
});
1424+
1425+
test.each([
1426+
[KeySpec.ML_DSA_44, 'ML_DSA_44'],
1427+
[KeySpec.ML_DSA_65, 'ML_DSA_65'],
1428+
[KeySpec.ML_DSA_87, 'ML_DSA_87'],
1429+
])('%s is not valid for default usage', (keySpec: KeySpec) => {
1430+
expect(() => new kms.Key(stack, 'Key1', { keySpec }))
1431+
.toThrow(`key spec \'${keySpec}\' is not valid with usage \'ENCRYPT_DECRYPT\'`);
1432+
});
1433+
1434+
test.each([
1435+
[KeySpec.ML_DSA_44, 'ML_DSA_44'],
1436+
[KeySpec.ML_DSA_65, 'ML_DSA_65'],
1437+
[KeySpec.ML_DSA_87, 'ML_DSA_87'],
1438+
])('%s can be used for KMS key creation', (keySpec: KeySpec, expected: string) => {
1439+
new kms.Key(stack, 'Key', {
1440+
keySpec,
1441+
keyUsage: KeyUsage.SIGN_VERIFY,
1442+
});
1443+
Template.fromStack(stack).hasResourceProperties('AWS::KMS::Key', {
1444+
KeySpec: expected,
1445+
KeyUsage: 'SIGN_VERIFY',
1446+
});
1447+
});
1448+
});
1449+
14181450
function generateInvalidKeySpecKeyUsageCombinations() {
14191451
// Copied from Key class
14201452
const denyLists = {

0 commit comments

Comments
 (0)