Scram class

Scram is a singleton class used for the SCRAM (Saited Challenge Response Authentication Mechanism) authentication in the XMPP protocol. It has a private constructor and a factory method that returns the constant instance of the class.

Constructors

Scram.new()
Factory method which returns private instance of this class.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

deriveKeys({required String password, required String hashName, required String salt, required int iterations}) Map<String, String>
A function that derives client and server keys using the PBKDF2 algorithm with a given password, salt, iterations, and hash function.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scramResponse(EchoX connection, String? challenge, String hashName, int hashBits) String?
Generates a SCRAM (Salted Challenge Response Authentication Mechanism) response string.
serverSign(String message, String serverKey, String hashName) String
The purpose ofthis method is to sign the given message using the serverKey and the specified hashName algorithm. It returns the signed message as a Uint8List.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

generateCNonce String
This method generates a client nonce, which is used as part of the SCRAM authentication protocol. It generates 16 random bytes, encodes them them in base64, and removes any commas from the resulting string.
no setter

Static Methods

clientChallenge(EchoX connection, String? testCNonce) String
Returns a string containing the client first message.
clientProof(String message, String clientKey, String hashName) String
This method is used to generate the proof of the client's identity to the server, which is required for the SCRAM authentication mechanism. Without this method, the authentication process cannot be completed successfully.
hashShaConvert(String data, [Hash hash = crypto.sha1]) String
Computes the SHA-1 hash of the input data.
hmacIteration({required String key, required String salt, required int iterations, String hashName = 'SHA-1', int blockNr = 1}) String
Performs an HMAC iteration operation using the provided parameters.
hmacShaConvert(String key, Uint8List data, [Hash hash = crypto.sha1]) String
Computes the HMAC-SHA1 hash of the input data using the provided key.
parseChallenge(String? challenge) Map<String, dynamic>?
Parses SCRAM challenge string and returns a Map of three values, including the nonce, salt, and iteration count, if they exist in the challenge string. Otherwise, it returns null if any of these values is missing or invalid.