Class ParsecPasswordPlugin
java.lang.Object
org.mariadb.jdbc.plugin.authentication.standard.ParsecPasswordPlugin
- All Implemented Interfaces:
AuthenticationPlugin
Parsec password plugin
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate static final intTime budget used when connectTimeout is disabled (zero).private byte[]private static final intAbsolute ceiling, whatever the time budget: a factor of 22 would overflow the1024 << iterationsround count.private static final longprivate static final longDeliberately conservative PBKDF2-HMAC-SHA512 throughput reference: 262144 rounds measured in 225ms.private final byte[] -
Constructor Summary
ConstructorsConstructorDescriptionParsecPasswordPlugin(String authenticationData, byte[] seed) Initialization. -
Method Summary
Modifier and TypeMethodDescriptionprivate 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 HashbooleanCan 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.Process parsec password plugin authentication.
-
Field Details
-
PBKDF2_REFERENCE_ROUNDS
private static final long PBKDF2_REFERENCE_ROUNDSDeliberately 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:
-
PBKDF2_REFERENCE_MS
private static final long PBKDF2_REFERENCE_MS- See Also:
-
DEFAULT_CONNECT_BUDGET_MS
private static final int DEFAULT_CONNECT_BUDGET_MSTime budget used when connectTimeout is disabled (zero).- See Also:
-
MAX_ITERATION_FACTOR
private static final int MAX_ITERATION_FACTORAbsolute ceiling, whatever the time budget: a factor of 22 would overflow the1024 << iterationsround count.- See Also:
-
authenticationData
-
seed
private final byte[] seed -
hash
private byte[] hash
-
-
Constructor Details
-
ParsecPasswordPlugin
Initialization.- Parameters:
authenticationData- authentication data (password/token)seed- server provided seed
-
-
Method Details
-
process
public ReadableByteBuf process(Writer out, Reader in, Context context, boolean sslFingerPrintValidation) throws SQLException, 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:
IOException- if socket errorSQLException- 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
Return Hash- Specified by:
hashin interfaceAuthenticationPlugin- Parameters:
credential- Credential- Returns:
- hash
-
combineArray
private byte[] combineArray(byte[] arr1, byte[] arr2)
-