1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* GraxRabble
* example programs for libsodium.
*/
/*
* This function computes a fixed-length fingerprint for an arbitrary long message.
*
* Sample use cases:
*
* File integrity checking
* Creating unique identifiers to index arbitrary long data
*
* The crypto_generichash() function puts a fingerprint of the
* message in whose length is inlen bytes into out. The output size
* can be chosen by the application.
*
* The minimum recommended output size is crypto_generichash_BYTES.
* This size makes it practically impossible for two messages to
* produce the same fingerprint.
*
* But for specific use cases, the size can be any value between
* crypto_generichash_BYTES_MIN (included) and
* crypto_generichash_BYTES_MAX (included).
*
* key can be NULL and keylen can be 0. In this case, a message will
* always have the same fingerprint, similar to the MD5 or SHA-1
* functions for which crypto_generichash() is a faster and more
* secure alternative.
*
* But a key can also be specified. A message will always have the
* same fingerprint for a given key, but different keys used to hash
* the same message are very likely to produce distinct fingerprints.
*
* In particular, the key can be used to make sure that different
* applications generate different fingerprints even if they process
* the same data.
*
* The recommended key size is crypto_generichash_KEYBYTES bytes.
*
* However, the key size can by any value between
* crypto_generichash_KEYBYTES_MIN (included) and
* crypto_generichash_KEYBYTES_MAX (included).
*/
void
int