Diffie-Hellman key exchange
Raised if the public key is degenerate. Implies either badly malfunctioning DH on the other side, or an attack attempt.
A DH group.
Sexplib
convertible.
A private secret.
Sexplib
convertible.
val modulus_size : group -> int
Bit size of the modulus.
key_of_secret group s
is the secret
and the corresponding public key which use s
as the secret exponent.
- raises Invalid_public_key
if
s
is degenerate.
shared group secret message
is Some key
, the shared key, given a group, a previously generated secret
and the other party's public message. It is None
if message
is degenerate.
gen_group bits
generates a random group
with modulus size bits
. Uses a safe prime p = 2q + 1
(with q
prime) for the modulus and 2
for the generator, such that 2^q = 1 mod p
. Runtime is on the order of minute for 1024 bits.
- raises Invalid_argument
if
bits
is ridiculously small.