Documentation ¶
Overview ¶
Package csprng wraps the golang crypto/rand package so that we can use different random number generators interchangeably when the need arises.
Package csprng wraps the golang crypto/rand package so that we can use different random number generators interchangeably when the need arises.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate a byte slice of size and return the result Note use of io.Reader interface, as Source implements that, we only require a Read function for these utilities.
func GenerateInGroup ¶
GenerateInGroup creates a byte slice of at most size inside the given prime group and returns the result.
WARNING: This can generate outside the subgroup generated by g if g does
not generate the entire space of 1 to p-1, so you will have to check for and compensate for this case. Similarly, using such generators is not valid for signatures. For details, see: “Generating ElGamal signatures without knowing the secret key” by Bleichenbacher, OR chapter 11 of the Handbook of Applied Crypto, note 11.67
Types ¶
type Source ¶
type Source interface { // Read returns a slice of len(b) size bytes from the random number // generator, or an error if one occurs Read(b []byte) (int, error) // SetSeed sets the internal state of the random number generator, or an error SetSeed(seed []byte) error }
Source is the common interface for all cryptographically secure random number generators