Some primitives for authentication
The HMAC algorithm of RFC 2104. The function
h is the hash function.
l are properties of
h (see the RFC or below). The string
k is the key, up to
b bytes. The
message is authenticated.
k should ideally have length
l. If this cannot be ensured
by other means, one should pass
k = h any_k.
Common values of
`Kcis used for computing checksums
`Keis used for encrypting confidential messages
`Kiis used for computing integrity checksums for encrypted messages
Derives a special key from a base key, as described in RFC 3961.
encrypt: Encrypts the argument with the base key and the initial cipher state.
random_to_key: Converts a random string of size
kto a key
block_size: The block size of the cipher underlying
encrypt. It is ensured that
encryptis called with strings having exactly this many bits. (The
cparameter in the RFC text.) Minimum: 40.
k: The input size for
random_to_keyin 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 derive
The output is a key as produced by
Performs the bitwise XOR of these strings (which must have the same length)
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
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.
Blumenthal's n-fold algorithm for an n that is divisible by 8. (RFC 3961, section 5.1)