public void CreateNewDescriptor_PropagatesOptions() { // Arrange var configuration = new CngCbcAuthenticatedEncryptorConfiguration(new CngCbcAuthenticatedEncryptionOptions()); // Act var descriptor = (CngCbcAuthenticatedEncryptorDescriptor)configuration.CreateNewDescriptor(); // Assert Assert.Equal(configuration.Options, descriptor.Options); }
public void CreateNewDescriptor_CreatesUniqueCorrectlySizedMasterKey() { // Arrange var configuration = new CngCbcAuthenticatedEncryptorConfiguration(new CngCbcAuthenticatedEncryptionOptions()); // Act var masterKey1 = ((CngCbcAuthenticatedEncryptorDescriptor)configuration.CreateNewDescriptor()).MasterKey; var masterKey2 = ((CngCbcAuthenticatedEncryptorDescriptor)configuration.CreateNewDescriptor()).MasterKey; // Assert SecretAssert.NotEqual(masterKey1, masterKey2); SecretAssert.LengthIs(512 /* bits */, masterKey1); SecretAssert.LengthIs(512 /* bits */, masterKey2); }
public void ResolvePolicy_CngCbcEncryption_WithoutExplicitSettings() { IServiceCollection serviceCollection = new ServiceCollection(); RunTestWithRegValues(serviceCollection, new Dictionary<string, object>() { ["EncryptionType"] = "cng-cbc" }); var services = serviceCollection.BuildServiceProvider(); var expectedConfiguration = new CngCbcAuthenticatedEncryptorConfiguration(new CngCbcAuthenticatedEncryptionOptions()); var actualConfiguration = (CngCbcAuthenticatedEncryptorConfiguration)services.GetService<IAuthenticatedEncryptorConfiguration>(); Assert.Equal(expectedConfiguration.Options.EncryptionAlgorithm, actualConfiguration.Options.EncryptionAlgorithm); Assert.Equal(expectedConfiguration.Options.EncryptionAlgorithmKeySize, actualConfiguration.Options.EncryptionAlgorithmKeySize); Assert.Equal(expectedConfiguration.Options.EncryptionAlgorithmProvider, actualConfiguration.Options.EncryptionAlgorithmProvider); Assert.Equal(expectedConfiguration.Options.HashAlgorithm, actualConfiguration.Options.HashAlgorithm); Assert.Equal(expectedConfiguration.Options.HashAlgorithmProvider, actualConfiguration.Options.HashAlgorithmProvider); }