mirror of
https://github.com/cryb-to/cryb-to.git
synced 2024-11-28 00:25:43 +00:00
Merge pull request #20 from cryb-to/cryb-hash-fnv
Implement the Fowler-No-Voll hash functions.
This commit is contained in:
commit
96a5cef4ba
24 changed files with 1016 additions and 96 deletions
|
@ -42,6 +42,12 @@ const char *cryb_hash_version(void);
|
||||||
#define fletcher16_hash cryb_fletcher16_hash
|
#define fletcher16_hash cryb_fletcher16_hash
|
||||||
#define fletcher32_hash cryb_fletcher32_hash
|
#define fletcher32_hash cryb_fletcher32_hash
|
||||||
#define fletcher64_hash cryb_fletcher64_hash
|
#define fletcher64_hash cryb_fletcher64_hash
|
||||||
|
#define fnv0_32_hash cryb_fnv0_32_hash
|
||||||
|
#define fnv0_64_hash cryb_fnv0_64_hash
|
||||||
|
#define fnv1_32_hash cryb_fnv1_32_hash
|
||||||
|
#define fnv1_64_hash cryb_fnv1_64_hash
|
||||||
|
#define fnv1a_32_hash cryb_fnv1a_32_hash
|
||||||
|
#define fnv1a_64_hash cryb_fnv1a_64_hash
|
||||||
#define murmur3_32_hash cryb_murmur3_32_hash
|
#define murmur3_32_hash cryb_murmur3_32_hash
|
||||||
#define pearson_hash cryb_pearson_hash
|
#define pearson_hash cryb_pearson_hash
|
||||||
#define pearson_hash_str cryb_pearson_hash_str
|
#define pearson_hash_str cryb_pearson_hash_str
|
||||||
|
@ -50,6 +56,12 @@ uint32_t adler32_hash(const void *, size_t);
|
||||||
uint16_t fletcher16_hash(const void *, size_t);
|
uint16_t fletcher16_hash(const void *, size_t);
|
||||||
uint32_t fletcher32_hash(const void *, size_t);
|
uint32_t fletcher32_hash(const void *, size_t);
|
||||||
uint64_t fletcher64_hash(const void *, size_t);
|
uint64_t fletcher64_hash(const void *, size_t);
|
||||||
|
uint32_t fnv0_32_hash(const void *, size_t);
|
||||||
|
uint64_t fnv0_64_hash(const void *, size_t);
|
||||||
|
uint32_t fnv1_32_hash(const void *, size_t);
|
||||||
|
uint64_t fnv1_64_hash(const void *, size_t);
|
||||||
|
uint32_t fnv1a_32_hash(const void *, size_t);
|
||||||
|
uint64_t fnv1a_64_hash(const void *, size_t);
|
||||||
uint32_t murmur3_32_hash(const void *, size_t, uint32_t);
|
uint32_t murmur3_32_hash(const void *, size_t, uint32_t);
|
||||||
uint8_t pearson_hash(const void *, size_t);
|
uint8_t pearson_hash(const void *, size_t);
|
||||||
uint8_t pearson_hash_str(const char *);
|
uint8_t pearson_hash_str(const char *);
|
||||||
|
|
|
@ -15,11 +15,16 @@ libcryb_digest_la_SOURCES = \
|
||||||
cryb_digest.c
|
cryb_digest.c
|
||||||
|
|
||||||
dist_man3_MANS = \
|
dist_man3_MANS = \
|
||||||
|
cryb_md2.3 \
|
||||||
|
cryb_md4.3 \
|
||||||
|
cryb_md5.3 \
|
||||||
cryb_sha1.3 \
|
cryb_sha1.3 \
|
||||||
cryb_sha224.3 \
|
cryb_sha224.3 \
|
||||||
cryb_sha256.3 \
|
cryb_sha256.3 \
|
||||||
cryb_sha384.3 \
|
cryb_sha384.3 \
|
||||||
cryb_sha512.3
|
cryb_sha512.3 \
|
||||||
|
\
|
||||||
|
cryb_digest.3
|
||||||
|
|
||||||
libcryb_digest_la_CFLAGS = \
|
libcryb_digest_la_CFLAGS = \
|
||||||
$(CRYB_CORE_CFLAGS)
|
$(CRYB_CORE_CFLAGS)
|
||||||
|
|
70
lib/digest/cryb_digest.3
Normal file
70
lib/digest/cryb_digest.3
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
.\"-
|
||||||
|
.\" Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
|
.\" All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
|
.\" 3. The name of the author may not be used to endorse or promote
|
||||||
|
.\" products derived from this software without specific prior written
|
||||||
|
.\" permission.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
.\" SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.Dd May 15, 2022
|
||||||
|
.Dt CRYB_DIGEST 3
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm cryb_digest_version
|
||||||
|
.Nd cryptographic message digest library
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libcryb-digest
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In stddef.h
|
||||||
|
.In stdint.h
|
||||||
|
.In cryb/digest.h
|
||||||
|
.Ft const char *
|
||||||
|
.Fn cryb_digest_version "void"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Fn cryb_digest_version
|
||||||
|
function returns a pointer to a string containing the specific version
|
||||||
|
of the
|
||||||
|
.Lb libcryb-digest
|
||||||
|
library.
|
||||||
|
.Pp
|
||||||
|
For descriptions of the other functions in this library, see their
|
||||||
|
respective manual pages.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr cryb_md2 3 ,
|
||||||
|
.Xr cryb_md4 3 ,
|
||||||
|
.Xr cryb_md5 3 ,
|
||||||
|
.Xr cryb_sha1 3 ,
|
||||||
|
.Xr cryb_sha224 3 ,
|
||||||
|
.Xr cryb_sha256 3 ,
|
||||||
|
.Xr cryb_sha384 3 ,
|
||||||
|
.Xr cryb_sha512 3
|
||||||
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
|
The
|
||||||
|
.Fn cryb_digest_version
|
||||||
|
function was written for the University of Oslo by
|
||||||
|
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
||||||
|
.Pp
|
||||||
|
This manual page was written by
|
||||||
|
.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
|
125
lib/digest/cryb_md2.3
Normal file
125
lib/digest/cryb_md2.3
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
.\"-
|
||||||
|
.\" Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
|
.\" All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
|
.\" 3. The name of the author may not be used to endorse or promote
|
||||||
|
.\" products derived from this software without specific prior written
|
||||||
|
.\" permission.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
.\" SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.Dd May 15, 2022
|
||||||
|
.Dt CRYB_MD2 3
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm cryb_md2_init ,
|
||||||
|
.Nm cryb_md2_update ,
|
||||||
|
.Nm cryb_md2_final ,
|
||||||
|
.Nm cryb_md2_complete
|
||||||
|
.Nd Message-Digest Algorithm 2
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libcryb-digest
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In stddef.h
|
||||||
|
.In stdint.h
|
||||||
|
.In cryb/md2.h
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md2_init "cryb_md2_ctx *context"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md2_update "cryb_md2_ctx *context" "const void *data" "size_t len"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md2_final "cryb_md2_ctx *context" "uint8_t *digest"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md2_complete "const void *data" "size_t len" "uint8_t *digest"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Nm cryb_md2
|
||||||
|
family of functions implements the MD2 message digest algorithm as
|
||||||
|
described in RFC 1319.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md2_init
|
||||||
|
function initializes the context structure pointed to by
|
||||||
|
.Va context .
|
||||||
|
It is the caller's responsibility to allocate this structure.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md2_update
|
||||||
|
function hashes the next
|
||||||
|
.Va len
|
||||||
|
bytes of data pointed to by the
|
||||||
|
.Va data
|
||||||
|
pointer into the given hash context.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md2_final
|
||||||
|
function finalizes the computation and writes the resulting message
|
||||||
|
digest to the caller-provided buffer pointed to by
|
||||||
|
.Va digest ,
|
||||||
|
which must be at least
|
||||||
|
.Dv MD2_DIGEST_LEN
|
||||||
|
bytes long.
|
||||||
|
It is the caller's responsibility to dispose of the context structure
|
||||||
|
after calling
|
||||||
|
.Fn cryb_md2_final .
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md2_complete
|
||||||
|
function is a shortcut to calling
|
||||||
|
.Fn cryb_md2_init ,
|
||||||
|
.Fn cryb_md2_update ,
|
||||||
|
and
|
||||||
|
.Fn cryb_md2_final
|
||||||
|
when the entire message is available up front in a single contiguous
|
||||||
|
buffer.
|
||||||
|
.Sh IMPLEMENTATION NOTES
|
||||||
|
The
|
||||||
|
.In cryb/md2.h
|
||||||
|
header provides macros which allows these functions and the context
|
||||||
|
type to be referred to without their
|
||||||
|
.Dq Li cryb_
|
||||||
|
prefix.
|
||||||
|
.Pp
|
||||||
|
The MD2 message digest algorithm has been proven to be vulnerable to
|
||||||
|
collision attacks and should not be used for cryptographic purposes.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr cryb_digest 3 ,
|
||||||
|
.Xr cryb_md4 3 ,
|
||||||
|
.Xr cryb_md5 3
|
||||||
|
.Sh REFERENCES
|
||||||
|
.Rs
|
||||||
|
.%A Kaliski, Burton S.
|
||||||
|
.%T The MD2 Message-Digest Algorithm
|
||||||
|
.%D April 1992
|
||||||
|
.%O RFC 1319
|
||||||
|
.%U https://datatracker.ietf.org/doc/html/rfc1319
|
||||||
|
.Re
|
||||||
|
.Rs
|
||||||
|
.%A Turner, Sean
|
||||||
|
.%A Chen, Lily
|
||||||
|
.%T MD2 to Historic Status
|
||||||
|
.%D March 2011
|
||||||
|
.%O RFC 6149
|
||||||
|
.%U https://datatracker.ietf.org/doc/html/rfc6149
|
||||||
|
.Re
|
||||||
|
.Sh AUTHORS
|
||||||
|
These functions and this manual page were written by
|
||||||
|
.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
|
125
lib/digest/cryb_md4.3
Normal file
125
lib/digest/cryb_md4.3
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
.\"-
|
||||||
|
.\" Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
|
.\" All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
|
.\" 3. The name of the author may not be used to endorse or promote
|
||||||
|
.\" products derived from this software without specific prior written
|
||||||
|
.\" permission.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
.\" SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.Dd May 15, 2022
|
||||||
|
.Dt CRYB_MD4 3
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm cryb_md4_init ,
|
||||||
|
.Nm cryb_md4_update ,
|
||||||
|
.Nm cryb_md4_final ,
|
||||||
|
.Nm cryb_md4_complete
|
||||||
|
.Nd Message-Digest Algorithm 2
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libcryb-digest
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In stddef.h
|
||||||
|
.In stdint.h
|
||||||
|
.In cryb/md4.h
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md4_init "cryb_md4_ctx *context"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md4_update "cryb_md4_ctx *context" "const void *data" "size_t len"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md4_final "cryb_md4_ctx *context" "uint8_t *digest"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md4_complete "const void *data" "size_t len" "uint8_t *digest"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Nm cryb_md4
|
||||||
|
family of functions implements the MD4 message digest algorithm as
|
||||||
|
described in RFC 1320.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md4_init
|
||||||
|
function initializes the context structure pointed to by
|
||||||
|
.Va context .
|
||||||
|
It is the caller's responsibility to allocate this structure.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md4_update
|
||||||
|
function hashes the next
|
||||||
|
.Va len
|
||||||
|
bytes of data pointed to by the
|
||||||
|
.Va data
|
||||||
|
pointer into the given hash context.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md4_final
|
||||||
|
function finalizes the computation and writes the resulting message
|
||||||
|
digest to the caller-provided buffer pointed to by
|
||||||
|
.Va digest ,
|
||||||
|
which must be at least
|
||||||
|
.Dv MD4_DIGEST_LEN
|
||||||
|
bytes long.
|
||||||
|
It is the caller's responsibility to dispose of the context structure
|
||||||
|
after calling
|
||||||
|
.Fn cryb_md4_final .
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md4_complete
|
||||||
|
function is a shortcut to calling
|
||||||
|
.Fn cryb_md4_init ,
|
||||||
|
.Fn cryb_md4_update ,
|
||||||
|
and
|
||||||
|
.Fn cryb_md4_final
|
||||||
|
when the entire message is available up front in a single contiguous
|
||||||
|
buffer.
|
||||||
|
.Sh IMPLEMENTATION NOTES
|
||||||
|
The
|
||||||
|
.In cryb/md4.h
|
||||||
|
header provides macros which allows these functions and the context
|
||||||
|
type to be referred to without their
|
||||||
|
.Dq Li cryb_
|
||||||
|
prefix.
|
||||||
|
.Pp
|
||||||
|
The MD4 message digest algorithm has been proven to be vulnerable to
|
||||||
|
collision attacks and should not be used for cryptographic purposes.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr cryb_digest 3 ,
|
||||||
|
.Xr cryb_md2 3 ,
|
||||||
|
.Xr cryb_md5 3
|
||||||
|
.Sh REFERENCES
|
||||||
|
.Rs
|
||||||
|
.%A Rivest, Ronald
|
||||||
|
.%T The MD4 Message-Digest Algorithm
|
||||||
|
.%D April 1992
|
||||||
|
.%O RFC 1320
|
||||||
|
.%U https://datatracker.ietf.org/doc/html/rfc1320
|
||||||
|
.Re
|
||||||
|
.Rs
|
||||||
|
.%A Turner, Sean
|
||||||
|
.%A Chen, Lily
|
||||||
|
.%T MD4 to Historic Status
|
||||||
|
.%D March 2011
|
||||||
|
.%O RFC 6150
|
||||||
|
.%U https://datatracker.ietf.org/doc/html/rfc6150
|
||||||
|
.Re
|
||||||
|
.Sh AUTHORS
|
||||||
|
These functions and this manual page were written by
|
||||||
|
.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
|
125
lib/digest/cryb_md5.3
Normal file
125
lib/digest/cryb_md5.3
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
.\"-
|
||||||
|
.\" Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
|
.\" All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
|
.\" 3. The name of the author may not be used to endorse or promote
|
||||||
|
.\" products derived from this software without specific prior written
|
||||||
|
.\" permission.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
.\" SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.Dd May 15, 2022
|
||||||
|
.Dt CRYB_MD5 3
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm cryb_md5_init ,
|
||||||
|
.Nm cryb_md5_update ,
|
||||||
|
.Nm cryb_md5_final ,
|
||||||
|
.Nm cryb_md5_complete
|
||||||
|
.Nd Message-Digest Algorithm 2
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libcryb-digest
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In stddef.h
|
||||||
|
.In stdint.h
|
||||||
|
.In cryb/md5.h
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md5_init "cryb_md5_ctx *context"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md5_update "cryb_md5_ctx *context" "const void *data" "size_t len"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md5_final "cryb_md5_ctx *context" "uint8_t *digest"
|
||||||
|
.Ft void
|
||||||
|
.Fn cryb_md5_complete "const void *data" "size_t len" "uint8_t *digest"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Nm cryb_md5
|
||||||
|
family of functions implements the MD5 message digest algorithm as
|
||||||
|
described in RFC 1321.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md5_init
|
||||||
|
function initializes the context structure pointed to by
|
||||||
|
.Va context .
|
||||||
|
It is the caller's responsibility to allocate this structure.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md5_update
|
||||||
|
function hashes the next
|
||||||
|
.Va len
|
||||||
|
bytes of data pointed to by the
|
||||||
|
.Va data
|
||||||
|
pointer into the given hash context.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md5_final
|
||||||
|
function finalizes the computation and writes the resulting message
|
||||||
|
digest to the caller-provided buffer pointed to by
|
||||||
|
.Va digest ,
|
||||||
|
which must be at least
|
||||||
|
.Dv MD5_DIGEST_LEN
|
||||||
|
bytes long.
|
||||||
|
It is the caller's responsibility to dispose of the context structure
|
||||||
|
after calling
|
||||||
|
.Fn cryb_md5_final .
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_md5_complete
|
||||||
|
function is a shortcut to calling
|
||||||
|
.Fn cryb_md5_init ,
|
||||||
|
.Fn cryb_md5_update ,
|
||||||
|
and
|
||||||
|
.Fn cryb_md5_final
|
||||||
|
when the entire message is available up front in a single contiguous
|
||||||
|
buffer.
|
||||||
|
.Sh IMPLEMENTATION NOTES
|
||||||
|
The
|
||||||
|
.In cryb/md5.h
|
||||||
|
header provides macros which allows these functions and the context
|
||||||
|
type to be referred to without their
|
||||||
|
.Dq Li cryb_
|
||||||
|
prefix.
|
||||||
|
.Pp
|
||||||
|
The MD5 message digest algorithm has been proven to be vulnerable to
|
||||||
|
collision attacks and should not be used for cryptographic purposes.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr cryb_digest 3 ,
|
||||||
|
.Xr cryb_md2 3 ,
|
||||||
|
.Xr cryb_md4 3
|
||||||
|
.Sh REFERENCES
|
||||||
|
.Rs
|
||||||
|
.%A Rivest, Ronald
|
||||||
|
.%T The MD5 Message-Digest Algorithm
|
||||||
|
.%D April 1992
|
||||||
|
.%O RFC 1321
|
||||||
|
.%U https://datatracker.ietf.org/doc/html/rfc1321
|
||||||
|
.Re
|
||||||
|
.Rs
|
||||||
|
.%A Turner, Sean
|
||||||
|
.%A Chen, Lily
|
||||||
|
.%T Updated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 Algorithms
|
||||||
|
.%D March 2011
|
||||||
|
.%O RFC 6151
|
||||||
|
.%U https://datatracker.ietf.org/doc/html/rfc6151
|
||||||
|
.Re
|
||||||
|
.Sh AUTHORS
|
||||||
|
These functions and this manual page were written by
|
||||||
|
.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
|
|
@ -1,6 +1,6 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2015 The University of Oslo
|
.\" Copyright (c) 2015 The University of Oslo
|
||||||
.\" Copyright (c) 2016 Dag-Erling Smørgrav
|
.\" Copyright (c) 2016-2022 Dag-Erling Smørgrav
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 17, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_SHA1 3
|
.Dt CRYB_SHA1 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -86,7 +86,7 @@ The
|
||||||
.Fn cryb_sha1_complete
|
.Fn cryb_sha1_complete
|
||||||
function is a shortcut to calling
|
function is a shortcut to calling
|
||||||
.Fn cryb_sha1_init ,
|
.Fn cryb_sha1_init ,
|
||||||
.Fn cryb_sha1_update
|
.Fn cryb_sha1_update ,
|
||||||
and
|
and
|
||||||
.Fn cryb_sha1_final
|
.Fn cryb_sha1_final
|
||||||
when the entire message is available up front in a single contiguous
|
when the entire message is available up front in a single contiguous
|
||||||
|
@ -114,6 +114,7 @@ collision attacks and should not be used for cryptographic purposes.
|
||||||
.%D March 2012
|
.%D March 2012
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
These functions and this manual page were written for the University
|
These functions and this manual page were written for the University
|
||||||
of Oslo by
|
of Oslo by
|
||||||
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2015 The University of Oslo
|
.\" Copyright (c) 2015 The University of Oslo
|
||||||
.\" Copyright (c) 2016 Dag-Erling Smørgrav
|
.\" Copyright (c) 2016-2022 Dag-Erling Smørgrav
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 17, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_SHA224 3
|
.Dt CRYB_SHA224 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -86,7 +86,7 @@ The
|
||||||
.Fn cryb_sha224_complete
|
.Fn cryb_sha224_complete
|
||||||
function is a shortcut to calling
|
function is a shortcut to calling
|
||||||
.Fn cryb_sha224_init ,
|
.Fn cryb_sha224_init ,
|
||||||
.Fn cryb_sha224_update
|
.Fn cryb_sha224_update ,
|
||||||
and
|
and
|
||||||
.Fn cryb_sha224_final
|
.Fn cryb_sha224_final
|
||||||
when the entire message is available up front in a single contiguous
|
when the entire message is available up front in a single contiguous
|
||||||
|
@ -111,6 +111,7 @@ prefix.
|
||||||
.%D March 2012
|
.%D March 2012
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
These functions and this manual page were written for the University
|
These functions and this manual page were written for the University
|
||||||
of Oslo by
|
of Oslo by
|
||||||
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2015 The University of Oslo
|
.\" Copyright (c) 2015 The University of Oslo
|
||||||
.\" Copyright (c) 2016 Dag-Erling Smørgrav
|
.\" Copyright (c) 2016-2022 Dag-Erling Smørgrav
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 17, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_SHA256 3
|
.Dt CRYB_SHA256 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -86,7 +86,7 @@ The
|
||||||
.Fn cryb_sha256_complete
|
.Fn cryb_sha256_complete
|
||||||
function is a shortcut to calling
|
function is a shortcut to calling
|
||||||
.Fn cryb_sha256_init ,
|
.Fn cryb_sha256_init ,
|
||||||
.Fn cryb_sha256_update
|
.Fn cryb_sha256_update ,
|
||||||
and
|
and
|
||||||
.Fn cryb_sha256_final
|
.Fn cryb_sha256_final
|
||||||
when the entire message is available up front in a single contiguous
|
when the entire message is available up front in a single contiguous
|
||||||
|
@ -111,6 +111,7 @@ prefix.
|
||||||
.%D March 2012
|
.%D March 2012
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
These functions and this manual page were written for the University
|
These functions and this manual page were written for the University
|
||||||
of Oslo by
|
of Oslo by
|
||||||
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2015 The University of Oslo
|
.\" Copyright (c) 2015 The University of Oslo
|
||||||
.\" Copyright (c) 2016 Dag-Erling Smørgrav
|
.\" Copyright (c) 2016-2022 Dag-Erling Smørgrav
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 17, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_SHA384 3
|
.Dt CRYB_SHA384 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -86,7 +86,7 @@ The
|
||||||
.Fn cryb_sha384_complete
|
.Fn cryb_sha384_complete
|
||||||
function is a shortcut to calling
|
function is a shortcut to calling
|
||||||
.Fn cryb_sha384_init ,
|
.Fn cryb_sha384_init ,
|
||||||
.Fn cryb_sha384_update
|
.Fn cryb_sha384_update ,
|
||||||
and
|
and
|
||||||
.Fn cryb_sha384_final
|
.Fn cryb_sha384_final
|
||||||
when the entire message is available up front in a single contiguous
|
when the entire message is available up front in a single contiguous
|
||||||
|
@ -111,6 +111,7 @@ prefix.
|
||||||
.%D March 2012
|
.%D March 2012
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
These functions and this manual page were written for the University
|
These functions and this manual page were written for the University
|
||||||
of Oslo by
|
of Oslo by
|
||||||
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2015 The University of Oslo
|
.\" Copyright (c) 2015 The University of Oslo
|
||||||
.\" Copyright (c) 2016 Dag-Erling Smørgrav
|
.\" Copyright (c) 2016-2022 Dag-Erling Smørgrav
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 17, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_SHA512 3
|
.Dt CRYB_SHA512 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -86,7 +86,7 @@ The
|
||||||
.Fn cryb_sha512_complete
|
.Fn cryb_sha512_complete
|
||||||
function is a shortcut to calling
|
function is a shortcut to calling
|
||||||
.Fn cryb_sha512_init ,
|
.Fn cryb_sha512_init ,
|
||||||
.Fn cryb_sha512_update
|
.Fn cryb_sha512_update ,
|
||||||
and
|
and
|
||||||
.Fn cryb_sha512_final
|
.Fn cryb_sha512_final
|
||||||
when the entire message is available up front in a single contiguous
|
when the entire message is available up front in a single contiguous
|
||||||
|
@ -111,6 +111,7 @@ prefix.
|
||||||
.%D March 2012
|
.%D March 2012
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
These functions and this manual page were written for the University
|
These functions and this manual page were written for the University
|
||||||
of Oslo by
|
of Oslo by
|
||||||
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2014-2016 Dag-Erling Smørgrav
|
.\" Copyright (c) 2014-2022 Dag-Erling Smørgrav
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd January 10, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_PERCENT 3
|
.Dt CRYB_PERCENT 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -129,14 +129,15 @@ prefix.
|
||||||
.Xr cryb_base64 3
|
.Xr cryb_base64 3
|
||||||
.Sh REFERENCES
|
.Sh REFERENCES
|
||||||
.Rs
|
.Rs
|
||||||
.%A "Berners-Lee, T."
|
.%A Berners-Lee, T.
|
||||||
.%A "Fielding, R."
|
.%A Fielding, R.
|
||||||
.%A "Masinter, L."
|
.%A Masinter, L.
|
||||||
.%D "January 2005"
|
.%R Uniform Resource Identifier (URI): Generic Syntax
|
||||||
.%R "Uniform Resource Identifier (URI): Generic Syntax"
|
.%D January 2005
|
||||||
.%O "RFC 3968"
|
.%O RFC 3968
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
The
|
The
|
||||||
.Fn cryb_percent_decode
|
.Fn cryb_percent_decode
|
||||||
and
|
and
|
||||||
|
|
|
@ -7,6 +7,7 @@ libcryb_hash_la_SOURCES = \
|
||||||
cryb_fletcher16.c \
|
cryb_fletcher16.c \
|
||||||
cryb_fletcher32.c \
|
cryb_fletcher32.c \
|
||||||
cryb_fletcher64.c \
|
cryb_fletcher64.c \
|
||||||
|
cryb_fnv.c \
|
||||||
cryb_murmur3_32.c \
|
cryb_murmur3_32.c \
|
||||||
cryb_pearson.c \
|
cryb_pearson.c \
|
||||||
\
|
\
|
||||||
|
@ -15,10 +16,15 @@ libcryb_hash_la_SOURCES = \
|
||||||
dist_man3_MANS = \
|
dist_man3_MANS = \
|
||||||
cryb_adler32.3 \
|
cryb_adler32.3 \
|
||||||
cryb_fletcher.3 \
|
cryb_fletcher.3 \
|
||||||
|
cryb_fnv.3 \
|
||||||
|
cryb_murmur3.3 \
|
||||||
cryb_pearson.3 \
|
cryb_pearson.3 \
|
||||||
\
|
\
|
||||||
cryb_hash.3
|
cryb_hash.3
|
||||||
|
|
||||||
|
noinst_HEADERS = \
|
||||||
|
cryb_fnv_impl.h
|
||||||
|
|
||||||
libcryb_hash_la_CFLAGS = \
|
libcryb_hash_la_CFLAGS = \
|
||||||
$(CRYB_CORE_CFLAGS)
|
$(CRYB_CORE_CFLAGS)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2015-2016 The University of Oslo
|
.\" Copyright (c) 2016-2022 Dag-Erling Smørgrav
|
||||||
.\" Copyright (c) 2016 Dag-Erling Smørgrav
|
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,12 +26,12 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd January 8, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_ADLER32 3
|
.Dt CRYB_ADLER32 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm cryb_adler32_hash
|
.Nm cryb_adler32_hash
|
||||||
.Nd hash functions
|
.Nd non-cryptographic hash functions
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libcryb-hash
|
.Lb libcryb-hash
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
|
@ -65,13 +64,14 @@ prefix.
|
||||||
.Xr cryb_hash 3
|
.Xr cryb_hash 3
|
||||||
.Sh REFERENCES
|
.Sh REFERENCES
|
||||||
.Rs
|
.Rs
|
||||||
.%A "Deutsch, P."
|
.%A Deutsch, P.
|
||||||
.%A "Gailly, J.-L."
|
.%A Gailly, J.-L.
|
||||||
.%D "May 1996"
|
.%D May 1996
|
||||||
.%R "ZLIB Compressed Data Format Specification version 3.3"
|
.%R ZLIB Compressed Data Format Specification version 3.3
|
||||||
.%O "RFC 1950"
|
.%O RFC 1950
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
The
|
The
|
||||||
.Fn cryb_adler32_hash
|
.Fn cryb_adler32_hash
|
||||||
function and this manual page were written by
|
function and this manual page were written by
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
.Nm cryb_fletcher16_hash ,
|
.Nm cryb_fletcher16_hash ,
|
||||||
.Nm cryb_fletcher32_hash ,
|
.Nm cryb_fletcher32_hash ,
|
||||||
.Nm cryb_fletcher64_hash
|
.Nm cryb_fletcher64_hash
|
||||||
.Nd hash functions
|
.Nd non-cryptographic hash functions
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libcryb-hash
|
.Lb libcryb-hash
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
|
@ -41,11 +41,11 @@
|
||||||
.In stdint.h
|
.In stdint.h
|
||||||
.In cryb/hash.h
|
.In cryb/hash.h
|
||||||
.Ft uint16_t
|
.Ft uint16_t
|
||||||
.Fn fletcher16_hash "const void *data" "size_t len"
|
.Fn cryb_fletcher16_hash "const void *data" "size_t len"
|
||||||
.Ft uint32_t
|
.Ft uint32_t
|
||||||
.Fn fletcher32_hash "const void *data" "size_t len"
|
.Fn cryb_fletcher32_hash "const void *data" "size_t len"
|
||||||
.Ft uint64_t
|
.Ft uint64_t
|
||||||
.Fn fletcher64_hash "const void *data" "size_t len"
|
.Fn cryb_fletcher64_hash "const void *data" "size_t len"
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Fn cryb_fletcher16_hash ,
|
.Fn cryb_fletcher16_hash ,
|
||||||
|
@ -75,16 +75,17 @@ argument before calling the checksum function.
|
||||||
.Xr cryb_hash 3
|
.Xr cryb_hash 3
|
||||||
.Sh STANDARDS
|
.Sh STANDARDS
|
||||||
.Rs
|
.Rs
|
||||||
.%A "Fletcher, John G."
|
.%A Fletcher, John G.
|
||||||
.%D "January 1982"
|
.%T An Arithmetic Checksum for Serial Transmissions
|
||||||
.%T "An Arithmetic Checksum for Serial Transmissions"
|
.%J IEEE Transactions on Communications
|
||||||
.%J "IEEE Transactions on Communications"
|
.%V 30
|
||||||
.%V "30"
|
.%N 1
|
||||||
.%N "1"
|
.%P 247-252
|
||||||
.%P "247-252"
|
.%D January 1982
|
||||||
.%O "doi:10.1109/tcom.1982.1095369"
|
.%O doi:10.1109/tcom.1982.1095369
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
The
|
The
|
||||||
.Fn cryb_fletcher16 ,
|
.Fn cryb_fletcher16 ,
|
||||||
.Fn cryb_fletcher32
|
.Fn cryb_fletcher32
|
||||||
|
|
107
lib/hash/cryb_fnv.3
Normal file
107
lib/hash/cryb_fnv.3
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
.\"-
|
||||||
|
.\" Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
|
.\" All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
|
.\" 3. The name of the author may not be used to endorse or promote
|
||||||
|
.\" products derived from this software without specific prior written
|
||||||
|
.\" permission.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
.\" SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.Dd May 15, 2022
|
||||||
|
.Dt CRYB_FNV 3
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm cryb_fnv0_32_hash ,
|
||||||
|
.Nm cryb_fnv0_64_hash ,
|
||||||
|
.Nm cryb_fnv1_32_hash ,
|
||||||
|
.Nm cryb_fnv1_64_hash ,
|
||||||
|
.Nm cryb_fnv1a_32_hash ,
|
||||||
|
.Nm cryb_fnv1a_64_hash
|
||||||
|
.Nd non-cryptographic hash functions
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libcryb-hash
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In stddef.h
|
||||||
|
.In stdint.h
|
||||||
|
.In cryb/hash.h
|
||||||
|
.Ft uint32_t
|
||||||
|
.Fn cryb_fnv0_32_hash "const void *data" "size_t len"
|
||||||
|
.Ft uint64_t
|
||||||
|
.Fn cryb_fnv0_64_hash "const void *data" "size_t len"
|
||||||
|
.Ft uint32_t
|
||||||
|
.Fn cryb_fnv1_32_hash "const void *data" "size_t len"
|
||||||
|
.Ft uint64_t
|
||||||
|
.Fn cryb_fnv1_64_hash "const void *data" "size_t len"
|
||||||
|
.Ft uint32_t
|
||||||
|
.Fn cryb_fnv1a_32_hash "const void *data" "size_t len"
|
||||||
|
.Ft uint64_t
|
||||||
|
.Fn cryb_fnv1a_64_hash "const void *data" "size_t len"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Fn cryb_fnv0_32_hash ,
|
||||||
|
.Fn cryb_fnv1_32_hash ,
|
||||||
|
and
|
||||||
|
.Fn cryb_fnv1a_32_hash ,
|
||||||
|
functions return a 32-bit hash of the
|
||||||
|
.Va len
|
||||||
|
first bytes of the object pointed to by
|
||||||
|
.Va data
|
||||||
|
using the Fowler-Noll-Vo (FNV) 0, 1, and 1a algorithms respectively.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Fn cryb_fnv0_64_hash ,
|
||||||
|
.Fn cryb_fnv1_64_hash ,
|
||||||
|
and
|
||||||
|
.Fn cryb_fnv1a_64_hash ,
|
||||||
|
functions return a 64-bit hash of the
|
||||||
|
.Va len
|
||||||
|
first bytes of the object pointed to by
|
||||||
|
.Va data
|
||||||
|
using the FNV 0, 1, and 1a algorithms respectively.
|
||||||
|
.Sh IMPLEMENTATION NOTES
|
||||||
|
The
|
||||||
|
.In cryb/hash.h
|
||||||
|
header provides macros which allows these functions to be referred to
|
||||||
|
without their
|
||||||
|
.Dq Li cryb_
|
||||||
|
prefix.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr cryb_hash 3
|
||||||
|
.Sh STANDARDS
|
||||||
|
.Rs
|
||||||
|
.%A Fowler, Glenn
|
||||||
|
.%A Noll, Landon Curt
|
||||||
|
.%A Vo, Kiem-Phong
|
||||||
|
.%A Eastlake, Donald
|
||||||
|
.%A Hansen, Tony
|
||||||
|
.%T The FNV Non-Cryptographic Hash Algorithm
|
||||||
|
.%D May 29, 2019
|
||||||
|
.%O draft-eastlake-fnv-17
|
||||||
|
.%U https://datatracker.ietf.org/doc/html/draft-eastlake-fnv-17
|
||||||
|
.Re
|
||||||
|
.Sh AUTHORS
|
||||||
|
The
|
||||||
|
.Fn cryb_pearson_hash
|
||||||
|
and
|
||||||
|
.Fn cryb_pearson_hash_str
|
||||||
|
functions and this manual page were written by
|
||||||
|
.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
|
113
lib/hash/cryb_fnv.c
Normal file
113
lib/hash/cryb_fnv.c
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <cryb/hash.h>
|
||||||
|
|
||||||
|
#include "cryb_fnv_impl.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implementations of the 32- and 64-bit Fowler-Noll-Vo (FNV) 0, 1, and 1a hashes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint32_t fnv0_32_hash(const void *data, size_t len)
|
||||||
|
{
|
||||||
|
const uint8_t *p;
|
||||||
|
uint32_t h;
|
||||||
|
|
||||||
|
for (p = data, h = 0; len > 0; ++p, --len) {
|
||||||
|
h *= FNV_32_PRIME;
|
||||||
|
h ^= *p;
|
||||||
|
}
|
||||||
|
return (h);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t fnv0_64_hash(const void *data, size_t len)
|
||||||
|
{
|
||||||
|
const uint8_t *p;
|
||||||
|
uint64_t h;
|
||||||
|
|
||||||
|
for (p = data, h = 0; len > 0; ++p, --len) {
|
||||||
|
h *= FNV_64_PRIME;
|
||||||
|
h ^= *p;
|
||||||
|
}
|
||||||
|
return (h);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t fnv1_32_hash(const void *data, size_t len)
|
||||||
|
{
|
||||||
|
const uint8_t *p;
|
||||||
|
uint32_t h;
|
||||||
|
|
||||||
|
for (p = data, h = FNV_32_OFFSET_BASIS; len > 0; ++p, --len) {
|
||||||
|
h *= FNV_32_PRIME;
|
||||||
|
h ^= *p;
|
||||||
|
}
|
||||||
|
return (h);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t fnv1_64_hash(const void *data, size_t len)
|
||||||
|
{
|
||||||
|
const uint8_t *p;
|
||||||
|
uint64_t h;
|
||||||
|
|
||||||
|
for (p = data, h = FNV_64_OFFSET_BASIS; len > 0; ++p, --len) {
|
||||||
|
h *= FNV_64_PRIME;
|
||||||
|
h ^= *p;
|
||||||
|
}
|
||||||
|
return (h);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t fnv1a_32_hash(const void *data, size_t len)
|
||||||
|
{
|
||||||
|
const uint8_t *p;
|
||||||
|
uint32_t h;
|
||||||
|
|
||||||
|
for (p = data, h = FNV_32_OFFSET_BASIS; len > 0; ++p, --len) {
|
||||||
|
h ^= *p;
|
||||||
|
h *= FNV_32_PRIME;
|
||||||
|
}
|
||||||
|
return (h);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t fnv1a_64_hash(const void *data, size_t len)
|
||||||
|
{
|
||||||
|
const uint8_t *p;
|
||||||
|
uint64_t h;
|
||||||
|
|
||||||
|
for (p = data, h = FNV_64_OFFSET_BASIS; len > 0; ++p, --len) {
|
||||||
|
h ^= *p;
|
||||||
|
h *= FNV_64_PRIME;
|
||||||
|
}
|
||||||
|
return (h);
|
||||||
|
}
|
36
lib/hash/cryb_fnv_impl.h
Normal file
36
lib/hash/cryb_fnv_impl.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define FNV_32_PRIME 0x01000193UL
|
||||||
|
#define FNV_32_OFFSET_BASIS 0x811c9dc5UL
|
||||||
|
|
||||||
|
#define FNV_64_PRIME 0x00000100000001B3ULL
|
||||||
|
#define FNV_64_OFFSET_BASIS 0xcbf29ce484222325ULL
|
||||||
|
|
||||||
|
#define FNV_SIGNATURE "chongo <Landon Curt Noll> /\\../\\"
|
|
@ -1,5 +1,5 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2016 Dag-Erling Smørgrav
|
.\" Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -26,18 +26,12 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 17, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_HASH 3
|
.Dt CRYB_HASH 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm cryb_hash_version ,
|
.Nm cryb_hash_version
|
||||||
.Nm cryb_adler32_hash ,
|
.Nd non-cryptographic hash function library
|
||||||
.Nm cryb_fletcher16_hash ,
|
|
||||||
.Nm cryb_fletcher32_hash ,
|
|
||||||
.Nm cryb_fletcher64_hash ,
|
|
||||||
.Nm cryb_pearson_hash ,
|
|
||||||
.Nm cryb_pearson_hash_str
|
|
||||||
.Nd hash and checksum functions
|
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libcryb-hash
|
.Lb libcryb-hash
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
|
@ -46,18 +40,6 @@
|
||||||
.In cryb/hash.h
|
.In cryb/hash.h
|
||||||
.Ft const char *
|
.Ft const char *
|
||||||
.Fn cryb_hash_version "void"
|
.Fn cryb_hash_version "void"
|
||||||
.Ft uint32_t
|
|
||||||
.Fn cryb_adler32_hash "const void *data" "size_t len"
|
|
||||||
.Ft uint16_t
|
|
||||||
.Fn fletcher16_hash "const void *data" "size_t len"
|
|
||||||
.Ft uint32_t
|
|
||||||
.Fn fletcher32_hash "const void *data" "size_t len"
|
|
||||||
.Ft uint64_t
|
|
||||||
.Fn fletcher64_hash "const void *data" "size_t len"
|
|
||||||
.Ft uint8_t
|
|
||||||
.Fn cryb_pearson_hash "const void *data" "size_t len"
|
|
||||||
.Ft uint8_t
|
|
||||||
.Fn cryb_pearson_hash_str "const char *str"
|
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Fn cryb_hash_version
|
.Fn cryb_hash_version
|
||||||
|
@ -71,22 +53,10 @@ respective manual pages.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr cryb_adler32 3 ,
|
.Xr cryb_adler32 3 ,
|
||||||
.Xr cryb_fletcher 3 ,
|
.Xr cryb_fletcher 3 ,
|
||||||
|
.Xr cryb_fnv 3 ,
|
||||||
|
.Xr cryb_murmur3 ,
|
||||||
.Xr cryb_pearson 3
|
.Xr cryb_pearson 3
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
The
|
.An -nosplit
|
||||||
.Fn cryb_hash_version ,
|
This manual page was written by
|
||||||
.Fn cryb_adler32_hash ,
|
|
||||||
.Fn cryb_fletcher16 ,
|
|
||||||
.Fn cryb_fletcher32
|
|
||||||
and
|
|
||||||
.Fn cryb_fletcher64
|
|
||||||
functions and corresponding manual pages were written by
|
|
||||||
.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
|
.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn cryb_pearson_hash
|
|
||||||
and
|
|
||||||
.Fn cryb_pearson_hash_str
|
|
||||||
functions and corresponding manual pages were written for the
|
|
||||||
University of Oslo by
|
|
||||||
.An Dag-Erling Sm\(/orgrav Aq Mt d.e.smorgrav@usit.uio.no .
|
|
||||||
|
|
64
lib/hash/cryb_murmur3.3
Normal file
64
lib/hash/cryb_murmur3.3
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
.\"-
|
||||||
|
.\" Copyright (c) 2022 Dag-Erling Smørgrav
|
||||||
|
.\" All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
|
.\" 3. The name of the author may not be used to endorse or promote
|
||||||
|
.\" products derived from this software without specific prior written
|
||||||
|
.\" permission.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
.\" SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.Dd May 15, 2022
|
||||||
|
.Dt CRYB_MURMUR3 3
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm cryb_murmur3_32_hash
|
||||||
|
.Nd non-cryptographic hash function
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libcryb-hash
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In stddef.h
|
||||||
|
.In stdint.h
|
||||||
|
.In cryb/hash.h
|
||||||
|
.Ft uint32_t
|
||||||
|
.Fn murmur3_32_hash "const void *data" "size_t len" "uint32_t seed"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Fn cryb_murmur3_32_hash
|
||||||
|
function returns a 32-bit hash of the
|
||||||
|
.Va len
|
||||||
|
first bytes of the object pointed to by
|
||||||
|
.Va data
|
||||||
|
using the 32-bit MurmurHash3 algorithm.
|
||||||
|
.Sh IMPLEMENTATION NOTES
|
||||||
|
The
|
||||||
|
.In cryb/hash.h
|
||||||
|
header provides macros which allows these functions to be referred to
|
||||||
|
without their
|
||||||
|
.Dq Li cryb_
|
||||||
|
prefix.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr cryb_hash 3
|
||||||
|
.Sh AUTHORS
|
||||||
|
The
|
||||||
|
.Fn cryb_murmur3_32_hash
|
||||||
|
function and this manual page were written by
|
||||||
|
.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
|
|
@ -1,6 +1,6 @@
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright (c) 2015-2016 The University of Oslo
|
.\" Copyright (c) 2015-2016 The University of Oslo
|
||||||
.\" Copyright (c) 2016 Dag-Erling Smørgrav
|
.\" Copyright (c) 2016-2022 Dag-Erling Smørgrav
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,13 +27,13 @@
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 17, 2016
|
.Dd May 15, 2022
|
||||||
.Dt CRYB_PEARSON_HASH 3
|
.Dt CRYB_PEARSON 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm cryb_pearson_hash ,
|
.Nm cryb_pearson_hash ,
|
||||||
.Nm cryb_pearson_hash_str
|
.Nm cryb_pearson_hash_str
|
||||||
.Nd hash functions
|
.Nd non-cryptographic hash functions
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libcryb-hash
|
.Lb libcryb-hash
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
|
@ -71,16 +71,17 @@ prefix.
|
||||||
.Xr cryb_hash 3
|
.Xr cryb_hash 3
|
||||||
.Sh STANDARDS
|
.Sh STANDARDS
|
||||||
.Rs
|
.Rs
|
||||||
.%A "Pearson, Peter K."
|
.%A Pearson, Peter K.
|
||||||
.%D "June 1990"
|
.%T Fast Hashing of Variable-Length Text Strings
|
||||||
.%T "Fast Hashing of Variable-Length Text Strings"
|
.%J Communications of the ACM
|
||||||
.%J "Communications of the ACM"
|
.%V 33
|
||||||
.%V "33"
|
.%N 6
|
||||||
.%N "6"
|
.%P 677
|
||||||
.%P "677"
|
.%D June 1990
|
||||||
.%O "doi:10.1145/78973.78978"
|
.%O doi:10.1145/78973.78978
|
||||||
.Re
|
.Re
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An -nosplit
|
||||||
The
|
The
|
||||||
.Fn cryb_pearson_hash
|
.Fn cryb_pearson_hash
|
||||||
and
|
and
|
||||||
|
|
1
t/.gitignore
vendored
1
t/.gitignore
vendored
|
@ -12,6 +12,7 @@
|
||||||
/t_endian
|
/t_endian
|
||||||
/t_ffs_fls
|
/t_ffs_fls
|
||||||
/t_fletcher
|
/t_fletcher
|
||||||
|
/t_fnv
|
||||||
/t_hash
|
/t_hash
|
||||||
/t_hmac_sha1
|
/t_hmac_sha1
|
||||||
/t_hmac_sha1_openssl
|
/t_hmac_sha1_openssl
|
||||||
|
|
|
@ -179,9 +179,11 @@ endif CRYB_ENC
|
||||||
if CRYB_HASH
|
if CRYB_HASH
|
||||||
TESTS += t_hash
|
TESTS += t_hash
|
||||||
t_hash_LDADD = $(libt) $(libhash)
|
t_hash_LDADD = $(libt) $(libhash)
|
||||||
TESTS += t_adler t_fletcher t_murmur3_32 t_pearson
|
TESTS += t_adler t_fletcher t_fnv t_murmur3_32 t_pearson
|
||||||
t_adler_LDADD = $(libt) $(libhash)
|
t_adler_LDADD = $(libt) $(libhash)
|
||||||
t_fletcher_LDADD = $(libt) $(libhash)
|
t_fletcher_LDADD = $(libt) $(libhash)
|
||||||
|
t_fnv_CFLAGS = -I$(top_srcdir)/lib/hash
|
||||||
|
t_fnv_LDADD = $(libt) $(libhash)
|
||||||
t_murmur3_32_LDADD = $(libt) $(libhash)
|
t_murmur3_32_LDADD = $(libt) $(libhash)
|
||||||
t_pearson_LDADD = $(libt) $(libhash)
|
t_pearson_LDADD = $(libt) $(libhash)
|
||||||
endif CRYB_HASH
|
endif CRYB_HASH
|
||||||
|
|
151
t/t_fnv.c
Normal file
151
t/t_fnv.c
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2014-2022 Dag-Erling Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cryb/impl.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <cryb/hash.h>
|
||||||
|
|
||||||
|
#include <cryb/test.h>
|
||||||
|
|
||||||
|
#include "cryb_fnv_impl.h"
|
||||||
|
|
||||||
|
struct t_case {
|
||||||
|
const char *str;
|
||||||
|
uint32_t h0_32, h1_32, h1a_32;
|
||||||
|
uint64_t h0_64, h1_64, h1a_64;
|
||||||
|
};
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Test cases
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test vectors from the IETF draft, expanded to also cover FNV-0 and FNV-1.
|
||||||
|
*/
|
||||||
|
static struct t_case t_cases[] = {
|
||||||
|
{
|
||||||
|
.str = "",
|
||||||
|
.h0_32 = 0x00000000UL,
|
||||||
|
.h1_32 = 0x811c9dc5UL,
|
||||||
|
.h1a_32 = 0x811c9dc5UL,
|
||||||
|
.h0_64 = 0x0000000000000000ULL,
|
||||||
|
.h1_64 = 0xcbf29ce484222325ULL,
|
||||||
|
.h1a_64 = 0xcbf29ce484222325ULL,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.str = "a",
|
||||||
|
.h0_32 = 0x00000061UL,
|
||||||
|
.h1_32 = 0x050c5d7eUL,
|
||||||
|
.h1a_32 = 0xe40c292cUL,
|
||||||
|
.h0_64 = 0x0000000000000061ULL,
|
||||||
|
.h1_64 = 0xaf63bd4c8601b7beULL,
|
||||||
|
.h1a_64 = 0xaf63dc4c8601ec8cULL,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.str = "foobar",
|
||||||
|
.h0_32 = 0xb74bb5efUL,
|
||||||
|
.h1_32 = 0x31f0b262UL,
|
||||||
|
.h1a_32 = 0xbf9cf968UL,
|
||||||
|
.h0_64 = 0x0b91ae3f7ccdc5efULL,
|
||||||
|
.h1_64 = 0x340d8765a4dda9c2ULL,
|
||||||
|
.h1a_64 = 0x85944171f73967e8ULL,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test case for the 32- and 64-bit offset bases.
|
||||||
|
*/
|
||||||
|
static struct t_case t_offset_basis = {
|
||||||
|
.str = FNV_SIGNATURE,
|
||||||
|
.h0_32 = FNV_32_OFFSET_BASIS,
|
||||||
|
.h0_64 = FNV_64_OFFSET_BASIS,
|
||||||
|
};
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Test functions
|
||||||
|
*/
|
||||||
|
#define T_FNV(V, B) \
|
||||||
|
static int \
|
||||||
|
t_fnv##V##_##B(char **desc, void *arg) \
|
||||||
|
{ \
|
||||||
|
struct t_case *t = arg; \
|
||||||
|
uint##B##_t h; \
|
||||||
|
\
|
||||||
|
if (!**desc) { \
|
||||||
|
(void)asprintf(desc, \
|
||||||
|
"FNV-" #V "-" #B " \"%s\"", t->str); \
|
||||||
|
} \
|
||||||
|
h = fnv##V##_##B##_hash(t->str, strlen(t->str)); \
|
||||||
|
return (t_compare_x##B(t->h##V##_##B, h)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
T_FNV(0, 32)
|
||||||
|
T_FNV(0, 64)
|
||||||
|
T_FNV(1, 32)
|
||||||
|
T_FNV(1, 64)
|
||||||
|
T_FNV(1a, 32)
|
||||||
|
T_FNV(1a, 64)
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Boilerplate
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
t_prepare(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
|
t_add_test(t_fnv0_32, &t_offset_basis, "FNV-32 offset basis");
|
||||||
|
t_add_test(t_fnv0_64, &t_offset_basis, "FNV-64 offset basis");
|
||||||
|
n = sizeof t_cases / sizeof t_cases[0];
|
||||||
|
for (i = 0; i < n; ++i) {
|
||||||
|
t_add_test(t_fnv0_32, &t_cases[i], "");
|
||||||
|
t_add_test(t_fnv0_64, &t_cases[i], "");
|
||||||
|
t_add_test(t_fnv1_32, &t_cases[i], "");
|
||||||
|
t_add_test(t_fnv1_64, &t_cases[i], "");
|
||||||
|
t_add_test(t_fnv1a_32, &t_cases[i], "");
|
||||||
|
t_add_test(t_fnv1a_64, &t_cases[i], "");
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
t_main(t_prepare, NULL, argc, argv);
|
||||||
|
}
|
Loading…
Reference in a new issue