Documentation ¶
Overview ¶
*Utility functions needed by calcpass.
Index ¶
- func ByteSequence(start byte, count int) []byte
- func Erase(sensitive []byte)
- func HmacSha256(key, message []byte) []byte
- func SecureShuffleBytes(array []byte, rng ByteSource) error
- func UnbiasedSmallInt(source ByteSource, n int) (int, error)
- type BitReader
- type ByteSource
- type ByteSourceReader
- type FixedByteSource
- type HmacCounterByteSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteSequence ¶
*Create an array of increasing byte values.
func HmacSha256 ¶
func SecureShuffleBytes ¶
func SecureShuffleBytes(array []byte, rng ByteSource) error
func UnbiasedSmallInt ¶
func UnbiasedSmallInt(source ByteSource, n int) (int, error)
*Create a random integer from [0, n) where n is <= 256. This function returns uniformly distributed numbers (no modulo bias).
I am not using math/rand because Intn() consumes bits too quickly (64 at a time).
Returns error if the random source is exhausted or n exceeds 256.
Types ¶
type BitReader ¶
type BitReader struct {
// contains filtered or unexported fields
}
func NewBitReader ¶
type ByteSource ¶
*Request a single byte at a time from some abstract source.
type ByteSourceReader ¶
type ByteSourceReader struct {
Source ByteSource
}
Convert a ByteSource to a Reader
type FixedByteSource ¶
type FixedByteSource struct { //The bytes Bytes []byte //Index of the next byte which will be returned Index int }
*Implement ByteSource using a fixed-length slice of bytes. It returns io.EOF once all bytes have been consumed.
func (*FixedByteSource) NextByte ¶
func (self *FixedByteSource) NextByte() (byte, error)
type HmacCounterByteSource ¶
type HmacCounterByteSource struct {
// contains filtered or unexported fields
}
A pseudo-random stream bytes obtained from HMAC-SHA256 with a secret key and an incrementing 32bit counter.
func NewHmacCounterByteSource ¶
func NewHmacCounterByteSource(key []byte, maxCounter uint32) *HmacCounterByteSource
After maxCounter invokations of HMAC-SHA256 the NextByte() function will return io.EOF. Each invokation yields 32 bytes.
func (*HmacCounterByteSource) NextByte ¶
func (self *HmacCounterByteSource) NextByte() (byte, error)