Package com.mku.salmon.password
Class SalmonPassword
java.lang.Object
com.mku.salmon.password.SalmonPassword
Generates security keys based on text passwords.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
getKeyFromPassword
(String password, byte[] salt, int iterations, int outputBytes) Function will derive a key from a text passwordstatic byte[]
getMasterKey
(String pass, byte[] salt, int iterations, int length) Derives the key from a text passwordstatic PbkdfAlgo
Returns the current global PBKDF algorithm.static void
setPbkdfAlgo
(PbkdfAlgo pbkdfAlgo) Set the global PDKDF algorithm to be used for key derivation.static void
setPbkdfProvider
(ISalmonPbkdfProvider pbkdfProvider) Set the global PBKDF provider to be used for text key derivation.static void
setPbkdfType
(PbkdfType pbkdfType) Set the global PBKDF implementation to be used for text key derivation.
-
Constructor Details
-
SalmonPassword
public SalmonPassword()
-
-
Method Details
-
getPbkdfAlgo
Returns the current global PBKDF algorithm.- Returns:
- The PBKDF algorithm to be used.
-
setPbkdfAlgo
Set the global PDKDF algorithm to be used for key derivation.- Parameters:
pbkdfAlgo
- The PBKDF algorithm to use
-
setPbkdfType
Set the global PBKDF implementation to be used for text key derivation.- Parameters:
pbkdfType
- The PBKDF implementation to use
-
setPbkdfProvider
Set the global PBKDF provider to be used for text key derivation.- Parameters:
pbkdfProvider
- The PBKDF provider
-
getMasterKey
Derives the key from a text password- Parameters:
pass
- The text password to be usedsalt
- The salt to be used for the key derivationiterations
- The number of iterations the key derivation algorithm will uselength
- The length of master key to return- Returns:
- The derived master key.
- Throws:
SalmonSecurityException
- Thrown if there is a security exception
-
getKeyFromPassword
public static byte[] getKeyFromPassword(String password, byte[] salt, int iterations, int outputBytes) Function will derive a key from a text password- Parameters:
password
- The password that will be used to derive the keysalt
- The salt byte array that will be used together with the passworditerations
- The iterations to be used with Pbkdf2outputBytes
- The number of bytes for the key- Returns:
- The derived key.
- Throws:
SalmonSecurityException
- Thrown if there is a security exception
-