upstream: https://github.com/mirage/mirage-crypto

feat(crypto-pk): add .mli interface files for pk library modules

Add documented .mli files for dh, dsa, rsa, and z_extra modules.

+201
+35
pk/dh.mli
··· 1 + (** Diffie-Hellman key exchange over multiplicative groups of integers mod p. *) 2 + 3 + exception Invalid_key 4 + 5 + type group = private { p : Z.t; gg : Z.t; q : Z.t option } 6 + 7 + val group : 8 + p:Z.t -> gg:Z.t -> ?q:Z.t -> unit -> (group, [> `Msg of string ]) result 9 + 10 + type secret = private { group : group; x : Z.t } 11 + 12 + val modulus_size : group -> int 13 + val key_of_secret : group -> s:string -> secret * string 14 + val gen_key : ?g:Crypto_rng.g -> ?bits:int -> group -> secret * string 15 + val shared : secret -> string -> string option 16 + val gen_group : ?g:Crypto_rng.g -> bits:int -> unit -> group 17 + 18 + module Group : sig 19 + val oakley_1 : group 20 + val oakley_2 : group 21 + val oakley_5 : group 22 + val oakley_14 : group 23 + val oakley_15 : group 24 + val oakley_16 : group 25 + val oakley_17 : group 26 + val oakley_18 : group 27 + val rfc_5114_1 : group 28 + val rfc_5114_2 : group 29 + val rfc_5114_3 : group 30 + val ffdhe2048 : group 31 + val ffdhe3072 : group 32 + val ffdhe4096 : group 33 + val ffdhe6144 : group 34 + val ffdhe8192 : group 35 + end
+43
pk/dsa.mli
··· 1 + (** DSA digital signature algorithm. *) 2 + 3 + type pub = private { p : Z.t; q : Z.t; gg : Z.t; y : Z.t } 4 + 5 + val pub : 6 + ?fips:bool -> 7 + p:Z.t -> 8 + q:Z.t -> 9 + gg:Z.t -> 10 + y:Z.t -> 11 + unit -> 12 + (pub, [> `Msg of string ]) result 13 + 14 + type priv = private { p : Z.t; q : Z.t; gg : Z.t; x : Z.t; y : Z.t } 15 + 16 + val priv : 17 + ?fips:bool -> 18 + p:Z.t -> 19 + q:Z.t -> 20 + gg:Z.t -> 21 + x:Z.t -> 22 + y:Z.t -> 23 + unit -> 24 + (priv, [> `Msg of string ]) result 25 + 26 + val pub_of_priv : priv -> pub 27 + 28 + type keysize = [ `Fips1024 | `Fips2048 | `Fips3072 | `Exactly of int * int ] 29 + type mask = [ `No | `Yes | `Yes_with of Crypto_rng.g ] 30 + 31 + val params : ?g:Crypto_rng.g -> keysize -> Z.t * Z.t * Z.t 32 + val generate : ?g:Crypto_rng.g -> keysize -> priv 33 + 34 + module K_gen (H : Digestif.S) : sig 35 + val z_gen : key:priv -> Z.t -> Z.t 36 + val generate : key:priv -> string -> Z.t 37 + end 38 + 39 + val sign_z : ?mask:mask -> ?k:Z.t -> key:priv -> Z.t -> Z.t * Z.t 40 + val verify_z : key:pub -> Z.t * Z.t -> Z.t -> bool 41 + val sign : ?mask:mask -> ?k:Z.t -> key:priv -> string -> string * string 42 + val verify : key:pub -> string * string -> string -> bool 43 + val massage : key:pub -> string -> string
+109
pk/rsa.mli
··· 1 + (** RSA public-key encryption and signature scheme. *) 2 + 3 + type 'a or_digest = [ `Message of 'a | `Digest of string ] 4 + 5 + exception Insufficient_key 6 + 7 + type pub = private { e : Z.t; n : Z.t } 8 + 9 + val pub : e:Z.t -> n:Z.t -> (pub, [> `Msg of string ]) result 10 + 11 + type priv = private { 12 + e : Z.t; 13 + d : Z.t; 14 + n : Z.t; 15 + p : Z.t; 16 + q : Z.t; 17 + dp : Z.t; 18 + dq : Z.t; 19 + q' : Z.t; 20 + } 21 + 22 + val priv : 23 + e:Z.t -> 24 + d:Z.t -> 25 + n:Z.t -> 26 + p:Z.t -> 27 + q:Z.t -> 28 + dp:Z.t -> 29 + dq:Z.t -> 30 + q':Z.t -> 31 + (priv, [> `Msg of string ]) result 32 + 33 + val priv_of_primes : 34 + e:Z.t -> p:Z.t -> q:Z.t -> (priv, [> `Msg of string ]) result 35 + 36 + val priv_of_exp : 37 + ?g:Crypto_rng.g -> 38 + ?attempts:int -> 39 + e:Z.t -> 40 + d:Z.t -> 41 + n:Z.t -> 42 + unit -> 43 + (priv, [> `Msg of string ]) result 44 + 45 + val pub_of_priv : priv -> pub 46 + val pub_bits : pub -> int 47 + val priv_bits : priv -> int 48 + val generate : ?g:Crypto_rng.g -> ?e:Z.t -> bits:int -> unit -> priv 49 + 50 + type mask = [ `No | `Yes | `Yes_with of Crypto_rng.g ] 51 + 52 + val encrypt : key:pub -> string -> string 53 + val decrypt : ?crt_hardening:bool -> ?mask:mask -> key:priv -> string -> string 54 + 55 + module PKCS1 : sig 56 + val sig_encode : 57 + ?crt_hardening:bool -> ?mask:mask -> key:priv -> string -> string 58 + 59 + val sig_decode : key:pub -> string -> string option 60 + val encrypt : ?g:Crypto_rng.g -> key:pub -> string -> string 61 + 62 + val decrypt : 63 + ?crt_hardening:bool -> ?mask:mask -> key:priv -> string -> string option 64 + 65 + val sign : 66 + ?crt_hardening:bool -> 67 + ?mask:mask -> 68 + hash:[< Digestif.hash' > `MD5 `SHA1 `SHA224 `SHA256 `SHA384 `SHA512 ] -> 69 + key:priv -> 70 + string or_digest -> 71 + string 72 + 73 + val verify : 74 + hashp: 75 + ([< Digestif.hash' > `MD5 `SHA1 `SHA224 `SHA256 `SHA384 `SHA512 ] -> bool) -> 76 + key:pub -> 77 + signature:string -> 78 + string or_digest -> 79 + bool 80 + 81 + val min_key : 82 + [< Digestif.hash' > `MD5 `SHA1 `SHA224 `SHA256 `SHA384 `SHA512 ] -> int 83 + end 84 + 85 + module OAEP (H : Digestif.S) : sig 86 + val encrypt : ?g:Crypto_rng.g -> ?label:string -> key:pub -> string -> string 87 + 88 + val decrypt : 89 + ?crt_hardening:bool -> 90 + ?mask:mask -> 91 + ?label:string -> 92 + key:priv -> 93 + string -> 94 + string option 95 + end 96 + 97 + module PSS (H : Digestif.S) : sig 98 + val sign : 99 + ?g:Crypto_rng.g -> 100 + ?crt_hardening:bool -> 101 + ?mask:mask -> 102 + ?slen:int -> 103 + key:priv -> 104 + string or_digest -> 105 + string 106 + 107 + val verify : 108 + ?slen:int -> key:pub -> signature:string -> string or_digest -> bool 109 + end
+14
pk/z_extra.mli
··· 1 + (** Extra Z arithmetic utilities for big-endian octet conversion and random 2 + generation. *) 3 + 4 + val bit_bound : Z.t -> int 5 + val of_octets_be : ?bits:int -> string -> Z.t 6 + val into_octets_be : Z.t -> bytes -> unit 7 + val to_octets_be : ?size:int -> Z.t -> string 8 + val pseudoprime : Z.t -> bool 9 + val strip_factor : f:Z.t -> Z.t -> (int * Z.t, [> `Msg of string ]) result 10 + val gen : ?g:Crypto_rng.g -> Z.t -> Z.t 11 + val gen_r : ?g:Crypto_rng.g -> Z.t -> Z.t -> Z.t 12 + val gen_bits : ?g:Crypto_rng.g -> ?msb:int -> int -> Z.t 13 + val prime : ?g:Crypto_rng.g -> ?msb:int -> int -> Z.t 14 + val safe_prime : ?g:Crypto_rng.g -> int -> Z.t * Z.t