module Netauth:Some primitives for authenticationsig
..end
val hmac : h:(string -> string) ->
b:int -> l:int -> k:string -> message:string -> string
h
is the hash function.
b
and l
are properties of h
(see the RFC or below). The string
k
is the key, up to b
bytes. The message
is authenticated.
The key k
should ideally have length l
. If this cannot be ensured
by other means, one should pass k = h any_k
.
Common values of b
and l
:
h=MD5
: b=64
, l=16
h=SHA-1
: b=64
, l=20
typekey_type =
[ `Kc | `Ke | `Ki ]
`Kc
is used for computing checksums`Ke
is used for encrypting confidential messages`Ki
is used for computing integrity checksums for encrypted
messagesval derive_key_rfc3961_simplified : encrypt:(string -> string) ->
random_to_key:(string -> string) ->
block_size:int -> k:int -> usage:int -> key_type:key_type -> string
encrypt
: Encrypts the argument with the base key and the
initial cipher state.random_to_key
: Converts a random string of size k
to a keyblock_size
: The block size of the cipher underlying encrypt
.
It is ensured that encrypt
is called with strings having exactly
this many bits. (The c
parameter in the RFC text.) Minimum: 40.k
: The input size for random_to_key
in bits. Must be divisible
by 8.usage
: The usage number (here restricted to 0-255, although the
RFC would allow 32 bits). Examples for usage numbers can be found
in RFC 4121 section 2.key_type
: Which key type to deriverandom_to_key
.val xor_s : string -> string -> string
val add_1_complement : string -> string -> string
val rotate_right : int -> string -> string
val n_fold : int -> string -> string