Top Description Fields Constructors Methods
com.mysql.cj.sasl

public Class ScramSha1SaslClient

extends ScramShaSaslClient
Class Inheritance
Imports
java.security.InvalidKeyException, .MessageDigest, .NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException, .KeySpec, javax.crypto.Mac, .SecretKeyFactory, javax.crypto.spec.PBEKeySpec, .SecretKeySpec, javax.security.sasl.SaslClient, .SaslException, com.mysql.cj.exceptions.ExceptionFactory

A SaslClient implementation for SCRAM-SHA-1, as specified in RFC 5802. The IANA-registered mechanism was renamed to "MYSQLCJ-SCRAM-SHA-1" in order to avoid future conflicts with an officially supported implementation. When there is a Java-supported implementation for SCRAM-SHA-1, it will have to be thoroughly tested with Connector/J and if that works, this code can be obsoleted.

Field Summary

Modifier and TypeField and Description
private static final String
public static final String
public static final String
private static final String
private static final String
private static final int
Inherited from com.mysql.cj.sasl.ScramShaSaslClient:
authenticationIdauthorizationIdCLIENT_KEYclientFirstMessageBarecNonceGS2_CBIND_FLAGgs2HeaderMINIMUM_ITERATIONSpasswordscramStageSERVER_KEYserverSignature

Constructor Summary

AccessConstructor and Description
public
ScramSha1SaslClient(String authorizationId, String authenticationId, String password)

Method Summary

Modifier and TypeMethod and Description
pack-priv String
getIanaMechanismName()

Implements abstract com.mysql.cj.sasl.ScramShaSaslClient.getIanaMechanismName.

Returns the real IANA-registered mechanism name of this SASL client.

public String
getMechanismName()

Implements javax.security.sasl.SaslClient.getMechanismName.

Returns the IANA-registered mechanism name of this SASL client.

pack-priv byte[]

Returns:

the hash value of the given string.
h
(byte[]
the string to hash.
str
)

Implements abstract com.mysql.cj.sasl.ScramShaSaslClient.h.

The "H(str)" cryptographic hash function as described in RFC 5802, Section 2.2.

pack-priv byte[]

Returns:

an hash value with an output length equal to the length of H(str).
hi
(String
the string value to use as the internal HMAC key.
str
,
byte[]
the input string to hash in the initial iteration.
salt
,
int
the number of iterations to run the algorithm.
iterations
)

Implements abstract com.mysql.cj.sasl.ScramShaSaslClient.hi.

The "Hi(str, salt, i)" PBKDF2 function as described in RFC 5802, Section 2.2.

pack-priv byte[]

Returns:

the hashed value of the given params.
hmac
(byte[]
the hash key.
key
,
byte[]
the input string.
str
)

Implements abstract com.mysql.cj.sasl.ScramShaSaslClient.hmac.

The "HMAC(key, str)" HMAC keyed hash algorithm as described in RFC 5802, Section 2.2.

Inherited from com.mysql.cj.sasl.ScramShaSaslClient:
disposeevaluateChallengegetNegotiatedPropertyhasInitialResponseisCompleteunwrapwrapxorInPlace

Field Detail

HMAC_SHA1_ALGORITHMback to summary
private static final String HMAC_SHA1_ALGORITHM
IANA_MECHANISM_NAMEback to summary
public static final String IANA_MECHANISM_NAME
MECHANISM_NAMEback to summary
public static final String MECHANISM_NAME
PBKCF2_HMAC_SHA1_ALGORITHMback to summary
private static final String PBKCF2_HMAC_SHA1_ALGORITHM
SHA1_ALGORITHMback to summary
private static final String SHA1_ALGORITHM
SHA1_HASH_LENGTHback to summary
private static final int SHA1_HASH_LENGTH

Constructor Detail

ScramSha1SaslClientback to summary
public ScramSha1SaslClient(String authorizationId, String authenticationId, String password) throws SaslException

Method Detail

getIanaMechanismNameback to summary
pack-priv String getIanaMechanismName()

Implements abstract com.mysql.cj.sasl.ScramShaSaslClient.getIanaMechanismName.

Doc from com.mysql.cj.sasl.ScramShaSaslClient.getIanaMechanismName.

Returns the real IANA-registered mechanism name of this SASL client. This is the same as SaslClient#getMechanismName() except that subclasses may use custom mechanism names to avoid future name clashes.

Returns:String

a non-null string representing the IANA-registered mechanism name.

Annotations
@Override
getMechanismNameback to summary
public String getMechanismName()

Implements javax.security.sasl.SaslClient.getMechanismName.

Doc from javax.security.sasl.SaslClient.getMechanismName.

Returns the IANA-registered mechanism name of this SASL client. (e.g. "CRAM-MD5", "GSSAPI").

Returns:String

A non-null string representing the IANA-registered mechanism name.

Annotations
@Override
hback to summary
pack-priv byte[] h(byte[] str)

Implements abstract com.mysql.cj.sasl.ScramShaSaslClient.h.

The "H(str)" cryptographic hash function as described in RFC 5802, Section 2.2. This implementation corresponds to SHA-1.

Parameters
str:byte[]

the string to hash.

Returns:byte[]

the hash value of the given string.

Annotations
@Override
hiback to summary
pack-priv byte[] hi(String str, byte[] salt, int iterations)

Implements abstract com.mysql.cj.sasl.ScramShaSaslClient.hi.

The "Hi(str, salt, i)" PBKDF2 function as described in RFC 5802, Section 2.2. This implementation corresponds to 'PBKDF2WithHmacSHA1'.

Parameters
str:String

the string value to use as the internal HMAC key.

salt:byte[]

the input string to hash in the initial iteration.

iterations:int

the number of iterations to run the algorithm.

Returns:byte[]

an hash value with an output length equal to the length of H(str).

Annotations
@Override
hmacback to summary
pack-priv byte[] hmac(byte[] key, byte[] str)

Implements abstract com.mysql.cj.sasl.ScramShaSaslClient.hmac.

The "HMAC(key, str)" HMAC keyed hash algorithm as described in RFC 5802, Section 2.2. This implementation corresponds to 'HmacSHA1'.

Parameters
key:byte[]

the hash key.

str:byte[]

the input string.

Returns:byte[]

the hashed value of the given params.

Annotations
@Override