ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/libs/libsodium/Makefile b/external/subpack/libs/libsodium/Makefile
new file mode 100644
index 0000000..9c207f8
--- /dev/null
+++ b/external/subpack/libs/libsodium/Makefile
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2009-2016 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libsodium
+PKG_VERSION:=1.0.19
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://download.libsodium.org/libsodium/releases \
+ https://github.com/jedisct1/libsodium/releases/download/$(PKG_VERSION)
+PKG_HASH:=018d79fe0a045cca07331d37bd0cb57b2e838c51bc48fd837a1472e50068bbea
+
+PKG_MAINTAINER:=Damiano Renfer <x9w2n7xnu@relay.firefox.com>
+PKG_LICENSE:=ISC
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_BUILD_FLAGS:=no-mips16
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TAR_OPTIONS+= --strip-components 1
+TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
+
+define Package/libsodium
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE:=P(ortable|ackageable) NaCl-based crypto library
+ URL:=https://github.com/jedisct1/libsodium
+endef
+
+define Package/libsodium/description
+ NaCl (pronounced "salt") is a new easy-to-use high-speed software library for network communication, encryption, decryption, signatures, etc.
+ NaCl's goal is to provide all of the core operations needed to build higher-level cryptographic tools.
+ Sodium is a portable, cross-compilable, installable, packageable fork of NaCl (based on the latest released upstream version nacl-20110221), with a compatible API.
+ The design choices, particularly in regard to the Curve25519 Diffie-Hellman function, emphasize security (whereas NIST curves emphasize "performance" at the cost of security), and "magic constants" in NaCl/Sodium have clear rationales.
+ The same cannot be said of NIST curves, where the specific origins of certain constants are not described by the standards.
+ And despite the emphasis on higher security, primitives are faster across-the-board than most implementations of the NIST standards.
+endef
+
+define Package/libsodium/config
+menu "Configuration"
+ depends on PACKAGE_libsodium
+ config LIBSODIUM_MINIMAL
+ bool "Compile only what is required for the high-level API (no aes128ctr), should be fine in most cases."
+ default y
+endmenu
+endef
+
+CONFIGURE_ARGS+= \
+ --disable-ssp \
+ $(if $(CONFIG_LIBSODIUM_MINIMAL),--enable,--disable)-minimal
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/sodium
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/sodium.h $(1)/usr/include
+ $(CP) $(PKG_INSTALL_DIR)/usr/include/sodium/*.h $(1)/usr/include/sodium
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsodium.{a,so*} $(1)/usr/lib
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libsodium.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libsodium/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsodium.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libsodium))
diff --git a/external/subpack/libs/libsodium/patches/001-revert-f5076db5f8ef27.patch b/external/subpack/libs/libsodium/patches/001-revert-f5076db5f8ef27.patch
new file mode 100644
index 0000000..c88ef10
--- /dev/null
+++ b/external/subpack/libs/libsodium/patches/001-revert-f5076db5f8ef27.patch
@@ -0,0 +1,36 @@
+--- a/src/libsodium/Makefile.am
++++ b/src/libsodium/Makefile.am
+@@ -73,6 +73,7 @@ libsodium_la_SOURCES = \
+ crypto_scalarmult/curve25519/ref10/x25519_ref10.h \
+ crypto_scalarmult/curve25519/scalarmult_curve25519.c \
+ crypto_scalarmult/curve25519/scalarmult_curve25519.h \
++ crypto_scalarmult/ed25519/ref10/scalarmult_ed25519_ref10.c \
+ crypto_secretbox/crypto_secretbox.c \
+ crypto_secretbox/crypto_secretbox_easy.c \
+ crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c \
+@@ -173,7 +174,6 @@ libsodium_la_SOURCES += \
+ crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.h \
+ crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c \
+ crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c \
+- crypto_scalarmult/ed25519/ref10/scalarmult_ed25519_ref10.c \
+ crypto_scalarmult/ristretto255/ref10/scalarmult_ristretto255_ref10.c \
+ crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c \
+ crypto_shorthash/siphash24/shorthash_siphashx24.c \
+--- a/src/libsodium/include/sodium.h
++++ b/src/libsodium/include/sodium.h
+@@ -39,6 +39,7 @@
+ #include "sodium/crypto_pwhash_argon2i.h"
+ #include "sodium/crypto_scalarmult.h"
+ #include "sodium/crypto_scalarmult_curve25519.h"
++#include "sodium/crypto_scalarmult_ed25519.h"
+ #include "sodium/crypto_secretbox.h"
+ #include "sodium/crypto_secretbox_xsalsa20poly1305.h"
+ #include "sodium/crypto_secretstream_xchacha20poly1305.h"
+@@ -64,7 +65,6 @@
+ #include "sodium/crypto_core_ed25519.h"
+ #include "sodium/crypto_core_ristretto255.h"
+ #include "sodium/crypto_pwhash_scryptsalsa208sha256.h"
+-#include "sodium/crypto_scalarmult_ed25519.h"
+ #include "sodium/crypto_scalarmult_ristretto255.h"
+ #include "sodium/crypto_secretbox_xchacha20poly1305.h"
+ #include "sodium/crypto_stream_salsa2012.h"
diff --git a/external/subpack/libs/libsodium/patches/100-minimal-build-with-ed25519-core.patch b/external/subpack/libs/libsodium/patches/100-minimal-build-with-ed25519-core.patch
new file mode 100644
index 0000000..7e92ffe
--- /dev/null
+++ b/external/subpack/libs/libsodium/patches/100-minimal-build-with-ed25519-core.patch
@@ -0,0 +1,36 @@
+--- a/src/libsodium/Makefile.am
++++ b/src/libsodium/Makefile.am
+@@ -23,6 +23,7 @@ libsodium_la_SOURCES = \
+ crypto_box/crypto_box_easy.c \
+ crypto_box/crypto_box_seal.c \
+ crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c \
++ crypto_core/ed25519/core_ed25519.c \
+ crypto_core/ed25519/ref10/ed25519_ref10.c \
+ crypto_core/hchacha20/core_hchacha20.c \
+ crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c \
+@@ -165,7 +166,6 @@ if !MINIMAL
+ libsodium_la_SOURCES += \
+ crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c \
+ crypto_box/curve25519xchacha20poly1305/box_seal_curve25519xchacha20poly1305.c \
+- crypto_core/ed25519/core_ed25519.c \
+ crypto_core/ed25519/core_ristretto255.c \
+ crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c \
+ crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h \
+--- a/src/libsodium/include/sodium.h
++++ b/src/libsodium/include/sodium.h
+@@ -16,6 +16,7 @@
+ #include "sodium/crypto_auth_hmacsha512256.h"
+ #include "sodium/crypto_box.h"
+ #include "sodium/crypto_box_curve25519xsalsa20poly1305.h"
++#include "sodium/crypto_core_ed25519.h"
+ #include "sodium/crypto_core_hchacha20.h"
+ #include "sodium/crypto_core_hsalsa20.h"
+ #include "sodium/crypto_core_salsa20.h"
+@@ -62,7 +63,6 @@
+
+ #ifndef SODIUM_LIBRARY_MINIMAL
+ #include "sodium/crypto_box_curve25519xchacha20poly1305.h"
+-#include "sodium/crypto_core_ed25519.h"
+ #include "sodium/crypto_core_ristretto255.h"
+ #include "sodium/crypto_pwhash_scryptsalsa208sha256.h"
+ #include "sodium/crypto_scalarmult_ristretto255.h"