Module Netauth

module Netauth: sig .. end
Some primitives for authentication

val hmac : h:(string -> string) ->
b:int -> l:int -> k:string -> message:string -> string
The HMAC algorithm of RFC 2104. The function 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:


type key_type = [ `Kc | `Ke | `Ki ] 
Key types:
val derive_key_rfc3961_simplified : encrypt:(string -> string) ->
random_to_key:(string -> string) ->
block_size:int -> k:int -> usage:int -> key_type:key_type -> string
Derives a special key from a base key, as described in RFC 3961.

The output is a key as produced by random_to_key.

Bitstring operations


val xor_s : string -> string -> string
Performs the bitwise XOR of these strings (which must have the same length)
val add_1_complement : string -> string -> string
The addition algorithm for 1's-complement numbers. The two numbers to add are given as bitstrings (big endian), and must have the same length
val rotate_right : int -> string -> string
Rotate the (big-endian) bitstring to the right by n bits. This also works for negative n (left rotation), and for n whose absolute value is greater or equal than the bit length of the string.
val n_fold : int -> string -> string
Blumenthal's n-fold algorithm for an n that is divisible by 8. (RFC 3961, section 5.1)