Esempio n. 1
0
        public EncryptionTestsV2() : base(KmsKeyIdProvider.Instance)
        {
            kmsKeyID = _kmsKeyIdProvider.GetKmsId();

            var rsa = RSA.Create();
            var aes = Aes.Create();

            var asymmetricEncryptionMaterials = new EncryptionMaterialsV2(rsa, AsymmetricAlgorithmType.RsaOaepSha1);
            var symmetricEncryptionMaterials  = new EncryptionMaterialsV2(aes, SymmetricAlgorithmType.AesGcm);

            var kmsEncryptionMaterials =
                new EncryptionMaterialsV2(kmsKeyID, KmsType.KmsContext, new Dictionary <string, string>());

            var fileConfig = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2)
            {
                StorageMode = CryptoStorageMode.InstructionFile
            };

            var metadataConfig = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2)
            {
                StorageMode = CryptoStorageMode.ObjectMetadata
            };

            s3EncryptionClientMetadataModeSymmetricWrap =
                new AmazonS3EncryptionClientV2(metadataConfig, symmetricEncryptionMaterials);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeSymmetricWrap);

            s3EncryptionClientFileModeSymmetricWrap =
                new AmazonS3EncryptionClientV2(fileConfig, symmetricEncryptionMaterials);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeSymmetricWrap);

            s3EncryptionClientMetadataModeAsymmetricWrap =
                new AmazonS3EncryptionClientV2(metadataConfig, asymmetricEncryptionMaterials);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeAsymmetricWrap);

            s3EncryptionClientFileModeAsymmetricWrap =
                new AmazonS3EncryptionClientV2(fileConfig, asymmetricEncryptionMaterials);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeAsymmetricWrap);

            s3EncryptionClientMetadataModeKMS = new AmazonS3EncryptionClientV2(metadataConfig, kmsEncryptionMaterials);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeKMS);

            s3EncryptionClientFileModeKMS = new AmazonS3EncryptionClientV2(fileConfig, kmsEncryptionMaterials);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeKMS);

            using (var writer = File.CreateText(filePath))
            {
                writer.Write(SampleContent);
            }

            bucketName = S3TestUtils.CreateBucketWithWait(s3EncryptionClientFileModeSymmetricWrap);
        }
        public EncryptionTestsV1InteropV2() : base(KmsKeyIdProvider.Instance)
        {
            kmsKeyID = _kmsKeyIdProvider.GetKmsId();

            var rsa = RSA.Create();
            var aes = Aes.Create();

            var asymmetricEncryptionMaterialsV1 = new Amazon.S3.Encryption.EncryptionMaterials(rsa);
            var asymmetricEncryptionMaterialsV2 = new EncryptionMaterialsV2(rsa, AsymmetricAlgorithmType.RsaOaepSha1);

            var symmetricEncryptionMaterialsV1 = new Amazon.S3.Encryption.EncryptionMaterials(aes);
            var symmetricEncryptionMaterialsV2 = new EncryptionMaterialsV2(aes, SymmetricAlgorithmType.AesGcm);

            var kmsEncryptionMaterialsV1 = new Amazon.S3.Encryption.EncryptionMaterials(kmsKeyID);
            var kmsEncryptionMaterialsV2 =
                new EncryptionMaterialsV2(kmsKeyID, KmsType.KmsContext, new Dictionary <string, string>());

            var configV1 = new Amazon.S3.Encryption.AmazonS3CryptoConfiguration
            {
                StorageMode = Amazon.S3.Encryption.CryptoStorageMode.InstructionFile
            };

            fileConfig = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2AndLegacy)
            {
                StorageMode = CryptoStorageMode.InstructionFile
            };
            metadataConfig = new AmazonS3CryptoConfigurationV2(SecurityProfile.V2AndLegacy)
            {
                StorageMode = CryptoStorageMode.ObjectMetadata
            };

            s3EncryptionClientMetadataModeAsymmetricWrapV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(asymmetricEncryptionMaterialsV1);

            s3EncryptionClientFileModeAsymmetricWrapV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(configV1, asymmetricEncryptionMaterialsV1);

            s3EncryptionClientMetadataModeSymmetricWrapV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(symmetricEncryptionMaterialsV1);

            s3EncryptionClientFileModeSymmetricWrapV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(configV1, symmetricEncryptionMaterialsV1);

            s3EncryptionClientMetadataModeKMSV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(kmsEncryptionMaterialsV1);

            s3EncryptionClientFileModeKMSV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(configV1, kmsEncryptionMaterialsV1);

            s3EncryptionClientMetadataModeAsymmetricWrapV2 =
                new AmazonS3EncryptionClientV2(metadataConfig, asymmetricEncryptionMaterialsV2);

            s3EncryptionClientFileModeAsymmetricWrapV2 =
                new AmazonS3EncryptionClientV2(fileConfig, asymmetricEncryptionMaterialsV2);

            s3EncryptionClientMetadataModeSymmetricWrapV2 =
                new AmazonS3EncryptionClientV2(metadataConfig, symmetricEncryptionMaterialsV2);

            s3EncryptionClientFileModeSymmetricWrapV2 =
                new AmazonS3EncryptionClientV2(fileConfig, symmetricEncryptionMaterialsV2);

            s3EncryptionClientMetadataModeKMSV2 =
                new AmazonS3EncryptionClientV2(metadataConfig, kmsEncryptionMaterialsV2);

            s3EncryptionClientFileModeKMSV2 = new AmazonS3EncryptionClientV2(fileConfig, kmsEncryptionMaterialsV2);

            using (var writer = File.CreateText(filePath))
            {
                writer.Write(SampleContent);
            }

            bucketName = S3TestUtils.CreateBucketWithWait(s3EncryptionClientFileModeAsymmetricWrapV1);
        }
Esempio n. 3
0
#pragma warning restore 0618

        public EncryptionTestsV1InteropV1N() : base(KmsKeyIdProvider.Instance)
        {
            filePath = Path.Combine(Path.GetTempPath(), $"EncryptionPutObjectFile-{Guid.NewGuid()}.txt");

            kmsKeyID = _kmsKeyIdProvider.GetKmsId();

            var rsa = RSA.Create();
            var aes = Aes.Create();

            var asymmetricEncryptionMaterialsV1  = new Amazon.S3.Encryption.EncryptionMaterials(rsa);
            var asymmetricEncryptionMaterialsV1N = new EncryptionMaterials(rsa);

            var symmetricEncryptionMaterialsV1  = new Amazon.S3.Encryption.EncryptionMaterials(aes);
            var symmetricEncryptionMaterialsV1N = new EncryptionMaterials(aes);

            var kmsEncryptionMaterialsV1  = new Amazon.S3.Encryption.EncryptionMaterials(kmsKeyID);
            var kmsEncryptionMaterialsV1N = new EncryptionMaterials(kmsKeyID);

            var configV1 = new Amazon.S3.Encryption.AmazonS3CryptoConfiguration()
            {
                StorageMode = Amazon.S3.Encryption.CryptoStorageMode.InstructionFile
            };
            var configV1N = new AmazonS3CryptoConfiguration()
            {
                StorageMode = CryptoStorageMode.InstructionFile
            };

            s3EncryptionClientMetadataModeAsymmetricWrapV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(asymmetricEncryptionMaterialsV1);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeAsymmetricWrapV1);

            s3EncryptionClientFileModeAsymmetricWrapV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(configV1, asymmetricEncryptionMaterialsV1);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeAsymmetricWrapV1);

            s3EncryptionClientMetadataModeSymmetricWrapV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(symmetricEncryptionMaterialsV1);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeSymmetricWrapV1);

            s3EncryptionClientFileModeSymmetricWrapV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(configV1, symmetricEncryptionMaterialsV1);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeSymmetricWrapV1);

            s3EncryptionClientMetadataModeKMSV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(kmsEncryptionMaterialsV1);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeKMSV1);

            s3EncryptionClientFileModeKMSV1 =
                new Amazon.S3.Encryption.AmazonS3EncryptionClient(configV1, kmsEncryptionMaterialsV1);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeKMSV1);

            s3EncryptionClientMetadataModeAsymmetricWrapV1N =
                new AmazonS3EncryptionClient(asymmetricEncryptionMaterialsV1N);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeAsymmetricWrapV1N);

            s3EncryptionClientFileModeAsymmetricWrapV1N =
                new AmazonS3EncryptionClient(configV1N, asymmetricEncryptionMaterialsV1N);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeAsymmetricWrapV1N);

            s3EncryptionClientMetadataModeSymmetricWrapV1N =
                new AmazonS3EncryptionClient(symmetricEncryptionMaterialsV1N);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeSymmetricWrapV1N);

            s3EncryptionClientFileModeSymmetricWrapV1N =
                new AmazonS3EncryptionClient(configV1N, symmetricEncryptionMaterialsV1N);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeSymmetricWrapV1N);

            s3EncryptionClientMetadataModeKMSV1N = new AmazonS3EncryptionClient(kmsEncryptionMaterialsV1N);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientMetadataModeKMSV1N);

            s3EncryptionClientFileModeKMSV1N = new AmazonS3EncryptionClient(configV1N, kmsEncryptionMaterialsV1N);
            RetryUtilities.ForceConfigureClient(s3EncryptionClientFileModeKMSV1N);

            using (var writer = File.CreateText(filePath))
            {
                writer.Write(SampleContent);
            }

            bucketName = S3TestUtils.CreateBucketWithWait(s3EncryptionClientFileModeAsymmetricWrapV1);
        }
Esempio n. 4
0
 public void Init()
 {
     bucketName = S3TestUtils.CreateBucketWithWait(Client);
 }