Documentation ¶
Overview ¶
Package dhparam is a pure Golang implementation of the openssl dhparam generator no requiring any CGO bindings
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAllParametersOK = errors.New("DH parameters appear to be ok")
ErrAllParametersOK is defined to check whether the returned error from Check is indeed no error For simplicity reasons it is defined as an error instead of an additional result parameter
var ErrInvalidPem = errors.New("invalid bytes for PEM data; does not seem to be PEM-encoded")
ErrInvalidPem is returned if pemData for the Decode function does not seem to be PEM-encoded data.
var ErrNoPem = errors.New("empty or nil bytes for PEM data")
ErrNoPem is returned if pemData for the Decode function is nil or empty.
Functions ¶
This section is empty.
Types ¶
type DH ¶
DH contains a prime (P) and a generator (G) number representing the DH parameters
func Generate ¶
func Generate(bits int, generator Generator, cb GeneratorCallback) (*DH, error)
Generate determines a prime number according to the generator having the specified number of bits
In OpenSSL defined generators are 2 and 5. Others are supported but the verification is not supported in an extend as with generators 2 and 5. The bit size should be adjusted to be high enough for the current requirements. Also, you should keep in mind the higher the bitsize, the longer the generation might take.
func GenerateWithContext ¶ added in v1.1.0
func GenerateWithContext(ctx context.Context, bits int, generator Generator, cb GeneratorCallback) (*DH, error)
GenerateWithContext is just like the Generate function, but it accepts a ctx parameter with a context, that can be used to interrupt the generation if needed
type Generator ¶
type Generator int
Generator is the generator number to use when determining the prime number
const ( // GeneratorTwo uses a generator 2 GeneratorTwo Generator = 2 // GeneratorFive uses a generator 5 GeneratorFive = 5 )
type GeneratorCallback ¶
type GeneratorCallback func(r GeneratorResult)
GeneratorCallback is a type of function to receive GeneratorResults while the prime number is determined
type GeneratorResult ¶
type GeneratorResult uint
GeneratorResult is a type of results sent to the GeneratorCallback function
const ( // GeneratorFoundPossiblePrime signals a possible (non-verified) prime number was found (OpenSSL: ".") GeneratorFoundPossiblePrime GeneratorResult = iota // GeneratorFirstConfirmation signals the prime number itself was verified but is not yet considered "safe" (OpenSSL: "+") GeneratorFirstConfirmation // GeneratorSafePrimeFound signals the prime number now is considered "safe" (OpenSSL: "*") GeneratorSafePrimeFound )