~/bend-docscommunity

src/crypto/password.bend checks

raw source on the hub · import 0xd9a2fae439ac7ff9e21e0853948f94fe/src/crypto/password.bend as Password

4 imports
import Base
import ./argon2/argon2.bend as A2
import ./argon2/phc.bend as PHC
import ./subtle.bend as Subtle

Types

type Params source · line 24 · raw

Data

Definitions

def owasp source · line 27 · raw

Params

def rfc9106 source · line 30 · raw

Params

def len source · line 33 · raw

@xs:List<&2, U32> -> Nat

def encode source · line 36 · raw

@+m:Nat -> @+t:Nat -> @+p:Nat -> @+salt:List<&2, U32> -> @r:Maybe<&2, List<&2, U32>> -> Maybe<&2, String>

def hash_password source · line 45 · raw

@+pw:List<&2, U32> -> @+salt:List<&2, U32> -> @params:Params -> Maybe<&2, String>

The PHC string of Argon2id(pw, salt) with the parameters, or None when they are out of the RFC 9106 ranges (or m > 2^23 KiB, this implementation's limit).

def verify_tag source · line 50 · raw

@+hash:List<&2, U32> -> @r:Maybe<&2, List<&2, U32>> -> Bool

def verify_phc source · line 57 · raw

@+pw:List<&2, U32> -> @x:0xd9a2fae439ac7ff9e21e0853948f94fe/src/crypto/argon2/phc.Phc -> Bool

def verify_parsed source · line 62 · raw

@+pw:List<&2, U32> -> @r:Maybe<&2, 0xd9a2fae439ac7ff9e21e0853948f94fe/src/crypto/argon2/phc.Phc> -> Bool

def verify_password source · line 70 · raw

@+pw:List<&2, U32> -> @encoded:String -> Bool

The password matches the encoded Argon2id hash.

def same source · line 73 · raw

@+x:0xd9a2fae439ac7ff9e21e0853948f94fe/src/crypto/argon2/phc.Phc -> @params:Params -> Bool

def rehash_parsed source · line 78 · raw

@r:Maybe<&2, 0xd9a2fae439ac7ff9e21e0853948f94fe/src/crypto/argon2/phc.Phc> -> @params:Params -> Bool

def needs_rehash source · line 87 · raw

@encoded:String -> @params:Params -> Bool

The encoded hash should be recomputed: it is not an Argon2id v=19 PHC string with exactly these memory, passes, lanes, tag and salt lengths.

def random_bytes source · line 91 · raw

@n:Nat -> IO(List<&2, U32>)

n bytes from the operating system's generator.

def salt_len source · line 101 · raw

@+params:Params -> Nat

def hash_password_os source · line 107 · raw

@+pw:List<&2, U32> -> @+params:Params -> IO(Maybe<&2, String>)

hash_password with a fresh salt of params' salt length from IO.random_u32.