package mirage-crypto-pk
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=cd215ea3267a22ae7d910590f4f7ed82d2dc575206191f5bba9b49bb9240b5db
sha512=378b9ae826212471c4820636fa0be27a33013ecf801ba7202fbf0bbf8ac20b1072f782d34b868e5491616ef93bd7c0ec81f9705f7afd287b2ac595a913d32401
doc/mirage-crypto-pk/Mirage_crypto_pk/Dh/index.html
Module Mirage_crypto_pk.DhSource
Diffie-Hellman, MODP version.
Diffie-Hellman key exchange
Raised if the private key material is degenerate. The following invariants are checked: Secret key: 1 < secret < p Public key: 1 < public < p-1 && public <> gg
group ~p ~gg ~q () constructs a group if p is odd, a prime number, and greater than zero. gg must be in the range 1 < gg < p.
val modulus_size : group -> intBit size of the modulus.
key_of_secret group s is the secret and the corresponding public key which use s as the secret exponent.
val gen_key : ?g:Mirage_crypto_rng.g -> ?bits:int -> group -> secret * stringshared secret public is Some shared_key given a a previously generated secret (which specifies the group) and the other party's public key. shared_key is the unpadded big-endian representation of the shared key. It is None if these invariants do not hold for public: 1 < public < p-1 && public <> gg.
val gen_group : ?g:Mirage_crypto_rng.g -> bits:int -> unit -> groupgen_group ~g ~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 a minute for 1024 bits. Note that no time masking is done for the modular exponentiation.
Note The process might diverge if there are no suitable groups. This happens with extremely small bits values.