sig
module Base64 :
sig
val encode : Cstruct.t -> Cstruct.t
val decode : Cstruct.t -> Cstruct.t option
val is_base64_char : char -> bool
end
module Uncommon :
sig
type 'a one = One of 'a
val cdiv : int -> int -> int
val ( &. ) : ('b -> 'c) -> ('a -> 'b) -> 'a -> 'c
val id : 'a -> 'a
module Option :
sig
val v_map : def:'b -> f:('a -> 'b) -> 'a option -> 'b
val map : f:('a -> 'b) -> 'a option -> 'b option
val get : def:'a -> 'a option -> 'a
end
module Cs :
sig
val empty : Cstruct.t
val null : Cstruct.t -> bool
val ( <+> ) : Cstruct.t -> Cstruct.t -> Cstruct.t
val ct_eq : Cstruct.t -> Cstruct.t -> bool
val xor_into : Cstruct.t -> Cstruct.t -> int -> unit
val xor : Cstruct.t -> Cstruct.t -> Cstruct.t
val create : ?init:int -> int -> Cstruct.t
val clone : ?off:int -> ?len:int -> Cstruct.t -> Cstruct.t
val ( lsl ) : Cstruct.t -> int -> Cstruct.t
val ( lsr ) : Cstruct.t -> int -> Cstruct.t
val of_hex : string -> Cstruct.t
end
module Arr : sig val mem : 'a -> 'a array -> bool end
val bracket :
init:(unit -> 'a) -> fini:('a -> unit) -> ('a -> 'b) -> 'b
end
module Numeric :
sig
module type S =
sig
type t
val zero : Nocrypto.Numeric.S.t
val one : Nocrypto.Numeric.S.t
val ( lsr ) : Nocrypto.Numeric.S.t -> int -> Nocrypto.Numeric.S.t
val ( lsl ) : Nocrypto.Numeric.S.t -> int -> Nocrypto.Numeric.S.t
val ( land ) :
Nocrypto.Numeric.S.t ->
Nocrypto.Numeric.S.t -> Nocrypto.Numeric.S.t
val ( lor ) :
Nocrypto.Numeric.S.t ->
Nocrypto.Numeric.S.t -> Nocrypto.Numeric.S.t
val ( lxor ) :
Nocrypto.Numeric.S.t ->
Nocrypto.Numeric.S.t -> Nocrypto.Numeric.S.t
val ( + ) :
Nocrypto.Numeric.S.t ->
Nocrypto.Numeric.S.t -> Nocrypto.Numeric.S.t
val ( - ) :
Nocrypto.Numeric.S.t ->
Nocrypto.Numeric.S.t -> Nocrypto.Numeric.S.t
val succ : Nocrypto.Numeric.S.t -> Nocrypto.Numeric.S.t
val pred : Nocrypto.Numeric.S.t -> Nocrypto.Numeric.S.t
val of_int : int -> Nocrypto.Numeric.S.t
val of_int32 : int32 -> Nocrypto.Numeric.S.t
val of_int64 : int64 -> Nocrypto.Numeric.S.t
val to_int : Nocrypto.Numeric.S.t -> int
val to_int32 : Nocrypto.Numeric.S.t -> int32
val to_int64 : Nocrypto.Numeric.S.t -> int64
val bit_bound : Nocrypto.Numeric.S.t -> int
val pp_print : Format.formatter -> Nocrypto.Numeric.S.t -> unit
val bits : Nocrypto.Numeric.S.t -> int
val of_cstruct_be : ?bits:int -> Cstruct.t -> Nocrypto.Numeric.S.t
val to_cstruct_be : ?size:int -> Nocrypto.Numeric.S.t -> Cstruct.t
val into_cstruct_be : Nocrypto.Numeric.S.t -> Cstruct.t -> unit
end
module Int :
sig
type t = int
val zero : t
val one : t
val ( lsr ) : t -> int -> t
val ( lsl ) : t -> int -> t
val ( land ) : t -> t -> t
val ( lor ) : t -> t -> t
val ( lxor ) : t -> t -> t
val ( + ) : t -> t -> t
val ( - ) : t -> t -> t
val succ : t -> t
val pred : t -> t
val of_int : int -> t
val of_int32 : int32 -> t
val of_int64 : int64 -> t
val to_int : t -> int
val to_int32 : t -> int32
val to_int64 : t -> int64
val bit_bound : t -> int
val pp_print : Format.formatter -> t -> unit
val bits : t -> int
val of_cstruct_be : ?bits:int -> Cstruct.t -> t
val to_cstruct_be : ?size:int -> t -> Cstruct.t
val into_cstruct_be : t -> Cstruct.t -> unit
end
module Int32 :
sig
type t = int32
val zero : t
val one : t
val ( lsr ) : t -> int -> t
val ( lsl ) : t -> int -> t
val ( land ) : t -> t -> t
val ( lor ) : t -> t -> t
val ( lxor ) : t -> t -> t
val ( + ) : t -> t -> t
val ( - ) : t -> t -> t
val succ : t -> t
val pred : t -> t
val of_int : int -> t
val of_int32 : int32 -> t
val of_int64 : int64 -> t
val to_int : t -> int
val to_int32 : t -> int32
val to_int64 : t -> int64
val bit_bound : t -> int
val pp_print : Format.formatter -> t -> unit
val bits : t -> int
val of_cstruct_be : ?bits:int -> Cstruct.t -> t
val to_cstruct_be : ?size:int -> t -> Cstruct.t
val into_cstruct_be : t -> Cstruct.t -> unit
end
module Int64 :
sig
type t = int64
val zero : t
val one : t
val ( lsr ) : t -> int -> t
val ( lsl ) : t -> int -> t
val ( land ) : t -> t -> t
val ( lor ) : t -> t -> t
val ( lxor ) : t -> t -> t
val ( + ) : t -> t -> t
val ( - ) : t -> t -> t
val succ : t -> t
val pred : t -> t
val of_int : int -> t
val of_int32 : int32 -> t
val of_int64 : int64 -> t
val to_int : t -> int
val to_int32 : t -> int32
val to_int64 : t -> int64
val bit_bound : t -> int
val pp_print : Format.formatter -> t -> unit
val bits : t -> int
val of_cstruct_be : ?bits:int -> Cstruct.t -> t
val to_cstruct_be : ?size:int -> t -> Cstruct.t
val into_cstruct_be : t -> Cstruct.t -> unit
end
module Z :
sig
type t = Z.t
val zero : t
val one : t
val ( lsr ) : t -> int -> t
val ( lsl ) : t -> int -> t
val ( land ) : t -> t -> t
val ( lor ) : t -> t -> t
val ( lxor ) : t -> t -> t
val ( + ) : t -> t -> t
val ( - ) : t -> t -> t
val succ : t -> t
val pred : t -> t
val of_int : int -> t
val of_int32 : int32 -> t
val of_int64 : int64 -> t
val to_int : t -> int
val to_int32 : t -> int32
val to_int64 : t -> int64
val bit_bound : t -> int
val pp_print : Format.formatter -> t -> unit
val bits : t -> int
val of_cstruct_be : ?bits:int -> Cstruct.t -> t
val to_cstruct_be : ?size:int -> t -> Cstruct.t
val into_cstruct_be : t -> Cstruct.t -> unit
end
val pseudoprime : Nocrypto.Numeric.Z.t -> bool
end
module Hash :
sig
module type S =
sig
type t
val digest_size : int
val init : unit -> Nocrypto.Hash.S.t
val feed : Nocrypto.Hash.S.t -> Cstruct.t -> unit
val get : Nocrypto.Hash.S.t -> Cstruct.t
val digest : Cstruct.t -> Cstruct.t
val digestv : Cstruct.t list -> Cstruct.t
val hmac : key:Cstruct.t -> Cstruct.t -> Cstruct.t
end
module MD5 : S
module SHA1 : S
module SHA224 : S
module SHA256 : S
module SHA384 : S
module SHA512 : S
type hash = [ `MD5 | `SHA1 | `SHA224 | `SHA256 | `SHA384 | `SHA512 ]
val digest : [< Nocrypto.Hash.hash ] -> Cstruct.t -> Cstruct.t
val mac :
[< Nocrypto.Hash.hash ] -> key:Cstruct.t -> Cstruct.t -> Cstruct.t
val digest_size : [< Nocrypto.Hash.hash ] -> int
val module_of : [< Nocrypto.Hash.hash ] -> (module Nocrypto.Hash.S)
val hash_of_sexp : Sexplib.Sexp.t -> Nocrypto.Hash.hash
val sexp_of_hash : Nocrypto.Hash.hash -> Sexplib.Sexp.t
end
module Cipher_block :
sig
module S :
sig
module type Core =
sig
type ekey
type dkey
val of_secret :
Cstruct.t ->
Nocrypto.Cipher_block.S.Core.ekey *
Nocrypto.Cipher_block.S.Core.dkey
val e_of_secret :
Cstruct.t -> Nocrypto.Cipher_block.S.Core.ekey
val d_of_secret :
Cstruct.t -> Nocrypto.Cipher_block.S.Core.dkey
val key : int array
val block : int
val encrypt :
key:Nocrypto.Cipher_block.S.Core.ekey ->
blocks:int ->
Native.buffer -> int -> Native.buffer -> int -> unit
val decrypt :
key:Nocrypto.Cipher_block.S.Core.dkey ->
blocks:int ->
Native.buffer -> int -> Native.buffer -> int -> unit
end
module type ECB =
sig
type key
val of_secret : Cstruct.t -> Nocrypto.Cipher_block.S.ECB.key
val key_sizes : int array
val block_size : int
val encrypt :
key:Nocrypto.Cipher_block.S.ECB.key -> Cstruct.t -> Cstruct.t
val decrypt :
key:Nocrypto.Cipher_block.S.ECB.key -> Cstruct.t -> Cstruct.t
end
module type CBC =
sig
type key
val of_secret : Cstruct.t -> Nocrypto.Cipher_block.S.CBC.key
val key_sizes : int array
val block_size : int
val next_iv : iv:Cstruct.t -> Cstruct.t -> Cstruct.t
val encrypt :
key:Nocrypto.Cipher_block.S.CBC.key ->
iv:Cstruct.t -> Cstruct.t -> Cstruct.t
val decrypt :
key:Nocrypto.Cipher_block.S.CBC.key ->
iv:Cstruct.t -> Cstruct.t -> Cstruct.t
end
module type CTR =
sig
type key
val of_secret : Cstruct.t -> Nocrypto.Cipher_block.S.CTR.key
val key_sizes : int array
val block_size : int
val stream :
key:Nocrypto.Cipher_block.S.CTR.key ->
ctr:Cstruct.t -> ?off:int -> int -> Cstruct.t
val encrypt :
key:Nocrypto.Cipher_block.S.CTR.key ->
ctr:Cstruct.t -> ?off:int -> Cstruct.t -> Cstruct.t
val decrypt :
key:Nocrypto.Cipher_block.S.CTR.key ->
ctr:Cstruct.t -> ?off:int -> Cstruct.t -> Cstruct.t
end
module type GCM =
sig
type key
type result = { message : Cstruct.t; tag : Cstruct.t; }
val of_secret : Cstruct.t -> Nocrypto.Cipher_block.S.GCM.key
val key_sizes : int array
val block_size : int
val encrypt :
key:Nocrypto.Cipher_block.S.GCM.key ->
iv:Cstruct.t ->
?adata:Cstruct.t ->
Cstruct.t -> Nocrypto.Cipher_block.S.GCM.result
val decrypt :
key:Nocrypto.Cipher_block.S.GCM.key ->
iv:Cstruct.t ->
?adata:Cstruct.t ->
Cstruct.t -> Nocrypto.Cipher_block.S.GCM.result
end
module type CCM =
sig
type key
val of_secret :
maclen:int -> Cstruct.t -> Nocrypto.Cipher_block.S.CCM.key
val key_sizes : int array
val mac_sizes : int array
val block_size : int
val encrypt :
key:Nocrypto.Cipher_block.S.CCM.key ->
nonce:Cstruct.t -> ?adata:Cstruct.t -> Cstruct.t -> Cstruct.t
val decrypt :
key:Nocrypto.Cipher_block.S.CCM.key ->
nonce:Cstruct.t ->
?adata:Cstruct.t -> Cstruct.t -> Cstruct.t option
end
end
module Counter :
sig
val incr1 : Cstruct.t -> int -> bool
val incr2 : Cstruct.t -> int -> bool
val incr4 : Cstruct.t -> int -> bool
val incr8 : Cstruct.t -> int -> bool
val incr16 : Cstruct.t -> int -> bool
val add4 : Cstruct.t -> int -> int32 -> unit
val add8 : Cstruct.t -> int -> int64 -> unit
val add16 : Cstruct.t -> int -> int64 -> unit
end
module AES :
sig
val mode : [ `AES_NI | `Generic ]
module ECB : S.ECB
module CBC : S.CBC
module CTR : S.CTR
module GCM : S.GCM
module CCM : S.CCM
end
module DES :
sig module ECB : S.ECB module CBC : S.CBC module CTR : S.CTR end
end
module Cipher_stream :
sig
module type S =
sig
type key
type result = {
message : Cstruct.t;
key : Nocrypto.Cipher_stream.S.key;
}
val of_secret : Cstruct.t -> Nocrypto.Cipher_stream.S.key
val encrypt :
key:Nocrypto.Cipher_stream.S.key ->
Cstruct.t -> Nocrypto.Cipher_stream.S.result
val decrypt :
key:Nocrypto.Cipher_stream.S.key ->
Cstruct.t -> Nocrypto.Cipher_stream.S.result
end
module ARC4 : S
end
module Rng :
sig
type g
exception Unseeded_generator
module S :
sig
module type Generator =
sig
type g
val block : int
val create : unit -> Nocrypto.Rng.S.Generator.g
val generate : g:Nocrypto.Rng.S.Generator.g -> int -> Cstruct.t
val reseed : g:Nocrypto.Rng.S.Generator.g -> Cstruct.t -> unit
val accumulate :
g:Nocrypto.Rng.S.Generator.g ->
(source:int -> Cstruct.t -> unit) Nocrypto.Uncommon.one
val seeded : g:Nocrypto.Rng.S.Generator.g -> bool
end
module type N =
sig
type t
val gen :
?g:Nocrypto.Rng.g -> Nocrypto.Rng.S.N.t -> Nocrypto.Rng.S.N.t
val gen_r :
?g:Nocrypto.Rng.g ->
Nocrypto.Rng.S.N.t ->
Nocrypto.Rng.S.N.t -> Nocrypto.Rng.S.N.t
val gen_bits :
?g:Nocrypto.Rng.g -> ?msb:int -> int -> Nocrypto.Rng.S.N.t
end
end
module Generators :
sig
module Fortuna : S.Generator
module Hmac_drgb :
sig module Make : functor (H : Hash.S) -> S.Generator end
module Null : S.Generator
end
val create :
?g:'a ->
?seed:Cstruct.t ->
?strict:bool ->
(module Nocrypto.Rng.S.Generator with type g = 'a) -> Nocrypto.Rng.g
val generator : Nocrypto.Rng.g Pervasives.ref
val generate : ?g:Nocrypto.Rng.g -> int -> Cstruct.t
val block : Nocrypto.Rng.g option -> int
val reseed : ?g:Nocrypto.Rng.g -> Cstruct.t -> unit
val accumulate :
Nocrypto.Rng.g option ->
(source:int -> Cstruct.t -> unit) Nocrypto.Uncommon.one
val seeded : Nocrypto.Rng.g option -> bool
module Make_N :
functor (N : Numeric.S) ->
sig
type t = N.t
val gen : ?g:g -> t -> t
val gen_r : ?g:g -> t -> t -> t
val gen_bits : ?g:g -> ?msb:int -> int -> t
end
module Int :
sig
type t = int
val gen : ?g:g -> t -> t
val gen_r : ?g:g -> t -> t -> t
val gen_bits : ?g:g -> ?msb:int -> int -> t
end
module Int32 :
sig
type t = int32
val gen : ?g:g -> t -> t
val gen_r : ?g:g -> t -> t -> t
val gen_bits : ?g:g -> ?msb:int -> int -> t
end
module Int64 :
sig
type t = int64
val gen : ?g:g -> t -> t
val gen_r : ?g:g -> t -> t -> t
val gen_bits : ?g:g -> ?msb:int -> int -> t
end
module Z :
sig
type t = Z.t
val gen : ?g:g -> t -> t
val gen_r : ?g:g -> t -> t -> t
val gen_bits : ?g:g -> ?msb:int -> int -> t
end
val prime : ?g:Nocrypto.Rng.g -> ?msb:int -> int -> Nocrypto.Rng.Z.t
val safe_prime :
?g:Nocrypto.Rng.g -> int -> Nocrypto.Rng.Z.t * Nocrypto.Rng.Z.t
type buffer = Cstruct.t
end
module Rsa :
sig
exception Insufficient_key
type pub = { e : Z.t; n : Z.t; }
type priv = {
e : Z.t;
d : Z.t;
n : Z.t;
p : Z.t;
q : Z.t;
dp : Z.t;
dq : Z.t;
q' : Z.t;
}
type mask = [ `No | `Yes | `Yes_with of Nocrypto.Rng.g ]
val pub_bits : Nocrypto.Rsa.pub -> int
val priv_bits : Nocrypto.Rsa.priv -> int
val priv_of_primes : e:Z.t -> p:Z.t -> q:Z.t -> Nocrypto.Rsa.priv
val pub_of_priv : Nocrypto.Rsa.priv -> Nocrypto.Rsa.pub
val encrypt : key:Nocrypto.Rsa.pub -> Cstruct.t -> Cstruct.t
val decrypt :
?mask:Nocrypto.Rsa.mask ->
key:Nocrypto.Rsa.priv -> Cstruct.t -> Cstruct.t
val generate : ?g:Nocrypto.Rng.g -> ?e:Z.t -> int -> Nocrypto.Rsa.priv
module PKCS1 :
sig
val sig_encode :
?mask:Nocrypto.Rsa.mask ->
key:Nocrypto.Rsa.priv -> Cstruct.t -> Cstruct.t
val sig_decode :
key:Nocrypto.Rsa.pub -> Cstruct.t -> Cstruct.t option
val encrypt :
?g:Nocrypto.Rng.g ->
key:Nocrypto.Rsa.pub -> Cstruct.t -> Cstruct.t
val decrypt :
?mask:Nocrypto.Rsa.mask ->
key:Nocrypto.Rsa.priv -> Cstruct.t -> Cstruct.t option
end
module OAEP :
functor (H : Hash.S) ->
sig
val encrypt :
?g:Nocrypto.Rng.g ->
?label:Cstruct.t ->
key:Nocrypto.Rsa.pub -> Cstruct.t -> Cstruct.t
val decrypt :
?mask:Nocrypto.Rsa.mask ->
?label:Cstruct.t ->
key:Nocrypto.Rsa.priv -> Cstruct.t -> Cstruct.t option
end
module PSS :
functor (H : Hash.S) ->
sig
val sign :
?g:Nocrypto.Rng.g ->
?slen:int -> key:Nocrypto.Rsa.priv -> Cstruct.t -> Cstruct.t
val verify :
?slen:int ->
key:Nocrypto.Rsa.pub ->
signature:Cstruct.t -> Cstruct.t -> bool
end
val pub_of_sexp : Sexplib.Sexp.t -> Nocrypto.Rsa.pub
val sexp_of_pub : Nocrypto.Rsa.pub -> Sexplib.Sexp.t
val priv_of_sexp : Sexplib.Sexp.t -> Nocrypto.Rsa.priv
val sexp_of_priv : Nocrypto.Rsa.priv -> Sexplib.Sexp.t
end
module Dsa :
sig
type priv = { p : Z.t; q : Z.t; gg : Z.t; x : Z.t; y : Z.t; }
type pub = { p : Z.t; q : Z.t; gg : Z.t; y : Z.t; }
type keysize =
[ `Exactly of int * int | `Fips1024 | `Fips2048 | `Fips3072 ]
type mask = [ `No | `Yes | `Yes_with of Nocrypto.Rng.g ]
val pub_of_priv : Nocrypto.Dsa.priv -> Nocrypto.Dsa.pub
val generate :
?g:Nocrypto.Rng.g -> Nocrypto.Dsa.keysize -> Nocrypto.Dsa.priv
val sign :
?mask:Nocrypto.Dsa.mask ->
?k:Z.t -> key:Nocrypto.Dsa.priv -> Cstruct.t -> Cstruct.t * Cstruct.t
val verify :
key:Nocrypto.Dsa.pub -> Cstruct.t * Cstruct.t -> Cstruct.t -> bool
val massage : key:Nocrypto.Dsa.pub -> Cstruct.t -> Cstruct.t
module K_gen :
functor (H : Hash.S) ->
sig val generate : key:Nocrypto.Dsa.priv -> Cstruct.t -> Z.t end
val pub_of_sexp : Sexplib.Sexp.t -> Nocrypto.Dsa.pub
val sexp_of_pub : Nocrypto.Dsa.pub -> Sexplib.Sexp.t
val priv_of_sexp : Sexplib.Sexp.t -> Nocrypto.Dsa.priv
val sexp_of_priv : Nocrypto.Dsa.priv -> Sexplib.Sexp.t
end
module Dh :
sig
exception Invalid_public_key
type group = { p : Z.t; gg : Z.t; q : Z.t option; }
type secret = private { x : Z.t; }
val modulus_size : Nocrypto.Dh.group -> int
val key_of_secret :
Nocrypto.Dh.group -> s:Cstruct.t -> Nocrypto.Dh.secret * Cstruct.t
val gen_key :
?g:Nocrypto.Rng.g ->
?bits:int -> Nocrypto.Dh.group -> Nocrypto.Dh.secret * Cstruct.t
val shared :
Nocrypto.Dh.group ->
Nocrypto.Dh.secret -> Cstruct.t -> Cstruct.t option
val gen_group : ?g:Nocrypto.Rng.g -> int -> Nocrypto.Dh.group
module Group :
sig
val oakley_1 : Nocrypto.Dh.group
val oakley_2 : Nocrypto.Dh.group
val oakley_5 : Nocrypto.Dh.group
val oakley_14 : Nocrypto.Dh.group
val oakley_15 : Nocrypto.Dh.group
val oakley_16 : Nocrypto.Dh.group
val oakley_17 : Nocrypto.Dh.group
val oakley_18 : Nocrypto.Dh.group
val rfc_5114_1 : Nocrypto.Dh.group
val rfc_5114_2 : Nocrypto.Dh.group
val rfc_5114_3 : Nocrypto.Dh.group
val ffdhe2048 : Nocrypto.Dh.group
val ffdhe3072 : Nocrypto.Dh.group
val ffdhe4096 : Nocrypto.Dh.group
val ffdhe6144 : Nocrypto.Dh.group
val ffdhe8192 : Nocrypto.Dh.group
end
val group_of_sexp : Sexplib.Sexp.t -> Nocrypto.Dh.group
val sexp_of_group : Nocrypto.Dh.group -> Sexplib.Sexp.t
val secret_of_sexp : Sexplib.Sexp.t -> Nocrypto.Dh.secret
val sexp_of_secret : Nocrypto.Dh.secret -> Sexplib.Sexp.t
end
end