Strong (well-distributed and unpredictable) hashes:

* Portable implementation of SipHash
* HighwayHash, a 5x faster SIMD hash with security claims

WWW: https://github.com/google/highwayhash

PR:		219232
Submitted by:	Yuri Victorovich (maintainer)
Reviewed by:	matthew (mentor)
Approved by:	matthew (mentor)
Differential Revision:	https://reviews.freebsd.org/D12002
This commit is contained in:
Richard Gallamore 2017-08-13 22:35:18 +00:00
parent a1453be727
commit 8af1279f69
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=447922
7 changed files with 157 additions and 0 deletions

View file

@ -209,6 +209,7 @@
SUBDIR += hashcat
SUBDIR += hashcat-legacy
SUBDIR += heimdal
SUBDIR += highwayhash
SUBDIR += hitch
SUBDIR += hlfl
SUBDIR += hmap

View file

@ -0,0 +1,37 @@
# Created by: Yuri Victorovich <yuri@rawbw.com>
# $FreeBSD$
PORTNAME= highwayhash
PORTVERSION= g20170512
CATEGORIES= security
MAINTAINER= yuri@rawbw.com
COMMENT= Fast strong hash functions: SipHash/HighwayHash
LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE
ONLY_FOR_ARCHS= amd64 arm64 powerpc powerpc64
ONLY_FOR_ARCHS_REASON= Assembly is implemented only for specific architectures in highwayhash/tsc_timer.h
USES= gmake
USE_GITHUB= yes
GH_ACCOUNT= google
GH_TAGNAME= 2b666ae
USE_LDCONFIG= yes
post-patch:
# Install flags upstream issue: https://github.com/google/highwayhash/issues/58
@${REINPLACE_CMD} -e '\
s|LIBDIR|XLIBDIR|; \
s| -O3||; \
s|install -m0755 high|${INSTALL_DATA} high|; \
s|install -m0755 lib|${INSTALL_LIB} lib|' \
${WRKSRC}/Makefile
post-install:
# Symlink upstream issue: https://github.com/google/highwayhash/issues/57
${RM} ${STAGEDIR}${PREFIX}/lib/libhighwayhash.so
${LN} -s libhighwayhash.so.0 ${STAGEDIR}${PREFIX}/lib/libhighwayhash.so
.include <bsd.port.mk>

View file

@ -0,0 +1,3 @@
TIMESTAMP = 1502493406
SHA256 (google-highwayhash-g20170512-2b666ae_GH0.tar.gz) = 294320a52169a3365818b98c7ee8438583d9f627ec84e4b61f2cb94f86796a73
SIZE (google-highwayhash-g20170512-2b666ae_GH0.tar.gz) = 139398

View file

@ -0,0 +1,64 @@
--- highwayhash/os_specific.cc.orig 2017-05-08 14:09:02 UTC
+++ highwayhash/os_specific.cc
@@ -40,6 +40,16 @@
#define OS_LINUX 0
#endif
+#ifdef __FreeBSD__
+#define OS_FREEBSD 1
+#include <sched.h>
+#include <sys/time.h>
+#include <sys/param.h>
+#include <sys/cpuset.h>
+#else
+#define OS_FREEBSD 0
+#endif
+
#ifdef __MACH__
#define OS_MAC 1
#include <mach/mach.h>
@@ -134,6 +144,10 @@ ThreadAffinity* GetThreadAffinity() {
const int err = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid,
sizeof(cpuset_t), &affinity->set);
CHECK(err == 0);
+#elif OS_FREEBSD
+ const pid_t pid = 0; // current thread
+ const int err = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, pid, sizeof(cpuset_t), &affinity->set);
+ CHECK(err == 0);
#endif
return affinity;
}
@@ -165,6 +179,10 @@ void SetThreadAffinity(ThreadAffinity* a
const int err = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid,
sizeof(cpuset_t), &affinity->set);
CHECK(err == 0);
+#elif OS_FREEBSD
+ const pid_t pid = 0; // current thread
+ const int err = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, pid, sizeof(cpuset_t), &affinity->set);
+ CHECK(err == 0);
#else
#error "port"
#endif
@@ -192,6 +210,12 @@ std::vector<int> AvailableCPUs() {
cpus.push_back(cpu);
}
}
+#elif OS_FREEBSD
+ for (size_t cpu = 0; cpu < sizeof(cpuset_t) * 8; ++cpu) {
+ if (CPU_ISSET(cpu, &affinity->set)) {
+ cpus.push_back(cpu);
+ }
+ }
#else
#error "port"
#endif
@@ -208,6 +232,9 @@ void PinThreadToCPU(const int cpu) {
#elif OS_FREEBSD
CPU_ZERO(&affinity.set);
CPU_SET(cpu, &affinity.set);
+#elif OS_FREEBSD
+ CPU_ZERO(&affinity.set);
+ CPU_SET(cpu, &affinity.set);
#else
#error "port"
#endif

View file

@ -0,0 +1,5 @@
Strong (well-distributed and unpredictable) hashes:
* Portable implementation of SipHash
* HighwayHash, a 5x faster SIMD hash with security claims
WWW: https://github.com/google/highwayhash

View file

@ -0,0 +1,32 @@
include/highwayhash/arch_specific.h
include/highwayhash/c_bindings.h
include/highwayhash/compiler_specific.h
include/highwayhash/data_parallel.h
include/highwayhash/endianess.h
include/highwayhash/hh_avx2.h
include/highwayhash/hh_buffer.h
include/highwayhash/hh_portable.h
include/highwayhash/hh_sse41.h
include/highwayhash/hh_types.h
include/highwayhash/highwayhash.h
include/highwayhash/highwayhash_target.h
include/highwayhash/highwayhash_test_target.h
include/highwayhash/iaca.h
include/highwayhash/instruction_sets.h
include/highwayhash/load3.h
include/highwayhash/nanobenchmark.h
include/highwayhash/os_specific.h
include/highwayhash/profiler.h
include/highwayhash/robust_statistics.h
include/highwayhash/scalar.h
include/highwayhash/scalar_sip_tree_hash.h
include/highwayhash/sip_hash.h
include/highwayhash/sip_tree_hash.h
include/highwayhash/state_helpers.h
include/highwayhash/tsc_timer.h
include/highwayhash/vector128.h
include/highwayhash/vector256.h
include/highwayhash/vector_test_target.h
lib/libhighwayhash.a
lib/libhighwayhash.so
lib/libhighwayhash.so.0

15
security/highwayhash/tags Normal file
View file

@ -0,0 +1,15 @@
!_TAG_FILE_SORTED 2 /0=unsorted, 1=sorted, 2=foldcase/
CATEGORIES /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^CATEGORIES= security$/;" m language:Make
COMMENT /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^COMMENT= Fast strong hash functions: SipHash\/HighwayHash$/;" m language:Make
GH_ACCOUNT /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^GH_ACCOUNT= google$/;" m language:Make
GH_TAGNAME /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^GH_TAGNAME= 2b666ae$/;" m language:Make
LICENSE /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^LICENSE= APACHE20$/;" m language:Make
LICENSE_FILE /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^LICENSE_FILE= ${WRKSRC}\/LICENSE$/;" m language:Make
MAINTAINER /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^MAINTAINER= yuri@rawbw.com$/;" m language:Make
ONLY_FOR_ARCHS /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^ONLY_FOR_ARCHS= amd64 arm64 powerpc powerpc64$/;" m language:Make
ONLY_FOR_ARCHS_REASON /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^ONLY_FOR_ARCHS_REASON= Assembly is implemented only for specific architectures in highwayhash\/tsc_timer.h$/;" m language:Make
PORTNAME /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^PORTNAME= highwayhash$/;" m language:Make
PORTVERSION /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^PORTVERSION= g20170512$/;" m language:Make
USES /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^USES= gmake$/;" m language:Make
USE_GITHUB /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^USE_GITHUB= yes$/;" m language:Make
USE_LDCONFIG /usr/home/ricky/FreeBSD/ports/security/highwayhash/Makefile /^USE_LDCONFIG= yes$/;" m language:Make