I am experimenting on incorporating FIPS 180-3 into my Java application. FIPS 180-3 allows you to use only 5 secure [hashes] (http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf), MD5 is not included in their number. Therefore, I am trying to programmatically remove the MD5 algorithms from the Sun provider. This is sample code.
public static void main(String[] args) throws Exception { Security.removeProvider("SUN"); Sun sun = new Sun(); sun.remove("MessageDigest.MD5");
But this throws the following exception. If you comment on "sun.remove (..", the program works fine. If I delete MD2, not MD5, then it works fine.
It seems to me that jre libs use MD5 to sign them, but I checked the jre / lib / ext / sunjce_provider.jar signer and its use sha1.
Any idea why my code is not working with this error?
An exception in the thread "main" java.lang.ExceptionInInitializerError on javax.crypto.Cipher.getInstance (DashoA13 * ..) on TestRemoveMD5.main (TestRemoveMD5.java:20)
Raised: java.lang.SecurityException: Cannot configure certificates for trusted certificate authorities on javax.crypto.SunJCE_b. (DashoA13 * ..) ... 3 more
Raised: java.lang.SecurityException: signature classes were tampered with javax.crypto.SunJCE_b.d (DashoA13 * ..) on javax.crypto.SunJCE_b.c (DashoA13 * ..) on javax.crypto.SunJCE_b $ 1.run ( DashoA13 * ..) in java.security.AccessController.doPrivileged (native method) ... 4 more
source share