Add check if OTP secrets length is 0 and updated docs

This commit is contained in:
TheArrayser 2023-06-30 22:52:32 +02:00
parent 6f3e7f1f5f
commit a2af6825f0
2 changed files with 2 additions and 2 deletions

View File

@ -45,7 +45,7 @@ public abstract class OTP {
* @param counter REQUIRED if HOTP, otherwise meaningless. The initial counter for HOTP (eg 21, if user reloaded counter 21 times)
* @param periodInSeconds OPTIONAL (default 30) for TOTP, the refresh rate of the TOTP
* @param checksum OPTIONAL: appends a checksum digit to the end of the string
* @return returns your wallet to the lost-and-found office
* @return returns a valid OTP object or null, which can be used to create a new OTP pin
*/
public static OTP createNewOTP(OTPType type, String secret, OTPAlgorithm algorithm, int digits, long counter, long periodInSeconds, boolean checksum) throws OTPException{
if(type == null) return null;

View File

@ -17,7 +17,7 @@ public enum OTPType {
}
public OTP instance(String secret, OTPAlgorithm algorithm, int digits, long counter, long periodInSeconds, boolean checksum) {
if(/*type == null ||*/ secret == null /*|| counter < 0*/) {
if(/*type == null ||*/ secret == null || secret.length() == 0/*|| counter < 0*/) {
return null;
}