3
3
include ".. / Model/ AwsCryptographyDynamoDbItemEncryptorTypes. dfy"
4
4
include ".. / .. / private- aws- encryption- sdk- dafny- staging/ AwsCryptographicMaterialProviders/ src/ CMMs/ ExpectedEncryptionContextCMM. dfy"
5
5
include "DynamoToStruct. dfy"
6
+ include "Util. dfy"
6
7
include ".. / .. / StructuredEncryption/ src/ SearchInfo. dfy"
7
8
include "InternalLegacyConfig. dfy"
8
9
9
10
module AwsCryptographyDynamoDbItemEncryptorOperations refines AbstractAwsCryptographyDynamoDbItemEncryptorOperations {
10
- import opened StructuredEncryptionUtil
11
11
import ComAmazonawsDynamodbTypes
12
+ import opened DynamoDbItemEncryptorUtil
12
13
import CMP = AwsCryptographyMaterialProvidersTypes
13
14
import StructuredEncryption
14
15
import DynamoToStruct
@@ -22,6 +23,7 @@ module AwsCryptographyDynamoDbItemEncryptorOperations refines AbstractAwsCryptog
22
23
import MaterialProviders
23
24
import ExpectedEncryptionContextCMM
24
25
import opened SearchableEncryptionInfo
26
+ import SET = AwsCryptographyStructuredEncryptionTypes
25
27
26
28
datatype Config = Config (
27
29
nameonly cmpClient : MaterialProviders .MaterialProvidersClient,
@@ -39,6 +41,24 @@ module AwsCryptographyDynamoDbItemEncryptorOperations refines AbstractAwsCryptog
39
41
)
40
42
41
43
type InternalConfig = Config
44
+ type ValidConfig = x : Config | ValidInternalConfig?(x) witness *
45
+
46
+ predicate method IsEncrypted (config : ValidConfig , attr : string )
47
+ {
48
+ && attr in config. attributeActions
49
+ && config. attributeActions[attr] == SET. ENCRYPT_AND_SIGN
50
+ }
51
+
52
+ predicate method IsSigned (config : ValidConfig , attr : string )
53
+ {
54
+ && attr in config. attributeActions
55
+ && config. attributeActions[attr] != SET. DO_NOTHING
56
+ }
57
+
58
+ const DoNotSign :=
59
+ CSE. AuthenticateSchema (content := CSE.AuthenticateSchemaContent.Action(CSE.AuthenticateAction.DO_NOT_SIGN), attributes := None)
60
+ const DoSign :=
61
+ CSE. AuthenticateSchema (content := CSE.AuthenticateSchemaContent.Action(CSE.AuthenticateAction.SIGN), attributes := None)
42
62
43
63
// constant attribute names for the encryption context
44
64
const TABLE_NAME : seq < uint8> := UTF8. EncodeAscii ("aws-crypto-table-name");
@@ -53,7 +73,7 @@ module AwsCryptographyDynamoDbItemEncryptorOperations refines AbstractAwsCryptog
53
73
{
54
74
|| (unauthenticatedAttributes. Some? && attr in unauthenticatedAttributes. value)
55
75
|| (unauthenticatedPrefix. Some? && unauthenticatedPrefix. value <= attr)
56
- || SE . ReservedPrefix <= attr
76
+ || ReservedPrefix <= attr
57
77
// Attributes with the reserved prefix are "allowed unauthenticated" in that
58
78
// they are not specified as signed within attributeActions.
59
79
// These attributes MAY still be authenticated via other methods,
@@ -106,7 +126,7 @@ module AwsCryptographyDynamoDbItemEncryptorOperations refines AbstractAwsCryptog
106
126
else if unauthenticatedPrefix. Some? && unauthenticatedPrefix. value <= attr then
107
127
"it also begins with the unauthenticatedPrefix. "
108
128
else
109
- assert SE . ReservedPrefix <= attr;
129
+ assert ReservedPrefix <= attr;
110
130
"it also begins with the reserved prefix. "
111
131
}
112
132
@@ -299,7 +319,7 @@ module AwsCryptographyDynamoDbItemEncryptorOperations refines AbstractAwsCryptog
299
319
300
320
// It is forbidden to explicitly configure an attribute with the reserved prefix
301
321
&& (forall attribute < - config. attributeActions. Keys ::
302
- ! (SE . ReservedPrefix <= attribute))
322
+ ! (ReservedPrefix <= attribute))
303
323
304
324
&& (config. beacons. Some? ==> config. beacons. value. ValidState ())
305
325
}
@@ -356,13 +376,13 @@ module AwsCryptographyDynamoDbItemEncryptorOperations refines AbstractAwsCryptog
356
376
// = type=implication
357
377
// # Otherwise, Attributes MUST be considered as within the signature scope.
358
378
ensures ret. Success? ==>
359
- ((ret. value == SE . DoNotSign) <= => ! InSignatureScope (config, attr))
379
+ ((ret. value == DoNotSign) <= => ! InSignatureScope (config, attr))
360
380
{
361
381
:- Need (!UnknownAttribute(config, attr), "Attribute " + attr + " is not configured");
362
382
if InSignatureScope (config, attr) then
363
- Success (SE. DoSign)
383
+ Success (DoSign)
364
384
else
365
- Success (SE. DoNotSign)
385
+ Success (DoNotSign)
366
386
}
367
387
368
388
// get CryptoSchema for this item
0 commit comments