When developing code intended for use in a
JCA (Java Cryptography Architecture) simplifies writing code for
Cipher cipher = Cipher.getInstance("AES256");Although, to request a cipher from a specific provider you could use:
Cipher cipher = Cipher.getInstance("AES256", "BCFIPS");
You should avoid this type of call because FIPS mode and non-FIPS mode-compliant algorithms use different providers. Requesting a specific provider results in code that only works in one environment.
The JCA arranges security providers in a given order. When a program requests an algorithm, the JCA goes through the ordered
list of providers and returns the first implementation it finds. In
In addition, with some exceptions, FIPS mode removes non-FIPS algorithms from the security providers list. This ensures that requests, which inadvertently introduce a non-FIPS algorithm, generate an exception.