File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed
DynamoDbEncryption/dafny/DynamoDbEncryptionTransforms/src Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -92,16 +92,15 @@ module QueryTransform {
92
92
var decryptRes := tableConfig. itemEncryptor. DecryptItem (decryptInput);
93
93
var decrypted :- MapError (decryptRes);
94
94
95
- if decrypted. parsedHeader. None? {
96
- :- Need (
95
+ // If the decrypted result was plaintext, i.e. has no parsedHeader
96
+ // then this is expected IFF the table config allows plaintext read
97
+ assert decrypted. parsedHeader. None? ==>
97
98
&& EncOps. IsPlaintextItem (encryptedItems[x])
99
+ && ! tableConfig. plaintextOverride. FORBID_PLAINTEXT_WRITE_FORBID_PLAINTEXT_READ?
98
100
&& (
99
101
|| tableConfig. plaintextOverride. FORBID_PLAINTEXT_WRITE_ALLOW_PLAINTEXT_READ?
100
102
|| tableConfig. plaintextOverride. FORCE_PLAINTEXT_WRITE_ALLOW_PLAINTEXT_READ?
101
- ),
102
- E ("Unexpected lack of parsed header.")
103
- );
104
- }
103
+ );
105
104
106
105
if keyId. KeyId? && decrypted. parsedHeader. Some? {
107
106
:- Need (|decrypted.parsedHeader.value.encryptedDataKeys| == 1, E("Query result has more than one Encrypted Data Key"));
Original file line number Diff line number Diff line change @@ -90,19 +90,17 @@ module ScanTransform {
90
90
var decryptRes := tableConfig. itemEncryptor. DecryptItem (decryptInput);
91
91
var decrypted :- MapError (decryptRes);
92
92
93
- if decrypted. parsedHeader. None? {
94
- :- Need (
93
+ // If the decrypted result was plaintext, i.e. has no parsedHeader
94
+ // then this is expected IFF the table config allows plaintext read
95
+ assert decrypted. parsedHeader. None? ==>
95
96
&& EncOps. IsPlaintextItem (encryptedItems[x])
97
+ && ! tableConfig. plaintextOverride. FORBID_PLAINTEXT_WRITE_FORBID_PLAINTEXT_READ?
96
98
&& (
97
99
|| tableConfig. plaintextOverride. FORBID_PLAINTEXT_WRITE_ALLOW_PLAINTEXT_READ?
98
100
|| tableConfig. plaintextOverride. FORCE_PLAINTEXT_WRITE_ALLOW_PLAINTEXT_READ?
99
- ),
100
- E ("Unexpected lack of parsed header.")
101
- );
102
- }
101
+ );
103
102
104
103
if keyId. KeyId? && decrypted. parsedHeader. Some? {
105
- :- Need (decrypted.parsedHeader.Some?, E("Decrypted scan result has no parsed header."));
106
104
:- Need (|decrypted.parsedHeader.value.encryptedDataKeys| == 1, E("Scan result has more than one Encrypted Data Key"));
107
105
if decrypted. parsedHeader. value. encryptedDataKeys[0]. keyProviderInfo == keyIdUtf8 {
108
106
decryptedItems := decryptedItems + [decrypted. plaintextItem];
You can’t perform that action at this time.
0 commit comments