Module dauth.core

DAuth - Salted Hashed Password Library for D Core package

Functions

Name Description
defaultDigestCodeOfObj Default implementation of 'digestCodeOfObj' for DAuth-style hash strings. See 'Hash!(TDigest).toString' for more info.
defaultDigestCryptCodeOfObj Default implementation of 'digestCodeOfObj' for Unix crypt-style hash strings. See 'Hash!(TDigest).toString' for more info.
defaultDigestFromCode Default implementation of 'digestFromCode' for DAuth-style hash strings. See 'parseHash' for more info.
defaultDigestFromCryptCode Default implementation of 'digestFromCode' for Unix crypt-style hash strings. See 'parseHash' for more info.
defaultSalter Default salter for 'makeHash' and 'isSameHash'.
dupPassword This function exists as a convenience in case you need it, HOWEVER it's recommended to design your code so you DON'T need to use this (use toPassword instead):
getDigestCode
isKnownWeak Note, this only checks Phobos's RNG's and digests, and only by type. This works on a blacklist basis - it blindly accepts any Phobos-compatible RNG or digest it does not know about. This is only supplied as a convenience. It is always your own responsibility to select an appropriate algorithm for your own needs.
isSameHash Validates a password against an existing salted hash.
lengthConstantEquals Compare two arrays in "length-constant" time. This thwarts timing-based attacks by guaranteeing all comparisons (of a given length) take the same amount of time.
makeHash Generates a salted password using any Phobos-compatible digest, default being SHA-512.
parseCryptHash Parses a string that was encoded by Hash.toString.
parseDAuthHash Parses a string that was encoded by Hash.toString.
parseHash Parses a string that was encoded by Hash.toString.
toPassword Constructs a Password from a ubyte[]. Mainly provided for syntactic consistency with 'toPassword(char[])'.
toPassword Constructs a Password from a char[] so you don't have to cast to ubyte[], and don't accidentally cast away immutability.

Classes

Name Description
KnownWeakException Thrown when a known-weak algortihm or setting it attempted, UNLESS compiled with '-version=DAuth_AllowWeakSecurity'
UnknownDigestException Thrown whenever a digest type cannot be determined. For example, when the provided (or default) 'digestCodeOfObj' or 'digestFromCode' delegates fail to find a match. Or when passing isSameHash a Hash!Digest with a null 'digest' member (which prevents it from determining the correct digest to match with).

Structs

Name Description
Hash Contains all the relevant information for a salted hash. Note the digest type can be obtained via DigestOf!(SomeHashType).

Templates

Name Description
AnyDigestType Like std.digest.digest.DigestType, but also accepts OO-style digests (ie. classes deriving from interface std.digest.digest.Digest)

Global variables

Name Type Description
isAnyDigest void Like std.digest.digest.isDigest, but also accepts OO-style digests (ie. classes deriving from interface std.digest.digest.Digest)
isHash void Tests if the type is an instance of struct Hash(some digest)

Aliases

Name Type Description
DefaultCryptoRand dauth.hashdrbg.__T14HashDRBGStreamTS5dauth3sha19__T3SHAVi1024Vi512Z3SHAVAyaa5_4441757468Z.HashDRBGStream Default is Hash_DRBG using SHA-512
DefaultDigest SHA!(1024,512) Default is SHA-512
DefaultDigestClass std.digest.digest.WrapperDigest!(dauth.sha.SHA!(1024,512).SHA) OO-style version of 'DefaultDigest'.
DigestOf TemplateArgsOf!T[0] Retreive the digest type of a struct Hash(some digest)
isPasswordCorrect Alias for backwards compatibility.
Password std.typecons.RefCounted!(dauth.core.PasswordData) A reference-counted type for passwords. The memory containing the password is automatically zeroed-out when there are no more references or when a new password is assigned.
Salt ubyte[] Salt type
Salter void delegate(ref TDigest, Password, Salt) Convenience alias for salter delegates.
TokenBase64 Implementation of Base64 engine used for tokens.

Authors

Copyright

License