@@ -227,7 +227,7 @@ module AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorOperations refines Abs
227
227
// # If this item does not have a sort key attribute,
228
228
// # the DynamoDB Item Context MUST NOT contain the key `aws-crypto-sort-name`.
229
229
ensures ret. Success? && config. sortKeyName. None? ==>
230
- SORT_NAME ! in ret. value
230
+ SORT_NAME ! in ret. value
231
231
{
232
232
UTF8. EncodeAsciiUnique ();
233
233
:- Need (config.partitionKeyName in item, DDBError("Partition key " + config.partitionKeyName + " not found in Item to be encrypted or decrypted"));
@@ -514,15 +514,47 @@ module AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorOperations refines Abs
514
514
{
515
515
// We can formally verify these properties, but it is too resource intensive
516
516
:- Need (forall k <- schema.content.SchemaMap :: InSignatureScope (config, k),
517
- DynamoDbItemEncryptorException ( message := "Recieved unexpected Crypto Schema: mismatch with signature scope"));
517
+ DynamoDbItemEncryptorException ( message := "Received unexpected Crypto Schema: mismatch with signature scope"));
518
518
:- Need (forall k <- schema.content.SchemaMap :: ComAmazonawsDynamodbTypes .IsValid_AttributeName(k),
519
- DynamoDbItemEncryptorException ( message := "Recieved unexpected Crypto Schema: Invalid attribute names"));
519
+ DynamoDbItemEncryptorException ( message := "Received unexpected Crypto Schema: Invalid attribute names"));
520
520
Success (map k <- schema.content.SchemaMap :: k := schema.content.SchemaMap[k].content.Action)
521
521
}
522
522
523
523
predicate EncryptItemEnsuresPublicly (input: EncryptItemInput , output: Result <EncryptItemOutput , Error>)
524
524
{true }
525
525
526
+ function method GetItemNames (item : ComAmazonawsDynamodbTypes .AttributeMap) : string
527
+ {
528
+ var keys := SortedSets. ComputeSetToOrderedSequence2 (item.Keys, CharLess);
529
+ if |keys| == 0 then
530
+ "item is empty"
531
+ else
532
+ Join (keys, " ")
533
+ }
534
+
535
+ function method KeyMissingMsg (
536
+ config: InternalConfig ,
537
+ item : ComAmazonawsDynamodbTypes .AttributeMap,
538
+ tag : string )
539
+ : string
540
+ {
541
+ "On " + tag + " : "
542
+ +
543
+ (if config. partitionKeyName ! in item then
544
+ "Partition key '" + config. partitionKeyName + "' does not exist in item. "
545
+ else
546
+ "")
547
+
548
+ +
549
+ (if config. sortKeyName. Some? && config. sortKeyName. value ! in item then
550
+ "Sort key '" + config. sortKeyName. value + "' does not exist in item. "
551
+ else
552
+ "")
553
+
554
+ + "Item contains these attributes : "
555
+ + GetItemNames (item) + ". "
556
+ }
557
+
526
558
// public Encrypt method
527
559
method {:vcs_split_on_every_assert} EncryptItem (config: InternalConfig , input: EncryptItemInput )
528
560
returns (output: Result< EncryptItemOutput, Error> )
@@ -621,7 +653,7 @@ module AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorOperations refines Abs
621
653
:- Need (
622
654
&& config.partitionKeyName in input.plaintextItem
623
655
&& (config.sortKeyName.None? || config.sortKeyName.value in input.plaintextItem)
624
- , DynamoDbItemEncryptorException ( message := "Configuration mismatch partition or sort key does not exist in item." ));
656
+ , E (KeyMissingMsg(config, input.plaintextItem, "Encrypt") ));
625
657
626
658
if |input. plaintextItem| > MAX_ATTRIBUTE_COUNT {
627
659
var actCount := String. Base10Int2String (|input.plaintextItem|);
@@ -839,7 +871,7 @@ module AwsCryptographyDbEncryptionSdkDynamoDbItemEncryptorOperations refines Abs
839
871
:- Need (
840
872
&& config.partitionKeyName in input.encryptedItem
841
873
&& (config.sortKeyName.None? || config.sortKeyName.value in input.encryptedItem)
842
- , DynamoDbItemEncryptorException ( message := "Configuration mismatch partition or sort key does not exist in item." ));
874
+ , DynamoDbItemEncryptorException ( message := KeyMissingMsg(config, input.encryptedItem, "Decrypt") ));
843
875
844
876
// = specification/dynamodb-encryption-client/decrypt-item.md#behavior
845
877
// # If a [Legacy Policy](./ddb-table-encryption-config.md#legacy-policy) of
0 commit comments