Writing Secure Code for Windows Vista (Best Practices (Microsoft))

The Federal Information Processing Standards (FIPS) at http://www.itl.nist.gov/fipspubs/ define standards and guidelines that are developed by the National Institute of Standards and Technology (NIST) for U.S. federal computer systems. Five standards pertinent to this chapter are as follows:

These standards define cryptographic requirements and cryptographic algorithms to be used in U.S. federal information systems. It is possible to configure Windows Vista to use only FIPS-mandated algorithms by performing these steps:

  1. Open MMC.

  2. Add the Group Policy Objects Snap-in.

  3. Navigate to Local Computer Policy, Computer Configurations, Windows Settings, Security Settings, Local Policies, Security Options.

  4. Enable the following option: “System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing.”

Now here’s the caveat. This setting only affects the protocol suites used by SSL/TLS and .NET code. The following C# will fail with a System.InvalidOperationException exception because it is using a non-FIPS compliant algorithm, MD5.

MD5CryptoServiceProvider hash = new MD5CryptoServiceProvider(); byte[] result = hash.ComputeHash(ASCIIEncoding.UTF8.GetBytes(message));

From a CNG application, it is possible to determine if the FIPS requirement is enabled or not by using the BCryptGetFipsAlgorithmMode function.

Категории