mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(kms): support SM2 signing in China regions (#3046)
* fix(kms): report SM2 as region unsupported * fix(kms): support SM2 in China regions * fix(kms): enable SM2 signing in China regions * fix(kms): restrict SM2 to China regions * fix(kms): accept the SM2DSA wire algorithm * test(kms): cover SM2 signing validation errors
This commit is contained in:
1 parent
2fd55b53df
commit
5198cf29ec
6 files changed
+205
-7
No files matched your search
@@ -1195,6 +1195,19 @@ class KmsIntegrationTest {
|
||||
.body("KeyMetadata.KeySpec", equalTo("ECC_NIST_P256"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createSm2KeyReportsRegionUnsupportedOperation() {
|
||||
given()
|
||||
.header("X-Amz-Target", "TrentService.CreateKey")
|
||||
.contentType(KMS_CONTENT_TYPE)
|
||||
.body("{\"KeyUsage\":\"SIGN_VERIFY\",\"KeySpec\":\"SM2\"}")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("UnsupportedOperationException"))
|
||||
.body("message", equalTo("KeySpec SM2 is not supported in this Region"));
|
||||
}
|
||||
|
||||
// ── Issue #1528 — ListKeyPolicies ────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
|
||||
@@ -78,6 +78,31 @@ class KmsServiceTest {
|
||||
assertEquals("Enabled", key.getKeyState());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"us-east-1", "cn-fake-1"})
|
||||
void createSm2KeyReportsRegionUnsupportedOperation(String region) {
|
||||
AwsException exception = assertThrows(AwsException.class, () ->
|
||||
kmsService.createKey(null, "SIGN_VERIFY", "SM2", null, Map.of(), region));
|
||||
|
||||
assertEquals("UnsupportedOperationException", exception.getErrorCode());
|
||||
assertEquals("KeySpec SM2 is not supported in this Region", exception.getMessage());
|
||||
assertEquals(400, exception.getHttpStatus());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"cn-north-1", "cn-northwest-1"})
|
||||
void createSm2KeySucceedsInChinaRegions(String region) {
|
||||
KmsKey key = kmsService.createKey(null, "SIGN_VERIFY", "SM2", null, Map.of(), region);
|
||||
byte[] message = "SM2 regional signing".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] signature = kmsService.sign(key.getKeyId(), message, "SM2DSA", region);
|
||||
|
||||
assertEquals(KmsKeySpec.SM2, key.getKeySpec());
|
||||
assertEquals(KmsKeyUsage.SIGN_VERIFY, key.getKeyUsage());
|
||||
assertNotNull(key.getPrivateKeyEncoded());
|
||||
assertNotNull(key.getPublicKeyEncoded());
|
||||
assertTrue(kmsService.verify(key.getKeyId(), message, signature, "SM2DSA", region));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateKeyDescriptionPersistsDescription() {
|
||||
KmsKey key = kmsService.createKey("old description", REGION);
|
||||
|
||||
Reference in new issue
Block a user