mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2026-09-22 15:29:03 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
baeab92737 | ||
|
|
95da2bcbcf | ||
|
|
a9e4fb0ed9 | ||
|
|
45b092532e | ||
|
|
3ec932e194 | ||
|
|
565bef05af | ||
|
|
a0c78da1ad | ||
|
|
7b14aeb53e | ||
|
|
f934a09baa | ||
|
|
414c248cc5 | ||
|
|
ca428233ba | ||
|
|
3712f9b318 | ||
|
|
11545bdb5d | ||
|
|
a390629371 | ||
|
|
e3e188109d | ||
|
|
7cbbc38b89 | ||
|
|
b152f9e1d3 | ||
|
|
4bd58d47cf | ||
|
|
982c32322b | ||
|
|
2fcc344299 | ||
|
|
3acd901c88 | ||
|
|
0795dbf5f1 | ||
|
|
101a3a7d74 | ||
|
|
2da162bed7 | ||
|
|
5282e06fd4 | ||
|
|
dc806dd718 | ||
|
|
31d8758ad9 | ||
|
|
6b67cb0e2a | ||
|
|
250f0ef9db | ||
|
|
4aab9121d9 | ||
|
|
5ea7ef6b65 | ||
|
|
a3875f9965 | ||
|
|
4e3a59f329 | ||
|
|
3730917dda | ||
|
|
57516cfbe6 | ||
|
|
bb62279a20 | ||
|
|
e8be28734b | ||
|
|
6c5a097711 | ||
|
|
16a878adb1 | ||
|
|
020d882e82 | ||
|
|
44af828aa4 | ||
|
|
26a0cbcd73 | ||
|
|
1a106bca3b | ||
|
|
cc42d6f4e0 | ||
|
|
1316ee3127 | ||
|
|
eadca9dd75 | ||
|
|
59dd71187e | ||
|
|
36e167013a | ||
|
|
2d489a8679 | ||
|
|
d735a1d04c | ||
|
|
9480ff1f37 | ||
|
|
d2f2abe525 | ||
|
|
e9e20fdad8 | ||
|
|
53ba413d32 | ||
|
|
7280fcdec2 | ||
|
|
cbcd2be232 | ||
|
|
83a2dcb65a | ||
|
|
dd65680150 | ||
|
|
90f18f7ee7 | ||
|
|
317263b31c | ||
|
|
52679d2784 | ||
|
|
763d1cc3dc | ||
|
|
c9fe04d8ea | ||
|
|
f2c490345c | ||
|
|
fe5aad3cef | ||
|
|
1331739ee4 | ||
|
|
3da8f5f053 | ||
|
|
fbbcf292c6 | ||
|
|
2851a9577c | ||
|
|
ed9b09e980 | ||
|
|
bcb3fc7fc0 | ||
|
|
70f37962cf | ||
|
|
8d83b9b7c5 | ||
|
|
2c75be0d64 | ||
|
|
ee04118172 |
No files matched your search
@@ -1,6 +1,28 @@
|
||||
ZeroTier Release Notes
|
||||
======
|
||||
|
||||
# 2020-11-19 -- Version 1.6.0
|
||||
|
||||
Version 1.6.0 is a major release that incorporates back-ported features from the 2.0 branch, which is still under development. It also fixes a number of issues.
|
||||
|
||||
New features and improvements (including those listed under 1.5.0):
|
||||
|
||||
* **Apple Silicon** (MacOS ARM64) native support via universal binary. ZeroTier now requires the very latest Xcode to build.
|
||||
* **Linux performance improvements** for up to 25% faster tun/tap I/O performance on multi-core systems.
|
||||
* **Multipath support** with modes modeled after the Linux kernel's bonding driver. This includes active-passive and active-active modes with fast failover and load balancing. See section 2.1.5 of the manual.
|
||||
* **DNS configuration** push from network controllers to end nodes, with locally configurable permissions for whether or not push is allowed.
|
||||
* **AES-GMAC-SIV** encryption mode, which is both somewhat more secure and significantly faster than the old Salsa20/12-Poly1305 mode on hardware that supports AES acceleration. This includes virtually all X86-64 chips and most ARM64. This mode is based on AES-SIV and has been audited by Trail of Bits to ensure that it is equivalent security-wise.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* **Managed route assignment fixes** to eliminate missing routes on Linux and what we believe to be the source of sporadic high CPU usage on MacOS.
|
||||
* **Hang on shutdown** issues should be fixed.
|
||||
* **Sporadic multicast outages** should be fixed.
|
||||
|
||||
Known remaining issues:
|
||||
|
||||
* AES hardware acceleration is not yet supported on 32-bit ARM, PowerPC (32 or 64), or MIPS (32 or 64) systems. Currently supported are X86-64 and ARM64/AARCH64 with crypto extensions.
|
||||
|
||||
# 2020-10-05 -- Version 1.5.0 (actually 1.6.0-beta1)
|
||||
|
||||
Version 1.6.0 (1.5.0 is a beta!) is a significant release that incorporates a number of back-ported fixes and features from the ZeroTier 2.0 tree.
|
||||
|
||||
Vendored
+6
@@ -1,3 +1,9 @@
|
||||
zerotier-one (1.6.0) unstable; urgency=medium
|
||||
|
||||
* See RELEASE-NOTES.md for release notes.
|
||||
|
||||
-- Adam Ierymenko <adam.ierymenko@zerotier.com> Thu, 19 Nov 2020 01:00:00 -0700
|
||||
|
||||
zerotier-one (1.5.0) unstable; urgency=medium
|
||||
|
||||
* Version 1.5.0 is actually 1.6.0-beta1
|
||||
|
||||
@@ -689,7 +689,7 @@
|
||||
<key>USE_HFS+_COMPRESSION</key>
|
||||
<false/>
|
||||
<key>VERSION</key>
|
||||
<string>1.5.0</string>
|
||||
<string>1.6.0</string>
|
||||
</dict>
|
||||
<key>TYPE</key>
|
||||
<integer>0</integer>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<DOCUMENT Type="Advanced Installer" CreateVersion="10.9" version="17.5" Modules="enterprise" RootPath="." Language="en" Id="{DC564647-6BF0-4550-87F4-89C938D0159C}">
|
||||
<DOCUMENT Type="Advanced Installer" CreateVersion="10.9" version="17.6" Modules="enterprise" RootPath="." Language="en" Id="{DC564647-6BF0-4550-87F4-89C938D0159C}">
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.MsiPropsComponent">
|
||||
<ROW Property="AI_BITMAP_DISPLAY_MODE" Value="0"/>
|
||||
<ROW Property="AI_EMBD_MSI_EXTR_PATH" Value="[TempFolder]" ValueLocId="-"/>
|
||||
@@ -25,10 +25,10 @@
|
||||
<ROW Property="CTRLS" Value="2"/>
|
||||
<ROW Property="MSIFASTINSTALL" MultiBuildValue="DefaultBuild:2"/>
|
||||
<ROW Property="Manufacturer" Value="ZeroTier, Inc."/>
|
||||
<ROW Property="ProductCode" Value="1033:{14C0E8A0-190B-4059-85D1-E00BA6EE37D9} " Type="16"/>
|
||||
<ROW Property="ProductCode" Value="1033:{A54427E1-76AC-4415-8A2C-C8928ACAE994} " Type="16"/>
|
||||
<ROW Property="ProductLanguage" Value="1033"/>
|
||||
<ROW Property="ProductName" Value="ZeroTier One"/>
|
||||
<ROW Property="ProductVersion" Value="1.5.0" Type="32"/>
|
||||
<ROW Property="ProductVersion" Value="1.5.1" Type="32"/>
|
||||
<ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/>
|
||||
<ROW Property="RUNAPPLICATION" Value="1" Type="4"/>
|
||||
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
|
||||
@@ -58,7 +58,7 @@
|
||||
<ROW Directory="x86_Dir" Directory_Parent="tapwindows_Dir" DefaultDir="x86"/>
|
||||
</COMPONENT>
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.MsiCompsComponent">
|
||||
<ROW Component="AI_CustomARPName" ComponentId="{A1B82D56-799A-488A-A764-594F66740565}" Directory_="APPDIR" Attributes="4" KeyPath="DisplayName" Options="1"/>
|
||||
<ROW Component="AI_CustomARPName" ComponentId="{551D28C1-E4A1-4CC5-9FB1-A840D70DC5AB}" Directory_="APPDIR" Attributes="4" KeyPath="DisplayName" Options="1"/>
|
||||
<ROW Component="AI_DisableModify" ComponentId="{020DCABD-5D56-49B9-AF48-F07F0B55E590}" Directory_="APPDIR" Attributes="4" KeyPath="NoModify" Options="1"/>
|
||||
<ROW Component="AI_ExePath" ComponentId="{8E02B36C-7A19-429B-A93E-77A9261AC918}" Directory_="APPDIR" Attributes="4" KeyPath="AI_ExePath"/>
|
||||
<ROW Component="APPDIR" ComponentId="{4DD7907D-D7FE-4CD6-B1A0-B5C1625F5133}" Directory_="APPDIR" Attributes="0"/>
|
||||
@@ -131,7 +131,7 @@
|
||||
<ROW Path="<AI_DICTS>ui_en.ail"/>
|
||||
</COMPONENT>
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.DigCertStoreComponent">
|
||||
<ROW TimeStampUrl="http://timestamp.verisign.com/scripts/timstamp.dll" SignerDescription="ZeroTier One" DescriptionUrl="https://www.zerotier.com/" SignOptions="0" SignTool="0" UseSha256="1" Subject="CN="Red Hat, Inc.", O="Red Hat, Inc.", L=Raleigh, S=North Carolina, C=US"/>
|
||||
<ROW TimeStampUrl="http://timestamp.verisign.com/scripts/timstamp.dll" SignerDescription="ZeroTier One" DescriptionUrl="https://www.zerotier.com/" SignOptions="7" SignTool="5" UseSha256="1" KVTenantId="5300bf3b-0eff-4a5f-a63f-821e22ed1730" KVAppId="5f94d77e-b795-41fd-afe7-ec913b03c1d3" KVName="ZeroTier-CS" KVCertName="ZT-EV-CS" KVCertVersion="442c2d6f77874ff99eed4b36f5cb401c"/>
|
||||
</COMPONENT>
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.FirewallExceptionComponent">
|
||||
<ROW FirewallException="ZeroTierOneControl" DisplayName="ZeroTier One TCP/9993" GroupName="ZeroTierOne" Enabled="1" Scope="*" Condition="1" Profiles="7" Port="9993" Protocol="TCP"/>
|
||||
@@ -465,28 +465,28 @@
|
||||
<ROW XmlAttribute="xsischemaLocation" XmlElement="swidsoftware_identification_tag" Name="xsi:schemaLocation" Flags="14" Order="3" Value="http://standards.iso.org/iso/19770/-2/2008/schema.xsd software_identification_tag.xsd"/>
|
||||
</COMPONENT>
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.XmlElementComponent">
|
||||
<ROW XmlElement="swidbuild" ParentElement="swidnumeric" Name="swid:build" Condition="1" Order="2" Flags="14" Text="0"/>
|
||||
<ROW XmlElement="swidentitlement_required_indicator" ParentElement="swidsoftware_identification_tag" Name="swid:entitlement_required_indicator" Condition="1" Order="0" Flags="14" Text="false"/>
|
||||
<ROW XmlElement="swidmajor" ParentElement="swidnumeric" Name="swid:major" Condition="1" Order="0" Flags="14" Text="1"/>
|
||||
<ROW XmlElement="swidminor" ParentElement="swidnumeric" Name="swid:minor" Condition="1" Order="1" Flags="14" Text="5"/>
|
||||
<ROW XmlElement="swidname" ParentElement="swidproduct_version" Name="swid:name" Condition="1" Order="0" Flags="14" Text="[ProductVersion]"/>
|
||||
<ROW XmlElement="swidname_1" ParentElement="swidsoftware_creator" Name="swid:name" Condition="1" Order="0" Flags="14" Text="ZeroTier, Inc."/>
|
||||
<ROW XmlElement="swidname_2" ParentElement="swidsoftware_licensor" Name="swid:name" Condition="1" Order="0" Flags="14" Text="ZeroTier, Inc."/>
|
||||
<ROW XmlElement="swidname_3" ParentElement="swidtag_creator" Name="swid:name" Condition="1" Order="0" Flags="14" Text="ZeroTier, Inc."/>
|
||||
<ROW XmlElement="swidnumeric" ParentElement="swidproduct_version" Name="swid:numeric" Condition="1" Order="1" Flags="14"/>
|
||||
<ROW XmlElement="swidproduct_title" ParentElement="swidsoftware_identification_tag" Name="swid:product_title" Condition="1" Order="1" Flags="14" Text="[ProductName]"/>
|
||||
<ROW XmlElement="swidproduct_version" ParentElement="swidsoftware_identification_tag" Name="swid:product_version" Condition="1" Order="2" Flags="14"/>
|
||||
<ROW XmlElement="swidregid" ParentElement="swidsoftware_creator" Name="swid:regid" Condition="1" Order="1" Flags="14" Text="regid.2010-01.com.zerotier"/>
|
||||
<ROW XmlElement="swidregid_1" ParentElement="swidsoftware_licensor" Name="swid:regid" Condition="1" Order="1" Flags="14" Text="regid.2010-01.com.zerotier"/>
|
||||
<ROW XmlElement="swidregid_2" ParentElement="swidtag_creator" Name="swid:regid" Condition="1" Order="1" Flags="14" Text="regid.2010-01.com.zerotier"/>
|
||||
<ROW XmlElement="swidreview" ParentElement="swidnumeric" Name="swid:review" Condition="1" Order="3" Flags="14" Text="0"/>
|
||||
<ROW XmlElement="swidsoftware_creator" ParentElement="swidsoftware_identification_tag" Name="swid:software_creator" Condition="1" Order="3" Flags="14"/>
|
||||
<ROW XmlElement="swidsoftware_id" ParentElement="swidsoftware_identification_tag" Name="swid:software_id" Condition="1" Order="5" Flags="14"/>
|
||||
<ROW XmlElement="swidsoftware_identification_tag" Name="swid:software_identification_tag" Condition="1" Order="0" Flags="14"/>
|
||||
<ROW XmlElement="swidsoftware_licensor" ParentElement="swidsoftware_identification_tag" Name="swid:software_licensor" Condition="1" Order="4" Flags="14"/>
|
||||
<ROW XmlElement="swidtag_creator" ParentElement="swidsoftware_identification_tag" Name="swid:tag_creator" Condition="1" Order="6" Flags="14"/>
|
||||
<ROW XmlElement="swidtag_creator_regid" ParentElement="swidsoftware_id" Name="swid:tag_creator_regid" Condition="1" Order="1" Flags="14" Text="regid.2010-01.com.zerotier"/>
|
||||
<ROW XmlElement="swidunique_id" ParentElement="swidsoftware_id" Name="swid:unique_id" Condition="1" Order="0" Flags="14" Text="ZeroTierOne"/>
|
||||
<ROW XmlElement="swidbuild" ParentElement="swidnumeric" Name="swid:build" Condition="1" Order="2" Flags="14" Text="1" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidentitlement_required_indicator" ParentElement="swidsoftware_identification_tag" Name="swid:entitlement_required_indicator" Condition="1" Order="0" Flags="14" Text="false" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidmajor" ParentElement="swidnumeric" Name="swid:major" Condition="1" Order="0" Flags="14" Text="1" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidminor" ParentElement="swidnumeric" Name="swid:minor" Condition="1" Order="1" Flags="14" Text="5" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidname" ParentElement="swidproduct_version" Name="swid:name" Condition="1" Order="0" Flags="14" Text="[ProductVersion]" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidname_1" ParentElement="swidsoftware_creator" Name="swid:name" Condition="1" Order="0" Flags="14" Text="ZeroTier, Inc." UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidname_2" ParentElement="swidsoftware_licensor" Name="swid:name" Condition="1" Order="0" Flags="14" Text="ZeroTier, Inc." UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidname_3" ParentElement="swidtag_creator" Name="swid:name" Condition="1" Order="0" Flags="14" Text="ZeroTier, Inc." UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidnumeric" ParentElement="swidproduct_version" Name="swid:numeric" Condition="1" Order="1" Flags="14" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidproduct_title" ParentElement="swidsoftware_identification_tag" Name="swid:product_title" Condition="1" Order="1" Flags="14" Text="[ProductName]" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidproduct_version" ParentElement="swidsoftware_identification_tag" Name="swid:product_version" Condition="1" Order="2" Flags="14" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidregid" ParentElement="swidsoftware_creator" Name="swid:regid" Condition="1" Order="1" Flags="14" Text="regid.2010-01.com.zerotier" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidregid_1" ParentElement="swidsoftware_licensor" Name="swid:regid" Condition="1" Order="1" Flags="14" Text="regid.2010-01.com.zerotier" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidregid_2" ParentElement="swidtag_creator" Name="swid:regid" Condition="1" Order="1" Flags="14" Text="regid.2010-01.com.zerotier" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidreview" ParentElement="swidnumeric" Name="swid:review" Condition="1" Order="3" Flags="14" Text="0" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidsoftware_creator" ParentElement="swidsoftware_identification_tag" Name="swid:software_creator" Condition="1" Order="3" Flags="14" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidsoftware_id" ParentElement="swidsoftware_identification_tag" Name="swid:software_id" Condition="1" Order="5" Flags="14" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidsoftware_identification_tag" Name="swid:software_identification_tag" Condition="1" Order="0" Flags="14" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidsoftware_licensor" ParentElement="swidsoftware_identification_tag" Name="swid:software_licensor" Condition="1" Order="4" Flags="14" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidtag_creator" ParentElement="swidsoftware_identification_tag" Name="swid:tag_creator" Condition="1" Order="6" Flags="14" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidtag_creator_regid" ParentElement="swidsoftware_id" Name="swid:tag_creator_regid" Condition="1" Order="1" Flags="14" Text="regid.2010-01.com.zerotier" UpdateIndexInParent="0"/>
|
||||
<ROW XmlElement="swidunique_id" ParentElement="swidsoftware_id" Name="swid:unique_id" Condition="1" Order="0" Flags="14" Text="ZeroTierOne" UpdateIndexInParent="0"/>
|
||||
</COMPONENT>
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.XmlFileComponent">
|
||||
<ROW XmlFile="regid.199509.com.example_ProductName.swidtag" FileName="REGID2~1.SWI|regid.2010-01.com.zerotier_ZeroTierOne.swidtag" DirProperty="APPDIR" Component="ProductInformation" RootElement="swidsoftware_identification_tag" Flags="25" Version="1.0" Encoding="UTF-8" IndentUnits="2"/>
|
||||
|
||||
+4
-1
@@ -15,7 +15,7 @@ APP_UNIFIED_HEADERS := true
|
||||
|
||||
LOCAL_CFLAGS := -DZT_USE_MINIUPNPC
|
||||
ifeq ($(TARGET_ARCH_ABI),x86_64)
|
||||
LOCAL_CXXFLAGS := -maes -mpclmul -msse4.1
|
||||
LOCAL_CXXFLAGS := -maes -mpclmul -msse3 -msse4.1
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
|
||||
LOCAL_ARM_NEON := true
|
||||
@@ -25,6 +25,8 @@ endif
|
||||
# ZeroTierOne SDK source files
|
||||
LOCAL_SRC_FILES := \
|
||||
$(ZT1)/node/AES.cpp \
|
||||
$(ZT1)/node/AES_aesni.cpp \
|
||||
$(ZT1)/node/AES_armcrypto.cpp \
|
||||
$(ZT1)/node/Bond.cpp \
|
||||
$(ZT1)/node/BondController.cpp \
|
||||
$(ZT1)/node/C25519.cpp \
|
||||
@@ -58,6 +60,7 @@ LOCAL_SRC_FILES := \
|
||||
# JNI Files
|
||||
LOCAL_SRC_FILES += \
|
||||
com_zerotierone_sdk_Node.cpp \
|
||||
ZT_jniarray.cpp \
|
||||
ZT_jniutils.cpp \
|
||||
ZT_jnilookup.cpp
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// Created by Grant Limberg on 10/21/20.
|
||||
//
|
||||
|
||||
#include "ZT_jniarray.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
jclass java_util_ArrayList;
|
||||
jmethodID java_util_ArrayList_;
|
||||
jmethodID java_util_ArrayList_size;
|
||||
jmethodID java_util_ArrayList_get;
|
||||
jmethodID java_util_ArrayList_add;
|
||||
|
||||
void InitListJNI(JNIEnv* env) {
|
||||
java_util_ArrayList = static_cast<jclass>(env->NewGlobalRef(env->FindClass("java/util/ArrayList")));
|
||||
java_util_ArrayList_ = env->GetMethodID(java_util_ArrayList, "<init>", "(I)V");
|
||||
java_util_ArrayList_size = env->GetMethodID (java_util_ArrayList, "size", "()I");
|
||||
java_util_ArrayList_get = env->GetMethodID(java_util_ArrayList, "get", "(I)Ljava/lang/Object;");
|
||||
java_util_ArrayList_add = env->GetMethodID(java_util_ArrayList, "add", "(Ljava/lang/Object;)Z");
|
||||
}
|
||||
|
||||
jclass ListJNI::getListClass(JNIEnv* env) {
|
||||
jclass jclazz = env->FindClass("java/util/List");
|
||||
assert(jclazz != nullptr);
|
||||
return jclazz;
|
||||
}
|
||||
|
||||
jclass ListJNI::getArrayListClass(JNIEnv* env) {
|
||||
jclass jclazz = env->FindClass("java/util/ArrayList");
|
||||
assert(jclazz != nullptr);
|
||||
return jclazz;
|
||||
}
|
||||
|
||||
jclass ListJNI::getIteratorClass(JNIEnv* env) {
|
||||
jclass jclazz = env->FindClass("java/util/Iterator");
|
||||
assert(jclazz != nullptr);
|
||||
return jclazz;
|
||||
}
|
||||
|
||||
jmethodID ListJNI::getIteratorMethod(JNIEnv* env) {
|
||||
static jmethodID mid = env->GetMethodID(
|
||||
getListClass(env), "iterator", "()Ljava/util/Iterator;");
|
||||
assert(mid != nullptr);
|
||||
return mid;
|
||||
}
|
||||
|
||||
jmethodID ListJNI::getHasNextMethod(JNIEnv* env) {
|
||||
static jmethodID mid = env->GetMethodID(
|
||||
getIteratorClass(env), "hasNext", "()Z");
|
||||
assert(mid != nullptr);
|
||||
return mid;
|
||||
}
|
||||
|
||||
jmethodID ListJNI::getNextMethod(JNIEnv* env) {
|
||||
static jmethodID mid = env->GetMethodID(
|
||||
getIteratorClass(env), "next", "()Ljava/lang/Object;");
|
||||
assert(mid != nullptr);
|
||||
return mid;
|
||||
}
|
||||
|
||||
jmethodID ListJNI::getArrayListConstructorMethodId(JNIEnv* env, jclass jclazz) {
|
||||
static jmethodID mid = env->GetMethodID(
|
||||
jclazz, "<init>", "(I)V");
|
||||
assert(mid != nullptr);
|
||||
return mid;
|
||||
}
|
||||
|
||||
jmethodID ListJNI::getListAddMethodId(JNIEnv* env) {
|
||||
static jmethodID mid = env->GetMethodID(
|
||||
getListClass(env), "add", "(Ljava/lang/Object;)Z");
|
||||
assert(mid != nullptr);
|
||||
return mid;
|
||||
}
|
||||
|
||||
jclass ByteJNI::getByteClass(JNIEnv* env) {
|
||||
jclass jclazz = env->FindClass("java/lang/Byte");
|
||||
assert(jclazz != nullptr);
|
||||
return jclazz;
|
||||
}
|
||||
|
||||
jmethodID ByteJNI::getByteValueMethod(JNIEnv* env) {
|
||||
static jmethodID mid = env->GetMethodID(
|
||||
getByteClass(env), "byteValue", "()B");
|
||||
assert(mid != nullptr);
|
||||
return mid;
|
||||
}
|
||||
|
||||
jobject cppToJava(JNIEnv* env, std::vector<std::string> vector) {
|
||||
jobject result = env->NewObject(java_util_ArrayList, java_util_ArrayList_, vector.size());
|
||||
for (std::string s: vector) {
|
||||
jstring element = env->NewStringUTF(s.c_str());
|
||||
env->CallBooleanMethod(result, java_util_ArrayList_add, element);
|
||||
env->DeleteLocalRef(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> javaToCpp(JNIEnv* env, jobject arrayList) {
|
||||
jint len = env->CallIntMethod(arrayList, java_util_ArrayList_size);
|
||||
std::vector<std::string> result;
|
||||
result.reserve(len);
|
||||
for (jint i=0; i<len; i++) {
|
||||
jstring element = static_cast<jstring>(env->CallObjectMethod(arrayList, java_util_ArrayList_get, i));
|
||||
const char* pchars = env->GetStringUTFChars(element, nullptr);
|
||||
result.emplace_back(pchars);
|
||||
env->ReleaseStringUTFChars(element, pchars);
|
||||
env->DeleteLocalRef(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// Created by Grant Limberg on 10/21/20.
|
||||
//
|
||||
|
||||
#ifndef ZEROTIERANDROID_ZT_JNIARRAY_H
|
||||
#define ZEROTIERANDROID_ZT_JNIARRAY_H
|
||||
|
||||
#include <jni.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
extern jclass java_util_ArrayList;
|
||||
extern jmethodID java_util_ArrayList_;
|
||||
extern jmethodID java_util_ArrayList_size;
|
||||
extern jmethodID java_util_ArrayList_get;
|
||||
extern jmethodID java_util_ArrayList_add;
|
||||
|
||||
void InitListJNI(JNIEnv* env);
|
||||
|
||||
class ListJNI {
|
||||
public:
|
||||
// Get the java class id of java.util.List.
|
||||
static jclass getListClass(JNIEnv* env);
|
||||
|
||||
// Get the java class id of java.util.ArrayList.
|
||||
static jclass getArrayListClass(JNIEnv* env);
|
||||
|
||||
// Get the java class id of java.util.Iterator.
|
||||
static jclass getIteratorClass(JNIEnv* env);
|
||||
|
||||
// Get the java method id of java.util.List.iterator().
|
||||
static jmethodID getIteratorMethod(JNIEnv* env);
|
||||
|
||||
// Get the java method id of java.util.Iterator.hasNext().
|
||||
static jmethodID getHasNextMethod(JNIEnv* env);
|
||||
|
||||
// Get the java method id of java.util.Iterator.next().
|
||||
static jmethodID getNextMethod(JNIEnv* env);
|
||||
|
||||
// Get the java method id of arrayList constructor.
|
||||
static jmethodID getArrayListConstructorMethodId(JNIEnv* env, jclass jclazz);
|
||||
|
||||
// Get the java method id of java.util.List.add().
|
||||
static jmethodID getListAddMethodId(JNIEnv* env);
|
||||
};
|
||||
|
||||
class ByteJNI {
|
||||
public:
|
||||
// Get the java class id of java.lang.Byte.
|
||||
static jclass getByteClass(JNIEnv* env);
|
||||
|
||||
// Get the java method id of java.lang.Byte.byteValue.
|
||||
static jmethodID getByteValueMethod(JNIEnv* env);
|
||||
};
|
||||
|
||||
jobject cppToJava(JNIEnv* env, std::vector<std::string> vector);
|
||||
|
||||
std::vector<std::string> javaToCpp(JNIEnv* env, jobject arrayList);
|
||||
|
||||
#endif //ZEROTIERANDROID_ZT_JNIARRAY_H
|
||||
@@ -65,8 +65,8 @@ jclass JniLookup::findClass(const std::string &name)
|
||||
LOGE("Error retreiving JNI Environment");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jclass cls = env->FindClass(name.c_str());
|
||||
const char *c = name.c_str();
|
||||
jclass cls = env->FindClass(c);
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
LOGE("Error finding class: %s", name.c_str());
|
||||
|
||||
@@ -18,9 +18,16 @@
|
||||
|
||||
#include "ZT_jniutils.h"
|
||||
#include "ZT_jnilookup.h"
|
||||
#include "ZT_jniarray.h"
|
||||
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
extern JniLookup lookup;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -623,6 +630,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig)
|
||||
jfieldID netconfRevisionField = NULL;
|
||||
jfieldID assignedAddressesField = NULL;
|
||||
jfieldID routesField = NULL;
|
||||
jfieldID dnsField = NULL;
|
||||
|
||||
vnetConfigClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkConfig");
|
||||
if(vnetConfigClass == NULL)
|
||||
@@ -739,6 +747,13 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dnsField = lookup.findField(vnetConfigClass, "dns", "Lcom/zerotier/sdk/VirtualNetworkDNS;");
|
||||
if(env->ExceptionCheck() || dnsField == NULL)
|
||||
{
|
||||
LOGE("Error getting DNS field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env->SetLongField(vnetConfigObj, nwidField, vnetConfig.nwid);
|
||||
env->SetLongField(vnetConfigObj, macField, vnetConfig.mac);
|
||||
jstring nameStr = env->NewStringUTF(vnetConfig.name);
|
||||
@@ -824,6 +839,10 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig)
|
||||
|
||||
env->SetObjectField(vnetConfigObj, routesField, routesArrayObj);
|
||||
|
||||
jobject dnsObj = newVirtualNetworkDNS(env, vnetConfig.dns);
|
||||
if (dnsObj != NULL) {
|
||||
env->SetObjectField(vnetConfigObj, dnsField, dnsObj);
|
||||
}
|
||||
return vnetConfigObj;
|
||||
}
|
||||
|
||||
@@ -947,6 +966,66 @@ jobject newVirtualNetworkRoute(JNIEnv *env, const ZT_VirtualNetworkRoute &route)
|
||||
return routeObj;
|
||||
}
|
||||
|
||||
jobject newVirtualNetworkDNS(JNIEnv *env, const ZT_VirtualNetworkDNS &dns)
|
||||
{
|
||||
jclass virtualNetworkDNSClass = NULL;
|
||||
jmethodID dnsConstructor = NULL;
|
||||
|
||||
virtualNetworkDNSClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkDNS");
|
||||
if (env->ExceptionCheck() || virtualNetworkDNSClass == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dnsConstructor = lookup.findMethod(virtualNetworkDNSClass, "<init>", "()V");
|
||||
if(env->ExceptionCheck() || dnsConstructor == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject dnsObj = env->NewObject(virtualNetworkDNSClass, dnsConstructor);
|
||||
if(env->ExceptionCheck() || dnsObj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jfieldID domainField = NULL;
|
||||
jfieldID serversField = NULL;
|
||||
|
||||
domainField = lookup.findField(virtualNetworkDNSClass, "domain", "Ljava/lang/String;");
|
||||
if(env->ExceptionCheck() || domainField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
serversField = lookup.findField(virtualNetworkDNSClass, "servers", "Ljava/util/ArrayList;");
|
||||
if(env->ExceptionCheck() || serversField == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strlen(dns.domain) > 0) {
|
||||
InitListJNI(env);
|
||||
jstring domain = env->NewStringUTF(dns.domain);
|
||||
|
||||
jobject addrArray = env->NewObject(java_util_ArrayList, java_util_ArrayList_, 0);
|
||||
|
||||
struct sockaddr_storage nullAddr;
|
||||
memset(&nullAddr, 0, sizeof(struct sockaddr_storage));
|
||||
for(int i = 0; i < ZT_MAX_DNS_SERVERS; ++i) {
|
||||
struct sockaddr_storage tmp = dns.server_addr[i];
|
||||
|
||||
if (memcmp(&tmp, &nullAddr, sizeof(struct sockaddr_storage)) != 0) {
|
||||
jobject addr = newInetSocketAddress(env, tmp);
|
||||
env->CallBooleanMethod(addrArray, java_util_ArrayList_add, addr);
|
||||
env->DeleteLocalRef(addr);
|
||||
}
|
||||
}
|
||||
|
||||
env->SetObjectField(dnsObj, domainField, domain);
|
||||
env->SetObjectField(dnsObj, serversField, addrArray);
|
||||
|
||||
return dnsObj;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -76,6 +76,8 @@ jobject newVersion(JNIEnv *env, int major, int minor, int rev);
|
||||
|
||||
jobject newVirtualNetworkRoute(JNIEnv *env, const ZT_VirtualNetworkRoute &route);
|
||||
|
||||
jobject newVirtualNetworkDNS(JNIEnv *env, const ZT_VirtualNetworkDNS &dns);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -56,6 +56,7 @@ public final class VirtualNetworkConfig implements Comparable<VirtualNetworkConf
|
||||
private long netconfRevision;
|
||||
private InetSocketAddress[] assignedAddresses;
|
||||
private VirtualNetworkRoute[] routes;
|
||||
private VirtualNetworkDNS dns;
|
||||
|
||||
private VirtualNetworkConfig() {
|
||||
|
||||
@@ -161,6 +162,7 @@ public final class VirtualNetworkConfig implements Comparable<VirtualNetworkConf
|
||||
this.broadcastEnabled == cfg.broadcastEnabled &&
|
||||
this.portError == cfg.portError &&
|
||||
this.enabled == cfg.enabled &&
|
||||
this.dns.equals(cfg.dns) &&
|
||||
aaEqual && routesEqual;
|
||||
}
|
||||
|
||||
@@ -278,4 +280,6 @@ public final class VirtualNetworkConfig implements Comparable<VirtualNetworkConf
|
||||
* @return
|
||||
*/
|
||||
public final VirtualNetworkRoute[] routes() { return routes; }
|
||||
|
||||
public final VirtualNetworkDNS dns() { return dns; }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2020 ZeroTier, Inc. https://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class VirtualNetworkDNS implements Comparable<VirtualNetworkDNS> {
|
||||
private String domain;
|
||||
private ArrayList<InetSocketAddress> servers;
|
||||
|
||||
public VirtualNetworkDNS() {}
|
||||
|
||||
public boolean equals(VirtualNetworkDNS o) {
|
||||
return domain.equals(o.domain) && servers.equals(o.servers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(VirtualNetworkDNS o) {
|
||||
return domain.compareTo(o.domain);
|
||||
}
|
||||
|
||||
public String getSearchDomain() { return domain; }
|
||||
|
||||
public ArrayList<InetSocketAddress> getServers() { return servers; }
|
||||
}
|
||||
@@ -103,7 +103,6 @@ public final class VirtualNetworkRoute implements Comparable<VirtualNetworkRoute
|
||||
viaEquals = via.toString().equals(other.via.toString());
|
||||
}
|
||||
|
||||
return viaEquals &&
|
||||
viaEquals;
|
||||
return viaEquals && targetEquals;
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -80,16 +80,16 @@ ifeq ($(CC_MACH),armv6kz)
|
||||
endif
|
||||
ifeq ($(CC_MACH),armv7)
|
||||
ZT_ARCHITECTURE=3
|
||||
override DEFS+=-DZT_NO_TYPE_PUNNING
|
||||
override DEFS+=-DZT_NO_TYPE_PUNNING -DZT_AES_NO_ACCEL
|
||||
ZT_USE_ARM32_NEON_ASM_SALSA2012=1
|
||||
endif
|
||||
ifeq ($(CC_MACH),arm64)
|
||||
ZT_ARCHITECTURE=4
|
||||
override DEFS+=-DZT_NO_TYPE_PUNNING
|
||||
override DEFS+=-DZT_NO_TYPE_PUNNING -march=armv8-a+crypto
|
||||
endif
|
||||
ifeq ($(CC_MACH),aarch64)
|
||||
ZT_ARCHITECTURE=4
|
||||
override DEFS+=-DZT_NO_TYPE_PUNNING
|
||||
override DEFS+=-DZT_NO_TYPE_PUNNING -march=armv8-a+crypto
|
||||
endif
|
||||
ifeq ($(CC_MACH),mipsel)
|
||||
ZT_ARCHITECTURE=5
|
||||
@@ -124,6 +124,7 @@ ifeq ($(ZT_USE_ARM32_NEON_ASM_SALSA2012),1)
|
||||
override DEFS+=-DZT_USE_ARM32_NEON_ASM_SALSA2012
|
||||
override CORE_OBJS+=ext/arm32-neon-salsa2012-asm/salsa2012.o
|
||||
override ASFLAGS+=-meabi=5
|
||||
override LDFLAGS+=-Wl,-z,notext
|
||||
endif
|
||||
|
||||
override DEFS+=-DZT_BUILD_PLATFORM=$(ZT_BUILD_PLATFORM) -DZT_BUILD_ARCHITECTURE=$(ZT_ARCHITECTURE) -DZT_SOFTWARE_UPDATE_DEFAULT="\"disable\""
|
||||
|
||||
+4
-4
@@ -119,15 +119,15 @@ ifeq ($(CC_MACH),x86_64)
|
||||
ZT_ARCHITECTURE=2
|
||||
ZT_USE_X64_ASM_SALSA=1
|
||||
ZT_USE_X64_ASM_ED25519=1
|
||||
override CFLAGS+=-msse -msse2 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mpclmul
|
||||
override CXXFLAGS+=-msse -msse2 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mpclmul
|
||||
override CFLAGS+=-msse -msse2
|
||||
override CXXFLAGS+=-msse -msse2
|
||||
endif
|
||||
ifeq ($(CC_MACH),amd64)
|
||||
ZT_ARCHITECTURE=2
|
||||
ZT_USE_X64_ASM_SALSA=1
|
||||
ZT_USE_X64_ASM_ED25519=1
|
||||
override CFLAGS+=-msse -msse2 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mpclmul
|
||||
override CXXFLAGS+=-msse -msse2 -mssse3 -msse4 -msse4.1 -msse4.2 -maes -mpclmul
|
||||
override CFLAGS+=-msse -msse2
|
||||
override CXXFLAGS+=-msse -msse2
|
||||
endif
|
||||
ifeq ($(CC_MACH),powerpc64le)
|
||||
ZT_ARCHITECTURE=8
|
||||
|
||||
+5
-3
@@ -3,7 +3,8 @@ CXX=clang++
|
||||
INCLUDES=
|
||||
DEFS=
|
||||
LIBS=
|
||||
ARCH_FLAGS=-msse -msse2 -mssse3 -msse4 -msse4.1 -maes -mpclmul
|
||||
ARCH_FLAGS=-msse -msse2 -arch x86_64 -arch arm64
|
||||
|
||||
CODESIGN=echo
|
||||
PRODUCTSIGN=echo
|
||||
CODESIGN_APP_CERT=
|
||||
@@ -66,6 +67,7 @@ endif
|
||||
# Debug mode -- dump trace output, build binary with -g
|
||||
ifeq ($(ZT_DEBUG),1)
|
||||
ZT_TRACE=1
|
||||
ARCH_FLAGS=
|
||||
CFLAGS+=-Wall -g $(INCLUDES) $(DEFS) $(ARCH_FLAGS)
|
||||
STRIP=echo
|
||||
# The following line enables optimization for the crypto code, since
|
||||
@@ -91,10 +93,10 @@ CXXFLAGS=$(CFLAGS) -std=c++11 -stdlib=libc++
|
||||
all: one macui
|
||||
|
||||
ext/x64-salsa2012-asm/salsa2012.o:
|
||||
$(CC) $(CFLAGS) -c ext/x64-salsa2012-asm/salsa2012.s -o ext/x64-salsa2012-asm/salsa2012.o
|
||||
as -arch x86_64 -o ext/x64-salsa2012-asm/salsa2012.o ext/x64-salsa2012-asm/salsa2012.s
|
||||
|
||||
mac-agent: FORCE
|
||||
$(CC) -Ofast -o MacEthernetTapAgent osdep/MacEthernetTapAgent.c
|
||||
$(CC) -Ofast $(ARCH_FLAGS) -o MacEthernetTapAgent osdep/MacEthernetTapAgent.c
|
||||
$(CODESIGN) -f --options=runtime -s $(CODESIGN_APP_CERT) MacEthernetTapAgent
|
||||
|
||||
osdep/MacDNSHelper.o: osdep/MacDNSHelper.mm
|
||||
|
||||
+23
-992
File diff suppressed because it is too large.
Load diff
+36
-21
@@ -18,6 +18,7 @@
|
||||
#include "Utils.hpp"
|
||||
#include "SHA512.hpp"
|
||||
|
||||
// Uncomment to disable all hardware acceleration (usually for testing)
|
||||
//#define ZT_AES_NO_ACCEL
|
||||
|
||||
#if !defined(ZT_AES_NO_ACCEL) && defined(ZT_ARCH_X64)
|
||||
@@ -73,7 +74,7 @@ public:
|
||||
{ this->init(key); }
|
||||
|
||||
ZT_INLINE ~AES()
|
||||
{ Utils::burn(&_k, sizeof(_k)); }
|
||||
{ Utils::burn(&p_k, sizeof(p_k)); }
|
||||
|
||||
/**
|
||||
* Set (or re-set) this AES256 cipher's key
|
||||
@@ -84,17 +85,17 @@ public:
|
||||
{
|
||||
#ifdef ZT_AES_AESNI
|
||||
if (likely(Utils::CPUID.aes)) {
|
||||
_init_aesni(reinterpret_cast<const uint8_t *>(key));
|
||||
p_init_aesni(reinterpret_cast<const uint8_t *>(key));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef ZT_AES_NEON
|
||||
if (Utils::ARMCAP.aes) {
|
||||
_init_armneon_crypto(reinterpret_cast<const uint8_t *>(key));
|
||||
p_init_armneon_crypto(reinterpret_cast<const uint8_t *>(key));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
_initSW(reinterpret_cast<const uint8_t *>(key));
|
||||
p_initSW(reinterpret_cast<const uint8_t *>(key));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,17 +108,17 @@ public:
|
||||
{
|
||||
#ifdef ZT_AES_AESNI
|
||||
if (likely(Utils::CPUID.aes)) {
|
||||
_encrypt_aesni(in, out);
|
||||
p_encrypt_aesni(in, out);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef ZT_AES_NEON
|
||||
if (Utils::ARMCAP.aes) {
|
||||
_encrypt_armneon_crypto(in, out);
|
||||
p_encrypt_armneon_crypto(in, out);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
_encryptSW(reinterpret_cast<const uint8_t *>(in), reinterpret_cast<uint8_t *>(out));
|
||||
p_encryptSW(reinterpret_cast<const uint8_t *>(in), reinterpret_cast<uint8_t *>(out));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,17 +131,17 @@ public:
|
||||
{
|
||||
#ifdef ZT_AES_AESNI
|
||||
if (likely(Utils::CPUID.aes)) {
|
||||
_decrypt_aesni(in, out);
|
||||
p_decrypt_aesni(in, out);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifdef ZT_AES_NEON
|
||||
if (Utils::ARMCAP.aes) {
|
||||
_decrypt_armneon_crypto(in, out);
|
||||
p_decrypt_armneon_crypto(in, out);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
_decryptSW(reinterpret_cast<const uint8_t *>(in), reinterpret_cast<uint8_t *>(out));
|
||||
p_decryptSW(reinterpret_cast<const uint8_t *>(in), reinterpret_cast<uint8_t *>(out));
|
||||
}
|
||||
|
||||
class GMACSIVEncryptor;
|
||||
@@ -225,6 +226,14 @@ public:
|
||||
void finish(uint8_t tag[16]) noexcept;
|
||||
|
||||
private:
|
||||
#ifdef ZT_AES_AESNI
|
||||
void p_aesNIUpdate(const uint8_t *in, unsigned int len) noexcept;
|
||||
void p_aesNIFinish(uint8_t tag[16]) noexcept;
|
||||
#endif
|
||||
#ifdef ZT_AES_NEON
|
||||
void p_armUpdate(const uint8_t *in, unsigned int len) noexcept;
|
||||
void p_armFinish(uint8_t tag[16]) noexcept;
|
||||
#endif
|
||||
const AES &_aes;
|
||||
unsigned int _rp;
|
||||
unsigned int _len;
|
||||
@@ -292,6 +301,12 @@ public:
|
||||
void finish() noexcept;
|
||||
|
||||
private:
|
||||
#ifdef ZT_AES_AESNI
|
||||
void p_aesNICrypt(const uint8_t *in, uint8_t *out, unsigned int len) noexcept;
|
||||
#endif
|
||||
#ifdef ZT_AES_NEON
|
||||
void p_armCrypt(const uint8_t *in, uint8_t *out, unsigned int len) noexcept;
|
||||
#endif
|
||||
const AES &_aes;
|
||||
uint64_t _ctr[2];
|
||||
uint8_t *_out;
|
||||
@@ -318,7 +333,7 @@ public:
|
||||
* @param k0 First of two AES instances keyed with K0
|
||||
* @param k1 Second of two AES instances keyed with K1
|
||||
*/
|
||||
ZT_INLINE GMACSIVEncryptor(const AES &k0, const AES &k1) noexcept:
|
||||
ZT_INLINE GMACSIVEncryptor(const AES &k0, const AES &k1) noexcept :
|
||||
_gmac(k0),
|
||||
_ctr(k1)
|
||||
{}
|
||||
@@ -528,9 +543,9 @@ private:
|
||||
static const uint8_t Td4[256];
|
||||
static const uint32_t rcon[15];
|
||||
|
||||
void _initSW(const uint8_t key[32]) noexcept;
|
||||
void _encryptSW(const uint8_t in[16], uint8_t out[16]) const noexcept;
|
||||
void _decryptSW(const uint8_t in[16], uint8_t out[16]) const noexcept;
|
||||
void p_initSW(const uint8_t *key) noexcept;
|
||||
void p_encryptSW(const uint8_t *in, uint8_t *out) const noexcept;
|
||||
void p_decryptSW(const uint8_t *in, uint8_t *out) const noexcept;
|
||||
|
||||
union
|
||||
{
|
||||
@@ -559,18 +574,18 @@ private:
|
||||
uint32_t ek[60];
|
||||
uint32_t dk[60];
|
||||
} sw;
|
||||
} _k;
|
||||
} p_k;
|
||||
|
||||
#ifdef ZT_AES_AESNI
|
||||
void _init_aesni(const uint8_t key[32]) noexcept;
|
||||
void _encrypt_aesni(const void *in, void *out) const noexcept;
|
||||
void _decrypt_aesni(const void *in, void *out) const noexcept;
|
||||
void p_init_aesni(const uint8_t *key) noexcept;
|
||||
void p_encrypt_aesni(const void *in, void *out) const noexcept;
|
||||
void p_decrypt_aesni(const void *in, void *out) const noexcept;
|
||||
#endif
|
||||
|
||||
#ifdef ZT_AES_NEON
|
||||
void _init_armneon_crypto(const uint8_t key[32]) noexcept;
|
||||
void _encrypt_armneon_crypto(const void *in, void *out) const noexcept;
|
||||
void _decrypt_armneon_crypto(const void *in, void *out) const noexcept;
|
||||
void p_init_armneon_crypto(const uint8_t *key) noexcept;
|
||||
void p_encrypt_armneon_crypto(const void *in, void *out) const noexcept;
|
||||
void p_decrypt_armneon_crypto(const void *in, void *out) const noexcept;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,388 @@
|
||||
/*
|
||||
* Copyright (c)2013-2020 ZeroTier, Inc.
|
||||
*
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file in the project's root directory.
|
||||
*
|
||||
* Change Date: 2025-01-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2.0 of the Apache License.
|
||||
*/
|
||||
/****/
|
||||
|
||||
#include "Constants.hpp"
|
||||
#include "AES.hpp"
|
||||
|
||||
#ifdef ZT_AES_NEON
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
namespace {
|
||||
|
||||
ZT_INLINE uint8x16_t s_clmul_armneon_crypto(uint8x16_t h, uint8x16_t y, const uint8_t b[16]) noexcept
|
||||
{
|
||||
uint8x16_t r0, r1, t0, t1;
|
||||
r0 = vld1q_u8(b);
|
||||
const uint8x16_t z = veorq_u8(h, h);
|
||||
y = veorq_u8(r0, y);
|
||||
y = vrbitq_u8(y);
|
||||
const uint8x16_t p = vreinterpretq_u8_u64(vdupq_n_u64(0x0000000000000087));
|
||||
t0 = vextq_u8(y, y, 8);
|
||||
__asm__ __volatile__("pmull %0.1q, %1.1d, %2.1d \n\t" : "=w" (r0) : "w" (h), "w" (y));
|
||||
__asm__ __volatile__("pmull2 %0.1q, %1.2d, %2.2d \n\t" :"=w" (r1) : "w" (h), "w" (y));
|
||||
__asm__ __volatile__("pmull %0.1q, %1.1d, %2.1d \n\t" : "=w" (t1) : "w" (h), "w" (t0));
|
||||
__asm__ __volatile__("pmull2 %0.1q, %1.2d, %2.2d \n\t" :"=w" (t0) : "w" (h), "w" (t0));
|
||||
t0 = veorq_u8(t0, t1);
|
||||
t1 = vextq_u8(z, t0, 8);
|
||||
r0 = veorq_u8(r0, t1);
|
||||
t1 = vextq_u8(t0, z, 8);
|
||||
r1 = veorq_u8(r1, t1);
|
||||
__asm__ __volatile__("pmull2 %0.1q, %1.2d, %2.2d \n\t" :"=w" (t0) : "w" (r1), "w" (p));
|
||||
t1 = vextq_u8(t0, z, 8);
|
||||
r1 = veorq_u8(r1, t1);
|
||||
t1 = vextq_u8(z, t0, 8);
|
||||
r0 = veorq_u8(r0, t1);
|
||||
__asm__ __volatile__("pmull %0.1q, %1.1d, %2.1d \n\t" : "=w" (t0) : "w" (r1), "w" (p));
|
||||
return vrbitq_u8(veorq_u8(r0, t0));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void AES::GMAC::p_armUpdate(const uint8_t *in, unsigned int len) noexcept
|
||||
{
|
||||
uint8x16_t y = vld1q_u8(reinterpret_cast<const uint8_t *>(_y));
|
||||
const uint8x16_t h = _aes.p_k.neon.h;
|
||||
|
||||
if (_rp) {
|
||||
for(;;) {
|
||||
if (!len)
|
||||
return;
|
||||
--len;
|
||||
_r[_rp++] = *(in++);
|
||||
if (_rp == 16) {
|
||||
y = s_clmul_armneon_crypto(h, y, _r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (len >= 16) {
|
||||
y = s_clmul_armneon_crypto(h, y, in);
|
||||
in += 16;
|
||||
len -= 16;
|
||||
}
|
||||
|
||||
vst1q_u8(reinterpret_cast<uint8_t *>(_y), y);
|
||||
|
||||
for (unsigned int i = 0; i < len; ++i)
|
||||
_r[i] = in[i];
|
||||
_rp = len; // len is always less than 16 here
|
||||
}
|
||||
|
||||
void AES::GMAC::p_armFinish(uint8_t tag[16]) noexcept
|
||||
{
|
||||
uint64_t tmp[2];
|
||||
uint8x16_t y = vld1q_u8(reinterpret_cast<const uint8_t *>(_y));
|
||||
const uint8x16_t h = _aes.p_k.neon.h;
|
||||
|
||||
if (_rp) {
|
||||
while (_rp < 16)
|
||||
_r[_rp++] = 0;
|
||||
y = s_clmul_armneon_crypto(h, y, _r);
|
||||
}
|
||||
|
||||
tmp[0] = Utils::hton((uint64_t)_len << 3U);
|
||||
tmp[1] = 0;
|
||||
y = s_clmul_armneon_crypto(h, y, reinterpret_cast<const uint8_t *>(tmp));
|
||||
|
||||
Utils::copy< 12 >(tmp, _iv);
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
reinterpret_cast<uint32_t *>(tmp)[3] = 0x00000001;
|
||||
#else
|
||||
reinterpret_cast<uint32_t *>(tmp)[3] = 0x01000000;
|
||||
#endif
|
||||
_aes.encrypt(tmp, tmp);
|
||||
|
||||
uint8x16_t yy = y;
|
||||
Utils::storeMachineEndian< uint64_t >(tag, tmp[0] ^ reinterpret_cast<const uint64_t *>(&yy)[0]);
|
||||
Utils::storeMachineEndian< uint64_t >(tag + 8, tmp[1] ^ reinterpret_cast<const uint64_t *>(&yy)[1]);
|
||||
}
|
||||
|
||||
void AES::CTR::p_armCrypt(const uint8_t *in, uint8_t *out, unsigned int len) noexcept
|
||||
{
|
||||
uint8x16_t dd = vrev32q_u8(vld1q_u8(reinterpret_cast<uint8_t *>(_ctr)));
|
||||
const uint32x4_t one = {0,0,0,1};
|
||||
|
||||
uint8x16_t k0 = _aes.p_k.neon.ek[0];
|
||||
uint8x16_t k1 = _aes.p_k.neon.ek[1];
|
||||
uint8x16_t k2 = _aes.p_k.neon.ek[2];
|
||||
uint8x16_t k3 = _aes.p_k.neon.ek[3];
|
||||
uint8x16_t k4 = _aes.p_k.neon.ek[4];
|
||||
uint8x16_t k5 = _aes.p_k.neon.ek[5];
|
||||
uint8x16_t k6 = _aes.p_k.neon.ek[6];
|
||||
uint8x16_t k7 = _aes.p_k.neon.ek[7];
|
||||
uint8x16_t k8 = _aes.p_k.neon.ek[8];
|
||||
uint8x16_t k9 = _aes.p_k.neon.ek[9];
|
||||
uint8x16_t k10 = _aes.p_k.neon.ek[10];
|
||||
uint8x16_t k11 = _aes.p_k.neon.ek[11];
|
||||
uint8x16_t k12 = _aes.p_k.neon.ek[12];
|
||||
uint8x16_t k13 = _aes.p_k.neon.ek[13];
|
||||
uint8x16_t k14 = _aes.p_k.neon.ek[14];
|
||||
|
||||
unsigned int totalLen = _len;
|
||||
if ((totalLen & 15U)) {
|
||||
for (;;) {
|
||||
if (unlikely(!len)) {
|
||||
vst1q_u8(reinterpret_cast<uint8_t *>(_ctr), vrev32q_u8(dd));
|
||||
_len = totalLen;
|
||||
return;
|
||||
}
|
||||
--len;
|
||||
out[totalLen++] = *(in++);
|
||||
if (!(totalLen & 15U)) {
|
||||
uint8_t *const otmp = out + (totalLen - 16);
|
||||
uint8x16_t d0 = vrev32q_u8(dd);
|
||||
uint8x16_t pt = vld1q_u8(otmp);
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k0));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k1));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k2));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k3));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k4));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k5));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k6));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k7));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k8));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k9));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k10));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k11));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k12));
|
||||
d0 = veorq_u8(vaeseq_u8(d0, k13), k14);
|
||||
vst1q_u8(otmp, veorq_u8(pt, d0));
|
||||
dd = (uint8x16_t)vaddq_u32((uint32x4_t)dd, one);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out += totalLen;
|
||||
_len = totalLen + len;
|
||||
|
||||
if (likely(len >= 64)) {
|
||||
const uint32x4_t four = vshlq_n_u32(one, 2);
|
||||
uint8x16_t dd1 = (uint8x16_t)vaddq_u32((uint32x4_t)dd, one);
|
||||
uint8x16_t dd2 = (uint8x16_t)vaddq_u32((uint32x4_t)dd1, one);
|
||||
uint8x16_t dd3 = (uint8x16_t)vaddq_u32((uint32x4_t)dd2, one);
|
||||
for (;;) {
|
||||
len -= 64;
|
||||
uint8x16_t d0 = vrev32q_u8(dd);
|
||||
uint8x16_t d1 = vrev32q_u8(dd1);
|
||||
uint8x16_t d2 = vrev32q_u8(dd2);
|
||||
uint8x16_t d3 = vrev32q_u8(dd3);
|
||||
uint8x16_t pt0 = vld1q_u8(in);
|
||||
in += 16;
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k0));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k0));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k0));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k0));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k1));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k1));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k1));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k1));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k2));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k2));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k2));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k2));
|
||||
uint8x16_t pt1 = vld1q_u8(in);
|
||||
in += 16;
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k3));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k3));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k3));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k3));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k4));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k4));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k4));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k4));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k5));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k5));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k5));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k5));
|
||||
uint8x16_t pt2 = vld1q_u8(in);
|
||||
in += 16;
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k6));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k6));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k6));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k6));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k7));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k7));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k7));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k7));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k8));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k8));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k8));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k8));
|
||||
uint8x16_t pt3 = vld1q_u8(in);
|
||||
in += 16;
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k9));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k9));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k9));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k9));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k10));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k10));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k10));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k10));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k11));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k11));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k11));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k11));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k12));
|
||||
d1 = vaesmcq_u8(vaeseq_u8(d1, k12));
|
||||
d2 = vaesmcq_u8(vaeseq_u8(d2, k12));
|
||||
d3 = vaesmcq_u8(vaeseq_u8(d3, k12));
|
||||
d0 = veorq_u8(vaeseq_u8(d0, k13), k14);
|
||||
d1 = veorq_u8(vaeseq_u8(d1, k13), k14);
|
||||
d2 = veorq_u8(vaeseq_u8(d2, k13), k14);
|
||||
d3 = veorq_u8(vaeseq_u8(d3, k13), k14);
|
||||
|
||||
d0 = veorq_u8(pt0, d0);
|
||||
d1 = veorq_u8(pt1, d1);
|
||||
d2 = veorq_u8(pt2, d2);
|
||||
d3 = veorq_u8(pt3, d3);
|
||||
|
||||
vst1q_u8(out, d0);
|
||||
vst1q_u8(out + 16, d1);
|
||||
vst1q_u8(out + 32, d2);
|
||||
vst1q_u8(out + 48, d3);
|
||||
out += 64;
|
||||
|
||||
dd = (uint8x16_t)vaddq_u32((uint32x4_t)dd, four);
|
||||
if (unlikely(len < 64))
|
||||
break;
|
||||
dd1 = (uint8x16_t)vaddq_u32((uint32x4_t)dd1, four);
|
||||
dd2 = (uint8x16_t)vaddq_u32((uint32x4_t)dd2, four);
|
||||
dd3 = (uint8x16_t)vaddq_u32((uint32x4_t)dd3, four);
|
||||
}
|
||||
}
|
||||
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
uint8x16_t d0 = vrev32q_u8(dd);
|
||||
uint8x16_t pt = vld1q_u8(in);
|
||||
in += 16;
|
||||
dd = (uint8x16_t)vaddq_u32((uint32x4_t)dd, one);
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k0));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k1));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k2));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k3));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k4));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k5));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k6));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k7));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k8));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k9));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k10));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k11));
|
||||
d0 = vaesmcq_u8(vaeseq_u8(d0, k12));
|
||||
d0 = veorq_u8(vaeseq_u8(d0, k13), k14);
|
||||
vst1q_u8(out, veorq_u8(pt, d0));
|
||||
out += 16;
|
||||
}
|
||||
|
||||
// Any remaining input is placed in _out. This will be picked up and crypted
|
||||
// on subsequent calls to crypt() or finish() as it'll mean _len will not be
|
||||
// an even multiple of 16.
|
||||
for (unsigned int i = 0; i < len; ++i)
|
||||
out[i] = in[i];
|
||||
|
||||
vst1q_u8(reinterpret_cast<uint8_t *>(_ctr), vrev32q_u8(dd));
|
||||
}
|
||||
|
||||
#define ZT_INIT_ARMNEON_CRYPTO_SUBWORD(w) ((uint32_t)s_sbox[w & 0xffU] + ((uint32_t)s_sbox[(w >> 8U) & 0xffU] << 8U) + ((uint32_t)s_sbox[(w >> 16U) & 0xffU] << 16U) + ((uint32_t)s_sbox[(w >> 24U) & 0xffU] << 24U))
|
||||
#define ZT_INIT_ARMNEON_CRYPTO_ROTWORD(w) (((w) << 8U) | ((w) >> 24U))
|
||||
#define ZT_INIT_ARMNEON_CRYPTO_NK 8
|
||||
#define ZT_INIT_ARMNEON_CRYPTO_NB 4
|
||||
#define ZT_INIT_ARMNEON_CRYPTO_NR 14
|
||||
|
||||
void AES::p_init_armneon_crypto(const uint8_t *key) noexcept
|
||||
{
|
||||
static const uint8_t s_sbox[256] = {0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c,
|
||||
0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea,
|
||||
0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16};
|
||||
|
||||
uint64_t h[2];
|
||||
uint32_t *const w = reinterpret_cast<uint32_t *>(p_k.neon.ek);
|
||||
|
||||
for (unsigned int i=0;i<ZT_INIT_ARMNEON_CRYPTO_NK;++i) {
|
||||
const unsigned int j = i * 4;
|
||||
w[i] = ((uint32_t)key[j] << 24U) | ((uint32_t)key[j + 1] << 16U) | ((uint32_t)key[j + 2] << 8U) | (uint32_t)key[j + 3];
|
||||
}
|
||||
|
||||
for (unsigned int i=ZT_INIT_ARMNEON_CRYPTO_NK;i<(ZT_INIT_ARMNEON_CRYPTO_NB * (ZT_INIT_ARMNEON_CRYPTO_NR + 1));++i) {
|
||||
uint32_t t = w[i - 1];
|
||||
const unsigned int imod = i & (ZT_INIT_ARMNEON_CRYPTO_NK - 1);
|
||||
if (imod == 0) {
|
||||
t = ZT_INIT_ARMNEON_CRYPTO_SUBWORD(ZT_INIT_ARMNEON_CRYPTO_ROTWORD(t)) ^ rcon[(i - 1) / ZT_INIT_ARMNEON_CRYPTO_NK];
|
||||
} else if (imod == 4) {
|
||||
t = ZT_INIT_ARMNEON_CRYPTO_SUBWORD(t);
|
||||
}
|
||||
w[i] = w[i - ZT_INIT_ARMNEON_CRYPTO_NK] ^ t;
|
||||
}
|
||||
|
||||
for (unsigned int i=0;i<(ZT_INIT_ARMNEON_CRYPTO_NB * (ZT_INIT_ARMNEON_CRYPTO_NR + 1));++i)
|
||||
w[i] = Utils::hton(w[i]);
|
||||
|
||||
p_k.neon.dk[0] = p_k.neon.ek[14];
|
||||
for (int i=1;i<14;++i)
|
||||
p_k.neon.dk[i] = vaesimcq_u8(p_k.neon.ek[14 - i]);
|
||||
p_k.neon.dk[14] = p_k.neon.ek[0];
|
||||
|
||||
p_encrypt_armneon_crypto(Utils::ZERO256, h);
|
||||
Utils::copy<16>(&(p_k.neon.h), h);
|
||||
p_k.neon.h = vrbitq_u8(p_k.neon.h);
|
||||
p_k.sw.h[0] = Utils::ntoh(h[0]);
|
||||
p_k.sw.h[1] = Utils::ntoh(h[1]);
|
||||
}
|
||||
|
||||
void AES::p_encrypt_armneon_crypto(const void *const in, void *const out) const noexcept
|
||||
{
|
||||
uint8x16_t tmp = vld1q_u8(reinterpret_cast<const uint8_t *>(in));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[0]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[1]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[2]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[3]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[4]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[5]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[6]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[7]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[8]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[9]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[10]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[11]));
|
||||
tmp = vaesmcq_u8(vaeseq_u8(tmp, p_k.neon.ek[12]));
|
||||
tmp = veorq_u8(vaeseq_u8(tmp, p_k.neon.ek[13]), p_k.neon.ek[14]);
|
||||
vst1q_u8(reinterpret_cast<uint8_t *>(out), tmp);
|
||||
}
|
||||
|
||||
void AES::p_decrypt_armneon_crypto(const void *const in, void *const out) const noexcept
|
||||
{
|
||||
uint8x16_t tmp = vld1q_u8(reinterpret_cast<const uint8_t *>(in));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[0]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[1]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[2]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[3]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[4]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[5]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[6]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[7]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[8]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[9]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[10]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[11]));
|
||||
tmp = vaesimcq_u8(vaesdq_u8(tmp, p_k.neon.dk[12]));
|
||||
tmp = veorq_u8(vaesdq_u8(tmp, p_k.neon.dk[13]), p_k.neon.dk[14]);
|
||||
vst1q_u8(reinterpret_cast<uint8_t *>(out), tmp);
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif // ZT_AES_NEON
|
||||
Loaded 20 of 53 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user