From 94b86b0faf62a1a1ed9cfd664b56319533dec90b Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Mon, 6 May 2024 12:03:32 -0700 Subject: [PATCH 01/28] [DO NOT MERGE] run hkeyring test vectors --- .../AWSEncryptionSDKTestVectorLib.csproj | 6 +- .../TestVectorLib/MaterialProviderFactory.cs | 74 ++++++++++++++++++- .../TestVectorLib/TestVectorTypes.cs | 6 ++ .../AWSEncryptionSDKTestVectors.csproj | 11 +-- .../TestVectors/TestVectors.cs | 6 ++ 5 files changed, 93 insertions(+), 10 deletions(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj index 6c283d130..6b27046de 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj @@ -9,7 +9,11 @@ - + + + + + diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 327648c55..093f9f3e4 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -2,9 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 using System.Diagnostics; +using Newtonsoft.Json; using Amazon; +using Amazon.DynamoDBv2; using Amazon.KeyManagementService; +using AWS.Cryptography.KeyStore; using AWS.Cryptography.MaterialProviders; +using AWS.Cryptography.MaterialProvidersTestVectorKeys; using RSAEncryption; @@ -18,6 +22,8 @@ public enum CryptoOperation public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); + private static KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig(); + private static KeyVectors keyVectors; public static ICryptographicMaterialsManager CreateDecryptCmm( DecryptVector vector, @@ -103,6 +109,7 @@ private static IKeyring CreateEncryptKeyring(EncryptVector vector, Dictionary= 1); Key generatorKey = keys[masterKeys[0].Key]; + Console.WriteLine(generatorKey.BranchKey); IKeyring generatorKeyring = CreateKeyring(masterKeys[0], generatorKey, CryptoOperation.ENCRYPT); List children = masterKeys @@ -160,6 +167,71 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio return materialProviders.CreateAwsKmsMrkDiscoveryKeyring(createKeyringInput); } + if (keyInfo.Type == "aws-kms-hierarchy") { + // keyInfo.Type = "static-branch-key-1"; + if (keyVectors == null) { + keyVectorsConfig.KeyManifestPath = "/Users/lucmcdon/Desktop/workplace/aws-encryption-sdk-python/net_vectors_test/312_hkeyring_manifest/keys.json"; + keyVectors = new KeyVectors(keyVectorsConfig); + } + + string jsonString = JsonConvert.SerializeObject(keyInfo); + + var stream = new MemoryStream(); + var writer = new StreamWriter(stream); + writer.Write(jsonString); + writer.Flush(); + stream.Position = 0; + + var getKeyDescriptionInput = new GetKeyDescriptionInput(); + getKeyDescriptionInput.Json = stream; + + var desc = keyVectors.GetKeyDescription(getKeyDescriptionInput); + + var testVectorKeyringInput = new TestVectorKeyringInput(); + testVectorKeyringInput.KeyDescription = desc.KeyDescription; + + var keyring = keyVectors.CreateTestVectorKeyring( + testVectorKeyringInput + ); + + Console.WriteLine(keyring); + + return keyring; + + // // TODO: When we have different keys, include the keystore KMS key ARN in the manifest. + // var kmsConfig = new KMSConfiguration { KmsKeyArn = "arn:aws:kms:us-west-2:370957321024:key/9d989aa2-2f9c-438c-a745-cc57d3ad0126" }; + // // Create an AWS KMS Configuration to use with your KeyStore. + // // The KMS Configuration MUST have the right access to the resources in the KeyStore. + // var keystoreConfig = new KeyStoreConfig + // { + // // Client MUST have permissions to decrypt kmsConfig.KmsKeyArn + // KmsClient = new AmazonKeyManagementServiceClient(GetRegionForArn("arn:aws:kms:us-west-2:370957321024:key/9d989aa2-2f9c-438c-a745-cc57d3ad0126")), + // KmsConfiguration = kmsConfig, + // // TODO: Don't hardcode + // DdbTableName = "KeyStoreDdbTable", + // DdbClient = new AmazonDynamoDBClient(GetRegionForArn("arn:aws:kms:us-west-2:370957321024:key/9d989aa2-2f9c-438c-a745-cc57d3ad0126")), + // // TODO: Don't hardcode + // LogicalKeyStoreName = "KeyStoreDdbTable" + // }; + // var keystore = new KeyStore(keystoreConfig); + + + + // Console.WriteLine(key.Id); + // Console.WriteLine(key.BranchKeyVersion); + + // // Create an AWS Hierarchical Keyring with the branch key id supplier + // var createKeyringInput = new CreateAwsKmsHierarchicalKeyringInput + // { + // KeyStore = keystore, + // BranchKeyId = key.Id, + // Cache = new CacheType { Default = new DefaultCache{EntryCapacity = 100} }, + // TtlSeconds = 0 + // }; + // return materialProviders.CreateAwsKmsHierarchicalKeyring(createKeyringInput); + + } + if (keyInfo.Type == "raw" && keyInfo.EncryptionAlgorithm == "aes") { CreateRawAesKeyringInput createKeyringInput = new CreateRawAesKeyringInput { @@ -209,7 +281,7 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio // string operationStr = operation == CryptoOperation.ENCRYPT // ? "encryption" // : "decryption"; - throw new Exception($"Unsupported keyring type for {operation}"); + throw new Exception($"Unsupported keyring {keyInfo.Type} type for {operation}"); } private static AesWrappingAlg AesAlgorithmFromBits(ushort bits) { diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/TestVectorTypes.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/TestVectorTypes.cs index a3e6dcf35..8dcc71151 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/TestVectorTypes.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/TestVectorTypes.cs @@ -25,6 +25,12 @@ public class Key { public string? Encoding { get; set; } [JsonProperty("material")] public string? Material { get; set; } + [JsonProperty("branchKeyVersion")] + public string? BranchKeyVersion { get; set; } + [JsonProperty("branchKey")] + public string? BranchKey { get; set; } + [JsonProperty("beaconKey")] + public string? BeaconKey { get; set; } } public class KeyManifest diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj index 1c2bbf34a..cdbf23fb1 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj @@ -13,22 +13,17 @@ + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs index dea6891cd..e2544912a 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs @@ -3,6 +3,7 @@ using System; using System.Collections; +using System.Text; using System.Collections.Generic; using System.IO; using System.Linq; @@ -177,6 +178,7 @@ NetV4_0_0_RetryPolicy _netV400RetryPolicy }; } AWS.Cryptography.EncryptionSDK.DecryptOutput decryptOutput = encryptionSdk.Decrypt(decryptInput); + if (expectedError != null) { throw new TestVectorShouldHaveFailedException( @@ -185,6 +187,10 @@ NetV4_0_0_RetryPolicy _netV400RetryPolicy } byte[] result = decryptOutput.Plaintext.ToArray(); + + Console.WriteLine(Encoding.Default.GetString(result)); + Console.WriteLine(Encoding.Default.GetString(expectedPlaintext)); + Assert.Equal(expectedPlaintext, result); } // Ensure Test Failure is not caught From efe212a4ea9fc0f42978c6a50359d27087cf3efe Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Mon, 6 May 2024 13:11:14 -0700 Subject: [PATCH 02/28] cleanup --- .../AWSEncryptionSDKTestVectorLib.csproj | 7 +- .../TestVectorLib/MaterialProviderFactory.cs | 67 +++++-------------- .../AWSEncryptionSDKTestVectors.csproj | 13 ++-- .../TestVectors/TestVectors.cs | 5 -- 4 files changed, 28 insertions(+), 64 deletions(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj index 6b27046de..d311b6da2 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj @@ -9,10 +9,9 @@ - - - - + + + diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 093f9f3e4..33453c444 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -22,8 +22,11 @@ public enum CryptoOperation public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); - private static KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig(); - private static KeyVectors keyVectors; + private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig + { + KeyManifestPath = "/Users/lucmcdon/Desktop/workplace/aws-encryption-sdk-python/net_vectors_test/312_hkeyring_manifest/keys.json" + }; + private static KeyVectors keyVectors = new(keyVectorsConfig); public static ICryptographicMaterialsManager CreateDecryptCmm( DecryptVector vector, @@ -109,7 +112,6 @@ private static IKeyring CreateEncryptKeyring(EncryptVector vector, Dictionary= 1); Key generatorKey = keys[masterKeys[0].Key]; - Console.WriteLine(generatorKey.BranchKey); IKeyring generatorKeyring = CreateKeyring(masterKeys[0], generatorKey, CryptoOperation.ENCRYPT); List children = masterKeys @@ -168,12 +170,7 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio } if (keyInfo.Type == "aws-kms-hierarchy") { - // keyInfo.Type = "static-branch-key-1"; - if (keyVectors == null) { - keyVectorsConfig.KeyManifestPath = "/Users/lucmcdon/Desktop/workplace/aws-encryption-sdk-python/net_vectors_test/312_hkeyring_manifest/keys.json"; - keyVectors = new KeyVectors(keyVectorsConfig); - } - + // Convert JSON to bytes for KeyVectors input string jsonString = JsonConvert.SerializeObject(keyInfo); var stream = new MemoryStream(); @@ -182,54 +179,24 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio writer.Flush(); stream.Position = 0; - var getKeyDescriptionInput = new GetKeyDescriptionInput(); - getKeyDescriptionInput.Json = stream; + // Create KeyVectors keyring + var getKeyDescriptionInput = new GetKeyDescriptionInput + { + Json = stream + }; var desc = keyVectors.GetKeyDescription(getKeyDescriptionInput); - var testVectorKeyringInput = new TestVectorKeyringInput(); - testVectorKeyringInput.KeyDescription = desc.KeyDescription; - + var testVectorKeyringInput = new TestVectorKeyringInput + { + KeyDescription = desc.KeyDescription + }; + var keyring = keyVectors.CreateTestVectorKeyring( testVectorKeyringInput ); - Console.WriteLine(keyring); - - return keyring; - - // // TODO: When we have different keys, include the keystore KMS key ARN in the manifest. - // var kmsConfig = new KMSConfiguration { KmsKeyArn = "arn:aws:kms:us-west-2:370957321024:key/9d989aa2-2f9c-438c-a745-cc57d3ad0126" }; - // // Create an AWS KMS Configuration to use with your KeyStore. - // // The KMS Configuration MUST have the right access to the resources in the KeyStore. - // var keystoreConfig = new KeyStoreConfig - // { - // // Client MUST have permissions to decrypt kmsConfig.KmsKeyArn - // KmsClient = new AmazonKeyManagementServiceClient(GetRegionForArn("arn:aws:kms:us-west-2:370957321024:key/9d989aa2-2f9c-438c-a745-cc57d3ad0126")), - // KmsConfiguration = kmsConfig, - // // TODO: Don't hardcode - // DdbTableName = "KeyStoreDdbTable", - // DdbClient = new AmazonDynamoDBClient(GetRegionForArn("arn:aws:kms:us-west-2:370957321024:key/9d989aa2-2f9c-438c-a745-cc57d3ad0126")), - // // TODO: Don't hardcode - // LogicalKeyStoreName = "KeyStoreDdbTable" - // }; - // var keystore = new KeyStore(keystoreConfig); - - - - // Console.WriteLine(key.Id); - // Console.WriteLine(key.BranchKeyVersion); - - // // Create an AWS Hierarchical Keyring with the branch key id supplier - // var createKeyringInput = new CreateAwsKmsHierarchicalKeyringInput - // { - // KeyStore = keystore, - // BranchKeyId = key.Id, - // Cache = new CacheType { Default = new DefaultCache{EntryCapacity = 100} }, - // TtlSeconds = 0 - // }; - // return materialProviders.CreateAwsKmsHierarchicalKeyring(createKeyringInput); - + return keyring!; } if (keyInfo.Type == "raw" && keyInfo.EncryptionAlgorithm == "aes") { diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj index cdbf23fb1..0852b3a43 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj @@ -13,17 +13,20 @@ - - - runtime; build; native; contentfiles; analyzers; buildtransitive + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs index e2544912a..76e38d36f 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs @@ -3,7 +3,6 @@ using System; using System.Collections; -using System.Text; using System.Collections.Generic; using System.IO; using System.Linq; @@ -178,7 +177,6 @@ NetV4_0_0_RetryPolicy _netV400RetryPolicy }; } AWS.Cryptography.EncryptionSDK.DecryptOutput decryptOutput = encryptionSdk.Decrypt(decryptInput); - if (expectedError != null) { throw new TestVectorShouldHaveFailedException( @@ -188,9 +186,6 @@ NetV4_0_0_RetryPolicy _netV400RetryPolicy byte[] result = decryptOutput.Plaintext.ToArray(); - Console.WriteLine(Encoding.Default.GetString(result)); - Console.WriteLine(Encoding.Default.GetString(expectedPlaintext)); - Assert.Equal(expectedPlaintext, result); } // Ensure Test Failure is not caught From cf24fc216b7cc32fbae1ff9e9703c2a3fc66b178 Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Mon, 6 May 2024 13:12:15 -0700 Subject: [PATCH 03/28] cleanup --- .../TestVectors/AWSEncryptionSDKTestVectors.csproj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj index 0852b3a43..1c2bbf34a 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/AWSEncryptionSDKTestVectors.csproj @@ -22,11 +22,13 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' "> + runtime; build; native; contentfiles; analyzers; buildtransitive all + Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' " /> + From 07f8efaa5966d0debb431b0b051e108a6439041d Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Mon, 6 May 2024 13:13:23 -0700 Subject: [PATCH 04/28] cleanup --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 1 + .../runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 33453c444..dd9a0e1ac 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -22,6 +22,7 @@ public enum CryptoOperation public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); + // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { KeyManifestPath = "/Users/lucmcdon/Desktop/workplace/aws-encryption-sdk-python/net_vectors_test/312_hkeyring_manifest/keys.json" diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs index 76e38d36f..dea6891cd 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/TestVectors.cs @@ -185,7 +185,6 @@ NetV4_0_0_RetryPolicy _netV400RetryPolicy } byte[] result = decryptOutput.Plaintext.ToArray(); - Assert.Equal(expectedPlaintext, result); } // Ensure Test Failure is not caught From e4e7503c71dc97cffa1b8b84bf9c7c8d507cb5e4 Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Wed, 26 Jun 2024 12:37:43 -0700 Subject: [PATCH 05/28] wip --- .../TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj index d311b6da2..5fd06ea5d 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/AWSEncryptionSDKTestVectorLib.csproj @@ -12,7 +12,7 @@ - + From a46051d3b82ceb73b5caccb3ee3c145cf6947004 Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Wed, 26 Jun 2024 12:43:35 -0700 Subject: [PATCH 06/28] debug --- .github/workflows/library_interop_tests.yml | 17 +++++++++++++++++ .github/workflows/library_net_tests.yml | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/.github/workflows/library_interop_tests.yml b/.github/workflows/library_interop_tests.yml index f526a9ef8..f8f0d6e36 100644 --- a/.github/workflows/library_interop_tests.yml +++ b/.github/workflows/library_interop_tests.yml @@ -76,6 +76,14 @@ jobs: # This works because `node` is installed by default on GHA runners CORES=$(node -e 'console.log(os.cpus().length)') make transpile_net CORES=$CORES + + - name: Compile MPL TestVectors implementation + shell: bash + working-directory: ./mpl/TestVectorsAwsCryptographicMaterialProviders + run: | + # This works because `node` is installed by default on GHA runners + CORES=$(node -e 'console.log(os.cpus().length)') + make transpile_net CORES=$CORES - name: Fetch Python 2.3.0 Test Vectors working-directory: ./ @@ -166,6 +174,15 @@ jobs: # This works because `node` is installed by default on GHA runners CORES=$(node -e 'console.log(os.cpus().length)') make transpile_net CORES=$CORES + + + - name: Compile MPL TestVectors implementation + shell: bash + working-directory: ./mpl/TestVectorsAwsCryptographicMaterialProviders + run: | + # This works because `node` is installed by default on GHA runners + CORES=$(node -e 'console.log(os.cpus().length)') + make transpile_net CORES=$CORES # # TODO: Fix Zip file creation on Windows diff --git a/.github/workflows/library_net_tests.yml b/.github/workflows/library_net_tests.yml index 463f83b0b..362dff0ea 100644 --- a/.github/workflows/library_net_tests.yml +++ b/.github/workflows/library_net_tests.yml @@ -92,6 +92,15 @@ jobs: CORES=$(node -e 'console.log(os.cpus().length)') make transpile_net CORES=$CORES + + - name: Compile MPL TestVectors implementation + shell: bash + working-directory: ./mpl/TestVectorsAwsCryptographicMaterialProviders + run: | + # This works because `node` is installed by default on GHA runners + CORES=$(node -e 'console.log(os.cpus().length)') + make transpile_net CORES=$CORES + - name: Test .NET Framework net48 working-directory: ./AwsEncryptionSDK if: matrix.os == 'windows-latest' From 96d6d607469edf3dd4b9bfe2790af459d360a0b1 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 28 Jun 2024 11:17:38 -0700 Subject: [PATCH 07/28] add keys.json to repo --- .../TestVectorLib/MaterialProviderFactory.cs | 2 +- .../TestVectorLib/resources/keys.json | 79 +++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/resources/keys.json diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index dd9a0e1ac..a8faa976c 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -25,7 +25,7 @@ public static class MaterialProviderFactory // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - KeyManifestPath = "/Users/lucmcdon/Desktop/workplace/aws-encryption-sdk-python/net_vectors_test/312_hkeyring_manifest/keys.json" + KeyManifestPath = "resources/keys.json" }; private static KeyVectors keyVectors = new(keyVectorsConfig); diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/resources/keys.json b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/resources/keys.json new file mode 100644 index 000000000..a960f8595 --- /dev/null +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/resources/keys.json @@ -0,0 +1,79 @@ +{ + "manifest": { + "type": "keys", + "version": 3 + }, + "keys": { + "aes-128": { + "key-id": "aes-128", + "encrypt": true, + "decrypt": true, + "algorithm": "aes", + "type": "symmetric", + "bits": 128, + "encoding": "base64", + "material": "AAECAwQFBgcICRAREhMUFQ==" + }, + "aes-192": { + "key-id": "aes-192", + "encrypt": true, + "decrypt": true, + "algorithm": "aes", + "type": "symmetric", + "bits": 192, + "encoding": "base64", + "material": "AAECAwQFBgcICRAREhMUFRYXGBkgISIj" + }, + "aes-256": { + "key-id": "aes-256", + "encrypt": true, + "decrypt": true, + "algorithm": "aes", + "type": "symmetric", + "bits": 256, + "encoding": "base64", + "material": "AAECAwQFBgcICRAREhMUFRYXGBkgISIjJCUmJygpMDE=" + }, + "rsa-4096-private": { + "key-id": "rsa-4096", + "encrypt": true, + "decrypt": true, + "algorithm": "rsa", + "type": "private", + "bits": 4096, + "encoding": "pem", + "material": "-----BEGIN PRIVATE KEY-----\nMIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCztGg1gQ8AjCzz\n1VX6StqtW//jBt2ZQBoApaBa7FmLmdr0YlKaeEKSrItGbvA9tBjgsKhrn8gxTGQc\nuxgM92651jRCbQZyjE6W8kodijhGMXsfKJLfgPp2/I7gZ3dqrSZkejFIYLFb/uF/\nTfAQzNyJUldYdeFojSUPqevMgSAusTgv7dXYt4BCO9mxMp35tgyp5k4vazKJVUgB\nTw87AAYZUGugmi94Wb9JSnqUKI3QzaRN7JADZrHdBO1lIBryfCsjtTnZc7NWZ0yJ\nwmz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r8khGcT6vqqoSxOoH3mPRgOfL\nJnppne8wlwIf7Vq3H8ka6zPSXEHma999gZcmy9t7AoIBAGbQhiLl79j3a0wXMvZp\nVf5IVYgXFDnAbG2hb7a06bhAAIgyexcjzsC4C2+DWdgOgwHkuoPg+062QV8zauGh\nsJKaa6cHlvIpSJeg3NjD/nfJN3CYzCd0yCIm2Z9Ka6xI5iYhm+pGPNhIG4Na8deS\ngVL46yv1pc/o73VxfoGg5UzgN3xlp97Cva0sHEGguHr4W8Qr59xZw3wGQ4SLW35M\nF6qXVNKUh12GSMCPbZK2RXBWVKqqJmca+WzJoJ6DlsT2lQdFhXCus9L007xlDXxF\nC/hCmw1dEl+VaNo2Ou26W/zdwTKYhNlxBwsg4SB8nPNxXIsmlBBY54froFhriNfn\nx/0CggEAUzz+VMtjoEWw2HSHLOXrO4EmwJniNgiiwfX3DfZE4tMNZgqZwLkq67ns\nT0n3b0XfAOOkLgMZrUoOxPHkxFeyLLf7pAEJe7QNB+Qilw8e2zVqtiJrRk6uDIGJ\nSv+yM52zkImZAe2jOdU3KeUZxSMmb5vIoiPBm+tb2WupAg3YdpKn1/jWTpVmV/+G\nUtTLVE6YpAyFp1gMxhutE9vfIS94ek+vt03AoEOlltt6hqZfv3xmY8vGuAjlnj12\nzHaq+fhCRPsbsZkzJ9nIVdXYnNIEGtMGNnxax7tYRej/UXqyazbxHiJ0iPF4PeDn\ndzxtGxpeTBi+KhKlca8SlCdCqYwG6Q==\n-----END PRIVATE KEY-----" + }, + "rsa-4096-public": { + "key-id": "rsa-4096", + "encrypt": true, + "decrypt": false, + "algorithm": "rsa", + "type": "public", + "bits": 4096, + "encoding": "pem", + "material": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAs7RoNYEPAIws89VV+kra\nrVv/4wbdmUAaAKWgWuxZi5na9GJSmnhCkqyLRm7wPbQY4LCoa5/IMUxkHLsYDPdu\nudY0Qm0GcoxOlvJKHYo4RjF7HyiS34D6dvyO4Gd3aq0mZHoxSGCxW/7hf03wEMzc\niVJXWHXhaI0lD6nrzIEgLrE4L+3V2LeAQjvZsTKd+bYMqeZOL2syiVVIAU8POwAG\nGVBroJoveFm/SUp6lCiN0M2kTeyQA2ax3QTtZSAa8nwrI7U52XOzVmdMicJsy2Pg\nuW98te3MuODdK24yNkHIkYameP/Umf/SJshUJQd5a/TUp3XE+HhOWAumx22tIDlC\nvZS11cuk2fp0WeHUnXaC19N5qWKfvHEKSugzty/z3lGP7ItFhrF2X1qJHeAAsL11\nkjo6Lc48KsE1vKvbnW4VLyB3wdNiVvmUNO29tPXwaR0Q5Gbr3jk3nUzdkEHouHWQ\n41lubOHCCBN3V13mh/MgtNhESHjfmmOnh54ErD9saA1d7CjTf8g2wqmjEqvGSW6N\nq7zhcWR2tp1olflS7oHzul4/I3hnkfL6Kb2xAWWaQKvg3mtsY2OPlzFEP0tR5UcH\nPfp5CeS1Xzg7hN6vRICW6m4l3u2HJFld2akDMm1vnSz8RCbPW7jp7YBxUkWJmypM\ntG7Yv2aGZXGbUtM8o1cZarECAwEAAQ==\n-----END PUBLIC KEY-----" + }, + "us-west-2-decryptable": { + "type": "aws-kms", + "key-id": "arn:aws:kms:us-west-2:658956600833:alias/EncryptDecrypt", + "encrypt": true, + "decrypt": true + }, + "us-west-2-encrypt-only": { + "type": "aws-kms", + "key-id": "arn:aws:kms:us-west-2:658956600833:alias/EncryptOnly", + "encrypt": true, + "decrypt": false + }, + "static-branch-key-1": { + "type": "static-branch-key", + "encrypt": true, + "decrypt": true, + "key-id" : "bd3842ff-3076-4092-9918-4395730050b8", + "branchKeyVersion" : "e9ce18a3-edb5-4272-9f86-1cacb7997ff6", + "branchKey" : "tJwf65epYvUt5HMiQsl/6jlvLxS0tgdjIuvFy2BLIwg=", + "beaconKey" : "RJiXTa/rJf+CLHAVyE652v3uhKreOuYjV+a7SVOugow=" + } + } +} From d9da67ba03a82b1e0d4568d2c3cf2374ea63a3cb Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 28 Jun 2024 13:24:00 -0700 Subject: [PATCH 08/28] fix --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index a8faa976c..ade6097fe 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -25,7 +25,7 @@ public static class MaterialProviderFactory // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - KeyManifestPath = "resources/keys.json" + KeyManifestPath = "resources/keys.json" }; private static KeyVectors keyVectors = new(keyVectorsConfig); From c61d3e022218795ab5b3b1189001916bac994c3e Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 28 Jun 2024 13:45:47 -0700 Subject: [PATCH 09/28] debug --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 2 +- .../{TestVectorLib => TestVectors}/resources/keys.json | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename AwsEncryptionSDK/runtimes/net/TestVectorsNative/{TestVectorLib => TestVectors}/resources/keys.json (100%) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index ade6097fe..412437b94 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -25,7 +25,7 @@ public static class MaterialProviderFactory // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - KeyManifestPath = "resources/keys.json" + KeyManifestPath = "../TestVectors/resources/keys.json" }; private static KeyVectors keyVectors = new(keyVectorsConfig); diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/resources/keys.json b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources/keys.json similarity index 100% rename from AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/resources/keys.json rename to AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources/keys.json From 8ee95df791b848e6c031e9453ddc8cb8aadd10c8 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 28 Jun 2024 14:43:16 -0700 Subject: [PATCH 10/28] fix: add curr dir path --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 412437b94..64c66783f 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -25,7 +25,7 @@ public static class MaterialProviderFactory // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - KeyManifestPath = "../TestVectors/resources/keys.json" + KeyManifestPath = Directory.GetCurrentDirectory() + "/../TestVectors/resources/keys.json"; }; private static KeyVectors keyVectors = new(keyVectorsConfig); From e415a5b905da718d1f1c1a963909844123f63a16 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 28 Jun 2024 14:52:12 -0700 Subject: [PATCH 11/28] fix --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 64c66783f..3f5d0f136 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -25,7 +25,7 @@ public static class MaterialProviderFactory // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - KeyManifestPath = Directory.GetCurrentDirectory() + "/../TestVectors/resources/keys.json"; + KeyManifestPath = Directory.GetCurrentDirectory() + "/../TestVectors/resources/keys.json" }; private static KeyVectors keyVectors = new(keyVectorsConfig); From ec7d644d3bdcc1f884a38457d04ac5c33a919863 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 28 Jun 2024 16:35:55 -0700 Subject: [PATCH 12/28] fix --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 3f5d0f136..add2ff13c 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -25,7 +25,7 @@ public static class MaterialProviderFactory // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - KeyManifestPath = Directory.GetCurrentDirectory() + "/../TestVectors/resources/keys.json" + KeyManifestPath = Directory.GetCurrentDirectory() + "/../bin/Debug/TestVectors/resources/keys.json" }; private static KeyVectors keyVectors = new(keyVectorsConfig); From 955c409591d526a192aca0b2b23d64b16b9fb927 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Fri, 28 Jun 2024 16:58:34 -0700 Subject: [PATCH 13/28] fix --- AwsEncryptionSDK/codebuild/release/test-prod.yml | 1 + .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/codebuild/release/test-prod.yml b/AwsEncryptionSDK/codebuild/release/test-prod.yml index da12cb44f..47053122f 100644 --- a/AwsEncryptionSDK/codebuild/release/test-prod.yml +++ b/AwsEncryptionSDK/codebuild/release/test-prod.yml @@ -60,6 +60,7 @@ phases: # Run Decrypt Test Vectors on .NET Framework net48 - cd ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors - export DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ + - ls $PYTHON_23_VECTOR_PATH - dotnet test --framework net48 # Run Decrypt Test Vectors on .NET net6.0 diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index add2ff13c..f7e695e85 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -25,7 +25,7 @@ public static class MaterialProviderFactory // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - KeyManifestPath = Directory.GetCurrentDirectory() + "/../bin/Debug/TestVectors/resources/keys.json" + KeyManifestPath = Environment.GetEnvironmentVariable(PYTHON_23_VECTOR_PATH) + "keys.json" }; private static KeyVectors keyVectors = new(keyVectorsConfig); From 581c46ba7806ad19d8f7afb9a47399554cebc43e Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 12:07:59 -0700 Subject: [PATCH 14/28] add ManifestUriToPath --- .../codebuild/release/test-prod.yml | 1 - .../TestVectorLib/MaterialProviderFactory.cs | 4 +- .../TestVectors/resources/keys.json | 79 ------------------- 3 files changed, 3 insertions(+), 81 deletions(-) delete mode 100644 AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources/keys.json diff --git a/AwsEncryptionSDK/codebuild/release/test-prod.yml b/AwsEncryptionSDK/codebuild/release/test-prod.yml index 47053122f..da12cb44f 100644 --- a/AwsEncryptionSDK/codebuild/release/test-prod.yml +++ b/AwsEncryptionSDK/codebuild/release/test-prod.yml @@ -60,7 +60,6 @@ phases: # Run Decrypt Test Vectors on .NET Framework net48 - cd ./AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors - export DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ - - ls $PYTHON_23_VECTOR_PATH - dotnet test --framework net48 # Run Decrypt Test Vectors on .NET net6.0 diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index f7e695e85..b3cca9260 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -25,7 +25,9 @@ public static class MaterialProviderFactory // TODO: Get this from CLI or something? private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - KeyManifestPath = Environment.GetEnvironmentVariable(PYTHON_23_VECTOR_PATH) + "keys.json" + manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); + DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); + KeyManifestPath = Utils.ManifestUriToPath(manifest.KeysUri, manifestPath); }; private static KeyVectors keyVectors = new(keyVectorsConfig); diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources/keys.json b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources/keys.json deleted file mode 100644 index a960f8595..000000000 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectors/resources/keys.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "manifest": { - "type": "keys", - "version": 3 - }, - "keys": { - "aes-128": { - "key-id": "aes-128", - "encrypt": true, - "decrypt": true, - "algorithm": "aes", - "type": "symmetric", - "bits": 128, - "encoding": "base64", - "material": "AAECAwQFBgcICRAREhMUFQ==" - }, - "aes-192": { - "key-id": "aes-192", - "encrypt": true, - "decrypt": true, - "algorithm": "aes", - "type": "symmetric", - "bits": 192, - "encoding": "base64", - "material": "AAECAwQFBgcICRAREhMUFRYXGBkgISIj" - }, - "aes-256": { - "key-id": "aes-256", - "encrypt": true, - "decrypt": true, - "algorithm": "aes", - "type": "symmetric", - "bits": 256, - "encoding": "base64", - "material": "AAECAwQFBgcICRAREhMUFRYXGBkgISIjJCUmJygpMDE=" - }, - "rsa-4096-private": { - "key-id": "rsa-4096", - "encrypt": true, - "decrypt": true, - "algorithm": "rsa", - "type": "private", - "bits": 4096, - "encoding": "pem", - "material": "-----BEGIN PRIVATE KEY-----\nMIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCztGg1gQ8AjCzz\n1VX6StqtW//jBt2ZQBoApaBa7FmLmdr0YlKaeEKSrItGbvA9tBjgsKhrn8gxTGQc\nuxgM92651jRCbQZyjE6W8kodijhGMXsfKJLfgPp2/I7gZ3dqrSZkejFIYLFb/uF/\nTfAQzNyJUldYdeFojSUPqevMgSAusTgv7dXYt4BCO9mxMp35tgyp5k4vazKJVUgB\nTw87AAYZUGugmi94Wb9JSnqUKI3Qza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nS8dfrO8ML+ki8Zqck8L1qhiNb5zkXtKExy4u+gNr8khGcT6vqqoSxOoH3mPRgOfL\nJnppne8wlwIf7Vq3H8ka6zPSXEHma999gZcmy9t7AoIBAGbQhiLl79j3a0wXMvZp\nVf5IVYgXFDnAbG2hb7a06bhAAIgyexcjzsC4C2+DWdgOgwHkuoPg+062QV8zauGh\nsJKaa6cHlvIpSJeg3NjD/nfJN3CYzCd0yCIm2Z9Ka6xI5iYhm+pGPNhIG4Na8deS\ngVL46yv1pc/o73VxfoGg5UzgN3xlp97Cva0sHEGguHr4W8Qr59xZw3wGQ4SLW35M\nF6qXVNKUh12GSMCPbZK2RXBWVKqqJmca+WzJoJ6DlsT2lQdFhXCus9L007xlDXxF\nC/hCmw1dEl+VaNo2Ou26W/zdwTKYhNlxBwsg4SB8nPNxXIsmlBBY54froFhriNfn\nx/0CggEAUzz+VMtjoEWw2HSHLOXrO4EmwJniNgiiwfX3DfZE4tMNZgqZwLkq67ns\nT0n3b0XfAOOkLgMZrUoOxPHkxFeyLLf7pAEJe7QNB+Qilw8e2zVqtiJrRk6uDIGJ\nSv+yM52zkImZAe2jOdU3KeUZxSMmb5vIoiPBm+tb2WupAg3YdpKn1/jWTpVmV/+G\nUtTLVE6YpAyFp1gMxhutE9vfIS94ek+vt03AoEOlltt6hqZfv3xmY8vGuAjlnj12\nzHaq+fhCRPsbsZkzJ9nIVdXYnNIEGtMGNnxax7tYRej/UXqyazbxHiJ0iPF4PeDn\ndzxtGxpeTBi+KhKlca8SlCdCqYwG6Q==\n-----END PRIVATE KEY-----" - }, - "rsa-4096-public": { - "key-id": "rsa-4096", - "encrypt": true, - "decrypt": false, - "algorithm": "rsa", - "type": "public", - "bits": 4096, - "encoding": "pem", - "material": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAs7RoNYEPAIws89VV+kra\nrVv/4wbdmUAaAKWgWuxZi5na9GJSmnhCkqyLRm7wPbQY4LCoa5/IMUxkHLsYDPdu\nudY0Qm0GcoxOlvJKHYo4RjF7HyiS34D6dvyO4Gd3aq0mZHoxSGCxW/7hf03wEMzc\niVJXWHXhaI0lD6nrzIEgLrE4L+3V2LeAQjvZsTKd+bYMqeZOL2syiVVIAU8POwAG\nGVBroJoveFm/SUp6lCiN0M2kTeyQA2ax3QTtZSAa8nwrI7U52XOzVmdMicJsy2Pg\nuW98te3MuODdK24yNkHIkYameP/Umf/SJshUJQd5a/TUp3XE+HhOWAumx22tIDlC\nvZS11cuk2fp0WeHUnXaC19N5qWKfvHEKSugzty/z3lGP7ItFhrF2X1qJHeAAsL11\nkjo6Lc48KsE1vKvbnW4VLyB3wdNiVvmUNO29tPXwaR0Q5Gbr3jk3nUzdkEHouHWQ\n41lubOHCCBN3V13mh/MgtNhESHjfmmOnh54ErD9saA1d7CjTf8g2wqmjEqvGSW6N\nq7zhcWR2tp1olflS7oHzul4/I3hnkfL6Kb2xAWWaQKvg3mtsY2OPlzFEP0tR5UcH\nPfp5CeS1Xzg7hN6vRICW6m4l3u2HJFld2akDMm1vnSz8RCbPW7jp7YBxUkWJmypM\ntG7Yv2aGZXGbUtM8o1cZarECAwEAAQ==\n-----END PUBLIC KEY-----" - }, - "us-west-2-decryptable": { - "type": "aws-kms", - "key-id": "arn:aws:kms:us-west-2:658956600833:alias/EncryptDecrypt", - "encrypt": true, - "decrypt": true - }, - "us-west-2-encrypt-only": { - "type": "aws-kms", - "key-id": "arn:aws:kms:us-west-2:658956600833:alias/EncryptOnly", - "encrypt": true, - "decrypt": false - }, - "static-branch-key-1": { - "type": "static-branch-key", - "encrypt": true, - "decrypt": true, - "key-id" : "bd3842ff-3076-4092-9918-4395730050b8", - "branchKeyVersion" : "e9ce18a3-edb5-4272-9f86-1cacb7997ff6", - "branchKey" : "tJwf65epYvUt5HMiQsl/6jlvLxS0tgdjIuvFy2BLIwg=", - "beaconKey" : "RJiXTa/rJf+CLHAVyE652v3uhKreOuYjV+a7SVOugow=" - } - } -} From e25bd46f42e758aa4131080644140992c9302df3 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 12:21:22 -0700 Subject: [PATCH 15/28] fix --- .../TestVectorLib/MaterialProviderFactory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index b3cca9260..5e3bb93d5 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -23,11 +23,11 @@ public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); // TODO: Get this from CLI or something? + protected manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); + protected DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { - manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); - DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); - KeyManifestPath = Utils.ManifestUriToPath(manifest.KeysUri, manifestPath); + KeyManifestPath = Utils.ManifestUriToPath(manifest.KeysUri, manifestPath) }; private static KeyVectors keyVectors = new(keyVectorsConfig); From ffbba92e4aafef3b576d1500d4cf9b0d6c5405c6 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 12:27:02 -0700 Subject: [PATCH 16/28] fix --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 5e3bb93d5..9b8b05d66 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -23,7 +23,7 @@ public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); // TODO: Get this from CLI or something? - protected manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); + protected string manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); protected DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { From d85bb1ecf8613c12a1beeaff762929e615123e85 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 13:45:28 -0700 Subject: [PATCH 17/28] static --- .../TestVectorLib/MaterialProviderFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 9b8b05d66..840bd6d4b 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -23,8 +23,8 @@ public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); // TODO: Get this from CLI or something? - protected string manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); - protected DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); + protected static string manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); + protected static DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { KeyManifestPath = Utils.ManifestUriToPath(manifest.KeysUri, manifestPath) From 594933d7e9bf140f4cced78af0238af5e574941b Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 13:50:30 -0700 Subject: [PATCH 18/28] private --- .../TestVectorLib/MaterialProviderFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 840bd6d4b..fa81d0006 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -23,8 +23,8 @@ public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); // TODO: Get this from CLI or something? - protected static string manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); - protected static DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); + private static string manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); + private static DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { KeyManifestPath = Utils.ManifestUriToPath(manifest.KeysUri, manifestPath) From 956c2066aca53cd71882fa58f1c87a2b663db3fb Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 15:55:19 -0700 Subject: [PATCH 19/28] set DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH in generate_vectors --- .github/workflows/library_interop_tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/library_interop_tests.yml b/.github/workflows/library_interop_tests.yml index 112b6825a..8e7bc189d 100644 --- a/.github/workflows/library_interop_tests.yml +++ b/.github/workflows/library_interop_tests.yml @@ -201,6 +201,8 @@ jobs: working-directory: ./AwsEncryptionSDK shell: bash run: | + PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors + DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ NET_41_VECTOR_PATH=net41/vectors mkdir -p $NET_41_VECTOR_PATH GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator From 1d9cdd11fbf9c64f435982092bf857f4d2a5efde Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 16:01:35 -0700 Subject: [PATCH 20/28] fix --- .github/workflows/library_interop_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/library_interop_tests.yml b/.github/workflows/library_interop_tests.yml index 8e7bc189d..b1fb0c962 100644 --- a/.github/workflows/library_interop_tests.yml +++ b/.github/workflows/library_interop_tests.yml @@ -201,11 +201,11 @@ jobs: working-directory: ./AwsEncryptionSDK shell: bash run: | - PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors - DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ NET_41_VECTOR_PATH=net41/vectors mkdir -p $NET_41_VECTOR_PATH GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator + PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors + DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ dotnet run --project $GEN_PATH --framework net6.0 -- \ --encrypt-manifest $GEN_PATH/resources/0006-awses-message-decryption-generation.v2.json \ --output-dir $NET_41_VECTOR_PATH From 463fc2714c8a1f4980168e55047d22e2b9ce414e Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 16:06:03 -0700 Subject: [PATCH 21/28] correct manifest path --- .github/workflows/library_interop_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/library_interop_tests.yml b/.github/workflows/library_interop_tests.yml index b1fb0c962..8a3a4201f 100644 --- a/.github/workflows/library_interop_tests.yml +++ b/.github/workflows/library_interop_tests.yml @@ -204,7 +204,7 @@ jobs: NET_41_VECTOR_PATH=net41/vectors mkdir -p $NET_41_VECTOR_PATH GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator - PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors + PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/runtimes/net/TestVectorsNative/TestVectors/python23/vectors DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ dotnet run --project $GEN_PATH --framework net6.0 -- \ --encrypt-manifest $GEN_PATH/resources/0006-awses-message-decryption-generation.v2.json \ From 368b6b92594945221eeecf22369c9b35c9adb7b5 Mon Sep 17 00:00:00 2001 From: Ritvik Kapila Date: Mon, 1 Jul 2024 16:19:21 -0700 Subject: [PATCH 22/28] download py23 test vectors for generate_vectors --- .github/workflows/library_interop_tests.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/library_interop_tests.yml b/.github/workflows/library_interop_tests.yml index 8a3a4201f..8e6beaca8 100644 --- a/.github/workflows/library_interop_tests.yml +++ b/.github/workflows/library_interop_tests.yml @@ -194,6 +194,16 @@ jobs: # # Set-Location -Path "$env:GITHUB_WORKSPACE\net41\vectors" # # Compress-Archive -Path "$env:GITHUB_WORKSPACE\net41\vectors\*" -DestinationPath "$env:GITHUB_WORKSPACE\net41\vectors\net41.zip" + - name: Fetch Python 2.3.0 Test Vectors + working-directory: ./ + shell: bash + run: | + PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors + mkdir -p $PYTHON_23_VECTOR_PATH + DOWNLOAD_NAME=python23.zip + curl --no-progress-meter --output $DOWNLOAD_NAME --location $VECTORS_URL + unzip -o -qq $DOWNLOAD_NAME -d $PYTHON_23_VECTOR_PATH + rm $DOWNLOAD_NAME - name: Generate Test Vectors with .NET Framework net6.0 # TODO Post-#619: Fix Zip file creation on Windows @@ -204,7 +214,7 @@ jobs: NET_41_VECTOR_PATH=net41/vectors mkdir -p $NET_41_VECTOR_PATH GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator - PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/runtimes/net/TestVectorsNative/TestVectors/python23/vectors + PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ dotnet run --project $GEN_PATH --framework net6.0 -- \ --encrypt-manifest $GEN_PATH/resources/0006-awses-message-decryption-generation.v2.json \ From 200bed840ba5551e91fa6eec8f6e885c2eb7334b Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Wed, 2 Oct 2024 16:09:56 -0700 Subject: [PATCH 23/28] Update AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index fa81d0006..d8646dfbc 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -22,7 +22,6 @@ public enum CryptoOperation public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); - // TODO: Get this from CLI or something? private static string manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); private static DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig From 6db2fa94ea6616114389a8436cc68fed8e201302 Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Wed, 2 Oct 2024 16:45:13 -0700 Subject: [PATCH 24/28] m --- .../TestVectorLib/MaterialProviderFactory.cs | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index d8646dfbc..ac7e36a89 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -22,13 +22,7 @@ public enum CryptoOperation public static class MaterialProviderFactory { private static readonly MaterialProviders materialProviders = new(new MaterialProvidersConfig()); - private static string manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); - private static DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); - private static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig - { - KeyManifestPath = Utils.ManifestUriToPath(manifest.KeysUri, manifestPath) - }; - private static KeyVectors keyVectors = new(keyVectorsConfig); + private static KeyVectors singletonKeyVectors; public static ICryptographicMaterialsManager CreateDecryptCmm( DecryptVector vector, @@ -187,14 +181,35 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio Json = stream }; - var desc = keyVectors.GetKeyDescription(getKeyDescriptionInput); + // Lazily create a singleton KeyVectors client. + // KeyVectors manifest is only required if a test vector specifies a hierarchy keyring. + // This specification can only be determined at runtime while reading the test vector manifest. + if (singletonKeyVectors == null) { + string manifestPath; + try + { + manifestPath = Utils.GetEnvironmentVariableOrError("DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH"); + } + catch (ArgumentException e) + { + throw new ArgumentException("Hierarchy keyring test vectors must supply a KeyVectors manifest", e); + } + DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); + static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig + { + KeyManifestPath = Utils.ManifestUriToPath(manifest.KeysUri, manifestPath) + }; + singletonKeyVectors = new(keyVectorsConfig); + } + + var desc = singletonKeyVectors.GetKeyDescription(getKeyDescriptionInput); var testVectorKeyringInput = new TestVectorKeyringInput { KeyDescription = desc.KeyDescription }; - var keyring = keyVectors.CreateTestVectorKeyring( + var keyring = singletonKeyVectors.CreateTestVectorKeyring( testVectorKeyringInput ); From 18694c1b920f08e5b10638051a0d2ccd61ecd31d Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Wed, 2 Oct 2024 16:50:25 -0700 Subject: [PATCH 25/28] m --- .github/workflows/library_interop_tests.yml | 13 --------- .../TestVectorLib/MaterialProviderFactory.cs | 29 ++++++++++--------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/.github/workflows/library_interop_tests.yml b/.github/workflows/library_interop_tests.yml index 8e6beaca8..40e7a1924 100644 --- a/.github/workflows/library_interop_tests.yml +++ b/.github/workflows/library_interop_tests.yml @@ -193,17 +193,6 @@ jobs: # # # NET_41_VECTOR_PATH=$GITHUB_WORKSPACE/net41/vectors # # Set-Location -Path "$env:GITHUB_WORKSPACE\net41\vectors" # # Compress-Archive -Path "$env:GITHUB_WORKSPACE\net41\vectors\*" -DestinationPath "$env:GITHUB_WORKSPACE\net41\vectors\net41.zip" - - - name: Fetch Python 2.3.0 Test Vectors - working-directory: ./ - shell: bash - run: | - PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors - mkdir -p $PYTHON_23_VECTOR_PATH - DOWNLOAD_NAME=python23.zip - curl --no-progress-meter --output $DOWNLOAD_NAME --location $VECTORS_URL - unzip -o -qq $DOWNLOAD_NAME -d $PYTHON_23_VECTOR_PATH - rm $DOWNLOAD_NAME - name: Generate Test Vectors with .NET Framework net6.0 # TODO Post-#619: Fix Zip file creation on Windows @@ -214,8 +203,6 @@ jobs: NET_41_VECTOR_PATH=net41/vectors mkdir -p $NET_41_VECTOR_PATH GEN_PATH=runtimes/net/TestVectorsNative/TestVectorGenerator - PYTHON_23_VECTOR_PATH=$GITHUB_WORKSPACE/python23/vectors - DAFNY_AWS_ESDK_TEST_VECTOR_MANIFEST_PATH="$PYTHON_23_VECTOR_PATH/manifest.json" \ dotnet run --project $GEN_PATH --framework net6.0 -- \ --encrypt-manifest $GEN_PATH/resources/0006-awses-message-decryption-generation.v2.json \ --output-dir $NET_41_VECTOR_PATH diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index ac7e36a89..30875bd49 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -166,20 +166,6 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio } if (keyInfo.Type == "aws-kms-hierarchy") { - // Convert JSON to bytes for KeyVectors input - string jsonString = JsonConvert.SerializeObject(keyInfo); - - var stream = new MemoryStream(); - var writer = new StreamWriter(stream); - writer.Write(jsonString); - writer.Flush(); - stream.Position = 0; - - // Create KeyVectors keyring - var getKeyDescriptionInput = new GetKeyDescriptionInput - { - Json = stream - }; // Lazily create a singleton KeyVectors client. // KeyVectors manifest is only required if a test vector specifies a hierarchy keyring. @@ -202,6 +188,21 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio singletonKeyVectors = new(keyVectorsConfig); } + // Convert JSON to bytes for KeyVectors input + string jsonString = JsonConvert.SerializeObject(keyInfo); + + var stream = new MemoryStream(); + var writer = new StreamWriter(stream); + writer.Write(jsonString); + writer.Flush(); + stream.Position = 0; + + // Create KeyVectors keyring + var getKeyDescriptionInput = new GetKeyDescriptionInput + { + Json = stream + }; + var desc = singletonKeyVectors.GetKeyDescription(getKeyDescriptionInput); var testVectorKeyringInput = new TestVectorKeyringInput From dfb6308d6531f2effd177da2e16b434357937965 Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Wed, 2 Oct 2024 16:51:32 -0700 Subject: [PATCH 26/28] m --- .github/workflows/library_interop_tests.yml | 1 + .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/library_interop_tests.yml b/.github/workflows/library_interop_tests.yml index 40e7a1924..0459dd51f 100644 --- a/.github/workflows/library_interop_tests.yml +++ b/.github/workflows/library_interop_tests.yml @@ -194,6 +194,7 @@ jobs: # # Set-Location -Path "$env:GITHUB_WORKSPACE\net41\vectors" # # Compress-Archive -Path "$env:GITHUB_WORKSPACE\net41\vectors\*" -DestinationPath "$env:GITHUB_WORKSPACE\net41\vectors\net41.zip" + - name: Generate Test Vectors with .NET Framework net6.0 # TODO Post-#619: Fix Zip file creation on Windows if: matrix.os != 'windows-latest' diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 30875bd49..9cbba3b19 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -166,9 +166,8 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio } if (keyInfo.Type == "aws-kms-hierarchy") { - // Lazily create a singleton KeyVectors client. - // KeyVectors manifest is only required if a test vector specifies a hierarchy keyring. + // A KeyVectors manifest is only required if a test vector specifies a hierarchy keyring. // This specification can only be determined at runtime while reading the test vector manifest. if (singletonKeyVectors == null) { string manifestPath; From 2728c909ff507354bb40cf8d629994401bbdc66f Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Wed, 2 Oct 2024 16:51:50 -0700 Subject: [PATCH 27/28] m --- .github/workflows/library_interop_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/library_interop_tests.yml b/.github/workflows/library_interop_tests.yml index 0459dd51f..112b6825a 100644 --- a/.github/workflows/library_interop_tests.yml +++ b/.github/workflows/library_interop_tests.yml @@ -193,7 +193,7 @@ jobs: # # # NET_41_VECTOR_PATH=$GITHUB_WORKSPACE/net41/vectors # # Set-Location -Path "$env:GITHUB_WORKSPACE\net41\vectors" # # Compress-Archive -Path "$env:GITHUB_WORKSPACE\net41\vectors\*" -DestinationPath "$env:GITHUB_WORKSPACE\net41\vectors\net41.zip" - + - name: Generate Test Vectors with .NET Framework net6.0 # TODO Post-#619: Fix Zip file creation on Windows From 5b97a1684a7ce0f6b4704eb2b837c0defa17b06c Mon Sep 17 00:00:00 2001 From: Lucas McDonald Date: Wed, 2 Oct 2024 16:55:36 -0700 Subject: [PATCH 28/28] m --- .../TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs index 9cbba3b19..14016c03b 100644 --- a/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs +++ b/AwsEncryptionSDK/runtimes/net/TestVectorsNative/TestVectorLib/MaterialProviderFactory.cs @@ -180,7 +180,7 @@ private static IKeyring CreateKeyring(MasterKey keyInfo, Key key, CryptoOperatio throw new ArgumentException("Hierarchy keyring test vectors must supply a KeyVectors manifest", e); } DecryptManifest manifest = Utils.LoadObjectFromPath(manifestPath); - static readonly KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig + KeyVectorsConfig keyVectorsConfig = new KeyVectorsConfig { KeyManifestPath = Utils.ManifestUriToPath(manifest.KeysUri, manifestPath) };