Documentation
¶
Overview ¶
Package hash provides an easy way to generate digest or one way hash. It wraps the standard library packages such as crypt/sha1 and crypt/sha256 into easy to use functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // MD5 is a pointer to MD5 creation function usable for HMAC and KDF MD5 Hashit = md5.New // SHA1 is a pointer to SHA1 creation function usable for HMAC and KDF SHA1 Hashit = sha1.New // SHA244 is a pointer to SHA2-224 creation function usable for HMAC and KDF SHA244 Hashit = sha256.New224 // SHA256 is a pointer to SHA2-256 creation function usable for HMAC and KDF SHA256 Hashit = sha256.New // SHA384 is a pointer to SHA2-384 creation function usable for HMAC and KDF SHA384 Hashit = sha512.New384 // SHA512 is a pointer to SHA2-512 creation function usable for HMAC and KDF SHA512 Hashit = sha512.New // SHA244Sha3 is a pointer to SHA3-244 creation function usable for HMAC and KDF SHA244Sha3 Hashit = sha3.New224 // SHA256Sha3 is a pointer to SHA3-256 creation function usable for HMAC and KDF SHA256Sha3 Hashit = sha3.New256 // SHA384Sha3 is a pointer to SHA3-384 creation function usable for HMAC and KDF SHA384Sha3 Hashit = sha3.New384 // SHA512Sha3 is a pointer to SHA3-512 creation function usable for HMAC and KDF SHA512Sha3 Hashit = sha3.New512 // SHAKE128 is a pointer to SHAKE128 creation function SHAKE128 ShakeHashit = sha3.NewShake128 // SHAKE256 is a pointer to SHAKE256 creation function SHAKE256 ShakeHashit = sha3.NewShake128 )
Functions ¶
func Compare ¶
Compare is the cryptographically constant time compare function. This allows the comparison of 2 byte slices. If they are equal a true value is returned else false.
func HMAC ¶
HMAC function calculates the Keyed-Hash Message Authentication Code (HMAC) using the supplied key and data. Depending the supplied newFn the respective HMAC computation would be performed. If sufficeint capacity (as pe the supplied size) is available in the supplied input buffer, then this function appends the MAC to it.
func ShakeMAC ¶
func ShakeMAC(s ShakeHashit, p, key []byte, size int) (mac []byte, err error)
ShakeMAC function performs the MAC operation using the Shake Variable Hash function. It mixes the input data 'p' with the authenticator part 'key' to generate the MAC code. The same can be performed and verified to check authenticity. It is recommended that the size should be at least 32 bytes. If sufficeint capacity (as pe the supplied size) is available in the supplied input buffer, then this function appends the MAC to it.
func ShakeSum ¶
func ShakeSum(s ShakeHashit, p []byte, size int) (r []byte)
ShakeSum function generates the Shake Variable Hash of the supplied input buffer. The size can be as big as needed. It is recommended that the size should be at least 32 bytes. If the size provided is 0 or no data is provided this function returns a nil. If sufficeint capacity (as pe the supplied size) is available in the supplied input buffer, then this function appends the digest to it.
Types ¶
type Hashit ¶
Hashit type is a function that implements the New creation Method that returns hash.Hash
type ShakeHashit ¶
ShakeHashit is a function that implements variable Hash creation Method for SHAKE128 and SHAKE256 algorithms