xref: /openbsd/share/man/man9/SipHash24.9 (revision 9b7c3dbb)
1.\"	$OpenBSD: SipHash24.9,v 1.6 2015/09/14 15:14:55 schwarze Exp $
2.\"
3.\" Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: September 14 2015 $
18.Dt SIPHASH24 9
19.Os
20.Sh NAME
21.Nm SipHash24_Init ,
22.Nm SipHash24_Update ,
23.Nm SipHash24_End ,
24.Nm SipHash24_Final ,
25.Nm SipHash24
26.Nd calculate SipHash24 hashes
27.Sh SYNOPSIS
28.In crypto/siphash.h
29.Ft void
30.Fn SipHash24_Init "SIPHASH_CTX *ctx" "const SIPHASH_KEY *key"
31.Ft void
32.Fn SipHash24_Update "SIPHASH_CTX *ctx" "const void *data" "size_t len"
33.Ft uint64_t
34.Fn SipHash24_End "SIPHASH_CTX *ctx"
35.Ft void
36.Fn SipHash24_Final "void *digest" "SIPHASH_CTX *ctx"
37.Ft uint64_t
38.Fn SipHash24 "const SIPHASH_KEY *key" "const void *data" "size_t len"
39.Sh DESCRIPTION
40The SipHash algorithm is a keyed hash algorithm optimised for short
41inputs which produces a 64-bit digest of data.
42The SipHash24 functions implement the algorithm with 2 compression
43rounds and 4 finalisation rounds.
44.Pp
45.Fn SipHash24_Init
46initialises a
47.Vt SIPHASH_CTX
48context
49.Fa ctx
50with the secret
51.Fa key .
52.Pp
53.Fn SipHash24_Update
54adds
55.Fa data
56of length
57.Fa len
58to the context
59.Fa ctx .
60.Pp
61.Fn SipHash24_End
62is called after all data has been added to
63.Fa ctx
64via
65.Fn SipHash24_Update
66and returns a message digest in the host's native endian.
67.Pp
68.Fn SipHash24_Final
69is called after all data has been added to
70.Fa ctx
71via
72.Fn SipHash24_Update
73and stores the message digest at the address specified by the
74.Fa digest
75parameter.
76The buffer at
77.Fa digest
78must be
79.Dv SIPHASH_DIGEST_LENGTH
80bytes long.
81.Pp
82.Fn SipHash24
83calculates the digest of
84.Fa data
85of length
86.Fa len
87with the secret
88.Fa key .
89.Pp
90It is recommended that the
91.Vt SIPHASH_KEY
92key be generated with
93.Xr arc4random_buf 9 .
94.Sh CONTEXT
95.Fn SipHash24_Init ,
96.Fn SipHash24_Update ,
97.Fn SipHash24_End ,
98.Fn SipHash24_Final
99and
100.Fn SipHash24
101can be called during autoconf, from process context, or from interrupt context.
102.Sh RETURN VALUES
103.Fn SipHash24_End
104and
105.Fn SipHash24
106return the 64-bit message digest in the host's native endian representation.
107.Sh SEE ALSO
108.Xr arc4random_buf 9
109