Documentation ¶
Overview ¶
Package dh implements the Diffie-Hellman key exchange over multiplicative groups of integers modulo a prime. This also defines some commen groups described in RFC 3526.
Index ¶
- func IsSafePrimeGroup(g *Group, n int) bool
- type Group
- func (g *Group) Check(peersPublic PublicKey) (err error)
- func (g *Group) ComputeSecret(private PrivateKey, peersPublic PublicKey) (secret *big.Int)
- func (g *Group) GenerateKey(rand io.Reader) (private PrivateKey, public PublicKey, err error)
- func (g *Group) PublicKey(private PrivateKey) (public PublicKey)
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSafePrimeGroup ¶
IsSafePrime returns true, if the prime of the group is a so called safe-prime. For a group with a safe-prime prime number the Decisional-Diffie-Hellman-Problem (DDH) is a 'hard' problem. The n argument is the number of iterations for the probabilistic prime test. It's recommend to use DDH-safe groups for DH-exchanges.
Types ¶
type Group ¶
Group represents a mathematical group defined by a large prime and a generator.
func RFC3526_2048 ¶
func RFC3526_2048() *Group
RFC3526_2048 creates a new dh.Group consisting of the prime and the generator. The prime (and generator) are described in RFC 3526 (3.). The prime is a 2048 bit value.
func RFC3526_3072 ¶
func RFC3526_3072() *Group
RFC3526_3072 creates a new dh.Group consisting of the prime and the generator. The prime (and generator) are described in RFC 3526 (4.). The prime is a 3072 bit value.
func RFC3526_4096 ¶
func RFC3526_4096() *Group
RFC3526_4096 creates a new dh.Group consisting of the prime and the generator. The prime (and generator) are described in RFC 3526 (5.). The prime is a 4096 bit value.
func (*Group) Check ¶
private returns a non-nil error if the given public key is not a possible element of the group. This means, that the public key is < 0 or > g.P.
func (*Group) ComputeSecret ¶
func (g *Group) ComputeSecret(private PrivateKey, peersPublic PublicKey) (secret *big.Int)
ComputeSecret returns the secret computed from the own private and the peer's public key.
func (*Group) GenerateKey ¶
GenerateKey generates a public/private key pair using entropy from rand. If rand is nil, crypto/rand.Reader will be used.
func (*Group) PublicKey ¶
func (g *Group) PublicKey(private PrivateKey) (public PublicKey)
PublicKey returns the public key corresponding to the given private one.