jchambers / java-otp

A one-time password (HOTP/TOTP) library for Java
MIT License
456 stars 122 forks source link

Handle NoSuchAlgorithmException exceptions for required algorithms #8

Closed Marcono1234 closed 5 years ago

Marcono1234 commented 5 years ago

The documentation of the Mac class requires that every Java platform supports the following algorithms:

What do you think about adding static factory methods (or changing the existing constructors) to catch NoSuchAlgorithmException for these algorithms and wrap them inside some unchecked exceptions? Since these algorithms will always be available (unless the JVM is incorrectly configured?) the user currently has to deal with exceptions which can never occur.

jchambers commented 5 years ago

Notably, SHA-512 is absent from that list, and that's an algorithm allowed by the TOTP standard. Your point is taken, but I think what we have now is correct.

Thanks kindly for the suggestion!