Best-practices security made usable.
Features
- Implements best-practices password security, made easy:
- Operations are length-constant time.
- Plaintext passwords and keys are proactively and aggressively destroyed.
- Passwords are salted and key-stretched.
Identifier
andSmallIdentifier
are 128-bit and 64-bit random identifiers:- Base-57 textual representation:
-
Uses an unambiguous subset of URL-safe characters. For example, the letter
B
is excluded as potentially ambiguous with the number8
. - The same length as unpadded base-64 (22 and 11 characters, respectively), while being completely URL safe.
- Shorter than padded base-64 (24 and 12 characters, respectively).
-
Uses an unambiguous subset of URL-safe characters. For example, the letter
- Base-57 textual representation:
Password
andKey
protect the plaintext from all normal access (reflection,Unsafe
, and other such mechanisms are unavoidable).UnprotectedPassword
andUnprotectedKey
provide access to the password and key, but with automatically destroyed copies.HashedPassword
andHashedKey
contain hashed/encrypted forms of passwords and keys:- Are strongly self-validating, including when deserialized.
- Are intended for long-term persistence, either in textual forms or in the provided SQL composite types.
- Multi-algorithm support, with backward compatibility mechanisms:
- Allows systems to upgrade crypto while maintaining compatibility.
- Textual form includes algorithm, iterations, salt, and hash - everything needed for future password validation even when default settings upgraded.
-
Algorithm support going back the full twenty years of AO application support, including the likes of
crypt
,MD5
,SHA-1
, … (don't use these for new passwords, but they are still supported for compatibility with ancient password databases).
- Robust, bi-directional, future-proof textual representations of
HashedPassword
andHashedKey
:- To and from
String
in Java allows storage and transmission as simple text. -
SQL
CAST
are declared for easy conversion of legacy databases to the new composite types, including database-level parsing of all supported algorithms (yes, even you,crypt
).
- To and from
- API-provided, actively supported default encryption settings:
- API recommends to re-hash passwords on login when default settings are stronger than those used to originally hash the password. This allows to keep the stored values up-to-date (or to prompt the user to change password, depending on needs).
- Java 1.8 implementation:
Password
andKey
areAutoCloseable
, to destroy the plaintext via try-with-resources.Optional
used where aPassword
orKey
may not be returned.- Very lambda-friendly:
Function
,Consumer
, andPredicate
all leveraged in the automatic destruction of passwords and keys.
- Small footprint, minimal dependencies - not part of a big monolithic package.
- Compatible PostgreSQL implementation:
- Composite types for
Identifier
,HashedPassword
, andHashedKey
. DOMAIN
type forSmallIdentifier
.- Full set of validation functions.
-
Very thorough validation, matching every detail the Java API. As an example, the first four bits
of the salt for
crypt
are verified to be zero, sincecrypt
only uses a 12-bit salt. -
Full set of bi-directional
TEXT
conversions, includingCAST
definitions, which makes for very simple legacy password database upgrades. All it will typically take is:ALTER TABLE … ALTER COLUMN … TYPE "com.aoapps.security"."HashedPassword";
- Composite types for