Class SRP6VerifierGenerator
- java.lang.Object
-
- de.bsvrz.sys.funclib.srp6.SRP6VerifierGenerator
-
public class SRP6VerifierGenerator extends java.lang.ObjectGenerator of password verifier 'v' values.SRP6Routines.generateRandomSalt(int)may be used to create a random salt 's' of a specified byte size.
-
-
Field Summary
Fields Modifier and Type Field Description protected SRP6Routinessrp6Routines
-
Constructor Summary
Constructors Constructor Description SRP6VerifierGenerator(SRP6CryptoParams config)Creates a new generator of password verifier 'v' values.SRP6VerifierGenerator(SRP6CryptoParams config, SRP6Routines srp6Routines)Creates a new generator of password verifier 'v' values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]generateRandomSalt()Generates a random 16-byte salt 's'.byte[]generateRandomSalt(int numBytes)Generates a random salt 's'.byte[]generateRandomSalt(int numBytes, java.security.SecureRandom random)Generates a random salt 's'.java.math.BigIntegergenerateVerifier(byte[] salt, byte[] password)Generates a new verifier 'v' from the specified parameters with the user identifier 'I' omitted.java.math.BigIntegergenerateVerifier(byte[] salt, byte[] userID, byte[] password)Generates a new verifier 'v' from the specified parameters.java.math.BigIntegergenerateVerifier(java.math.BigInteger salt, java.lang.String password)Generates a new verifier 'v' from the specified parameters with the user identifier 'I' omitted.java.math.BigIntegergenerateVerifier(java.math.BigInteger salt, java.lang.String userID, java.lang.String password)Generates a new verifier 'v' from the specified parameters.XRoutinegetXRoutine()Gets the custom routine for the password key 'x' computation.voidsetXRoutine(XRoutine routine)Sets a custom routine for the password key 'x' computation.
-
-
-
Field Detail
-
srp6Routines
protected final SRP6Routines srp6Routines
-
-
Constructor Detail
-
SRP6VerifierGenerator
public SRP6VerifierGenerator(SRP6CryptoParams config)
Creates a new generator of password verifier 'v' values.- Parameters:
config- The SRP-6a crypto parameters configuration. Must not benull.
-
SRP6VerifierGenerator
public SRP6VerifierGenerator(SRP6CryptoParams config, SRP6Routines srp6Routines)
Creates a new generator of password verifier 'v' values.- Parameters:
config- The SRP-6a crypto parameters configuration. Must not benull.srp6Routines- The cryptographic routines.
-
-
Method Detail
-
generateRandomSalt
public byte[] generateRandomSalt(int numBytes)
Generates a random salt 's'.This method is a shortcut to
SRP6Routines.generateRandomSalt(int).- Parameters:
numBytes- The number of bytes the salt 's' must have.- Returns:
- The salt 's' as a byte array.
-
generateRandomSalt
public byte[] generateRandomSalt(int numBytes, java.security.SecureRandom random)Generates a random salt 's'.This method is a shortcut to
SRP6Routines.generateRandomSalt(int).- Parameters:
numBytes- The number of bytes the salt 's' must have.random- A secure random number generator.- Returns:
- The salt 's' as a byte array.
-
generateRandomSalt
public byte[] generateRandomSalt()
Generates a random 16-byte salt 's'.This method is a shortcut to
SRP6Routines.generateRandomSalt(int).- Returns:
- The salt 's' as a byte array.
-
setXRoutine
public void setXRoutine(XRoutine routine)
Sets a custom routine for the password key 'x' computation.- Parameters:
routine- The password key 'x' routine ornullto use thedefault oneinstead.
-
getXRoutine
public XRoutine getXRoutine()
Gets the custom routine for the password key 'x' computation.- Returns:
- The routine instance or
nullif the defaultdefault oneis used.
-
generateVerifier
public java.math.BigInteger generateVerifier(byte[] salt, byte[] userID, byte[] password)Generates a new verifier 'v' from the specified parameters.The verifier is computed as v = g^x (mod N). If a custom
'x' computation routineis set it will be used instead of thedefault one.Tip: To convert a string to a byte array you can use
String.getBytes()orString.getBytes(java.nio.charset.Charset). To convert a big integer to a byte array you can useBigInteger.toByteArray().- Parameters:
salt- The salt 's'. Must not benull.userID- The user identity 'I'. May benullif the default 'x' routine is used or the custom one ignores it.password- The user password 'P'. Must not benull.- Returns:
- The resulting verifier 'v'.
-
generateVerifier
public java.math.BigInteger generateVerifier(java.math.BigInteger salt, java.lang.String userID, java.lang.String password)Generates a new verifier 'v' from the specified parameters.The verifier is computed as v = g^x (mod N). If a custom
'x' computation routineis set it will be used instead of thedefault one.- Parameters:
salt- The salt 's'. Must not benull.userID- The user identity 'I', as an UTF-8 encoded string. May benullif the default 'x' routine is used or the custom one ignores it.password- The user password 'P', as an UTF-8 encoded string. Must not benull.- Returns:
- The resulting verifier 'v'.
-
generateVerifier
public java.math.BigInteger generateVerifier(byte[] salt, byte[] password)Generates a new verifier 'v' from the specified parameters with the user identifier 'I' omitted.The verifier is computed as v = g^x (mod N). If a custom
'x' computation routineis set it must omit the user identity 'I' as well.Tip: To convert a string to a byte array you can use
String.getBytes()orString.getBytes(java.nio.charset.Charset). To convert a big integer to a byte array you can useBigInteger.toByteArray().- Parameters:
salt- The salt 's'. Must not benull.password- The user password 'P'. Must not benull.- Returns:
- The resulting verifier 'v'.
-
generateVerifier
public java.math.BigInteger generateVerifier(java.math.BigInteger salt, java.lang.String password)Generates a new verifier 'v' from the specified parameters with the user identifier 'I' omitted.The verifier is computed as v = g^x (mod N). If a custom
'x' computation routineis set it must omit the user identity 'I' as well.- Parameters:
salt- The salt 's'. Must not benull.password- The user password 'P', as an UTF-8 encoded string. Must not benull.- Returns:
- The resulting verifier 'v'.
-
-