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