public class ScramFunctions extends Object
Constructor and Description |
---|
ScramFunctions() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
clientKey(ScramMechanism scramMechanism,
byte[] saltedPassword)
Generates a client key, from the salted password.
|
static byte[] |
clientKey(ScramMechanism scramMechanism,
StringPreparation stringPreparation,
String password,
byte[] salt,
int iteration)
Generates a client key from the password and salt.
|
static byte[] |
clientProof(byte[] clientKey,
byte[] clientSignature)
Computes the SCRAM client proof to be sent to the server on the client-final-message.
|
static byte[] |
clientSignature(ScramMechanism scramMechanism,
byte[] storedKey,
String authMessage)
Computes the SCRAM client signature.
|
static byte[] |
hash(ScramMechanism scramMechanism,
byte[] value)
Computes the hash function of a given value, based on the SCRAM mechanism hash function.
|
static byte[] |
hmac(ScramMechanism scramMechanism,
byte[] message,
byte[] key)
Computes the HMAC of the message and key, using the given SCRAM mechanism.
|
static byte[] |
saltedPassword(ScramMechanism scramMechanism,
StringPreparation stringPreparation,
String password,
byte[] salt,
int iteration)
Compute the salted password, based on the given SCRAM mechanism, the String preparation algorithm,
the provided salt and the number of iterations.
|
static byte[] |
serverKey(ScramMechanism scramMechanism,
byte[] saltedPassword)
Generates a server key, from the salted password.
|
static byte[] |
serverKey(ScramMechanism scramMechanism,
StringPreparation stringPreparation,
String password,
byte[] salt,
int iteration)
Generates a server key from the password and salt.
|
static byte[] |
serverSignature(ScramMechanism scramMechanism,
byte[] serverKey,
String authMessage)
Compute the SCRAM server signature.
|
static byte[] |
storedKey(ScramMechanism scramMechanism,
byte[] clientKey)
Generates a stored key, from the salted password.
|
static boolean |
verifyClientProof(ScramMechanism scramMechanism,
byte[] clientProof,
byte[] storedKey,
String authMessage)
Verifies that a provided client proof is correct.
|
static boolean |
verifyServerSignature(ScramMechanism scramMechanism,
byte[] serverKey,
String authMessage,
byte[] serverSignature)
Verifies that a provided server proof is correct.
|
public static byte[] saltedPassword(ScramMechanism scramMechanism, StringPreparation stringPreparation, String password, byte[] salt, int iteration)
SaltedPassword := Hi(Normalize(password), salt, i)
scramMechanism
- The SCRAM mechanismstringPreparation
- The String preparationpassword
- The non-salted passwordsalt
- The bytes representing the saltiteration
- The number of iterationspublic static byte[] hmac(ScramMechanism scramMechanism, byte[] message, byte[] key)
scramMechanism
- The SCRAM mechanismmessage
- The message to compute the HMACkey
- The key used to initialize the MACpublic static byte[] clientKey(ScramMechanism scramMechanism, byte[] saltedPassword)
ClientKey := HMAC(SaltedPassword, "Client Key")
scramMechanism
- The SCRAM mechanismsaltedPassword
- The salted passwordpublic static byte[] clientKey(ScramMechanism scramMechanism, StringPreparation stringPreparation, String password, byte[] salt, int iteration)
SaltedPassword := Hi(Normalize(password), salt, i)
ClientKey := HMAC(SaltedPassword, "Client Key")
scramMechanism
- The SCRAM mechanismstringPreparation
- The String preparationpassword
- The non-salted passwordsalt
- The bytes representing the saltiteration
- The number of iterationspublic static byte[] serverKey(ScramMechanism scramMechanism, byte[] saltedPassword)
ServerKey := HMAC(SaltedPassword, "Server Key")
scramMechanism
- The SCRAM mechanismsaltedPassword
- The salted passwordpublic static byte[] serverKey(ScramMechanism scramMechanism, StringPreparation stringPreparation, String password, byte[] salt, int iteration)
SaltedPassword := Hi(Normalize(password), salt, i)
ServerKey := HMAC(SaltedPassword, "Server Key")
scramMechanism
- The SCRAM mechanismstringPreparation
- The String preparationpassword
- The non-salted passwordsalt
- The bytes representing the saltiteration
- The number of iterationspublic static byte[] hash(ScramMechanism scramMechanism, byte[] value)
scramMechanism
- The SCRAM mechanismvalue
- The value to hashpublic static byte[] storedKey(ScramMechanism scramMechanism, byte[] clientKey)
StoredKey := H(ClientKey)
scramMechanism
- The SCRAM mechanismclientKey
- The client keypublic static byte[] clientSignature(ScramMechanism scramMechanism, byte[] storedKey, String authMessage)
ClientSignature := HMAC(StoredKey, AuthMessage)
scramMechanism
- The SCRAM mechanismstoredKey
- The stored keyauthMessage
- The auth messagepublic static byte[] clientProof(byte[] clientKey, byte[] clientSignature)
ClientProof := ClientKey XOR ClientSignature
clientKey
- The client keyclientSignature
- The client signaturepublic static byte[] serverSignature(ScramMechanism scramMechanism, byte[] serverKey, String authMessage)
ServerSignature := HMAC(ServerKey, AuthMessage)
scramMechanism
- The SCRAM mechanismserverKey
- The server keyauthMessage
- The auth messagepublic static boolean verifyClientProof(ScramMechanism scramMechanism, byte[] clientProof, byte[] storedKey, String authMessage)
scramMechanism
- The SCRAM mechanismclientProof
- The provided client proofstoredKey
- The stored keyauthMessage
- The auth messagepublic static boolean verifyServerSignature(ScramMechanism scramMechanism, byte[] serverKey, String authMessage, byte[] serverSignature)
scramMechanism
- The SCRAM mechanismserverKey
- The server keyauthMessage
- The auth messageserverSignature
- The provided server signatureCopyright © 2017–2018. All rights reserved.