@@ -25,12 +25,9 @@ module TestAESKeyring {
2525
2626 method {:test} TestOnEncryptOnDecryptGenerateDataKey ()
2727 {
28- var name :- expect UTF8. Encode ("test Name");
29- var namespace :- expect UTF8. Encode ("test Namespace");
30- var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (name, namespace, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
31- var keyA :- expect UTF8. Encode ("keyA");
32- var valA :- expect UTF8. Encode ("valA");
33- var encryptionContext := map [keyA := valA];
28+ var namespace, name := TestUtils. NamespaceAndName (0);
29+ var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (namespace, name, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
30+ var encryptionContext := TestUtils. SmallEncryptionContext (TestUtils.SmallEncryptionContextVariation.A);
3431 ExpectSerializableEncryptionContext (encryptionContext);
3532
3633 var wrappingAlgorithmID := AlgorithmSuite. AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384;
@@ -50,12 +47,9 @@ module TestAESKeyring {
5047
5148 method {:test} TestOnEncryptOnDecryptSuppliedDataKey ()
5249 {
53- var name :- expect UTF8. Encode ("test Name");
54- var namespace :- expect UTF8. Encode ("test Namespace");
55- var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (name, namespace, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
56- var keyA :- expect UTF8. Encode ("keyA");
57- var valA :- expect UTF8. Encode ("valA");
58- var encryptionContext := map [keyA := valA];
50+ var namespace, name := TestUtils. NamespaceAndName (0);
51+ var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (namespace, name, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
52+ var encryptionContext := TestUtils. SmallEncryptionContext (TestUtils.SmallEncryptionContextVariation.A);
5953 ExpectSerializableEncryptionContext (encryptionContext);
6054
6155 var pdk := seq (32, i => 0);
@@ -79,13 +73,10 @@ module TestAESKeyring {
7973
8074 method {:test} TestOnDecryptNoEDKs ()
8175 {
82- var name :- expect UTF8. Encode ("test Name");
83- var namespace :- expect UTF8. Encode ("test Namespace");
84- var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (name, namespace, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
76+ var namespace, name := TestUtils. NamespaceAndName (0);
77+ var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (namespace, name, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
8578 var wrappingAlgorithmID := AlgorithmSuite. AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384;
86- var keyA :- expect UTF8. Encode ("keyA");
87- var valA :- expect UTF8. Encode ("valA");
88- var encryptionContext := map [keyA := valA];
79+ var encryptionContext := TestUtils. SmallEncryptionContext (TestUtils.SmallEncryptionContextVariation.A);
8980 var verificationKey := seq (32, i => 0);
9081
9182 var decryptionMaterialsIn := Materials. DecryptionMaterials. WithoutPlaintextDataKey (encryptionContext, wrappingAlgorithmID, Some(verificationKey));
@@ -95,11 +86,9 @@ module TestAESKeyring {
9586
9687 method {:test} TestOnEncryptUnserializableEC ()
9788 {
98- var name :- expect UTF8. Encode ("test Name");
99- var namespace :- expect UTF8. Encode ("test Namespace");
100- var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (name, namespace, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
101- var keyA :- expect UTF8. Encode ("keyA");
102- var unserializableEncryptionContext := generateUnserializableEncryptionContext (keyA);
89+ var namespace, name := TestUtils. NamespaceAndName (0);
90+ var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (namespace, name, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
91+ var unserializableEncryptionContext := generateUnserializableEncryptionContext ();
10392 ExpectNonSerializableEncryptionContext (unserializableEncryptionContext);
10493
10594 var wrappingAlgorithmID := AlgorithmSuite. AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384;
@@ -112,12 +101,9 @@ module TestAESKeyring {
112101 method {:test} TestOnDecryptUnserializableEC ()
113102 {
114103 // Set up valid EDK for decryption
115- var name :- expect UTF8. Encode ("test Name");
116- var namespace :- expect UTF8. Encode ("test Namespace");
117- var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (name, namespace, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
118- var keyA :- expect UTF8. Encode ("keyA");
119- var valA :- expect UTF8. Encode ("valA");
120- var encryptionContext := map [keyA := valA];
104+ var encryptionContext := TestUtils. SmallEncryptionContext (TestUtils.SmallEncryptionContextVariation.A);
105+ var namespace, name := TestUtils. NamespaceAndName (0);
106+ var rawAESKeyring := new RawAESKeyringDef. RawAESKeyring (namespace, name, seq(32, i => 0), EncryptionSuites. AES_GCM_256);
121107 var wrappingAlgorithmID := AlgorithmSuite. AES_256_GCM_IV12_TAG16_HKDF_SHA384_ECDSA_P384;
122108 var signingKey := seq (32, i => 0);
123109 var encryptionMaterialsIn := Materials. EncryptionMaterials. WithoutDataKeys (encryptionContext, wrappingAlgorithmID, Some(signingKey));
@@ -127,7 +113,7 @@ module TestAESKeyring {
127113 var edk := encryptionMaterialsOut. encryptedDataKeys[0];
128114
129115 // Set up EC that can't be serialized
130- var unserializableEncryptionContext := generateUnserializableEncryptionContext (keyA );
116+ var unserializableEncryptionContext := generateUnserializableEncryptionContext ();
131117 ExpectNonSerializableEncryptionContext (unserializableEncryptionContext);
132118 var verificationKey := seq (32, i => 0);
133119
@@ -155,8 +141,9 @@ module TestAESKeyring {
155141 expect serializedEDKCiphertext == ciphertext + authTag;
156142 }
157143
158- method generateUnserializableEncryptionContext (keyA: UTF8 .ValidUTF8Bytes ) returns (encCtx: EncryptionContext. Map)
144+ method generateUnserializableEncryptionContext () returns (encCtx: EncryptionContext. Map)
159145 {
146+ var keyA :- expect UTF8. Encode ("keyA");
160147 var invalidVal := seq (0x1_0000, _ => 0);
161148 AssumeLongSeqIsValidUTF8 (invalidVal);
162149 return map [keyA:= invalidVal];
0 commit comments