Interface TwoFactorPasswordGenerator
-
- All Known Implementing Classes:
MockTwoFactorPasswordGenerator
,TwoFactorPasswordGeneratorImpl
public interface TwoFactorPasswordGenerator
Generates TOTP passwords (RFC 6238) with HMAC algorithm for two-factor authentication by secret key and timestamp The hash function that is used in HMAC is SHA-1 (Can be extended to SHA-2 family, depends on authenticator apps).- Author:
- Daniil Boger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Set<Integer>
generatePasswords(String secretKey, long timestampSec)
Generates and returns all TOTP passwords that will be considered as correct, using secret key and UNIX timestamp.Set<String>
generateRecoveryKeys()
Generates set of recovery keys with cryptographically strong generator.String
generateSecretKey()
Generates secret key with cryptographically strong generator
-
-
-
Method Detail
-
generatePasswords
@NotNull Set<Integer> generatePasswords(@NotNull String secretKey, long timestampSec)
Generates and returns all TOTP passwords that will be considered as correct, using secret key and UNIX timestamp. The multiple correct passwords are allowed to prevent time desynchroniation between client and server. For example, password from previous 30-sec. epoch can be allowed.- Parameters:
secretKey
- secret keytimestampSec
- current UNIX timestamp in seconds- Returns:
- set of all correct password
-
generateSecretKey
@NotNull String generateSecretKey()
Generates secret key with cryptographically strong generator- Returns:
- generated secret key
-
-