private static RegistryPolicy RunTestWithRegValues(Dictionary <string, object> regValues) { return(WithUniqueTempRegKey(registryKey => { foreach (var entry in regValues) { registryKey.SetValue(entry.Key, entry.Value); } var policyResolver = new RegistryPolicyResolver( registryKey, activator: SimpleActivator.DefaultWithoutServices); return policyResolver.ResolvePolicy(); })); }
public void Configure(KeyManagementOptions options) { RegistryPolicy context = null; if (_registryPolicyResolver != null) { context = _registryPolicyResolver.ResolvePolicy(); } if (context != null) { if (context.DefaultKeyLifetime.HasValue) { options.NewKeyLifetime = TimeSpan.FromDays(context.DefaultKeyLifetime.Value); } options.AuthenticatedEncryptorConfiguration = context.EncryptorConfiguration; var escrowSinks = context.KeyEscrowSinks; if (escrowSinks != null) { foreach (var escrowSink in escrowSinks) { options.KeyEscrowSinks.Add(escrowSink); } } } if (options.AuthenticatedEncryptorConfiguration == null) { options.AuthenticatedEncryptorConfiguration = new AuthenticatedEncryptorConfiguration(); } options.AuthenticatedEncryptorFactories.Add(new CngGcmAuthenticatedEncryptorFactory(_loggerFactory)); options.AuthenticatedEncryptorFactories.Add(new CngCbcAuthenticatedEncryptorFactory(_loggerFactory)); options.AuthenticatedEncryptorFactories.Add(new ManagedAuthenticatedEncryptorFactory(_loggerFactory)); options.AuthenticatedEncryptorFactories.Add(new AuthenticatedEncryptorFactory(_loggerFactory)); }