| @@ -438,6 +438,7 @@ namespace GSF.Security.Cryptography · 437 unmodified lines |
| 438 | 438 | s_textEncoding = Encoding.Unicode; |
| 439 | 439 | #endif |
| 440 | 440 | KeyIVCache localKeyIVCache; |
| 441 | + EnabledState useFIPSModules = EnabledState.Auto; |
| 441 | 442 | string localCacheFileName = DefaultCacheFileName; |
| 442 | 443 | double retryDelayInterval = DefaultRetryDelayInterval; |
| 443 | 444 | int maximumRetryAttempts = DefaultMaximumRetryAttempts; |
| @@ -446,14 +447,19 @@ namespace GSF.Security.Cryptography · 2 unmodified lines |
| 446 | 447 | ConfigurationFile config = ConfigurationFile.Current; |
| 447 | 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 | 451 | settings.Add("CryptoCache", localCacheFileName, "Path and file name of cryptographic key and initialization vector cache."); |
| 450 | 452 | settings.Add("CacheRetryDelayInterval", retryDelayInterval, "Wait interval, in milliseconds, before retrying load of cryptographic key and initialization vector cache."); |
| 451 | 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 | 456 | localCacheFileName = FilePath.GetAbsolutePath(settings["CryptoCache"].ValueAs(localCacheFileName)); |
| 454 | 457 | retryDelayInterval = settings["CacheRetryDelayInterval"].ValueAs(retryDelayInterval); |
| 455 | 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 | 463 | s_keyIVCache = new Lazy<KeyIVCache>(() => |
| 458 | 464 | { |
| 459 | 465 | KeyIVCache globalKeyIVCache; |
| @@ -468,9 +474,9 @@ namespace GSF.Security.Cryptography · 8 unmodified lines |
| 468 | 474 | #if DNF45 && !MONO |
| 469 | 475 | ReloadOnChange = true, |
| 470 | 476 | #else |
| 471 | | − // 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. |
| 473 | | − ReloadOnChange = false, |
| 477 | + // Reload on change is disabled to eliminate GC handle leaks on .NET 4.0, this prevents |
| 478 | + // automatic runtime reloading of key/iv data cached by another application. |
| 479 | + ReloadOnChange = false, |
| 474 | 480 | #endif |
| 475 | 481 | AutoSave = false |
| 476 | 482 | }; |
| @@ -518,9 +524,9 @@ namespace GSF.Security.Cryptography · 41 unmodified lines |
| 518 | 524 | #if DNF45 && !MONO |
| 519 | 525 | ReloadOnChange = true, |
| 520 | 526 | #else |
| 521 | | − // 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. |
| 523 | | − ReloadOnChange = false, |
| 527 | + // Reload on change is disabled to eliminate GC handle leaks on .NET 4.0, this prevents |
| 528 | + // automatic runtime reloading of key/iv data cached by another application. |
| 529 | + ReloadOnChange = false, |
| 524 | 530 | #endif |
| 525 | 531 | AutoSave = true |
| 526 | 532 | }; |