Documentation ¶
Overview ¶
Package diffieHellman implements a Diffie-Hellman key exchange. Includes creation of DH keypairs, DH session keys, and checking the validity of DH public keys
Index ¶
- Constants
- func CheckPublicKey(group *cyclic.Group, publicKey *cyclic.Int) bool
- func GeneratePrivateKey(size int, group *cyclic.Group, source io.Reader) *cyclic.Int
- func GeneratePublicKey(myPrivateKey *cyclic.Int, group *cyclic.Group) *cyclic.Int
- func GenerateSessionKey(myPrivateKey *cyclic.Int, theirPublicKey *cyclic.Int, group *cyclic.Group) *cyclic.Int
Constants ¶
const DefaultPrivateKeyLength = DefaultPrivateKeyLengthBits / 8
const DefaultPrivateKeyLengthBits = 256
Variables ¶
This section is empty.
Functions ¶
func CheckPublicKey ¶
CheckPublicKey uses the Legendre Symbol calculation to check if a specific public key is valid This function can return false positives, but never false negatives A valid public key will never trigger a negative response from this function Legendre Symbol = a^(p-1)/2 mod p
func GeneratePrivateKey ¶
GeneratePrivateKey creates a private key of the passed length in bits in the given group using the passed csprng. The length of the key must be within the prime of the group. It is recommended to use the size of the prime for most use cases, but it is possible to use key private key sizes as small as DefaultPrivateKeyLength safely so long as the prime group size is over 3072 bits. See RFC 3766 (pg 19) and/or ECRYPT CSA "Algorithms, Key Size and Protocols Report (2018)" (pg 48) for more details. key size must be divisible by 8
func GeneratePublicKey ¶
Computes a public key for the given private key. The private key must be in the group passed
Types ¶
This section is empty.