@@ -102,7 +102,7 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
102
102
grantTokens: KMS .GrantTokenList,
103
103
kmsClient: KMS .IKMSClient
104
104
)
105
- returns (res: Result< KMS. GenerateDataKeyWithoutPlaintextResponse, Types . Error > )
105
+ returns (res: Result< KMS. GenerateDataKeyWithoutPlaintextResponse, KmsError > )
106
106
requires kmsClient. ValidState ()
107
107
requires HasKeyId (kmsConfiguration) && KmsArn. ValidKmsArn?(GetKeyId (kmsConfiguration))
108
108
requires AttemptKmsOperation?(kmsConfiguration, encryptionContext)
@@ -145,14 +145,14 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
145
145
146
146
:- Need (
147
147
&& generateResponse.KeyId.Some?,
148
- Types.KeyStoreException (
149
- message := "Invalid response from KMS GenerateDataKey: : Invalid Key Id")
148
+ Types.KeyManagementException (
149
+ message := "Invalid response from AWS KMS GenerateDataKey: Invalid Key Id")
150
150
);
151
151
152
152
:- Need (
153
153
&& generateResponse.CiphertextBlob.Some?
154
154
&& KMS.IsValid_CiphertextType(generateResponse.CiphertextBlob.value),
155
- Types. KeyStoreException (
155
+ Types. KeyManagementException (
156
156
message := "Invalid response from AWS KMS GenerateDataKey: Invalid ciphertext")
157
157
);
158
158
@@ -278,7 +278,7 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
278
278
&& reEncryptResponse.SourceKeyId.value == kmsKeyArn
279
279
&& reEncryptResponse.KeyId.value == kmsKeyArn,
280
280
Types.KeyManagementException(
281
- message := "Invalid response from AWS KMS ReEncrypt:: Invalid KMS Key Id")
281
+ message := "Invalid response from AWS KMS ReEncrypt: Invalid KMS Key Id")
282
282
);
283
283
284
284
:- Need (
@@ -353,113 +353,12 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
353
353
&& decryptResponse.KeyId.Some?
354
354
&& decryptResponse.KeyId.value == kmsKeyArn,
355
355
Types.KeyManagementException(
356
- message := "Invalid response from AWS KMS Decrypt : : Invalid KMS Key Id"
356
+ message := "Invalid response from AWS KMS Decrypt: Invalid KMS Key Id"
357
357
));
358
358
359
359
return Success (decryptResponse);
360
360
}
361
361
362
- method MutateViaDecryptEncrypt (
363
- ciphertext: seq <uint8 >,
364
- sourceEncryptionContext: Structure .BranchKeyContext,
365
- destinationEncryptionContext: Structure .BranchKeyContext,
366
- sourceKmsArn: string ,
367
- destinationKmsArn: string ,
368
- decryptGrantTokens: KMS .GrantTokenList,
369
- decryptKmsClient: KMS .IKMSClient,
370
- encryptGrantTokens: KMS .GrantTokenList,
371
- encryptKmsClient: KMS .IKMSClient
372
- )
373
- returns (res: Result< KMS. CiphertextType, KmsError> )
374
- requires
375
- && Structure. BranchKeyContext?(sourceEncryptionContext)
376
- && Structure. BranchKeyContext?(destinationEncryptionContext)
377
- requires AttemptReEncrypt?(sourceEncryptionContext, destinationEncryptionContext)
378
- requires KmsArn. ValidKmsArn?(sourceKmsArn) && KmsArn. ValidKmsArn?(destinationKmsArn)
379
- requires decryptKmsClient. Modifies !! encryptKmsClient. Modifies
380
- requires decryptKmsClient. ValidState () && encryptKmsClient. ValidState ()
381
- modifies decryptKmsClient. Modifies + encryptKmsClient. Modifies
382
- ensures decryptKmsClient. ValidState () && encryptKmsClient. ValidState ()
383
- ensures
384
- res. Success?
385
- ==>
386
- && KMS. IsValid_CiphertextType (ciphertext)
387
- && |decryptKmsClient. History. Decrypt| == |old (decryptKmsClient. History. Decrypt)| + 1
388
- && var decryptInput := Seq. Last (decryptKmsClient.History.Decrypt). input;
389
- && var decryptOutput := Seq. Last (decryptKmsClient.History.Decrypt). output;
390
- && KMS. DecryptRequest (
391
- CiphertextBlob := ciphertext,
392
- EncryptionContext := Some(sourceEncryptionContext),
393
- GrantTokens := Some (decryptGrantTokens),
394
- KeyId := Some (sourceKmsArn)
395
- ) == decryptInput
396
- && decryptOutput. Success? && decryptOutput. value. Plaintext. Some? && decryptOutput. value. KeyId. Some?
397
- && decryptOutput. value. KeyId. value == sourceKmsArn
398
- && |encryptKmsClient. History. Encrypt| == |old (encryptKmsClient. History. Encrypt)| + 1
399
- && var encryptInput := Seq. Last (encryptKmsClient.History.Encrypt). input;
400
- && var encryptResponse := Seq. Last (encryptKmsClient.History.Encrypt). output;
401
- && KMS. EncryptRequest (
402
- KeyId := destinationKmsArn,
403
- Plaintext := decryptOutput.value.Plaintext.value,
404
- EncryptionContext := Some(destinationEncryptionContext),
405
- GrantTokens := Some (encryptGrantTokens)
406
- ) == encryptInput
407
- && old (encryptKmsClient. History. Encrypt) < encryptKmsClient. History. Encrypt
408
- && encryptResponse. Success?
409
- && encryptResponse. value. CiphertextBlob. Some?
410
- && encryptResponse. value. KeyId. Some?
411
- && encryptResponse. value. KeyId. value == destinationKmsArn // kmsKeyArn
412
- && KMS. IsValid_CiphertextType (encryptResponse.value.CiphertextBlob.value)
413
- && encryptResponse. value. CiphertextBlob. value == res. value
414
- {
415
- :- Need (
416
- KMS.IsValid_CiphertextType(ciphertext),
417
- Types. KeyManagementException (
418
- message := "Invalid KMS ciphertext.")
419
- );
420
-
421
- var kmsDecryptRequest := KMS. DecryptRequest (
422
- CiphertextBlob := ciphertext,
423
- EncryptionContext := Some(sourceEncryptionContext),
424
- GrantTokens := Some (decryptGrantTokens),
425
- KeyId := Some (sourceKmsArn)
426
- );
427
-
428
- var decryptResponse? := decryptKmsClient. Decrypt (kmsDecryptRequest);
429
- var decryptResponse :- decryptResponse?
430
- .MapFailure (e => Types.ComAmazonawsKms(ComAmazonawsKms := e));
431
-
432
- :- Need (
433
- && decryptResponse.Plaintext.Some?
434
- && decryptResponse.KeyId.Some?
435
- && decryptResponse.KeyId.value == sourceKmsArn,
436
- Types.KeyManagementException(
437
- message := "Invalid response from AWS KMS Decrypt :: Invalid KMS Key Id"
438
- ));
439
-
440
- var kmsEncryptRequest := KMS. EncryptRequest (
441
- KeyId := destinationKmsArn,
442
- Plaintext := decryptResponse.Plaintext.value,
443
- EncryptionContext := Some(destinationEncryptionContext),
444
- GrantTokens := Some (encryptGrantTokens)
445
- );
446
-
447
- var encryptResponse? := encryptKmsClient. Encrypt (kmsEncryptRequest);
448
- var encryptResponse :- encryptResponse?
449
- .MapFailure (e => Types.ComAmazonawsKms(ComAmazonawsKms := e));
450
-
451
- :- Need (
452
- && encryptResponse.CiphertextBlob.Some?
453
- && KMS.IsValid_CiphertextType(encryptResponse.CiphertextBlob.value)
454
- && encryptResponse. KeyId. Some?
455
- && encryptResponse. KeyId. value == destinationKmsArn,
456
- Types. KeyManagementException (
457
- message := "Invalid response from AWS KMS Encrypt :: Invalid KMS Key Id"
458
- ));
459
-
460
- return Success (encryptResponse.CiphertextBlob.value);
461
- }
462
-
463
362
method MutateViaDecryptEncryptOnInitializeMutation (
464
363
ciphertext: seq <uint8 >,
465
364
sourceEncryptionContext: Structure .BranchKeyContext,
@@ -532,7 +431,7 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
532
431
&& decryptResponse.KeyId.Some?
533
432
&& decryptResponse.KeyId.value == sourceKmsArn,
534
433
Types.KeyManagementException(
535
- message := "Invalid response from AWS KMS Decrypt : : Invalid KMS Key Id"
434
+ message := "Invalid response from AWS KMS Decrypt: Invalid KMS Key Id"
536
435
));
537
436
538
437
var kmsEncryptRequest := KMS. EncryptRequest (
@@ -552,7 +451,7 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
552
451
&& encryptResponse. KeyId. Some?
553
452
&& encryptResponse. KeyId. value == destinationKmsArn,
554
453
Types. KeyManagementException (
555
- message := "Invalid response from AWS KMS Encrypt : : Invalid KMS Key Id"
454
+ message := "Invalid response from AWS KMS Encrypt: Invalid KMS Key Id"
556
455
));
557
456
558
457
return Success (encryptResponse.CiphertextBlob.value);
@@ -640,13 +539,13 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
640
539
&& reEncryptResponse.SourceKeyId.Some?
641
540
&& reEncryptResponse.SourceKeyId.value == sourceKmsArn, //kmsKeyArn
642
541
Types.KeyManagementException(
643
- message := "Invalid response from KMS ReEncrypt:: Invalid Source Key Id")
542
+ message := "Invalid response from KMS ReEncrypt: Invalid Source Key Id")
644
543
);
645
544
:- Need (
646
545
&& reEncryptResponse.KeyId.Some?
647
546
&& reEncryptResponse.KeyId.value == destinationKmsArn, // kmsKeyArn,
648
547
Types.KeyManagementException(
649
- message := "Invalid response from KMS ReEncrypt:: Invalid Destination Key Id")
548
+ message := "Invalid response from KMS ReEncrypt: Invalid Destination Key Id")
650
549
);
651
550
652
551
:- Need (
0 commit comments