[PATCH] Add class java.security.StandardMessageDigests

Florian Weimer fweimer at redhat.com
Mon Mar 24 16:30:50 UTC 2014


This CR adds a new class java.security.StandardMessageDigests:

<http://fweimer.fedorapeople.org/openjdk/standard-message-digests/>

Could I get a bug number if this change is fine in principle?

Cryptographic hash functions are frequently used directly, often for 
non-cryptographic purposes, so I think it makes sense to provide a 
convenient way to access implementations for the most common hashes. 
The new class follows the java.nio.charset.StandardCharsets precedent 
(separate class, "Standard" in the name).

I deliberately did not include support for MD5.  It would be nice if we 
could drop the NoSuchAlgorithmException, but this would be problematic 
once there are providers that do not support SHA-1.

Instantiating digest objects through cloning should be quite a bit 
faster than the provider route (but I measured this some time ago only, 
so these results could be outdated by now).

-- 
Florian Weimer / Red Hat Product Security Team



More information about the security-dev mailing list