Detecting whether an algorithm is supported without creating one?

Bradford Wetmore bradford.wetmore at oracle.com
Fri Dec 12 04:12:08 UTC 2014



On 12/11/2014 8:02 PM, Weijun Wang wrote:
> I'd like to check if "SHA-256" is supported without calling
> MessageDigest.getInstance("SHA-256"). Does such a method exist?

Not that I'm aware of.

Brad



> My case is a multi-thread digestor like this:
>
> class Digestor {
>     Digestor(String alg) throws NSAE;
>     @ThreadSafe byte[] digest(byte[]) throws Nothing;
> }
>
> So a Digestor is created and multiple threads can call the digest()
> method. I would be glad if the constructor can throw an NSAE but not
> creating a MessageDigest object because I don't know how to safely use
> it inside digest().
>
> Thanks
> Max



More information about the security-dev mailing list