mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(kms): match the AWS error codes, messages and check order (#3968)
* fix(kms): reject Sign and Verify on keys that are not SIGN_VERIFY * fix(kms): validate SigningAlgorithm and key spec * refactor(kms): keep only comments the code cannot show * fix(kms): check the DIGEST length for every signing algorithm * fix(kms): refuse disabled and pending deletion keys * fix(kms): answer a failed Verify with KMSInvalidSignatureException * fix(kms): fix MAC key usage and invalid MAC errors * fix(kms): validate MacAlgorithm * fix(kms): use the key spec error for an unsupported MAC algorithm * fix(kms): only treat a malformed signature as invalid in Verify * fix(kms): answer a key pending import with its ARN and state * fix(kms): name the key ARN when it is pending deletion * fix(kms): refuse a key pending deletion in key management operations * fix(kms): check the key state in GetPublicKey * test(kms): drop the real AWS notes from test comments * fix(kms): send no message when GetPublicKey gets a symmetric key * fix(kms): check the key state before changing key rotation * fix(kms): send no message when the key spec does not rotate * fix(kms): accept DisableKeyRotation on a key spec that does not rotate * fix(kms): name the key ARN and origin when the origin is not valid * fix(kms): ask for new key material when rotating an EXTERNAL key on demand * fix(kms): validate RotationPeriodInDays * fix(kms): use the AWS wording for IncorrectKeyException * fix(kms): send no message with InvalidCiphertextException * fix(kms): list EncryptionAlgorithm values in the AWS order * fix(kms): validate the data key KeySpec and NumberOfBytes * fix(kms): require either KeySpec or NumberOfBytes for a data key * fix(kms): make an AES_128 data key 16 bytes long * fix(kms): use the AWS error for a data key under an asymmetric key * fix(kms): name GenerateDataKeyWithoutPlaintext in its key usage error * fix(kms): report the GenerateRandom bound that NumberOfBytes breaks * fix(kms): say NumberOfBytes is required in GenerateRandom * fix(kms): list the MessageType values in its validation error * fix(kms): answer NotFoundException with status 400 * fix(kms): use the AWS wording when a key does not exist * fix(kms): use the AWS wording when an alias does not exist * fix(kms): reject a key or alias ARN from another region * fix(kms): validate a missing, empty or non-ASCII KeyId * fix(kms): validate blob members before looking up the key * fix(kms): reject an alias in operations that need a key * test(compat): stop scheduling a KMS key for deletion twice
This commit is contained in:
1 parent
ee74fd0a49
commit
68425d942a
17 files changed
+1549
-383
No files matched your search
+16
-24
@@ -407,17 +407,13 @@ class KmsFeaturesTest {
|
||||
void encryptWithPendingDeletionKeyRaisesKmsInvalidStateException() {
|
||||
String keyId = kms.createKey(b -> b.description("pending-encrypt")).keyMetadata().keyId();
|
||||
|
||||
try {
|
||||
kms.scheduleKeyDeletion(b -> b.keyId(keyId).pendingWindowInDays(7));
|
||||
kms.scheduleKeyDeletion(b -> b.keyId(keyId).pendingWindowInDays(7));
|
||||
|
||||
assertThatThrownBy(
|
||||
() -> kms.encrypt(b -> b
|
||||
.keyId(keyId)
|
||||
.plaintext(SdkBytes.fromString("secret data", StandardCharsets.UTF_8)))
|
||||
).isInstanceOf(KmsInvalidStateException.class);
|
||||
} finally {
|
||||
kms.scheduleKeyDeletion(b -> b.keyId(keyId).pendingWindowInDays(7));
|
||||
}
|
||||
assertThatThrownBy(
|
||||
() -> kms.encrypt(b -> b
|
||||
.keyId(keyId)
|
||||
.plaintext(SdkBytes.fromString("secret data", StandardCharsets.UTF_8)))
|
||||
).isInstanceOf(KmsInvalidStateException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -425,22 +421,18 @@ class KmsFeaturesTest {
|
||||
void decryptWithPendingDeletionKeyRaisesKmsInvalidStateException() {
|
||||
String keyId = kms.createKey(b -> b.description("pending-decrypt")).keyMetadata().keyId();
|
||||
|
||||
try {
|
||||
SdkBytes ciphertext = kms.encrypt(b -> b
|
||||
.keyId(keyId)
|
||||
.plaintext(SdkBytes.fromString("secret data", StandardCharsets.UTF_8)))
|
||||
.ciphertextBlob();
|
||||
SdkBytes ciphertext = kms.encrypt(b -> b
|
||||
.keyId(keyId)
|
||||
.plaintext(SdkBytes.fromString("secret data", StandardCharsets.UTF_8)))
|
||||
.ciphertextBlob();
|
||||
|
||||
kms.scheduleKeyDeletion(b -> b.keyId(keyId).pendingWindowInDays(7));
|
||||
kms.scheduleKeyDeletion(b -> b.keyId(keyId).pendingWindowInDays(7));
|
||||
|
||||
assertThatThrownBy(
|
||||
() -> kms.decrypt(b -> b
|
||||
.ciphertextBlob(ciphertext)
|
||||
.keyId(keyId))
|
||||
).isInstanceOf(KmsInvalidStateException.class);
|
||||
} finally {
|
||||
kms.scheduleKeyDeletion(b -> b.keyId(keyId).pendingWindowInDays(7));
|
||||
}
|
||||
assertThatThrownBy(
|
||||
() -> kms.decrypt(b -> b
|
||||
.ciphertextBlob(ciphertext)
|
||||
.keyId(keyId))
|
||||
).isInstanceOf(KmsInvalidStateException.class);
|
||||
}
|
||||
|
||||
// ── Issue #3024: Encrypt/Decrypt apply real RSAES-OAEP for RSA keys ──────
|
||||
|
||||
Reference in new issue
Block a user