| @@ -438,6 +438,7 @@ namespace GSF.Security.Cryptography · 437 unmodified lines |
| 438 | s_textEncoding = Encoding.Unicode; | 438 | s_textEncoding = Encoding.Unicode; |
| 439 | #endif | 439 | #endif |
| 440 | KeyIVCache localKeyIVCache; | 440 | KeyIVCache localKeyIVCache; |
| | 441 | EnabledState useFIPSModules = EnabledState.Auto; |
| 441 | string localCacheFileName = DefaultCacheFileName; | 442 | string localCacheFileName = DefaultCacheFileName; |
| 442 | double retryDelayInterval = DefaultRetryDelayInterval; | 443 | double retryDelayInterval = DefaultRetryDelayInterval; |
| 443 | int maximumRetryAttempts = DefaultMaximumRetryAttempts; | 444 | int maximumRetryAttempts = DefaultMaximumRetryAttempts; |
| @@ -446,14 +447,19 @@ namespace GSF.Security.Cryptography · 2 unmodified lines |
| 446 | ConfigurationFile config = ConfigurationFile.Current; | 447 | ConfigurationFile config = ConfigurationFile.Current; |
| 447 | CategorizedSettingsElementCollection settings = config.Settings[CryptoServicesSettingsCategory]; | 448 | CategorizedSettingsElementCollection settings = config.Settings[CryptoServicesSettingsCategory]; |
| 448 | | 449 | |
| | 450 | settings.Add("UseFIPSModules", useFIPSModules, "Determines if security functions should use FIPS cryptographic modules. Value is one of \"Auto\", \"On\" or \"Off\". Defaults to \"Auto\" which reads FIPS setting from registry."); |
| 449 | settings.Add("CryptoCache", localCacheFileName, "Path and file name of cryptographic key and initialization vector cache."); | 451 | settings.Add("CryptoCache", localCacheFileName, "Path and file name of cryptographic key and initialization vector cache."); |
| 450 | settings.Add("CacheRetryDelayInterval", retryDelayInterval, "Wait interval, in milliseconds, before retrying load of cryptographic key and initialization vector cache."); | 452 | settings.Add("CacheRetryDelayInterval", retryDelayInterval, "Wait interval, in milliseconds, before retrying load of cryptographic key and initialization vector cache."); |
| 451 | settings.Add("CacheMaximumRetryAttempts", maximumRetryAttempts, "Maximum retry attempts allowed for loading cryptographic key and initialization vector cache."); | 453 | settings.Add("CacheMaximumRetryAttempts", maximumRetryAttempts, "Maximum retry attempts allowed for loading cryptographic key and initialization vector cache."); |
| 452 | | 454 | |
| | 455 | useFIPSModules = settings["UseFIPSModules"].ValueAs(useFIPSModules); |
| 453 | localCacheFileName = FilePath.GetAbsolutePath(settings["CryptoCache"].ValueAs(localCacheFileName)); | 456 | localCacheFileName = FilePath.GetAbsolutePath(settings["CryptoCache"].ValueAs(localCacheFileName)); |
| 454 | retryDelayInterval = settings["CacheRetryDelayInterval"].ValueAs(retryDelayInterval); | 457 | retryDelayInterval = settings["CacheRetryDelayInterval"].ValueAs(retryDelayInterval); |
| 455 | maximumRetryAttempts = settings["CacheMaximumRetryAttempts"].ValueAs(maximumRetryAttempts); | 458 | maximumRetryAttempts = settings["CacheMaximumRetryAttempts"].ValueAs(maximumRetryAttempts); |
| 456 | | 459 | |
| | 460 | if (useFIPSModules != EnabledState.Auto) |
| | 461 | s_managedEncryption = useFIPSModules == EnabledState.Off; // FIPS Off means use managed encryption |
| | 462 | |
| 457 | s_keyIVCache = new Lazy<KeyIVCache>(() => | 463 | s_keyIVCache = new Lazy<KeyIVCache>(() => |
| 458 | { | 464 | { |
| 459 | KeyIVCache globalKeyIVCache; | 465 | KeyIVCache globalKeyIVCache; |
| @@ -468,9 +474,9 @@ namespace GSF.Security.Cryptography · 8 unmodified lines |
| 468 | #if DNF45 && !MONO | 474 | #if DNF45 && !MONO |
| 469 | ReloadOnChange = true, | 475 | ReloadOnChange = true, |
| 470 | #else | 476 | #else |
| 471 | // Reload on change is disabled to eliminate GC handle leaks on .NET 4.0, this prevents | 477 | // Reload on change is disabled to eliminate GC handle leaks on .NET 4.0, this prevents |
| 472 | // automatic runtime reloading of key/iv data cached by another application. | 478 | // automatic runtime reloading of key/iv data cached by another application. |
| 473 | ReloadOnChange = false, | 479 | ReloadOnChange = false, |
| 474 | #endif | 480 | #endif |
| 475 | AutoSave = false | 481 | AutoSave = false |
| 476 | }; | 482 | }; |
| @@ -518,9 +524,9 @@ namespace GSF.Security.Cryptography · 41 unmodified lines |
| 518 | #if DNF45 && !MONO | 524 | #if DNF45 && !MONO |
| 519 | ReloadOnChange = true, | 525 | ReloadOnChange = true, |
| 520 | #else | 526 | #else |
| 521 | // Reload on change is disabled to eliminate GC handle leaks on .NET 4.0, this prevents | 527 | // Reload on change is disabled to eliminate GC handle leaks on .NET 4.0, this prevents |
| 522 | // automatic runtime reloading of key/iv data cached by another application. | 528 | // automatic runtime reloading of key/iv data cached by another application. |
| 523 | ReloadOnChange = false, | 529 | ReloadOnChange = false, |
| 524 | #endif | 530 | #endif |
| 525 | AutoSave = true | 531 | AutoSave = true |
| 526 | }; | 532 | }; |