Documentation
¶
Overview ¶
Package pin hashes and checks the owner's PIN or passphrase. It is pure: no file, no clock, no randomness of its own - the caller passes the salt.
New hashes are Argon2id at RFC 9106's second recommended setting (t=3, 64 MiB, p=4): memory-hard, so a stolen hash costs a GPU far more to guess than an iterated hash does. Hashes from earlier releases are PBKDF2-HMAC-SHA256 at 600,000 iterations; they still verify, and Verify reports them stale so the caller rehashes on the next correct entry. The encoded form names its algorithm and cost, so this can change again without invalidating a PIN anyone has set.
Index ¶
Constants ¶
const ( ArgonTime = 3 ArgonMemory = 64 * 1024 // KiB ArgonThreads = 4 )
The Argon2id cost new hashes are made with: RFC 9106 section 4, the second recommended option, for an environment that cannot spare 2 GiB.
const ( MinLen = 6 MaxLen = 128 )
MinLen and MaxLen bound a PIN or passphrase, in characters.
const Algorithm = "argon2id"
Algorithm is the tag new hashes are encoded under.
const Iterations = 600_000
Iterations is the PBKDF2 cost earlier releases hashed with.
const LegacyAlgorithm = "pbkdf2-sha256"
LegacyAlgorithm is the tag of the hashes earlier releases made; they still verify, and are reported stale.
const SaltLen = 16
SaltLen is the salt length, in bytes, that Hash expects.
Variables ¶
var ErrMalformed = errors.New("the stored PIN hash is not in a form authama reads")
ErrMalformed is an encoded hash this package cannot read.
Functions ¶
func Hash ¶
Hash returns the encoded hash of p with salt, at the current cost: argon2id$v=19$m=65536,t=3,p=4$<salt>$<key>, both base64 (raw, standard alphabet), the parameters as the PHC string format writes them.
func Policy ¶
Policy reports why a candidate PIN cannot be used, or nil. Six digits is the floor a phone asks for; a passphrase may be anything printable up to 128.
Types ¶
This section is empty.