Skip to content
This repository was archived by the owner on Dec 27, 2019. It is now read-only.

Commit 5627157

Browse files
committed
crypto: import zinc
1 parent 02ae6d9 commit 5627157

56 files changed

Lines changed: 13139 additions & 6552 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contrib/examples/keygen-html/src/curve25519_generate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static __always_inline void normalize_secret(u8 secret[CURVE25519_POINT_SIZE])
4444
secret[31] |= 64;
4545
}
4646

47-
#include "../../../../src/crypto/curve25519-fiat32.h"
47+
#include "../../../../src/crypto/zinc/curve25519/curve25519-fiat32.h"
4848

4949
EMSCRIPTEN_KEEPALIVE void curve25519_generate_public(u8 public[static 32], const u8 private[static 32])
5050
{

contrib/kernel-tree/create-patch.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
#
44
# Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
55

6+
shopt -s globstar
7+
68
WG="$(readlink -f "$(dirname "$(readlink -f "$0")")/../../src/")"
79

8-
for i in "$WG"/*.c "$WG"/*.h "$WG"/uapi/*.h "$WG"/selftest/*.h "$WG"/crypto/*.c "$WG"/crypto/*.h "$WG"/crypto/*.S "$WG"/Kbuild "$WG"/Kconfig $(find "$WG"/compat -name '*.c' -o -name '*.h' -o -name '*.include'); do
10+
for i in "$WG"/*.c "$WG"/*.h "$WG"/uapi/*.h "$WG"/selftest/*.h "$WG"/Kbuild "$WG"/Kconfig "$WG"/crypto/**/*.c "$WG"/crypto/**/*.h "$WG"/crypto/**/*.S "$WG"/crypto/**/*.include "$WG"/compat/**/*.c "$WG"/compat/**/*.h "$WG"/compat/**/*.include; do
911
diff -u /dev/null "$i" | sed "s:${WG}:b/net/wireguard:;s:Kbuild:Makefile:"
1012
done
1113

src/Kbuild

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ ccflags-y := -O3 -fvisibility=hidden
66
ccflags-$(CONFIG_WIREGUARD_DEBUG) += -DDEBUG -g
77
ccflags-y += -Wframe-larger-than=8192
88
ccflags-y += -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt'
9-
wireguard-y := main.o noise.o device.o peer.o timers.o queueing.o send.o receive.o socket.o hashtables.o allowedips.o ratelimiter.o cookie.o netlink.o
10-
wireguard-y += crypto/chacha20.o crypto/poly1305.o crypto/chacha20poly1305.o crypto/curve25519.o crypto/blake2s.o
119

12-
wireguard-$(CONFIG_X86_64) += crypto/chacha20-x86_64.o crypto/poly1305-x86_64.o crypto/blake2s-x86_64.o
13-
wireguard-$(CONFIG_ARM) += crypto/chacha20-arm.o crypto/poly1305-arm.o crypto/curve25519-arm.o
14-
wireguard-$(CONFIG_ARM64) += crypto/chacha20-arm64.o crypto/poly1305-arm64.o
15-
wireguard-$(if $(filter yy,$(CONFIG_MIPS)$(CONFIG_64BIT)),y,n) += crypto/poly1305-mips64.o
16-
wireguard-$(if $(filter yy,$(CONFIG_MIPS)$(CONFIG_CPU_MIPS32_R2)),y,n) += crypto/poly1305-mips.o crypto/chacha20-mips.o
10+
wireguard-y := main.o noise.o device.o peer.o timers.o queueing.o send.o receive.o socket.o hashtables.o allowedips.o ratelimiter.o cookie.o netlink.o
1711

12+
include $(src)/crypto/Kbuild.include
1813
include $(src)/compat/Kbuild.include
1914

2015
obj-$(if $(KBUILD_EXTMOD),m,$(CONFIG_WIREGUARD)) := wireguard.o

src/Makefile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,10 @@ install:
5151
depmod -a
5252
@$(MAKE) -C tools install
5353

54-
DKMS_TOP_LEVEL := Makefile Kbuild Kconfig $(filter-out wireguard.mod.c, $(wildcard *.c)) $(filter-out version.h, $(wildcard *.h)) version.h dkms.conf
55-
DKMS_SELFTEST_LEVEL := $(wildcard selftest/*.c) $(wildcard selftest/*.h)
56-
DKMS_CRYPTO_LEVEL := $(wildcard crypto/*.c) $(wildcard crypto/*.h) $(wildcard crypto/*.S)
57-
DKMS_UAPI_LEVEL := $(wildcard uapi/*.h)
58-
DKMS_COMPAT_LEVEL := $(shell find compat/ -name '*.c' -o -name '*.h' -o -name '*.include')
59-
dkms-install: $(DKMS_TOP_LEVEL) $(DKMS_SELFTEST_LEVEL) $(DKMS_CRYPTO_LEVEL) $(DKMS_UAPI_LEVEL) $(DKMS_COMPAT_LEVEL)
60-
@install -v -m0644 -D -t$(DESTDIR)$(DKMSDIR) $(DKMS_TOP_LEVEL)
61-
@install -v -m0644 -D -t$(DESTDIR)$(DKMSDIR)/selftest $(DKMS_SELFTEST_LEVEL)
62-
@install -v -m0644 -D -t$(DESTDIR)$(DKMSDIR)/crypto $(DKMS_CRYPTO_LEVEL)
63-
@install -v -m0644 -D -t$(DESTDIR)$(DKMSDIR)/uapi $(DKMS_UAPI_LEVEL)
64-
@for file in $(DKMS_COMPAT_LEVEL); do install -v -m0644 -D $$file $(DESTDIR)$(DKMSDIR)/$$file; done
54+
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
55+
DKMS_SOURCES := version.h Makefile Kbuild Kconfig dkms.conf $(filter-out version.h wireguard.mod.c,$(wildcard *.c *.h selftest/*.h uapi/*.h)) $(call rwildcard,crypto/,*.c *.h *.S *.include) $(call rwildcard,compat/,*.c *.h *.include)
56+
dkms-install: $(DKMS_SOURCES)
57+
@$(foreach f,$(DKMS_SOURCES),install -v -m0644 -D $(f) $(DESTDIR)$(DKMSDIR)/$(f);)
6558

6659
tools:
6760
@$(MAKE) -C tools

src/cookie.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#include "messages.h"
1010
#include "ratelimiter.h"
1111
#include "timers.h"
12-
#include "crypto/blake2s.h"
13-
#include "crypto/chacha20poly1305.h"
12+
13+
#include <zinc/blake2s.h>
14+
#include <zinc/chacha20poly1305.h>
1415

1516
#include <net/ipv6.h>
1617
#include <crypto/algapi.h>

src/crypto/Kbuild.include

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
ifeq ($(wildcard $(src)/compat/compat.h),)
2+
cmd_include_path_prefix := $(srctree)/$(src)
3+
else
4+
cmd_include_path_prefix := $(src)
5+
endif
6+
7+
ccflags-y += -I$(src)/crypto/include
8+
9+
wireguard-y += crypto/zinc/chacha20/chacha20.o
10+
ifeq ($(CONFIG_X86_64)$(CONFIG_UML),y)
11+
wireguard-y += crypto/zinc/chacha20/chacha20-x86_64.o
12+
CFLAGS_chacha20.o += -include $(cmd_include_path_prefix)/crypto/zinc/chacha20/chacha20-x86_64-glue.h
13+
endif
14+
ifeq ($(CONFIG_ARM),y)
15+
wireguard-y += crypto/zinc/chacha20/chacha20-arm.o
16+
CFLAGS_chacha20.o += -include $(cmd_include_path_prefix)/crypto/zinc/chacha20/chacha20-arm-glue.h
17+
endif
18+
ifeq ($(CONFIG_ARM64),y)
19+
wireguard-y += crypto/zinc/chacha20/chacha20-arm64.o
20+
CFLAGS_chacha20.o += -include $(cmd_include_path_prefix)/crypto/zinc/chacha20/chacha20-arm-glue.h
21+
endif
22+
ifeq ($(CONFIG_MIPS)$(CONFIG_CPU_MIPS32_R2),yy)
23+
wireguard-y += crypto/zinc/chacha20/chacha20-mips.o
24+
CFLAGS_chacha20.o += -include $(cmd_include_path_prefix)/crypto/zinc/chacha20/chacha20-mips-glue.h
25+
endif
26+
27+
wireguard-y += crypto/zinc/poly1305/poly1305.o
28+
ifeq ($(CONFIG_X86_64)$(CONFIG_UML),y)
29+
wireguard-y += crypto/zinc/poly1305/poly1305-x86_64.o
30+
CFLAGS_poly1305.o += -include $(cmd_include_path_prefix)/crypto/zinc/poly1305/poly1305-x86_64-glue.h
31+
endif
32+
ifeq ($(CONFIG_ARM),y)
33+
wireguard-y += crypto/zinc/poly1305/poly1305-arm.o
34+
CFLAGS_poly1305.o += -include $(cmd_include_path_prefix)/crypto/zinc/poly1305/poly1305-arm-glue.h
35+
endif
36+
ifeq ($(CONFIG_ARM64),y)
37+
wireguard-y += crypto/zinc/poly1305/poly1305-arm64.o
38+
CFLAGS_poly1305.o += -include $(cmd_include_path_prefix)/crypto/zinc/poly1305/poly1305-arm-glue.h
39+
endif
40+
ifeq ($(CONFIG_MIPS)$(CONFIG_CPU_MIPS32_R2),yy)
41+
wireguard-y += crypto/zinc/poly1305/poly1305-mips.o
42+
CFLAGS_poly1305.o += -include $(cmd_include_path_prefix)/crypto/zinc/poly1305/poly1305-mips-glue.h
43+
endif
44+
ifeq ($(CONFIG_MIPS)$(CONFIG_64BIT),yy)
45+
wireguard-y += crypto/zinc/poly1305/poly1305-mips64.o
46+
CFLAGS_poly1305.o += -include $(cmd_include_path_prefix)/crypto/zinc/poly1305/poly1305-mips-glue.h
47+
endif
48+
49+
wireguard-y += crypto/zinc/chacha20poly1305.o
50+
51+
wireguard-y += crypto/zinc/curve25519/curve25519.o
52+
ifeq ($(CONFIG_ARM)$(CONFIG_KERNEL_MODE_NEON),yy)
53+
wireguard-y += crypto/zinc/curve25519/curve25519-arm.o
54+
CFLAGS_curve25519.o += -include $(cmd_include_path_prefix)/crypto/zinc/curve25519/curve25519-arm-glue.h
55+
endif
56+
ifeq ($(CONFIG_X86_64)$(CONFIG_UML),y)
57+
CFLAGS_curve25519.o += -include $(cmd_include_path_prefix)/crypto/zinc/curve25519/curve25519-x86_64-glue.h
58+
endif
59+
60+
wireguard-y += crypto/zinc/blake2s/blake2s.o
61+
ifeq ($(CONFIG_X86_64)$(CONFIG_UML),y)
62+
wireguard-y += crypto/zinc/blake2s/blake2s-x86_64.o
63+
CFLAGS_blake2s.o += -include $(cmd_include_path_prefix)/crypto/zinc/blake2s/blake2s-x86_64-glue.h
64+
endif

src/crypto/chacha20.c

Lines changed: 0 additions & 240 deletions
This file was deleted.

0 commit comments

Comments
 (0)