diffieHellman

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 4 Imported by: 23

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

View Source
const DefaultPrivateKeyLength = DefaultPrivateKeyLengthBits / 8
View Source
const DefaultPrivateKeyLengthBits = 256

Variables

This section is empty.

Functions

func CheckPublicKey

func CheckPublicKey(group *cyclic.Group, publicKey *cyclic.Int) bool

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

func GeneratePrivateKey(size int, group *cyclic.Group, source io.Reader) *cyclic.Int

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

func GeneratePublicKey(myPrivateKey *cyclic.Int, group *cyclic.Group) *cyclic.Int

Computes a public key for the given private key. The private key must be in the group passed

func GenerateSessionKey

func GenerateSessionKey(myPrivateKey *cyclic.Int, theirPublicKey *cyclic.Int,
	group *cyclic.Group) *cyclic.Int

CreateSessionKey takes the prime, the other party's public key and private key Function returns a valid session Key within the group

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL