Class ParsecPasswordPlugin
- java.lang.Object
-
- org.mariadb.jdbc.plugin.authentication.standard.ParsecPasswordPlugin
-
- All Implemented Interfaces:
AuthenticationPlugin
public class ParsecPasswordPlugin extends java.lang.Object implements AuthenticationPlugin
Parsec password plugin
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringauthenticationDataprivate static intDEFAULT_CONNECT_BUDGET_MSTime budget used when connectTimeout is disabled (zero).private byte[]hashprivate static intMAX_ITERATION_FACTORAbsolute ceiling, whatever the time budget: a factor of 22 would overflow the1024 << iterationsround count.private static longPBKDF2_REFERENCE_MSprivate static longPBKDF2_REFERENCE_ROUNDSDeliberately conservative PBKDF2-HMAC-SHA512 throughput reference: 262144 rounds measured in 225ms.private byte[]seed
-
Constructor Summary
Constructors Constructor Description ParsecPasswordPlugin(java.lang.String authenticationData, byte[] seed)Initialization.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private byte[]combineArray(byte[] arr1, byte[] arr2)(package private) static intconnectBudgetMs(int connectTimeout)Connection time budget the PBKDF2 hashing must fit in: the configured connectTimeout, or a default budget when connectTimeout is disabled (zero).byte[]hash(Credential credential)Return HashbooleanisMitMProof()Can plugins are MitM-proof, permitting returning HASH(package private) static intmaxIterationFactor(int budgetMs)Maximum iteration factor a server may request, derived from the connection time budget.ReadableByteBufprocess(Writer out, Reader in, Context context, boolean sslFingerPrintValidation)Process parsec password plugin authentication.
-
-
-
Field Detail
-
PBKDF2_REFERENCE_ROUNDS
private static final long PBKDF2_REFERENCE_ROUNDS
Deliberately conservative PBKDF2-HMAC-SHA512 throughput reference: 262144 rounds measured in 225ms. Used to convert the connection time budget into a maximum iteration factor.- See Also:
- Constant Field Values
-
PBKDF2_REFERENCE_MS
private static final long PBKDF2_REFERENCE_MS
- See Also:
- Constant Field Values
-
DEFAULT_CONNECT_BUDGET_MS
private static final int DEFAULT_CONNECT_BUDGET_MS
Time budget used when connectTimeout is disabled (zero).- See Also:
- Constant Field Values
-
MAX_ITERATION_FACTOR
private static final int MAX_ITERATION_FACTOR
Absolute ceiling, whatever the time budget: a factor of 22 would overflow the1024 << iterationsround count.- See Also:
- Constant Field Values
-
authenticationData
private final java.lang.String authenticationData
-
seed
private final byte[] seed
-
hash
private byte[] hash
-
-
Method Detail
-
process
public ReadableByteBuf process(Writer out, Reader in, Context context, boolean sslFingerPrintValidation) throws java.sql.SQLException, java.io.IOException
Process parsec password plugin authentication. see parsec-plugin- Specified by:
processin interfaceAuthenticationPlugin- Parameters:
out- out streamin- in streamcontext- connection contextsslFingerPrintValidation- true if SSL certificate fingerprint validation is enabled- Returns:
- response packet
- Throws:
java.io.IOException- if socket errorjava.sql.SQLException- if plugin exception
-
connectBudgetMs
static int connectBudgetMs(int connectTimeout)
Connection time budget the PBKDF2 hashing must fit in: the configured connectTimeout, or a default budget when connectTimeout is disabled (zero).- Parameters:
connectTimeout- configured connect timeout, in milliseconds- Returns:
- time budget in milliseconds
-
maxIterationFactor
static int maxIterationFactor(int budgetMs)
Maximum iteration factor a server may request, derived from the connection time budget. The factor is an exponent: hashing costs1024 << factorPBKDF2-HMAC-SHA512 rounds, which are computed before authentication completes, with no interruptible socket read in between. The bound therefore scales with connectTimeout: a client declaring a longer budget permits a larger factor (100ms→6, 2500ms→11, 10s→13, 30s→15).- Parameters:
budgetMs- connection time budget, in milliseconds- Returns:
- maximum permitted iteration factor
-
isMitMProof
public boolean isMitMProof()
Description copied from interface:AuthenticationPluginCan plugins are MitM-proof, permitting returning HASH- Specified by:
isMitMProofin interfaceAuthenticationPlugin- Returns:
- true if permitted
-
hash
public byte[] hash(Credential credential)
Return Hash- Specified by:
hashin interfaceAuthenticationPlugin- Parameters:
credential- Credential- Returns:
- hash
-
combineArray
private byte[] combineArray(byte[] arr1, byte[] arr2)
-
-