Update to CryptoPP 8.5.0. This should make it work with Apple M1

This commit is contained in:
Sebastian Messmer 2021-01-12 22:36:27 -08:00 committed by Sebastian Messmer
parent fd72b8c7ab
commit 46ada21a30
367 changed files with 39938 additions and 29066 deletions

View File

@ -9,6 +9,9 @@ Security:
able to access those two blocks (i.e. 64KB of the stored data) is bad enough. See Section 8.3 in https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
XChaCha20-Poly1305 does not suffer from this constraint and stays secure even if the filesystem gets very large.
New platforms:
* CryFS should now work on devices with Apple M1 silicon
Build changes:
* Switch to Conan package manager
* Allow an easy way to modify how the dependencies are found. This is mostly helpful for package maintainers.
@ -18,7 +21,7 @@ Build changes:
Improvements:
* Display the file system configuration when mounting a file system
* Now shows a better error message when failing to load the config file and distinguishes between "wrong password" and "config file not found".
* Now shows a better error message when failing to load the config file that distinguishes between "wrong password" and "config file not found".
New features:
* Add support for atime mount options (noatime, strictatime, relatime, atime, nodiratime).
@ -32,6 +35,8 @@ Other:
* Updated to spdlog 1.8.5
* Updated to ranges-v3 0.11.0
* Updated to boost 1.75
* Updated to crypto++ 8.5
Version 0.10.3
---------------

9
vendor/README vendored
View File

@ -1,9 +1,8 @@
This directory contains external projects, taken from the following locations:
googletest: https://github.com/google/googletest/commit/eaf9a3fd77869cf95befb87455a2e2a2e85044ff
- changed: In googletest/cmake/internal_utils.cmake, add cmake_policy(SET CMP0069 NEW) to silence a warning
cryptopp: https://github.com/weidai11/cryptopp/tree/CRYPTOPP_8_2_0
- changed: added CMakeLists.txt and cryptopp-config.cmake from https://github.com/noloader/cryptopp-cmake/tree/CRYPTOPP_8_2_0
- changed: commented out line including winapifamily.h in CMakeLists.txt
cryptopp: https://github.com/weidai11/cryptopp/tree/CRYPTOPP_8_5_0
- changed: added CMakeLists.txt and cryptopp-config.cmake from https://github.com/noloader/cryptopp-cmake/tree/CRYPTOPP_8_5_0
- changed: In CMakeLists.txt, rename BUILD_TESTING to CRYPTOPP_BUILD_TESTING so it doesn't clash with our BUILD_TESTING
- changed: In CmakeLists.txt, add cmake_policy(SET CMP0069 NEW) to silence a warning
- changed: Fix Android compilation using patch file https://github.com/termux/termux-root-packages/files/4664745/config.h.patch.txt from https://github.com/cryfs/cryfs/issues/345
- changed: In CMakeLists.txt, add cmake_policy(SET CMP0069 NEW) to silence a warning
- changed: In .gitignore, remove *.cxx entry so we don't miss checking in the test files, see https://github.com/noloader/cryptopp-cmake/issues/66

View File

@ -0,0 +1,55 @@
# Appveyor's documentation is at https://www.appveyor.com/docs/build-phase/,
# and a sample configuration file is at https://www.appveyor.com/docs/appveyor-yml/.
# I have to admit its a bit complex and I don't fully understand it.
version: 1.0.{build}
clone_depth: 5
skip_tags: true
configuration:
- Debug
- Release
platform:
- Win32
- x64
image:
- Visual Studio 2019
- Visual Studio 2017
- Visual Studio 2015
- Visual Studio 2013
environment:
matrix:
- BUILD_MODE: MSBuild
# Disable build through solution file
build: off
# Build through commands in script below
test_script:
- ps: >-
msbuild /t:Build /p:platform="$env:platform" /p:configuration="$env:configuration" cryptlib.vcxproj
msbuild /t:Build /p:platform="$env:platform" /p:configuration="$env:configuration" cryptest.vcxproj
msbuild /t:CopyCryptestToRoot cryptest.vcxproj
.\cryptest.exe v
.\cryptest.exe tv all
notifications:
- provider: Email
to:
- cryptopp-build@googlegroups.com
on_build_success: true
on_build_failure: true

View File

@ -0,0 +1,59 @@
# https://cirrus-ci.org/examples/
# https://github.com/curl/curl/blob/master/.cirrus.yml
# FreeBSD seems to have constant version problems, which requires IGNORE_OSVERSION.
env:
CIRRUS_CLONE_DEPTH: 5
IGNORE_OSVERSION: yes
task:
matrix:
- name: Debug build, FreeBSD 12.1
freebsd_instance:
image_family: freebsd-12-1
pkginstall_script:
- pkg update -f
- pkg install -y gmake
configure_script:
compile_script:
- CXXFLAGS="-DDEBUG -g3 -O0" gmake -j 3
test_script:
- ./cryptest.exe v
- ./cryptest.exe tv all
- name: Release build, FreeBSD 12.1
freebsd_instance:
image_family: freebsd-12-1
pkginstall_script:
- pkg update -f
- pkg install -y gmake
configure_script:
compile_script:
- gmake -j 3
test_script:
- ./cryptest.exe v
- ./cryptest.exe tv all
- name: Debug build, FreeBSD 13.0 (snap)
freebsd_instance:
image_family: freebsd-13-0-snap
pkginstall_script:
- pkg update -f
- pkg install -y gmake
configure_script:
compile_script:
- CXXFLAGS="-DDEBUG -g3 -O0" gmake -j 3
test_script:
- ./cryptest.exe v
- ./cryptest.exe tv all
- name: Release build, FreeBSD 13.0 (snap)
freebsd_instance:
image_family: freebsd-13-0-snap
pkginstall_script:
- pkg update -f
- pkg install -y gmake
configure_script:
compile_script:
- gmake -j 3
test_script:
- ./cryptest.exe v
- ./cryptest.exe tv all

View File

@ -0,0 +1 @@
*.sh eol=lf

View File

@ -0,0 +1,17 @@
### Crypto++ Issue Report
Thanks for taking the time to report an issue. Reporting issues helps us improve stability and reliability for all users, so it is a valuable contribution.
Please do not ask questions in the bug tracker. Please ask questions on the Crypto++ Users List at http://groups.google.com/forum/#!forum/cryptopp-users.
Please _do not_ ask questions at Stack Overflow. We may not be able to answer your question.
There is a wiki page with information on filing useful bug reports. If you have some time please visit http://www.cryptopp.com/wiki/Bug_Report on the wiki. The executive summary is:
* State the operating system and version (Ubutnu 17 x86_64, Windows 7 Professional x64, etc)
* State the version of the Crypto++ library (Crypto++ 7.0, Master, etc)
* State how you built the library (Makefile, Cmake, distro, etc)
* Show a typical command line (the output of the compiler for cryptlib.cpp)
* Show the link command (the output of the linker for libcryptopp.so or cryptest.exe)
* Show the exact error message you are receiving (copy and paste it); or
* Clearly state the undesired behavior (and state the expected behavior)

View File

@ -0,0 +1,19 @@
name: C/C++ CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: make
run: make all
- name: make test
run: make test

View File

@ -3,7 +3,7 @@
# Allows you to use test.cxx and
# avoid getting in the way of things
####################################
*.cxx
#*.cxx
####################
## Crypto++ specific
@ -38,6 +38,18 @@ a.out
*.o
#################
## Emacs
#################
*~
\#*\#
#################
## Vi swap
#################
*.swp
*.swo
#################
## Eclipse
#################
@ -85,7 +97,10 @@ local.properties
[Dd]ebug/
[Rr]elease/
Win32/
x64/
Arm/
Arm64/
build/
[Bb]in/
[Oo]bj/

View File

@ -0,0 +1,655 @@
# In the YML below each job gets an environment that includes
# BUILD_OS and BUILD_MODE. The variables are used in the driver
# scripts and is used to select a test. For example, BUILD_OS=linux
# and BUILD_MODE=all means run 'make all' on Linux. The Android
# tests specify a ANDROID_API, ANDROID_CPU; and the iOS tests
# specify IOS_SDK and IOS_CPU. They are exported for the underlying
# setenv-*.sh scripts.
# DO NOT create top level (global) keys like env, arch, os, compiler.
# The top level/global keys invoke [unwanted] matrix expansion. Also
# see https://stackoverflow.com/q/58473000/608639 and
# https://docs.travis-ci.com/user/reference/overview/ and
# https://docs.travis-ci.com/user/multi-cpu-architectures and
# https://github.com/travis-ci/travis-yml/blob/master/schema.json.
language: cpp
dist: bionic
git:
depth: 5
# Use jobs rather than matrix since we are precisely
# specifiying our test cases. Do not move any of the
# keys (env, os, arch, compiler, etc) into global.
# Putting them in global invokes the matrix expansion.
jobs:
include:
- name: Standard build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=all
- name: Native build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=native
- name: No-asm build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=no-asm
- name: Debug build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=debug
- name: Asan build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=asan
- name: UBsan build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=ubsan
- name: PEM build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=pem
- name: Autotools build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=autotools
- name: CMake build, GCC, Linux, amd64
os: linux
arch: amd64
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=cmake
- name: Standard build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=all
- name: Native build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=native
- name: No-asm build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=no-asm
- name: Debug build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=debug
- name: Asan build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=asan
- name: UBsan build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=ubsan
- name: PEM build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=pem
- name: Autotools build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=autotools
- name: CMake build, Clang, Linux, amd64
os: linux
arch: amd64
compiler: clang
env:
- BUILD_OS=linux
- BUILD_MODE=cmake
- name: Standard build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=all
- name: Standard build (64-bit), Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- CXXFLAGS="-DNDEBUG -g2 -O3 -arch x86_64"
- BUILD_OS=osx
- BUILD_MODE=all
- name: Standard build (32-bit), Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- CXXFLAGS="-DNDEBUG -g2 -O3 -arch i386"
- BUILD_OS=osx
- BUILD_MODE=all
- name: Standard build (fat), Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- CXXFLAGS="-DNDEBUG -g2 -O3 -arch i386 -arch x86_64"
- BUILD_OS=osx
- BUILD_MODE=osx-fat
- name: Native build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=native
- name: No-asm build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=no-asm
- name: Debug build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=debug
- name: Asan build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=asan
- name: UBsan build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=ubsan
- name: PEM build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=pem
- name: Autotools build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=autotools
- name: CMake build, Clang, OS X, amd64
os: osx
osx_image: xcode10.1
arch: amd64
compiler: clang
env:
- BUILD_OS=osx
- BUILD_MODE=cmake
- name: Standard build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=all
- name: Native build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=native
- name: No-asm build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=no-asm
- name: Debug build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=debug
- name: Asan build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=asan
- name: UBsan build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=ubsan
- name: PEM build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=pem
- name: Autotools build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=autotools
- name: CMake build, GCC, Linux, arm64
os: linux
arch: arm64
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=cmake
- name: Standard build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=all
- name: Native build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=native
- name: No-asm build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=no-asm
- name: Debug build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=debug
- name: Asan build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=asan
- name: UBsan build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=ubsan
- name: PEM build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=pem
- name: Autotools build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=autotools
- name: CMake build, Clang, Linux, arm64
os: linux
arch: arm64
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=cmake
- name: Standard build, GCC, Linux, ppc64le
os: linux
arch: ppc64le
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=all
- name: Debug build, GCC, Linux, ppc64le
os: linux
arch: ppc64le
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=debug
- name: Standard build, Clang, Linux, ppc64le
os: linux
arch: ppc64le
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=all
- CC=clang-8
- CXX=clang++-8
- name: Debug build, Clang, Linux, ppc64le
os: linux
arch: ppc64le
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=debug
- CC=clang-8
- CXX=clang++-8
- name: Standard build, GCC, Linux, s390x
os: linux
arch: s390x
compiler: gcc
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=all
- name: Debug build, GCC, Linux, s390x
os: linux
arch: s390x
compiler: gcc
env:
- BUILD_OS=linux
- BUILD_MODE=debug
- name: Standard build, Clang, Linux, s390x
os: linux
arch: s390x
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=all
- CC=clang-8
- CXX=clang++-8
- name: Debug build, Clang, Linux, s390x
os: linux
arch: s390x
compiler: clang
dist: bionic
env:
- BUILD_OS=linux
- BUILD_MODE=debug
- CC=clang-8
- CXX=clang++-8
- name: Android, armv7a, Linux
os: linux
arch: amd64
env:
- BUILD_OS=linux
- BUILD_MODE=android
- ANDROID_CPU=armv7a
- ANDROID_API=23
- ANDROID_SDK_ROOT="/opt/android-sdk"
- ANDROID_NDK_ROOT="/opt/android-ndk"
- name: Android, aarch64, Linux
os: linux
arch: amd64
env:
- BUILD_OS=linux
- BUILD_MODE=android
- ANDROID_CPU=aarch64
- ANDROID_API=23
- ANDROID_SDK_ROOT="/opt/android-sdk"
- ANDROID_NDK_ROOT="/opt/android-ndk"
- name: Android, x86, Linux
os: linux
arch: amd64
env:
- BUILD_OS=linux
- BUILD_MODE=android
- ANDROID_CPU=x86
- ANDROID_API=23
- ANDROID_SDK_ROOT="/opt/android-sdk"
- ANDROID_NDK_ROOT="/opt/android-ndk"
- name: Android, x86_64, Linux
os: linux
arch: amd64
env:
- BUILD_OS=linux
- BUILD_MODE=android
- ANDROID_CPU=x86_64
- ANDROID_API=23
- ANDROID_SDK_ROOT="/opt/android-sdk"
- ANDROID_NDK_ROOT="/opt/android-ndk"
- name: iPhoneOS, armv7, iOS
os: osx
osx_image: xcode10.1
arch: amd64
env:
- BUILD_OS=osx
- BUILD_MODE=ios
- IOS_CPU=armv7s
- IOS_SDK=iPhoneOS
- name: iPhoneOS, arm64, iOS
os: osx
osx_image: xcode10.1
arch: amd64
env:
- BUILD_OS=osx
- BUILD_MODE=ios
- IOS_CPU=arm64
- IOS_SDK=iPhoneOS
- name: AppleTVOS, arm64, iOS
os: osx
osx_image: xcode10.1
arch: amd64
env:
- BUILD_OS=osx
- BUILD_MODE=ios
- IOS_CPU=arm64
- IOS_SDK=AppleTVOS
- name: WatchOS, armv7, iOS
os: osx
osx_image: xcode10.1
arch: amd64
env:
- BUILD_OS=osx
- BUILD_MODE=ios
- IOS_CPU=armv7k
- IOS_SDK=WatchOS
- name: iPhoneSimulator, i386, OS X
os: osx
osx_image: xcode10.1
arch: amd64
env:
- BUILD_OS=osx
- BUILD_MODE=ios
- IOS_CPU=i386
- IOS_SDK=iPhoneSimulator
- name: iPhoneSimulator, x86_64, OS X
os: osx
osx_image: xcode10.1
arch: amd64
env:
- BUILD_OS=osx
- BUILD_MODE=ios
- IOS_CPU=x86_64
- IOS_SDK=iPhoneSimulator
- name: AppleTVSimulator, x86_64, OS X
os: osx
osx_image: xcode10.1
arch: amd64
env:
- BUILD_OS=osx
- BUILD_MODE=ios
- IOS_CPU=x86_64
- IOS_SDK=AppleTVSimulator
- name: WatchSimulator, i386, OS X
os: osx
osx_image: xcode10.1
arch: amd64
env:
- BUILD_OS=osx
- BUILD_MODE=ios
- IOS_CPU=i386
- IOS_SDK=WatchSimulator
allow_failures:
# Clang has a fair amount of trouble
# on platforms Apple does not support
- os: linux
arch: s390x
compiler: clang
# Clang 7.0 and below will likely have trouble on ppc64le
# due to https://bugs.llvm.org/show_bug.cgi?id=39704.
- os: linux
arch: ppc64le
compiler: clang
before_install:
- |
if [[ "$BUILD_OS" == "linux" ]] && [[ "$BUILD_MODE" == "android" ]]; then
# https://github.com/travis-ci/travis-ci/issues/9037
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A145
sudo apt-get -qq -y update
sudo -E TestScripts/install-ndk.sh
fi
if [[ "$BUILD_OS" == "linux" ]] && [[ "$BUILD_MODE" == "autotools" ]]; then
# https://github.com/travis-ci/travis-ci/issues/9037
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A145
sudo apt-get -qq -y install autoconf automake libtool
fi
# Clang 7 compiler is completely broken on PPC64 and s390x
if [[ "$TRAVIS_CPU_ARCH" == "ppc64le" ]] || [[ "$TRAVIS_CPU_ARCH" == "s390x" ]]; then
if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$TRAVIS_COMPILER" == "clang" ]]; then
# https://github.com/travis-ci/travis-ci/issues/9037
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A145
sudo apt-get -qq -y install --no-install-recommends clang-8
fi
fi
script:
- |
if [[ "$BUILD_MODE" == "ios" ]]; then
source TestScripts/setenv-ios.sh
make -f GNUmakefile-cross -j 2 all static dynamic
elif [[ "$BUILD_MODE" == "android" ]]; then
source TestScripts/setenv-android.sh
make -f GNUmakefile-cross -j 2 all static dynamic
elif [[ "$BUILD_MODE" == "autotools" ]]; then
bash TestScripts/cryptest-autotools.sh
elif [[ "$BUILD_MODE" == "cmake" ]]; then
bash TestScripts/cryptest-cmake.sh
elif [[ "$BUILD_MODE" == "pem" ]]; then
bash TestScripts/cryptest-pem.sh
elif [[ "$BUILD_MODE" == "osx-fat" ]]; then
CXXFLAGS="-DNDEBUG -g2 -O3 -arch i386 -arch x86_64" make -j 2
arch -i386 ./cryptest.exe v
arch -i386 ./cryptest.exe tv all
arch -x86_64 ./cryptest.exe v
arch -x86_64 ./cryptest.exe tv all
elif [[ "$BUILD_MODE" == "debug" ]]; then
CXXFLAGS="-DDEBUG -g2 -O1" make -j 2
./cryptest.exe v
./cryptest.exe tv all
else
make "$BUILD_MODE" -j 2
./cryptest.exe v
./cryptest.exe tv all
fi
# Whitelist branches to avoid testing feature branches twice
branches:
only:
- master
- /\/ci$/
notifications:
email:
recipients:
- cryptopp-build@googlegroups.com
on_success: always # default: change
on_failure: always # default: always

View File

@ -1,4 +1,4 @@
// 3way.cpp - modifed by Wei Dai from Joan Daemen's 3way.c
// 3way.cpp - modified by Wei Dai from Joan Daemen's 3way.c
// The original code and all modifications are in the public domain.
#include "pch.h"

View File

@ -34,11 +34,11 @@ cmake_policy(SET CMP0069 NEW)
if (${CMAKE_VERSION} VERSION_LESS "3.0.0")
project(cryptopp)
set(cryptopp_VERSION_MAJOR 8)
set(cryptopp_VERSION_MINOR 2)
set(cryptopp_VERSION_MINOR 5)
set(cryptopp_VERSION_PATCH 0)
else ()
cmake_policy(SET CMP0048 NEW)
project(cryptopp VERSION 8.2.0)
project(cryptopp VERSION 8.3.0)
if (NOT ${CMAKE_VERSION} VERSION_LESS "3.1.0")
cmake_policy(SET CMP0054 NEW)
endif ()
@ -84,7 +84,6 @@ option(DISABLE_AESNI "Disable AES-NI" OFF)
option(DISABLE_SHA "Disable SHA" OFF)
option(DISABLE_AVX "Disable AVX" OFF)
option(DISABLE_AVX2 "Disable AVX2" OFF)
option(CRYPTOPP_NATIVE_ARCH "Enable native architecture" OFF)
set(CRYPTOPP_DATA_DIR "" CACHE PATH "Crypto++ test data directory")
#============================================================================
@ -117,9 +116,24 @@ endif ()
if (DISABLE_SSE4)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE4)
endif ()
if (DISABLE_CLMUL)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_CLMUL)
endif ()
if (DISABLE_AESNI)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AESNI)
endif ()
if (DISABLE_RDRAND)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_RDRAND)
endif ()
if (DISABLE_RDSEED)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_RDSEED)
endif ()
if (DISABLE_AVX)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AVX)
endif ()
if (DISABLE_AVX2)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AVX2)
endif ()
if (DISABLE_SHA)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SHA)
endif ()
@ -227,28 +241,23 @@ function(CheckCompileLinkOption opt var prog)
# TODO: improve this...
CHECK_CXX_COMPILER_FLAG(${opt} ${var})
elseif (APPLE)
message(STATUS "Performing Test ${var}")
try_compile(COMMAND_SUCCESS ${CMAKE_BINARY_DIR} ${prog} COMPILE_DEFINITIONS ${opt})
if (COMMAND_SUCCESS)
set(${var} 1 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Success")
else ()
set(${var} 0 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Failed")
endif ()
else ()
message(STATUS "Performing Test ${var}")
execute_process(
COMMAND sh -c "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${opt} ${prog} 2>&1"
RESULT_VARIABLE COMMAND_RESULT
OUTPUT_VARIABLE COMMAND_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE)
# message(STATUS "RESULT_VARIABLE ${RESULT_VARIABLE}")
# message(STATUS "COMMAND_RESULT ${COMMAND_RESULT}")
# message(STATUS "OUTPUT_VARIABLE ${OUTPUT_VARIABLE}")
# message(STATUS "COMMAND_OUTPUT ${COMMAND_OUTPUT}")
# This test is strict. We require two things. First, the invocation
# of the compile command must return 0. Second, there must be no
# messages on the console. We are interested in diagnostics like
# warnings to decide when to reject an option. But we will probably
# capture chatty compiler that want to say, "Hooray, success". For
# chatty compilers we will need to find a quiet option and use it
# for the test. Microsoft compilers come to mind.
if ("${COMMAND_RESULT}" EQUAL 0 AND "${COMMAND_OUTPUT}" STREQUAL "")
try_compile(COMMAND_SUCCESS ${CMAKE_BINARY_DIR} ${prog} COMPILE_DEFINITIONS ${opt})
if (COMMAND_SUCCESS)
set(${var} 1 PARENT_SCOPE)
message(STATUS "Performing Test ${var} - Success")
else ()
@ -279,35 +288,36 @@ function(DumpMachine output pattern)
set(${output} 0 PARENT_SCOPE)
else ()
execute_process(
COMMAND sh -c "${CMAKE_CXX_COMPILER} -dumpmachine 2>&1"
COMMAND ${GREP_CMD} -i -c -E "${pattern}"
OUTPUT_VARIABLE ${output}
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(${output} "${${output}}" PARENT_SCOPE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES ${pattern})
set(${output} TRUE PARENT_SCOPE)
endif()
endif()
endfunction(DumpMachine)
# Thansk to Anonimal for MinGW; see http://github.com/weidai11/cryptopp/issues/466
DumpMachine(CRYPTOPP_AMD64 "amd64|x86_64")
DumpMachine(CRYPTOPP_I386 "i.86")
DumpMachine(CRYPTOPP_MINGW32 "\\<mingw32\\>")
DumpMachine(CRYPTOPP_MINGW64 "w64-mingw32|mingw64")
DumpMachine(CRYPTOPP_X32 "x32")
DumpMachine(CRYPTOPP_AARCH32 "Aarch32")
DumpMachine(CRYPTOPP_AARCH64 "Aarch64")
DumpMachine(CRYPTOPP_ARMHF "armhf|arm7l|eabihf")
DumpMachine(CRYPTOPP_ARM "\\<arm\\>")
DumpMachine(CRYPTOPP_AMD64 "(x86_64|AMD64|amd64)")
DumpMachine(CRYPTOPP_I386 "^i.86$")
DumpMachine(CRYPTOPP_MINGW32 "^mingw32")
DumpMachine(CRYPTOPP_MINGW64 "(w64-mingw32)|(mingw64)")
DumpMachine(CRYPTOPP_ARMV8 "(armv8|aarch32|aarch64)")
DumpMachine(CRYPTOPP_ARM32 "(arm|armhf|arm7l|eabihf)")
DumpMachine(CRYPTOPP_PPC32 "^(powerpc|ppc)")
DumpMachine(CRYPTOPP_PPC64 "^ppc64")
# Cleanup 32/64 bit
if (CRYPTOPP_AMD64)
set (CRYPTOPP_I386 0)
endif ()
if (CRYPTOPP_ARMV8)
set (CRYPTOPP_ARM32 0)
endif ()
if (CRYPTOPP_PPC64)
set (CRYPTOPP_PPC32 0)
endif ()
# Detecting PowerPC is only good with GCC. IBM XLC compiler is
# a little different and I don't know how to ask to the triplet
# XLC is targeting. Below we punt by setting CRYPTOPP_POWERPC64
# if we detect the compiler is XLC.
DumpMachine(CRYPTOPP_POWERPC "ppc|powerpc")
DumpMachine(CRYPTOPP_POWERPC64 "ppc64")
###############################################################################
@ -328,8 +338,8 @@ if (NOT CRYPTOPP_SOLARIS)
endif ()
# Fixup PowerPC. If both 32-bit and 64-bit use 64-bit.
if (CRYPTOPP_POWERPC AND CRYPTOPP_POWERPC64)
unset(CRYPTOPP_POWERPC)
if (CRYPTOPP_PPC32 AND CRYPTOPP_PPC64)
unset(CRYPTOPP_PPC32)
endif ()
# Fixup for xlC compiler. -dumpmachine fails so we miss PowerPC
@ -337,7 +347,7 @@ endif ()
# Must use CMAKE_CXX_COMPILER here due to XLC 13.1 and LLVM front-end.
if (CMAKE_CXX_COMPILER MATCHES "xlC")
message ("-- Fixing platform due to IBM xlC")
set(CRYPTOPP_POWERPC64 1)
set(CRYPTOPP_PPC64 1)
endif ()
# DumpMachine SunCC style
@ -378,77 +388,12 @@ endif ()
###############################################################################
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
execute_process(COMMAND sh -c "${CMAKE_CXX_COMPILER} --version 2>&1"
COMMAND ${GREP_CMD} -i -c "macports"
OUTPUT_VARIABLE MACPORTS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (MACPORTS EQUAL 0)
# Get GAS version, add defs + set as appropriate
set(GAS_CMD sh -c "${CMAKE_CXX_COMPILER} -xc -c /dev/null -Wa,-v -o/dev/null 2>&1")
execute_process(COMMAND ${GAS_CMD}
OUTPUT_VARIABLE GAS_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(FIND "${GAS_STRING}" "GNU assembler" GAS_OUTPUT)
if (NOT GAS_OUTPUT EQUAL -1)
#.intel_syntax wasn't supported until GNU assembler 2.10
# TODO(unassigned): string() REGEX was not cooperating at time of writing. Re-implement as needed.
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.[1-9][0-9]|[3-9])"
OUTPUT_VARIABLE GAS210_OR_LATER)
if (GAS210_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_ASM)
set(DISABLE_ASM 1)
endif ()
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.1[7-9]|2\\.[2-9]|[3-9])"
OUTPUT_VARIABLE GAS217_OR_LATER)
if (GAS217_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE3)
set(DISABLE_SSSE3 1)
endif ()
# OpenBSD and CentOS 5 needed this one due to ARIA and BLAKE2
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.1[8-9]|2\\.[2-9]|[3-9])"
OUTPUT_VARIABLE GAS218_OR_LATER)
if (GAS218_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE4)
set(DISABLE_SSE4 1)
endif ()
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.19|2\\.[2-9]|[3-9])"
OUTPUT_VARIABLE GAS219_OR_LATER)
if (GAS219_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AESNI)
set(DISABLE_AESNI 1)
endif ()
# Ubuntu 10 and Ubuntu 12 needed this one
execute_process(COMMAND echo ${GAS_STRING}
COMMAND ${GREP_CMD} -i -c -E "GNU.[Aa]ssembler.*(2\\.2[3-9]|2\\.[3-9]|[3-9])"
OUTPUT_VARIABLE GAS223_OR_LATER)
if (GAS223_OR_LATER EQUAL 0)
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SHA)
set(DISABLE_SHA 1)
endif ()
endif ()
endif ()
endif ()
# TODO: what about ICC and LLVM on Windows?
if (MSVC)
if (CMAKE_SYSTEM_VERSION MATCHES "10\\.0.*")
list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "_WIN32_WINNT=0x0A00")
endif ()
#list(APPEND CRYPTOPP_COMPILE_OPTIONS "/FI\"winapifamily.h\"")
list(APPEND CRYPTOPP_COMPILE_OPTIONS /FI winapifamily.h)
endif ()
# Enable PIC for all target machines except 32-bit i386 due to register pressures.
@ -563,6 +508,11 @@ set(cryptopp_SOURCES
${cryptopp_SOURCES}
)
if(ANDROID)
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
list(APPEND cryptopp_SOURCES ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
endif()
set(cryptopp_SOURCES_ASM)
if (MSVC AND NOT DISABLE_ASM)
@ -572,6 +522,7 @@ if (MSVC AND NOT DISABLE_ASM)
enable_language(ASM_MASM)
list(APPEND cryptopp_SOURCES_ASM
${SRC_DIR}/rdrand.asm
${SRC_DIR}/rdseed.asm
)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND cryptopp_SOURCES_ASM
@ -596,7 +547,7 @@ endif ()
# Must use CMAKE_CXX_COMPILER here due to XLC 13.1 and LLVM front-end.
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR CMAKE_CXX_COMPILER MATCHES "xlC")
if (CRYPTOPP_AMD64 OR CRYPTOPP_I386 OR CRYPTOPP_X32)
if (CRYPTOPP_AMD64 OR CRYPTOPP_I386)
CheckCompileLinkOption("-msse2" CRYPTOPP_IA32_SSE2
"${TEST_PROG_DIR}/test_x86_sse2.cxx")
@ -616,8 +567,13 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
"${TEST_PROG_DIR}/test_x86_avx2.cxx")
CheckCompileLinkOption("-msse4.2 -msha" CRYPTOPP_IA32_SHA
"${TEST_PROG_DIR}/test_x86_sha.cxx")
if (EXISTS "${TEST_PROG_DIR}/test_asm_mixed.cxx")
CheckCompileLinkOption("" CRYPTOPP_MIXED_ASM
"${TEST_PROG_DIR}/test_asm_mixed.cxx")
else ()
CheckCompileLinkOption("" CRYPTOPP_MIXED_ASM
"${TEST_PROG_DIR}/test_mixed_asm.cxx")
endif ()
# https://github.com/weidai11/cryptopp/issues/756
if (NOT CRYPTOPP_MIXED_ASM)
@ -638,7 +594,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/keccak_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3")
if (NOT CRYPTOPP_IA32_SSE41 AND NOT DISABLE_SSE4)
@ -646,16 +601,14 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
elseif (CRYPTOPP_IA32_SSE41 AND NOT DISABLE_SSE4)
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1")
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1")
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1")
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1")
endif ()
if (NOT CRYPTOPP_IA32_SSE42 AND NOT DISABLE_SSE4)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SSE4")
elseif (CRYPTOPP_IA32_SSE42 AND NOT DISABLE_SSE4)
set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2")
if (NOT CRYPTOPP_IA32_CLMUL AND NOT DISABLE_AES)
if (NOT CRYPTOPP_IA32_CLMUL AND NOT DISABLE_CLMUL)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_CLMUL")
elseif (CRYPTOPP_IA32_CLMUL AND NOT DISABLE_AES)
elseif (CRYPTOPP_IA32_CLMUL AND NOT DISABLE_CLMUL)
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3 -mpclmul")
set_source_files_properties(${SRC_DIR}/gf2n_simd.cpp PROPERTIES COMPILE_FLAGS "-mpclmul")
endif ()
@ -684,12 +637,22 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
endif ()
endif ()
elseif (CRYPTOPP_AARCH32 OR CRYPTOPP_AARCH64)
elseif (CRYPTOPP_ARMV8)
# This checks for <arm_acle.h>
CheckCompileLinkOption("-march=armv8-a" CRYPTOPP_ARM_ACLE_HEADER
"${TEST_PROG_DIR}/test_arm_acle_header.cxx")
# Use <arm_acle.h> if available
if (CRYPTOPP_ARM_NEON_HEADER)
CheckCompileOption("-march=armv8-a -DCRYPTOPP_ARM_ACLE_HEADER=1" CRYPTOPP_ARMV8A_ASIMD)
CheckCompileOption("-march=armv8-a+crc -DCRYPTOPP_ARM_ACLE_HEADER=1" CRYPTOPP_ARMV8A_CRC)
CheckCompileOption("-march=armv8-a+crypto -DCRYPTOPP_ARM_ACLE_HEADER=1" CRYPTOPP_ARMV8A_CRYPTO)
else ()
CheckCompileOption("-march=armv8-a" CRYPTOPP_ARMV8A_ASIMD)
CheckCompileOption("-march=armv8-a+crc" CRYPTOPP_ARMV8A_CRC)
CheckCompileOption("-march=armv8-a+crypto" CRYPTOPP_ARMV8A_CRYPTO)
CheckCompileOption("-march=armv8-a" CRYPTOPP_ARMV8A_NATIVE)
endif ()
if (CRYPTOPP_ARMV8A_ASIMD)
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
@ -699,10 +662,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/neon_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a")
endif ()
if (CRYPTOPP_ARMV8A_CRC)
@ -716,73 +676,90 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
set_source_files_properties(${SRC_DIR}/shacal2_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto")
endif ()
elseif (CRYPTOPP_ARM OR CRYPTOPP_ARMHF)
elseif (CRYPTOPP_ARM32)
# Need to set floating point ABI to something, like "hard" of "softfp".
# Most Linux use hard floats.
# This checks for <arm_neon.h>
CheckCompileLinkOption("-march=armv7-a -mfpu=neon" CRYPTOPP_ARM_NEON_HEADER
"${TEST_PROG_DIR}/test_arm_neon_header.cxx")
# Use <arm_neon.h> if available
if (CRYPTOPP_ARM_NEON_HEADER)
CheckCompileLinkOption("-march=armv7-a -mfpu=neon -DCRYPTOPP_ARM_NEON_HEADER=1" CRYPTOPP_ARMV7A_NEON
"${TEST_PROG_DIR}/test_arm_neon.cxx")
else ()
CheckCompileLinkOption("-march=armv7-a -mfpu=neon" CRYPTOPP_ARMV7A_NEON
"${TEST_PROG_DIR}/test_arm_neon.cxx")
CheckCompileLinkOption("-march=armv7-a -mfloat-abi=hard -mfpu=neon" CRYPTOPP_ARMV7A_HARD
"${TEST_PROG_DIR}/test_arm_neon.cxx")
CheckCompileLinkOption("-march=armv7-a -mfloat-abi=softfp -mfpu=neon" CRYPTOPP_ARMV7A_SOFTFP
"${TEST_PROG_DIR}/test_arm_neon.cxx")
if (CRYPTOPP_ARMV7A_HARD)
set(CRYPTOPP_ARMV7A_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon")
elseif (CRYPTOPP_ARMV7A_SOFTFP)
set(CRYPTOPP_ARMV7A_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon")
else ()
AddCompileOption("-DCRYPTOPP_DISABLE_NEON")
endif ()
if (CRYPTOPP_ARMV7A_HARD OR CRYPTOPP_ARMV7A_SOFTFP)
# Add ASM files for ARM
if (NOT MSVC)
if (CRYPTOPP_ARMV7A_NEON)
# Add Cryptogams ASM files for ARM on Linux. Linux is required due to GNU Assembler.
# AES requires -mthumb under Clang. Do not add -mthumb for SHA for any files.
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
list(APPEND cryptopp_SOURCES ${SRC_DIR}/aes_armv4.S)
set_source_files_properties(${SRC_DIR}/aes_armv4.S PROPERTIES LANGUAGE C)
list(APPEND cryptopp_SOURCES ${SRC_DIR}/sha1_armv4.S)
list(APPEND cryptopp_SOURCES ${SRC_DIR}/sha256_armv4.S)
list(APPEND cryptopp_SOURCES ${SRC_DIR}/sha512_armv4.S)
set_source_files_properties(${SRC_DIR}/aes_armv4.S PROPERTIES LANGUAGE CXX)
set_source_files_properties(${SRC_DIR}/sha1_armv4.S PROPERTIES LANGUAGE CXX)
set_source_files_properties(${SRC_DIR}/sha256_armv4.S PROPERTIES LANGUAGE CXX)
set_source_files_properties(${SRC_DIR}/sha512_armv4.S PROPERTIES LANGUAGE CXX)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_source_files_properties(${SRC_DIR}/aes_armv4.S PROPERTIES COMPILE_FLAGS "-march=armv7-a -mthumb -mfpu=neon -Wa,--noexecstack")
else ()
set_source_files_properties(${SRC_DIR}/aes_armv4.S PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon -Wa,--noexecstack")
endif ()
set_source_files_properties(${SRC_DIR}/aes_armv4.S PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/neon_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/sm4_simd.cpp PROPERTIES COMPILE_FLAGS "${CRYPTOPP_ARMV7A_FLAGS}")
set_source_files_properties(${SRC_DIR}/sha1_armv4.S PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon -Wa,--noexecstack")
set_source_files_properties(${SRC_DIR}/sha256_armv4.S PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon -Wa,--noexecstack")
set_source_files_properties(${SRC_DIR}/sha512_armv4.S PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon -Wa,--noexecstack")
endif ()
elseif (CRYPTOPP_POWERPC OR CRYPTOPP_POWERPC64)
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/neon_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
set_source_files_properties(${SRC_DIR}/sm4_simd.cpp PROPERTIES COMPILE_FLAGS "-march=armv7-a -mfpu=neon")
else ()
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_ARM_NEON_AVAILABLE=0")
endif ()
elseif (CRYPTOPP_PPC32 OR CRYPTOPP_PPC64)
# XLC requires -qaltivec in addition to Arch or CPU option
# Disable POWER9 due to https://github.com/weidai11/cryptopp/issues/986.
if (CMAKE_CXX_COMPILER MATCHES "xlC")
set(CRYPTOPP_ALTIVEC_FLAGS "-qaltivec")
set(CRYPTOPP_POWER4_FLAGS "-qarch=pwr4 -qaltivec")
set(CRYPTOPP_POWER5_FLAGS "-qarch=pwr5 -qaltivec")
set(CRYPTOPP_POWER6_FLAGS "-qarch=pwr6 -qaltivec")
set(CRYPTOPP_POWER7_FLAGS "-qarch=pwr7 -qaltivec")
set(CRYPTOPP_POWER7_VSX_FLAG "-qarch=pwr7 -qvsx -qaltivec")
set(CRYPTOPP_POWER7_PWR_FLAGS "-qarch=pwr7 -qaltivec")
set(CRYPTOPP_POWER8_FLAGS "-qarch=pwr8 -qaltivec")
set(CRYPTOPP_POWER9_FLAGS "-qarch=pwr9 -qaltivec")
#set(CRYPTOPP_POWER9_FLAGS "-qarch=pwr9 -qaltivec")
else ()
set(CRYPTOPP_ALTIVEC_FLAGS "-maltivec")
set(CRYPTOPP_POWER7_FLAGS "-mcpu=power7 -maltivec")
set(CRYPTOPP_POWER8_FLAGS "-mcpu=power8 -maltivec")
set(CRYPTOPP_POWER9_FLAGS "-mcpu=power9 -maltivec")
set(CRYPTOPP_POWER7_VSX_FLAGS "-mcpu=power7 -mvsx")
set(CRYPTOPP_POWER7_PWR_FLAGS "-mcpu=power7")
set(CRYPTOPP_POWER8_FLAGS "-mcpu=power8")
#set(CRYPTOPP_POWER9_FLAGS "-mcpu=power9")
endif ()
CheckCompileLinkOption("${CRYPTOPP_ALTIVEC_FLAGS}" PPC_ALTIVEC_FLAG
"${TEST_PROG_DIR}/test_ppc_altivec.cxx")
# Hack for XLC
# Hack for XLC. Find the lowest PWR architecture.
if (CMAKE_CXX_COMPILER MATCHES "xlC")
if (NOT PPC_ALTIVEC_FLAG)
CheckCompileLinkOption("${CRYPTOPP_POWER4_FLAGS}" PPC_POWER4_FLAG
@ -810,25 +787,39 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
endif ()
endif ()
CheckCompileLinkOption("${CRYPTOPP_POWER7_FLAGS}" PPC_POWER7_FLAG
# Hack for XLC and GCC. Find the right combination for PWR7 and the VSX unit.
CheckCompileLinkOption("${CRYPTOPP_POWER7_VSX_FLAGS}" PPC_POWER7_FLAG
"${TEST_PROG_DIR}/test_ppc_power7.cxx")
if (PPC_POWER7_FLAG)
set (CRYPTOPP_POWER7_FLAGS "${CRYPTOPP_POWER7_VSX_FLAGS}")
else ()
CheckCompileLinkOption("${CRYPTOPP_POWER7_PWR_FLAGS}" PPC_POWER7_FLAG
"${TEST_PROG_DIR}/test_ppc_power7.cxx")
if (PPC_POWER7_FLAG)
set (CRYPTOPP_POWER7_FLAGS "${CRYPTOPP_POWER7_PWR_FLAGS}")
endif ()
endif ()
CheckCompileLinkOption("${CRYPTOPP_POWER8_FLAGS}" PPC_POWER8_FLAG
"${TEST_PROG_DIR}/test_ppc_power8.cxx")
CheckCompileLinkOption("${CRYPTOPP_POWER9_FLAGS}" PPC_POWER9_FLAG
"${TEST_PROG_DIR}/test_ppc_power9.cxx")
# Disable POWER9 due to https://github.com/weidai11/cryptopp/issues/986.
#CheckCompileLinkOption("${CRYPTOPP_POWER9_FLAGS}" PPC_POWER9_FLAG
# "${TEST_PROG_DIR}/test_ppc_power9.cxx")
if (PPC_POWER9_FLAG AND NOT DISABLE_POWER9)
set_source_files_properties(${SRC_DIR}/ppc_power9.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER9_FLAGS})
endif ()
#if (PPC_POWER9_FLAG AND NOT DISABLE_POWER9)
# set_source_files_properties(${SRC_DIR}/ppc_power9.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER9_FLAGS})
#endif ()
if (PPC_POWER8_FLAG AND NOT DISABLE_POWER8)
set_source_files_properties(${SRC_DIR}/ppc_power8.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
#set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
#set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/gf2n_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
set_source_files_properties(${SRC_DIR}/shacal2_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER8_FLAGS})
@ -838,34 +829,18 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
if (PPC_POWER7_FLAG AND NOT DISABLE_POWER7)
set_source_files_properties(${SRC_DIR}/ppc_power7.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
endif ()
if (PPC_ALTIVEC_FLAG AND NOT DISABLE_ALTIVEC)
set_source_files_properties(${SRC_DIR}/ppc_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
endif ()
# Drop to Power7 if Power8 unavailable
if (NOT PPC_POWER8_FLAG)
if (PPC_POWER7_FLAG)
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_POWER7_FLAGS})
endif ()
endif ()
# Drop to Altivec if Power7 unavailable
if (NOT PPC_POWER7_FLAG)
if (PPC_ALTIVEC_FLAG)
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
set_source_files_properties(${SRC_DIR}/chacha_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
endif ()
# Drop to Altivec if Power8 unavailable
if (NOT PPC_POWER8_FLAG)
if (PPC_ALTIVEC_FLAG)
set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS ${CRYPTOPP_ALTIVEC_FLAGS})
endif ()
endif ()
@ -875,8 +850,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_POWER7")
elseif (NOT PPC_POWER8_FLAG)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_POWER8")
elseif (NOT PPC_POWER9_FLAG)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_POWER9")
#elseif (NOT PPC_POWER9_FLAG)
# list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_POWER9")
endif ()
endif ()
@ -885,7 +860,7 @@ endif ()
# New as of Pull Request 461, http://github.com/weidai11/cryptopp/pull/461.
if (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
if (CRYPTOPP_AMD64 OR CRYPTOPP_I386 OR CRYPTOPP_X32)
if (CRYPTOPP_AMD64 OR CRYPTOPP_I386)
CheckCompileLinkOption("-xarch=sse2" CRYPTOPP_IA32_SSE2
"${TEST_PROG_DIR}/test_x86_sse2.cxx")
@ -918,15 +893,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set_source_files_properties(${SRC_DIR}/aria_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/cham_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/lea_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/simeck_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/simon128_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set_source_files_properties(${SRC_DIR}/speck128_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=ssse3")
set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=ssse3")
if (CRYPTOPP_IA32_SSE41 AND NOT DISABLE_SSE4)
set_source_files_properties(${SRC_DIR}/blake2s_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_1")
set_source_files_properties(${SRC_DIR}/blake2b_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_1")
set_source_files_properties(${SRC_DIR}/simon64_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_1")
set_source_files_properties(${SRC_DIR}/speck64_simd.cpp PROPERTIES COMPILE_FLAGS "-xarch=sse4_1")
set(XARCH_LDFLAGS "${XARCH_LDFLAGS} -xarch=sse4_1")
endif ()
if (CRYPTOPP_IA32_SSE42 AND NOT DISABLE_SSE4)
@ -967,25 +939,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
endif ()
endif ()
# Attempt to determine a suitable native option
if (CRYPTOPP_NATIVE_ARCH)
CheckCompileOption("-march=native" NATIVE_ARCH)
if (NATIVE_ARCH)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-march=native")
else ()
CheckCompileOption("-native" NATIVE_ARCH)
if (NATIVE_ARCH)
list(APPEND CRYPTOPP_COMPILE_OPTIONS "-native")
endif ()
endif ()
if (NOT NATIVE_ARCH)
message(WARNING "CRYPTOPP_NATIVE_ARCH enabled, but failed to detect native architecture option")
endif ()
endif()
#============================================================================
# Compile targets
#============================================================================
@ -1001,7 +954,7 @@ function(cryptopp_target_compile_properties target)
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS "${CRYPTOPP_COMPILE_DEFINITIONS}")
endif()
if (NOT ${CMAKE_VERSION} VERSION_LESS "2.8.12")
target_compile_options(${target} PUBLIC ${CRYPTOPP_COMPILE_OPTIONS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
else()
string (REPLACE ";" " " PROP_STR "${CRYPTOPP_COMPILE_OPTIONS}")
set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${PROP_STR}")
@ -1203,23 +1156,17 @@ if (CRYPTOPP_I386)
message(STATUS "Platform: i386/i686")
elseif (CRYPTOPP_AMD64)
message(STATUS "Platform: x86_64")
elseif (CRYPTOPP_X32)
message(STATUS "Platform: x86_64-x32")
elseif (CRYPTOPP_ARMHF)
message(STATUS "Platform: armhf")
elseif (CRYPTOPP_ARM)
message(STATUS "Platform: arm")
elseif (CRYPTOPP_AARCH32)
message(STATUS "Platform: Aarch32")
elseif (CRYPTOPP_AARCH64)
message(STATUS "Platform: Aarch64")
elseif (CRYPTOPP_ARM32)
message(STATUS "Platform: ARM-32")
elseif (CRYPTOPP_ARMV8)
message(STATUS "Platform: ARMv8")
elseif (CRYPTOPP_SPARC)
message(STATUS "Platform: Sparc")
elseif (CRYPTOPP_SPARC64)
message(STATUS "Platform: Sparc64")
elseif (CRYPTOPP_POWERPC)
elseif (CRYPTOPP_PPC32)
message(STATUS "Platform: PowerPC")
elseif (CRYPTOPP_POWERPC64)
elseif (CRYPTOPP_PPC64)
message(STATUS "Platform: PowerPC-64")
elseif (CRYPTOPP_MINGW32)
message(STATUS "Platform: MinGW-32")
@ -1229,11 +1176,6 @@ endif ()
if (CRYPTOPP_ARMV7A_NEON)
message(STATUS "NEON: TRUE")
endif ()
if (CRYPTOPP_NATIVE_ARCH)
message(STATUS "Native arch: TRUE")
else ()
message(STATUS "Native arch: FALSE")
endif ()
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS} ${CRYPTOPP_COMPILE_OPTIONS}")
message(STATUS "Compiler definitions: ${CRYPTOPP_COMPILE_DEFINITIONS}")

View File

@ -1,4 +1,4 @@
# Doxyfile 1.8.9
# Doxyfile 1.8.13
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@ -12,9 +12,6 @@
# For lists, items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (\" \").
#
# The file can be upgraded to the latest version of Doxygen with `doxygen -u <file`
#
#---------------------------------------------------------------------------
# Project related configuration options
@ -41,14 +38,13 @@ PROJECT_NAME = Crypto++
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 8.2
PROJECT_NUMBER = 8.5
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
# Without the HTML escape characters, Doxygen concatenates the string below...
PROJECT_BRIEF = Free&nbsp;C&#43;&#43;&nbsp;class&nbsp;library&nbsp;of&nbsp;cryptographic&nbsp;schemes
PROJECT_BRIEF = "Free&nbsp;C&#43;&#43;&nbsp;class&nbsp;library&nbsp;of&nbsp;cryptographic&nbsp;schemes"
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
@ -235,12 +231,6 @@ TAB_SIZE = 4
ALIASES =
# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class"
# will allow you to use the command class in the itcl::class meaning.
TCL_SUBST =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C. For
# instance, some of the names that are used will be different. The list of all
@ -298,6 +288,15 @@ EXTENSION_MAPPING =
MARKDOWN_SUPPORT = NO
# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
# to that level are automatically included in the table of contents, even if
# they do not have an id attribute.
# Note: This feature currently applies only to Markdown headings.
# Minimum value: 0, maximum value: 99, default value: 0.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
TOC_INCLUDE_HEADINGS = 0
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
# be prevented in individual cases by putting a % sign in front of the word or
@ -348,6 +347,13 @@ IDL_PROPERTY_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
# If one adds a struct or class to a group and this option is enabled, then also
# any nested class or struct is added to the same group. By default this option
# is disabled and one has to add nested compounds explicitly via \ingroup.
# The default value is: NO.
GROUP_NESTED_COMPOUNDS = NO
# Set the SUBGROUPING tag to YES to allow class member groups of the same type
# (for instance a group of public functions) to be put as a subgroup of that
# type (e.g. under the Public Functions section). Set it to NO to prevent
@ -737,6 +743,12 @@ WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
# a warning is encountered.
# The default value is: NO.
WARN_AS_ERROR = NO
# The WARN_FORMAT tag determines the format of the warning messages that doxygen
# can produce. The string should contain the $file, $line, and $text tags, which
# will be replaced by the file and line number from which the warning originated
@ -760,14 +772,13 @@ WARN_LOGFILE =
# The INPUT tag is used to specify the files and/or directories that contain
# documented source files. You may enter file names like myfile.cpp or
# directories like /usr/src/myproject. Separate the files or directories with
# spaces.
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = . \
GNUmakefile \
GNUmakefile-cross \
rdrand.asm \
rdrand.s
rdrand.asm
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@ -780,12 +791,17 @@ INPUT_ENCODING = UTF-8
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
# *.h) to filter out the source-files in the directories. If left blank the
# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,
# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,
# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,
# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,
# *.qsf, *.as and *.js.
# *.h) to filter out the source-files in the directories.
#
# Note that for custom extensions or not directly supported extensions you also
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
# read by doxygen.
#
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf.
FILE_PATTERNS = *.h \
*.cpp
@ -803,7 +819,7 @@ RECURSIVE = NO
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = adhoc.cpp cryptlib_bds.cpp
EXCLUDE = adhoc.cpp
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
@ -819,7 +835,8 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*
EXCLUDE_PATTERNS = *test* *validat*
EXCLUDE_PATTERNS = *test* \
*validat*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
@ -872,6 +889,10 @@ IMAGE_PATH =
# Note that the filter must not add or remove lines; it is applied before the
# code is scanned, but not when the output code is generated. If lines are added
# or removed, the anchors will not be placed correctly.
#
# Note that for custom extensions or not directly supported extensions you also
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
# properly processed by doxygen.
INPUT_FILTER =
@ -881,6 +902,10 @@ INPUT_FILTER =
# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
# patterns match the file name, INPUT_FILTER is applied.
#
# Note that for custom extensions or not directly supported extensions you also
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
# properly processed by doxygen.
FILTER_PATTERNS =
@ -992,6 +1017,25 @@ USE_HTAGS = NO
VERBATIM_HEADERS = YES
# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
# cost of reduced performance. This can be particularly helpful with template
# rich C++ code for which doxygen's built-in parser lacks the necessary type
# information.
# Note: The availability of this option depends on whether or not doxygen was
# generated with the -Duse-libclang=ON option for CMake.
# The default value is: NO.
CLANG_ASSISTED_PARSING = NO
# If clang assisted parsing is enabled you can provide the compiler with command
# line options that you would normally use when invoking the compiler. Note that
# the include paths will already be set by doxygen for the files and directories
# specified with INPUT and INCLUDE_PATH.
# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
CLANG_OPTIONS =
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
@ -1139,8 +1183,9 @@ HTML_COLORSTYLE_GAMMA = 80
# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
# page will contain the date and time when the page was generated. Setting this
# to NO can help when comparing the output of multiple runs.
# The default value is: YES.
# to YES can help to show when doxygen was last run and thus if the
# documentation is up to date.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_TIMESTAMP = YES
@ -1225,6 +1270,7 @@ DOCSET_PUBLISHER_NAME = Crypto++
# compressed HTML files.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_HTMLHELP = NO
# The CHM_FILE tag can be used to specify the file name of the resulting .chm
@ -1493,9 +1539,6 @@ MATHJAX_CODEFILE =
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
# JW: Do _not_ enable server-side search. It consumes too many resources
# and results in OOM Kills on MySQL, which corrupts the database.
# https://github.com/weidai11/cryptopp/issues/720
SEARCHENGINE = NO
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
@ -1508,9 +1551,6 @@ SEARCHENGINE = NO
# The default value is: NO.
# This tag requires that the tag SEARCHENGINE is set to YES.
# JW: Do _not_ enable server-side search. It consumes too many resources
# and results in OOM Kills on MySQL, which corrupts the database.
# https://github.com/weidai11/cryptopp/issues/720
SERVER_BASED_SEARCH = NO
# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
@ -1619,9 +1659,12 @@ COMPACT_LATEX = NO
PAPER_TYPE = a4
# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
# that should be included in the LaTeX output. To get the times font for
# instance you can specify
# EXTRA_PACKAGES=times
# that should be included in the LaTeX output. The package can be specified just
# by its name or with the correct syntax as to be used with the LaTeX
# \usepackage command. To get the times font for instance you can specify :
# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
# To use the option intlimits with the amsmath package you can specify:
# EXTRA_PACKAGES=[intlimits]{amsmath}
# If left blank no extra packages will be included.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@ -1724,6 +1767,14 @@ LATEX_SOURCE_CODE = NO
LATEX_BIB_STYLE = plain
# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
# page will contain the date and time when the page was generated. Setting this
# to NO can help when comparing the output of multiple runs.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_TIMESTAMP = NO
#---------------------------------------------------------------------------
# Configuration options related to the RTF output
#---------------------------------------------------------------------------
@ -2065,12 +2116,6 @@ EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of 'which perl').
# The default file (with absolute path) is: /usr/bin/perl.
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
@ -2084,15 +2129,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = YES
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see:
# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
@ -2111,7 +2147,7 @@ HIDE_UNDOC_RELATIONS = YES
# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
# Bell Labs. The other options in this section have no effect if this option is
# set to NO
# The default value is: NO.
# The default value is: YES.
HAVE_DOT = NO
@ -2133,7 +2169,7 @@ DOT_NUM_THREADS = 0
# The default value is: Helvetica.
# This tag requires that the tag HAVE_DOT is set to YES.
# DOT_FONTNAME = FreeSans.ttf
DOT_FONTNAME = Helvetica
# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
# dot graphs.
@ -2225,7 +2261,8 @@ INCLUDED_BY_GRAPH = YES
#
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable call graphs for selected
# functions only using the \callgraph command.
# functions only using the \callgraph command. Disabling a call graph can be
# accomplished by means of the command \hidecallgraph.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
@ -2236,7 +2273,8 @@ CALL_GRAPH = NO
#
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable caller graphs for selected
# functions only using the \callergraph command.
# functions only using the \callergraph command. Disabling a caller graph can be
# accomplished by means of the command \hidecallergraph.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
@ -2259,11 +2297,17 @@ GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot.
# generated by dot. For an explanation of the image formats see the section
# output formats in the documentation of the dot tool (Graphviz (see:
# http://www.graphviz.org/)).
# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
# to make the SVG files visible in IE 9+ (other browsers do not have this
# requirement).
# Possible values are: png, jpg, gif and svg.
# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo,
# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
# png:gdiplus:gdiplus.
# The default value is: png.
# This tag requires that the tag HAVE_DOT is set to YES.
@ -2314,6 +2358,11 @@ DIAFILE_DIRS =
PLANTUML_JAR_PATH =
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
# configuration file for plantuml.
PLANTUML_CFG_FILE =
# When using plantuml, the specified paths are searched for files specified by
# the !include statement in a plantuml block.

View File

@ -11,6 +11,8 @@ algebra.cpp
algebra.h
algparam.cpp
algparam.h
allocate.cpp
allocate.h
arc4.cpp
arc4.h
ariatab.cpp
@ -66,6 +68,16 @@ channels.h
cmac.cpp
cmac.h
config.h
config_align.h
config_asm.h
config_cpu.h
config_cxx.h
config_dll.h
config_int.h
config_misc.h
config_ns.h
config_os.h
config_ver.h
cpu.cpp
cpu.h
crc.cpp
@ -73,7 +85,6 @@ crc_simd.cpp
crc.h
cryptdll.vcxproj
cryptdll.vcxproj.filters
cryptest.sh
cryptest.sln
cryptest.vcxproj
cryptest.vcxproj.user
@ -263,12 +274,10 @@ rc5.cpp
rc5.h
rc6.cpp
rc6.h
rdrand-masm.cmd
rdrand-nasm.sh
rdrand.s
rdrand.asm
rdrand.cpp
rdrand.h
rdseed.asm
rdtables.cpp
regtest1.cpp
regtest2.cpp
@ -295,6 +304,7 @@ scrypt.h
seal.cpp
seal.h
secblock.h
secblockfwd.h
seckey.h
seed.cpp
seed.h
@ -304,6 +314,12 @@ serpentp.h
sha.cpp
sha_simd.cpp
sha.h
sha1_armv4.h
sha1_armv4.S
sha256_armv4.h
sha256_armv4.S
sha512_armv4.h
sha512_armv4.S
sha3.cpp
sha3.h
shacal2.cpp
@ -318,10 +334,8 @@ simple.cpp
simple.h
siphash.h
simeck.cpp
simeck_simd.cpp
simeck.h
simon.cpp
simon64_simd.cpp
simon128_simd.cpp
simon.h
skipjack.cpp
@ -335,7 +349,6 @@ smartptr.h
sosemanuk.cpp
sosemanuk.h
speck.cpp
speck64_simd.cpp
speck128_simd.cpp
speck.h
square.cpp
@ -390,6 +403,8 @@ xtr.cpp
xtr.h
xtrcrypt.cpp
xtrcrypt.h
xts.cpp
xts.h
zdeflate.cpp
zdeflate.h
zinflate.cpp
@ -421,6 +436,8 @@ TestData/dlie2048.dat
TestData/dsa1024.dat
TestData/dsa1024b.dat
TestData/dsa512.dat
TestData/ecies_p160.dat
TestData/ecies_t163.dat
TestData/ed25519.dat
TestData/ed25519_ver.dat
TestData/ed25519v0.dat
@ -554,21 +571,46 @@ TestVectors/vmac.txt
TestVectors/wake.txt
TestVectors/whrlpool.txt
TestVectors/xchacha.txt
TestVectors/xts.txt
TestPrograms/test_32bit.cxx
TestPrograms/test_64bit.cxx
TestPrograms/test_arm_acle.cxx
TestPrograms/test_arm_acle_header.cxx
TestPrograms/test_arm_aes.cxx
TestPrograms/test_arm_asimd.cxx
TestPrograms/test_arm_crc.cxx
TestPrograms/test_arm_neon.cxx
TestPrograms/test_arm_neon_header.cxx
TestPrograms/test_arm_pmull.cxx
TestPrograms/test_arm_sha.cxx
TestPrograms/test_arm_sha1.cxx
TestPrograms/test_arm_sha256.cxx
TestPrograms/test_arm_sha3.cxx
TestPrograms/test_arm_sha512.cxx
TestPrograms/test_arm_sm3.cxx
TestPrograms/test_arm_sm4.cxx
TestPrograms/test_asm_mixed.cxx
TestPrograms/test_cxx11_alignas.cxx
TestPrograms/test_cxx11_alignof.cxx
TestPrograms/test_cxx11_assert.cxx
TestPrograms/test_cxx11_atomic.cxx
TestPrograms/test_cxx11_auto.cxx
TestPrograms/test_cxx11_constexpr.cxx
TestPrograms/test_cxx11.cxx
TestPrograms/test_cxx11_deletefn.cxx
TestPrograms/test_cxx11_staticinit.cxx
TestPrograms/test_cxx11_enumtype.cxx
TestPrograms/test_cxx11_initializer.cxx
TestPrograms/test_cxx11_lambda.cxx
TestPrograms/test_cxx11_noexcept.cxx
TestPrograms/test_cxx11_nullptr.cxx
TestPrograms/test_cxx11_sync.cxx
TestPrograms/test_cxx11_vartemplates.cxx
TestPrograms/test_cxx14.cxx
TestPrograms/test_cxx17_assert.cxx
TestPrograms/test_cxx17.cxx
TestPrograms/test_cxx17_exceptions.cxx
TestPrograms/test_cxx98_exception.cxx
TestPrograms/test_cxx.cxx
TestPrograms/test_mixed_asm.cxx
TestPrograms/test_glibc.cxx
TestPrograms/test_newlib.cxx
TestPrograms/test_ppc_aes.cxx
TestPrograms/test_ppc_altivec.cxx
@ -579,14 +621,19 @@ TestPrograms/test_ppc_sha.cxx
TestPrograms/test_ppc_vmull.cxx
TestPrograms/test_pthreads.cxx
TestPrograms/test_x86_aes.cxx
TestPrograms/test_x86_avx.cxx
TestPrograms/test_x86_avx2.cxx
TestPrograms/test_x86_avx512.cxx
TestPrograms/test_x86_avx.cxx
TestPrograms/test_x86_clmul.cxx
TestPrograms/test_x86_cpuid.cxx
TestPrograms/test_x86_rdrand.cxx
TestPrograms/test_x86_rdseed.cxx
TestPrograms/test_x86_sha.cxx
TestPrograms/test_x86_sse2.cxx
TestPrograms/test_x86_sse3.cxx
TestPrograms/test_x86_sse41.cxx
TestPrograms/test_x86_sse42.cxx
TestPrograms/test_x86_ssse3.cxx
TestPrograms/test_x86_via_aes.cxx
TestPrograms/test_x86_via_rng.cxx
TestPrograms/test_x86_via_sha.cxx

877
vendor/cryptopp/vendor_cryptopp/GNUmakefile vendored Executable file → Normal file

File diff suppressed because it is too large Load Diff

411
vendor/cryptopp/vendor_cryptopp/GNUmakefile-cross vendored Executable file → Normal file
View File

@ -5,12 +5,16 @@ SHELL = /bin/sh
# If needed
TMPDIR ?= /tmp
# Used for ARMv7 and NEON.
FP_ABI ?= hard
# Used for feature tests
TOUT ?= a.out
TOUT := $(strip $(TOUT))
# Allow override for the cryptest.exe recipe. Change to
# ./libcryptopp.so or ./libcryptopp.dylib to suit your
# taste. https://github.com/weidai11/cryptopp/issues/866
LINK_LIBRARY ?= libcryptopp.a
LINK_LIBRARY_PATH ?= ./
# Default CXXFLAGS if none were provided
CXXFLAGS ?= -DNDEBUG -g2 -O3 -fPIC -pipe
@ -21,7 +25,8 @@ CP ?= cp
MV ?= mv
CHMOD ?= chmod
MKDIR ?= mkdir -p
EGREP ?= egrep
GREP ?= grep
SED ?= sed
LN ?= ln -sf
LDCONF ?= /sbin/ldconfig -n
@ -29,7 +34,16 @@ LDCONF ?= /sbin/ldconfig -n
IS_IOS ?= 0
IS_ANDROID ?= 0
IS_ARM_EMBEDDED ?= 0
IS_NEON ?= 0
# Clang is reporting armv8l-unknown-linux-gnueabihf
# for ARMv7 images on Aarch64 hardware.
MACHINEX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
HOSTX := $(shell echo $(MACHINEX) | cut -f 1 -d '-')
ifeq ($(HOSTX),)
HOSTX := $(shell uname -m 2>/dev/null)
endif
IS_LINUX := $(shell echo $(MACHINEX) | $(GREP) -i -c "Linux")
# Can be used by Android and Embeeded cross-compiles. Disable by default because
# Android and embedded users typically don't run this configuration.
@ -83,14 +97,11 @@ endif
# iOS cross-compile configuration.
# See http://www.cryptopp.com/wiki/iOS_(Command_Line).
ifeq ($(IS_IOS),1)
CXX = clang++
CXXFLAGS += $(IOS_FLAGS) -arch $(IOS_ARCH)
CXXFLAGS += -isysroot "$(IOS_SYSROOT)" -stdlib=libc++
CXXFLAGS += $(IOS_CXXFLAGS) -stdlib=libc++
CXXFLAGS += --sysroot "$(IOS_SYSROOT)"
AR = libtool
ARFLAGS = -static -o
RANLIB = ranlib
endif
###########################################################
@ -100,22 +111,22 @@ endif
# Android cross-compile configuration.
# See http://www.cryptopp.com/wiki/Android_(Command_Line).
ifeq ($(IS_ANDROID),1)
# CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-android.sh'
CXXFLAGS += $(AOSP_FLAGS) -DANDROID --sysroot=$(AOSP_SYSROOT)
CXXFLAGS += -Wa,--noexecstack -I$(AOSP_STL_INC) -I$(AOSP_SYS_ARCH_INC)
LDFLAGS += --sysroot=$(AOSP_LD_SYSROOT)
CPPFLAGS += $(ANDROID_CPPFLAGS)
CPPFLAGS += -DANDROID
CXXFLAGS += $(ANDROID_CXXFLAGS)
CXXFLAGS += --sysroot=$(ANDROID_SYSROOT)
CXXFLAGS += -Wa,--noexecstack
# c++config.h shows up in odd places at times.
ifneq ($(AOSP_BITS_INC),)
CXXFLAGS += -I$(AOSP_BITS_INC)
endif
# STL headers
LDLIBS += $(AOSP_STL_LIB)
# Aarch64 ld does not understand --warn-execstack
LDFLAGS += $(ANDROID_LDFLAGS)
LDFLAGS += -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
LDFLAGS += -Wl,--warn-shared-textrel -Wl,--warn-common
LDFLAGS += -Wl,--warn-unresolved-symbols
LDFLAGS += -Wl,--gc-sections -Wl,--fatal-warnings
# Source files copied into PWD for Android cpu-features
# setenv-android.sh does the copying. Its a dirty compile.
AOSP_CPU_OBJ = cpu-features.o
ANDROID_CPU_OBJ = cpu-features.o
endif
###########################################################
@ -136,8 +147,8 @@ endif
# Wait until CXXFLAGS have been set by setenv scripts.
GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(EGREP) -v -E 'llvm|clang' | $(EGREP) -i -c -E '(gcc|g\+\+)')
CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(EGREP) -i -c -E 'llvm|clang')
GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -v -E 'llvm|clang' | $(GREP) -i -c -E '(gcc|g\+\+)')
CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(GREP) -i -c -E 'llvm|clang')
HOSTX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | cut -f 1 -d '-')
ifeq ($(HOSTX),)
@ -149,17 +160,25 @@ endif
# -arch arm64 yields x86_64 instead of aarch64 or arm64.
ifeq ($(CLANG_COMPILER),1)
IS_X86 := $(shell echo $(CXXFLAGS) | $(EGREP) -v 64 | $(EGREP) -i -c -E 'i.86')
IS_X64 := $(shell echo $(CXXFLAGS) | $(EGREP) -i -c -E 'x86_64|amd64')
IS_ARM32 := $(shell echo $(CXXFLAGS) | $(EGREP) -v 64 | $(EGREP) -i -c -E 'arm|armhf|arm7l|eabihf')
IS_ARMV8 := $(shell echo $(CXXFLAGS) | $(EGREP) -i -c -E 'aarch32|aarch64|arm64|armv8')
IS_X86 := $(shell echo $(CXXFLAGS) | $(GREP) -v 64 | $(GREP) -i -c -E 'i.86')
IS_X64 := $(shell echo $(CXXFLAGS) | $(GREP) -i -c -E 'x86_64|amd64')
IS_ARM32 := $(shell echo $(CXXFLAGS) | $(GREP) -v 64 | $(GREP) -i -c -E 'arm|armhf|arm7l|eabihf')
IS_ARMV8 := $(shell echo $(CXXFLAGS) | $(GREP) -i -c -E 'aarch32|aarch64|arm64|armv8')
else
IS_X86 := $(shell echo $(HOSTX) | $(EGREP) -v 64 | $(EGREP) -i -c -E 'i.86')
IS_X64 := $(shell echo $(HOSTX) | $(EGREP) -i -c -E 'x86_64|amd64')
IS_ARM32 := $(shell echo $(HOSTX) | $(EGREP) -v 64 | $(EGREP) -i -c -E 'arm|armhf|arm7l|eabihf')
IS_ARMV8 := $(shell echo $(HOSTX) | $(EGREP) -i -c -E 'aarch32|aarch64|arm64|armv8')
IS_X86 := $(shell echo $(HOSTX) | $(GREP) -v 64 | $(GREP) -i -c -E 'i.86')
IS_X64 := $(shell echo $(HOSTX) | $(GREP) -i -c -E 'x86_64|amd64')
IS_ARM32 := $(shell echo $(HOSTX) | $(GREP) -v 64 | $(GREP) -i -c -E 'arm|armhf|arm7l|eabihf')
IS_ARMV8 := $(shell echo $(HOSTX) | $(GREP) -i -c -E 'aarch32|aarch64|arm64|armv8')
endif
ifeq ($(IS_ARMV8),1)
IS_ARM32 = 0
endif
IS_X32 := 0
IS_PPC32 := 0
IS_PPC64 := 0
$(info Here's what we found... IS_X86: $(IS_X86), IS_X64: $(IS_X64), IS_ARM32: $(IS_ARM32), IS_ARMV8: $(IS_ARMV8))
###########################################################
@ -176,11 +195,14 @@ else ifeq ($(findstring distclean,$(MAKECMDGOALS)),distclean)
DETECT_FEATURES := 0
else ifeq ($(findstring distclean,$(MAKECMDGOALS)),trim)
DETECT_FEATURES := 0
else ifeq ($(IS_IOS),1)
DETECT_FEATURES := 0
endif
# Strip out -Wall, -Wextra and friends for feature testing
# Strip out -Wall, -Wextra and friends for feature testing. FORTIFY_SOURCE is removed
# because it requires -O1 or higher, but we use -O0 to tame the optimizer.
ifeq ($(DETECT_FEATURES),1)
TCXXFLAGS := $(filter-out -Wall -Wextra -Werror% -Wunused -Wconversion -Wp%, $(CXXFLAGS))
TCXXFLAGS := $(filter-out -D_FORTIFY_SOURCE=% -M -MM -Wall -Wextra -Werror% -Wunused -Wconversion -Wp%, $(CXXFLAGS))
ifneq ($(strip $(TCXXFLAGS)),)
$(info Using testing flags: $(TCXXFLAGS))
endif
@ -212,7 +234,7 @@ ifeq ($(DETECT_FEATURES),1)
TPROG = TestPrograms/test_x86_sse2.cxx
TOPT = $(SSE2_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
CHACHA_FLAG = $(SSE2_FLAG)
else
@ -221,15 +243,13 @@ ifeq ($(DETECT_FEATURES),1)
TPROG = TestPrograms/test_x86_ssse3.cxx
TOPT = $(SSSE3_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
ARIA_FLAG = $(SSSE3_FLAG)
CHAM_FLAG = $(SSSE3_FLAG)
KECCAK_FLAG = $(SSSE3_FLAG)
LEA_FLAG = $(SSSE3_FLAG)
SIMECK_FLAG = $(SSSE3_FLAG)
SIMON64_FLAG = $(SSSE3_FLAG)
SIMON128_FLAG = $(SSSE3_FLAG)
SPECK64_FLAG = $(SSSE3_FLAG)
SPECK128_FLAG = $(SSSE3_FLAG)
else
SSSE3_FLAG =
@ -237,19 +257,17 @@ ifeq ($(DETECT_FEATURES),1)
TPROG = TestPrograms/test_x86_sse41.cxx
TOPT = $(SSE41_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
BLAKE2B_FLAG = $(SSE41_FLAG)
BLAKE2S_FLAG = $(SSE41_FLAG)
SIMON64_FLAG = $(SSE41_FLAG)
SPECK64_FLAG = $(SSE41_FLAG)
else
SSE41_FLAG =
endif
TPROG = TestPrograms/test_x86_sse42.cxx
TOPT = $(SSE42_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
CRC_FLAG = $(SSE42_FLAG)
else
@ -258,16 +276,17 @@ ifeq ($(DETECT_FEATURES),1)
TPROG = TestPrograms/test_x86_clmul.cxx
TOPT = $(CLMUL_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
GCM_FLAG = $(SSSE3_FLAG) $(CLMUL_FLAG)
GF2N_FLAG = $(CLMUL_FLAG)
else
CLMUL_FLAG =
endif
TPROG = TestPrograms/test_x86_aes.cxx
TOPT = $(AESNI_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
AES_FLAG = $(SSE41_FLAG) $(AESNI_FLAG)
SM4_FLAG = $(SSSE3_FLAG) $(AESNI_FLAG)
@ -277,7 +296,7 @@ ifeq ($(DETECT_FEATURES),1)
TPROG = TestPrograms/test_x86_avx.cxx
TOPT = $(AVX_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
# XXX_FLAG = $(AVX_FLAG)
else
@ -286,7 +305,7 @@ ifeq ($(DETECT_FEATURES),1)
TPROG = TestPrograms/test_x86_avx2.cxx
TOPT = $(AVX2_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
CHACHA_AVX2_FLAG = $(AVX2_FLAG)
else
@ -295,7 +314,7 @@ ifeq ($(DETECT_FEATURES),1)
TPROG = TestPrograms/test_x86_sha.cxx
TOPT = $(SHANI_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
SHA_FLAG = $(SSE42_FLAG) $(SHANI_FLAG)
else
@ -341,6 +360,18 @@ ifeq ($(DETECT_FEATURES),1)
endif
endif
# Most Clang cannot handle mixed asm with positional arguments, where the
# body is Intel style with no prefix and the templates are AT&T style.
# Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
# CRYPTOPP_DISABLE_MIXED_ASM is now being added in config_asm.h for all
# Clang compilers. This test will need to be re-enabled if Clang fixes it.
#TPROG = TestPrograms/test_asm_mixed.cxx
#HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
#ifneq ($(strip $(HAVE_OPT)),0)
# CXXFLAGS += -DCRYPTOPP_DISABLE_MIXED_ASM
#endif
# DETECT_FEATURES
endif
@ -348,23 +379,30 @@ endif
endif
###########################################################
##### ARM A-32, Aach64 and NEON #####
##### ARM A-32 and NEON #####
###########################################################
ifneq ($(IS_ARM32)$(IS_ARMV8),00)
ifneq ($(IS_ARM32),0)
ifeq ($(DETECT_FEATURES),1)
ifeq ($(IS_ARM32),1)
ifneq ($(IS_IOS)$(IS_ANDROID),00)
NEON_FLAG =
# Android needs -c compile flag for NEON. Otherwise there's an odd linker message.
ifeq ($(IS_ANDROID),1)
NEON_FLAG = -march=armv7-a -mfpu=vfpv3-d16 -mfpu=neon
else
NEON_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
NEON_FLAG = -march=armv7-a -mfpu=neon
endif
# Clang needs an option to include <arm_neon.h>
TPROG = TestPrograms/test_arm_neon_header.cxx
TOPT = $(NEON_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
THEADER += -DCRYPTOPP_ARM_NEON_HEADER=1
endif
TPROG = TestPrograms/test_arm_neon.cxx
TOPT = $(NEON_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
ARIA_FLAG = $(NEON_FLAG)
AES_FLAG = $(NEON_FLAG)
@ -376,10 +414,7 @@ ifeq ($(IS_ARM32),1)
CHAM_FLAG = $(NEON_FLAG)
LEA_FLAG = $(NEON_FLAG)
SHA_FLAG = $(NEON_FLAG)
SIMECK_FLAG = $(NEON_FLAG)
SIMON64_FLAG = $(NEON_FLAG)
SIMON128_FLAG = $(NEON_FLAG)
SPECK64_FLAG = $(NEON_FLAG)
SPECK128_FLAG = $(NEON_FLAG)
SM4_FLAG = $(NEON_FLAG)
else
@ -387,10 +422,17 @@ ifeq ($(IS_ARM32),1)
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
endif
# DETECT_FEATURES
endif
# IS_ARM32
endif
ifeq ($(IS_ARMV8),1)
###########################################################
##### Aach32 and Aarch64 #####
###########################################################
ifneq ($(IS_ARMV8),0)
ifeq ($(DETECT_FEATURES),1)
ifeq ($(IS_IOS),1)
ASIMD_FLAG =
@ -402,22 +444,28 @@ ifeq ($(IS_ARMV8),1)
ASIMD_FLAG = -march=armv8-a
CRC_FLAG = -march=armv8-a+crc
AES_FLAG = -march=armv8-a+crypto
PMULL_FLAG = -march=armv8-a+crypto
GCM_FLAG = -march=armv8-a+crypto
GF2N_FLAG = -march=armv8-a+crypto
SHA_FLAG = -march=armv8-a+crypto
endif
TPROG = TestPrograms/test_arm_acle.cxx
TOPT = $(ASIMD_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
TPROG = TestPrograms/test_arm_neon_header.cxx
TOPT =
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
ACLE_FLAG += -DCRYPTOPP_ARM_ACLE_AVAILABLE=1
else
CXXFLAGS += -DCRYPTOPP_ARM_ACLE_AVAILABLE=0
THEADER += -DCRYPTOPP_ARM_NEON_HEADER=1
endif
TPROG = TestPrograms/test_arm_acle_header.cxx
TOPT = $(ASIMD_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
THEADER += -DCRYPTOPP_ARM_ACLE_HEADER=1
endif
TPROG = TestPrograms/test_arm_asimd.cxx
TOPT = $(ASIMD_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
ARIA_FLAG = $(ASIMD_FLAG)
BLAKE2B_FLAG = $(ASIMD_FLAG)
@ -426,10 +474,7 @@ ifeq ($(IS_ARMV8),1)
CHAM_FLAG = $(ASIMD_FLAG)
LEA_FLAG = $(ASIMD_FLAG)
NEON_FLAG = $(ASIMD_FLAG)
SIMECK_FLAG = $(ASIMD_FLAG)
SIMON64_FLAG = $(ASIMD_FLAG)
SIMON128_FLAG = $(ASIMD_FLAG)
SPECK64_FLAG = $(ASIMD_FLAG)
SPECK128_FLAG = $(ASIMD_FLAG)
SM4_FLAG = $(ASIMD_FLAG)
else
@ -439,59 +484,70 @@ ifeq ($(IS_ARMV8),1)
TPROG = TestPrograms/test_arm_crc.cxx
TOPT = $(CRC_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifneq ($(strip $(HAVE_OPT)),0)
CRC_FLAG =
CXXFLAGS += -DCRYPTOPP_ARM_CRC32_AVAILABLE=0
CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_CRC32
endif
TPROG = TestPrograms/test_arm_aes.cxx
TOPT = $(AES_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifneq ($(strip $(HAVE_OPT)),0)
AES_FLAG =
CXXFLAGS += -DCRYPTOPP_ARM_AES_AVAILABLE=0
CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_AES
endif
TPROG = TestPrograms/test_arm_pmull.cxx
TOPT = $(PMULL_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifneq ($(strip $(HAVE_OPT)),0)
PMULL_FLAG =
CXXFLAGS += -DCRYPTOPP_ARM_PMULL_AVAILABLE=0
GCM_FLAG =
GF2N_FLAG =
CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_PMULL
endif
TPROG = TestPrograms/test_arm_sha.cxx
TPROG = TestPrograms/test_arm_sha1.cxx
TOPT = $(SHA_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifneq ($(strip $(HAVE_OPT)),0)
SHA_FLAG =
CXXFLAGS += -DCRYPTOPP_ARM_SHA_AVAILABLE=0
CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA1
endif
TPROG = TestPrograms/test_arm_sha256.cxx
TOPT = $(SHA_FLAG)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifneq ($(strip $(HAVE_OPT)),0)
SHA_FLAG =
CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA2
endif
TPROG = TestPrograms/test_arm_sm3.cxx
TOPT = -march=armv8.4-a+crypto
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
SM3_FLAG = -march=armv8.4-a+crypto
SM4_FLAG = -march=armv8.4-a+crypto
else
#CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SM3
#CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SM4
endif
TPROG = TestPrograms/test_arm_sha3.cxx
TOPT = -march=armv8.4-a+crypto
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(THEADER) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | wc -w)
ifeq ($(strip $(HAVE_OPT)),0)
SHA3_FLAG = -march=armv8.4-a+crypto
SHA512_FLAG = -march=armv8.4-a+crypto
endif
# IS_ARMV8
else
#CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SHA3
#CXXFLAGS += -DCRYPTOPP_DISABLE_ARM_SM4
endif
# DETECT_FEATURES
endif
# IS_ARM32, IS_ARMV8, IS_NEON
# IS_ARMV8
endif
###########################################################
@ -531,7 +587,7 @@ endif # Asan
# LD gold linker testing. Triggered by 'LD=ld.gold'.
ifeq ($(findstring ld.gold,$(LD)),ld.gold)
ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(EGREP) -i -c "elf")
ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(GREP) -i -c "elf")
ifneq ($(ELF_FORMAT),0)
LDFLAGS += -fuse-ld=gold
endif # ELF/ELF64
@ -544,15 +600,15 @@ ifneq ($(filter valgrind,$(MAKECMDGOALS)),)
CXXFLAGS := $(CXXFLAGS:-g%=-g3)
CXXFLAGS := $(CXXFLAGS:-O%=-O1)
CXXFLAGS := $(CXXFLAGS:-xO%=-xO1)
ifeq ($(findstring -DCRYPTOPP_VALGRIND,$(CXXFLAGS)),)
CXXFLAGS += -DCRYPTOPP_VALGRIND
endif # -DCRYPTOPP_VALGRIND
ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
CXXFLAGS += -DCRYPTOPP_COVERAGE
endif # -DCRYPTOPP_COVERAGE
endif # Valgrind
# Debug testing on GNU systems. Triggered by -DDEBUG.
# Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
USING_GLIBCXX := $(shell $(CXX) $(CXXFLAGS) -E pch.cpp 2>&1 | $(EGREP) -i -c "__GLIBCXX__")
USING_GLIBCXX := $(shell $(CXX) $(CXXFLAGS) -E pch.cpp 2>&1 | $(GREP) -i -c "__GLIBCXX__")
ifneq ($(USING_GLIBCXX),0)
ifeq ($(HAS_NEWLIB),0)
ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CXXFLAGS)),)
@ -586,18 +642,34 @@ endif # Dead code stripping
###########################################################
# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp cryptlib_bds.cpp,$(sort $(wildcard *.cpp)))
SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp,$(sort $(wildcard *.cpp)))
# For Makefile.am; resource.h is Windows
INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
# Cryptogams AES for ARMv4 and above. We couple to ARMv7.
# Avoid iOS. It cannot consume the assembly.
ifeq ($(IS_ARM32),1)
ifneq ($(IS_IOS),1)
CRYPTOGAMS_AES_FLAG = -march=armv7-a
CRYPTOGAMS_AES_FLAG += -Wa,--noexecstack
SRCS += aes_armv4.S
# Cryptogams source files. We couple to ARMv7.
# Limit to Linux. The source files target the GNU assembler.
# Also see https://www.cryptopp.com/wiki/Cryptogams.
ifeq ($(IS_ARM32)$(IS_LINUX),11)
ifeq ($(CLANG_COMPILER),1)
CRYPTOGAMS_ARMV4_FLAG = -march=armv7-a -Wa,--noexecstack
CRYPTOGAMS_ARMV4_THUMB_FLAG = -march=armv7-a -mthumb -Wa,--noexecstack
else
CRYPTOGAMS_ARMV4_FLAG = -march=armv7-a -Wa,--noexecstack
CRYPTOGAMS_ARMV4_THUMB_FLAG = -march=armv7-a -Wa,--noexecstack
endif
SRCS += aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S
endif
# Remove unneeded arch specific files to speed build time.
ifeq ($(IS_PPC32)$(IS_PPC64),00)
SRCS := $(filter-out ppc_%,$(SRCS))
endif
ifeq ($(IS_ARM32)$(IS_ARMV8),00)
SRCS := $(filter-out arm_%,$(SRCS))
SRCS := $(filter-out neon_%,$(SRCS))
endif
ifeq ($(IS_X86)$(IS_X32)$(IS_X64),000)
SRCS := $(filter-out sse_%,$(SRCS))
endif
# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
@ -612,8 +684,13 @@ TESTINCL := bench.h factory.h validate.h
TESTOBJS := $(TESTSRCS:.cpp=.o)
LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
# Clean recipe, Issue 998. Don't filter-out some artifacts from the list of objects
# The *.S is a hack. It makes the ASM appear like C++ so the object files make the CLEAN_OBJS list
CLEAN_SRCS := $(wildcard *.cpp) $(patsubst %.S,%.cpp,$(wildcard *.S))
CLEAN_OBJS := $(CLEAN_SRCS:.cpp=.o) $(CLEAN_SRCS:.cpp=.import.o) $(CLEAN_SRCS:.cpp=.export.o)
# For Shared Objects, Diff, Dist/Zip rules
LIB_VER := $(shell $(EGREP) "define CRYPTOPP_VERSION" config.h | cut -d" " -f 3)
LIB_VER := $(shell $(GREP) "define CRYPTOPP_VERSION" config_ver.h | cut -d" " -f 3)
LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
@ -660,7 +737,7 @@ lean: static dynamic cryptest.exe
.PHONY: clean
clean:
-$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(AOSP_CPU_OBJ) rdrand-*.o $(TESTOBJS) $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
-$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(CLEAN_OBJS) $(ANDROID_CPU_OBJ) rdrand-*.o
@-$(RM) libcryptopp.a libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
@-$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX) libcryptopp.so$(SOLIB_VERSION_SUFFIX)
@-$(RM) cryptest.exe dlltest.exe cryptest.import.exe cryptest.info ct et
@ -677,15 +754,20 @@ autotools-clean:
@-$(RM) -f config.guess config.status config.sub config.h.in compile depcomp
@-$(RM) -f install-sh stamp-h1 ar-lib *.lo *.la *.m4 local.* lt*.sh missing
@-$(RM) -f cryptest cryptestcwd libtool* libcryptopp.la libcryptopp.pc*
@-$(RM) -rf m4/ auto*.cache/ .deps/ .libs/
@-$(RM) -rf build-aux/ m4/ auto*.cache/ .deps/ .libs/
.PHONY: cmake-clean
cmake-clean:
@-$(RM) -f cryptopp-config.cmake CMakeLists.txt
@-$(RM) -rf cmake_build/
.PHONY: android-clean
android-clean:
@-$(RM) -f $(patsubst %_simd.cpp,%_simd.cpp.neon,$(wildcard *_simd.cpp))
@-$(RM) -rf obj/
.PHONY: distclean
distclean: clean autotools-clean cmake-clean
distclean: clean autotools-clean cmake-clean android-clean
-$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt
@-$(RM) cryptest-*.txt cryptopp.tgz libcryptopp.pc *.o *.bc *.ii *~
@-$(RM) -r cryptlib.lib cryptest.exe *.suo *.sdf *.pdb Win32/ x64/ ipch/
@ -700,13 +782,13 @@ distclean: clean autotools-clean cmake-clean
install: cryptest.exe install-lib
@-$(MKDIR) $(DESTDIR)$(BINDIR)
$(CP) cryptest.exe $(DESTDIR)$(BINDIR)
$(CHMOD) 0755 $(DESTDIR)$(BINDIR)/cryptest.exe
$(CHMOD) u=rwx,go=rx $(DESTDIR)$(BINDIR)/cryptest.exe
@-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestData
@-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
$(CP) TestData/*.dat $(DESTDIR)$(DATADIR)/cryptopp/TestData
$(CHMOD) 0644 $(DESTDIR)$(DATADIR)/cryptopp/TestData/*.dat
$(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/cryptopp/TestData/*.dat
$(CP) TestVectors/*.txt $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
$(CHMOD) 0644 $(DESTDIR)$(DATADIR)/cryptopp/TestVectors/*.txt
$(CHMOD) u=rw,go=r $(DESTDIR)$(DATADIR)/cryptopp/TestVectors/*.txt
# A recipe to install only the library, and not cryptest.exe. Also
# see https://github.com/weidai11/cryptopp/issues/653.
@ -714,22 +796,22 @@ install: cryptest.exe install-lib
install-lib:
@-$(MKDIR) $(DESTDIR)$(INCLUDEDIR)/cryptopp
$(CP) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
$(CHMOD) 0644 $(DESTDIR)$(INCLUDEDIR)/cryptopp/*.h
$(CHMOD) u=rw,go=r $(DESTDIR)$(INCLUDEDIR)/cryptopp/*.h
ifneq ($(wildcard libcryptopp.a),)
@-$(MKDIR) $(DESTDIR)$(LIBDIR)
$(CP) libcryptopp.a $(DESTDIR)$(LIBDIR)
$(CHMOD) 0644 $(DESTDIR)$(LIBDIR)/libcryptopp.a
$(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/libcryptopp.a
endif
ifneq ($(wildcard libcryptopp.dylib),)
@-$(MKDIR) $(DESTDIR)$(LIBDIR)
$(CP) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
$(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
-install_name_tool -id $(DESTDIR)$(LIBDIR)/libcryptopp.dylib $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
endif
ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
@-$(MKDIR) $(DESTDIR)$(LIBDIR)
$(CP) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
$(CHMOD) 0755 $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
$(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
ifeq ($(HAS_SOLIB_VERSION),1)
-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
$(LDCONF) $(DESTDIR)$(LIBDIR)
@ -738,7 +820,7 @@ endif
ifneq ($(wildcard libcryptopp.pc),)
@-$(MKDIR) $(DESTDIR)$(LIBDIR)/pkgconfig
$(CP) libcryptopp.pc $(DESTDIR)$(LIBDIR)/pkgconfig
$(CHMOD) 0644 $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
$(CHMOD) u=rw,go=r $(DESTDIR)$(LIBDIR)/pkgconfig/libcryptopp.pc
endif
.PHONY: remove uninstall
@ -751,8 +833,8 @@ remove uninstall:
@-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
@-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
libcryptopp.a: $(LIBOBJS) $(AOSP_CPU_OBJ)
$(AR) $(ARFLAGS) $@ $(LIBOBJS) $(AOSP_CPU_OBJ)
libcryptopp.a: $(LIBOBJS) $(ANDROID_CPU_OBJ)
$(AR) $(ARFLAGS) $@ $(LIBOBJS) $(ANDROID_CPU_OBJ)
$(RANLIB) $@
ifeq ($(HAS_SOLIB_VERSION),1)
@ -760,18 +842,18 @@ ifeq ($(HAS_SOLIB_VERSION),1)
libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
endif
libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS) $(AOSP_CPU_OBJ)
$(CXX) -shared $(SOLIB_FLAGS) -o $@ $(strip $(CXXFLAGS)) -Wl,--exclude-libs,ALL $(LIBOBJS) $(AOSP_CPU_OBJ) $(LDFLAGS) $(LDLIBS)
libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS) $(ANDROID_CPU_OBJ)
$(CXX) -shared $(SOLIB_FLAGS) -o $@ $(strip $(CPPFLAGS) $(CXXFLAGS)) -Wl,--exclude-libs,ALL $(LIBOBJS) $(ANDROID_CPU_OBJ) $(LDFLAGS) $(LDLIBS)
ifeq ($(HAS_SOLIB_VERSION),1)
-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so
-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
endif
libcryptopp.dylib: $(LIBOBJS) $(AOSP_CPU_OBJ)
$(CXX) -dynamiclib -o $@ $(strip $(CXXFLAGS)) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" -headerpad_max_install_names $(LDFLAGS) $(LIBOBJS) $(AOSP_CPU_OBJ)
libcryptopp.dylib: $(LIBOBJS)
$(CXX) -dynamiclib -o $@ $(strip $(CPPFLAGS) $(CXXFLAGS)) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" -headerpad_max_install_names $(LDFLAGS) $(LIBOBJS)
cryptest.exe: libcryptopp.a $(TESTOBJS)
$(CXX) -o $@ $(strip $(CXXFLAGS)) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)
cryptest.exe: $(LINK_LIBRARY) $(TESTOBJS)
$(CXX) -o $@ $(strip $(CPPFLAGS) $(CXXFLAGS)) $(TESTOBJS) $(LINK_LIBRARY_PATH)$(LINK_LIBRARY) $(LDFLAGS) $(LDLIBS)
# Used to generate list of source files for Autotools, CMakeList and Android.mk
.PHONY: sources
@ -800,108 +882,121 @@ ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
-include GNUmakefile.deps
endif # Dependencies
# Cryptogams ARM asm implementation.
aes_armv4.o : aes_armv4.S
$(CXX) $(strip $(CXXFLAGS) -fpermissive $(CRYPTOGAMS_AES_FLAG) -c) $<
# A few recipes trigger warnings for -std=c++11 and -stdlib=c++
NOSTD_CXXFLAGS=$(filter-out -stdlib=%,$(filter-out -std=%,$(CXXFLAGS)))
# Cryptogams ARM asm implementation. AES needs -mthumb for Clang
aes_armv4.o : aes_armv4.S
$(CXX) $(strip $(CPPFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARMV4_THUMB_FLAG) -c) $<
# Use C++ compiler on C source after patching.
# https://github.com/weidai11/cryptopp/issues/926
cpu-features.o: cpu-features.h cpu-features.c
$(CXX) $(strip $(CXXFLAGS) -fpermissive -c) cpu-features.c
$(CXX) -x c $(strip $(CPPFLAGS) $(NOSTD_CXXFLAGS) -c) cpu-features.c
# SSSE3 or NEON available
aria_simd.o : aria_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(ARIA_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(ARIA_FLAG) -c) $<
# SSE, NEON or POWER7 available
blake2s_simd.o : blake2s_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
# SSE, NEON or POWER8 available
blake2b_simd.o : blake2b_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
# SSE2 or NEON available
chacha_simd.o : chacha_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
# AVX2 available
chacha_avx.o : chacha_avx.cpp
$(CXX) $(strip $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
# SSSE3 available
cham_simd.o : cham_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(CHAM_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CHAM_FLAG) -c) $<
# Power9 available
darn.o : darn.cpp
$(CXX) $(strip $(CXXFLAGS) $(DARN_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(DARN_FLAG) -c) $<
# SSE2 on i686
donna_sse.o : donna_sse.cpp
$(CXX) $(strip $(CXXFLAGS) $(SSE2_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
# SSE2 on i686
sse_simd.o : sse_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SSE2_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SSE2_FLAG) -c) $<
# SSE4.2 or ARMv8a available
crc_simd.o : crc_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(CRC_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(CRC_FLAG) -c) $<
# PCLMUL or ARMv7a/ARMv8a available
gcm_simd.o : gcm_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(GCM_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GCM_FLAG) -c) $<
# Carryless multiply
gf2n_simd.o : gf2n_simd.cpp
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(GF2N_FLAG) -c) $<
# SSSE3 available
keccak_simd.o : keccak_simd.cpp
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(KECCAK_FLAG) -c) $<
# SSSE3 available
lea_simd.o : lea_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(LEA_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(LEA_FLAG) -c) $<
# NEON available
neon_simd.o : neon_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(NEON_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(NEON_FLAG) -c) $<
# AESNI or ARMv7a/ARMv8a available
rijndael_simd.o : rijndael_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(AES_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(AES_FLAG) -c) $<
# SSE4.2/SHA-NI or ARMv8a available
sha_simd.o : sha_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SHA_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
# Cryptogams SHA1 asm implementation.
sha1_armv4.o : sha1_armv4.S
$(CXX) $(strip $(CPPFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
# Cryptogams SHA256 asm implementation.
sha256_armv4.o : sha256_armv4.S
$(CXX) $(strip $(CPPFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
# Cryptogams SHA512 asm implementation.
sha512_armv4.o : sha512_armv4.S
$(CXX) $(strip $(CPPFLAGS) $(NOSTD_CXXFLAGS) $(CRYPTOGAMS_ARMV4_FLAG) -c) $<
# SSE4.2/SHA-NI or ARMv8a available
shacal2_simd.o : shacal2_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SHA_FLAG) -c) $<
# SSSE3 or NEON available
simeck_simd.o : simeck_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SIMECK_FLAG) -c) $<
# SSE4.1, NEON or POWER7 available
simon64_simd.o : simon64_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SIMON64_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SHA_FLAG) -c) $<
# SSSE3, NEON or POWER8 available
simon128_simd.o : simon128_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
# SSE4.1, NEON or POWER7 available
speck64_simd.o : speck64_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SPECK64_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
# SSSE3, NEON or POWER8 available
speck128_simd.o : speck128_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
# ARMv8.4 available
sm3_simd.o : sm3_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SM3_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM3_FLAG) -c) $<
# AESNI available
sm4_simd.o : sm4_simd.cpp
$(CXX) $(strip $(CXXFLAGS) $(SM4_FLAG) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) $(SM4_FLAG) -c) $<
%.o : %.cpp
$(CXX) $(strip $(CXXFLAGS) -c) $<
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS) -c) $<
.PHONY: dep deps depend
dep deps depend GNUmakefile.deps:
$(CXX) $(strip $(CXXFLAGS) -DCRYPTOPP_DISABLE_ASM) -MM *.cpp > GNUmakefile.deps
$(CXX) $(strip $(CPPFLAGS) $(CXXFLAGS)) -MM *.cpp > GNUmakefile.deps

View File

@ -480,3 +480,65 @@ last several releases.
- fix missing GF2NT_233_Multiply_Reduce_CLMUL in FIPS DLL
- add missing BLAKE2 constructors
- fix missing BlockSize() in BLAKE2 classes
8.3.0 - December 20, 2020
- minor release, recompile of programs required
- expanded community input and support
* 66 unique contributors as of this release
- fix use of macro CRYPTOPP_ALIGN_DATA
- fix potential out-of-bounds read in ECDSA
- fix std::bad_alloc when using ByteQueue in pipeline
- fix missing CRYPTOPP_CXX17_EXCEPTIONS with Clang
- fix potential out-of-bounds read in GCM mode
- add configure.sh when preprocessor macros fail
- fix potential out-of-bounds read in SipHash
- fix compile error on POWER9 due to vec_xl_be
- fix K233 curve on POWER8
- add Cirrus CI testing
- fix broken encryption for some 64-bit ciphers
- fix Android cpu-features.c using C++ compiler
- disable RDRAND and RDSEED for some AMD processors
- fix BLAKE2 hash calculation using Salt and Personalization
- refresh Android and iOS build scripts
- add XTS mode
- fix circular dependency between misc.h and secblock.h
- add Certificate interface
- fix recursion in AES::Encryption without AESNI
- add missing OID for ElGamal encryption
- fix missing override in KeyDerivationFunction-derived classes
- fix RDSEED assemble under MSVC
- fix elliptic curve timing leaks (CVE-2019-14318)
- add link-library variable to Makefiles
- fix SIZE_MAX definition in misc.h
- add GetWord64 and PutWord64 to BufferedTransformation
- use HKDF in AutoSeededX917RNG::Reseed
- fix Asan finding in VMAC on i686 in inline asm
- fix undeclared identifier _mm_roti_epi64 on Gentoo
- fix ECIES and GetSymmetricKeyLength
- fix possible divide by zero in PKCS5_PBKDF2_HMAC
- refine ASN.1 encoders and decoders
- disable BMI2 code paths in Integer class
- fix use of CRYPTOPP_CLANG_VERSION
- add NEON SHA1, SHA256 and SHA512 from Cryptogams
- add ARM SHA1, SHA256 and SHA512 from Cryptogams
- make config.h more autoconf friendly
- handle Clang triplet armv8l-unknown-linux-gnueabihf
- fix reference binding to misaligned address in xed25519
- clear asserts in TestDataNameValuePairs
8.4.0 - January 2, 2021
- minor release, recompile of programs required
- expanded community input and support
* 67 unique contributors as of this release
- fix SIGILL on POWER8 when compiling with GCC 10
- fix potential out-of-bounds write in FixedSizeAllocatorWithCleanup
- fix compile on AIX POWER7 with IBM XLC 12.01
- fix compile on Solaris with SunCC 12.6
- revert changes for constant-time elliptic curve algorithms
- fix makefile clean and distclean recipes
8.5.0 - March 7, 2021
- minor release, no recompile of programs required
- expanded community input and support
* 70 unique contributors as of this release
- port to Apple M1

View File

@ -2,6 +2,7 @@ CONTENTS OF THIS FILE
---------------------
* Introduction
* Prerequisites
* Building the Library
* Alternate Build Systems
* Installing the Library
@ -16,27 +17,34 @@ INTRODUCTION
Crypto++ Library is a free C++ class library of cryptographic algorithms and schemes. The library was originally written and placed in public domain by Wei Dai, but it is now maintained by the community. The library homepage is at http://www.cryptopp.com/. The latest library source code can be found at http://github.com/weidai11/cryptopp. For licensing and copyright information, please see License.txt.
These are general instructions for the AIX, BSDs, Linux, OS X, Solaris and Unix. The library uses a GNU makefile, which combines configuration and a non-anemic make. On AIX, BSD and Solaris you will likely have to use `gmake` to build the library. On Linux, OS X and Unix, the system's make should be OK. On Windows, Crypto++ provides Visual Studio solutions.
These are general instructions for AIX, BSDs, Linux, OS X, Solaris and Unix. The library uses GNU Make and a GNUmakefile to avoid anemic make. On AIX, BSD and Solaris you will likely have to use `gmake` to build the library. On Linux and OS X, the system's make should be OK. On Windows, Crypto++ provides Visual Studio solutions.
You should look through the GNUmakefile and config.h to ensure settings look reasonable before building. There are two wiki pages that help explain them at http://www.cryptopp.com/wiki/GNUmakefile and http://www.cryptopp.com/wiki/Config.h.
Wiki pages are available for some platforms with specific build instructions. The pages include Android, ARM, iOS, MSBuild and Solaris. Solaris users should visit the wiki for important information on compiling the library with different versions of SunCC and options, and information on improving library performance and features.
Crypto++ does not depend upon other tools or libraries. It does not use Autotools, does not use CMake, and does not use Boost. If you use an alternate build system, like Autotools or CMake, then see the warning below about CXXFLAGS and lack of -DNDEBUG. CMake is available in Master as a matter of convenience, but its not officially supported.
Crypto++ does not depend upon other tools or libraries. The library only needs GNU Make 3.80 on Unix & Linux; or Visual Studio 2010 and above build tools on Windows. The library does not use Autotools, does not use CMake, and does not use Boost.
There is a partially complete CmakeList.txt available on the wiki at http://www.cryptopp.com/wiki/CMake. It is not recommended for use because it is not in a good state. If you have CMake expertise and can work some problems, then please see the wiki page for tasks related to CMake.
Autotools and CMake projects are not officially supported. The build systems take too much time and effort. Unofficial projects are available at https://github.com/noloader/cryptopp-autotools and https://github.com/noloader/cryptopp-cmake. The projects provide a central location to support Autotools and CMake. Collaborators for Autotools and CMake are welcomed.
PREREQUISITES
-------------
The library requires a semi-modern C++ compiler and GNU Make 3.81 or above. The compiler must support 64-bit words, C++03, namespaces, RTTI and exceptions.
The library does not depend on other build systems, like Autotools or CMake. The library does not depend on other libraries, like Boost.
BUILDING THE LIBRARY
--------------------
In general, all you should have to do is open a terminal, and then:
In general, all you should have to do is open a terminal, cd to the cryptopp directory, and then:
make
make test
sudo make install
The command above builds the static library and cryptest.exe program. It also uses a sane set of default flags, which are usually "-DNDEBUG -g2 -O3 -fPIC".
The command above builds the static library and cryptest.exe program. It also uses a sane default flags, which are usually "-DNDEBUG -g2 -O3 -fPIC".
If you want to build the shared object, then issue:
@ -70,7 +78,16 @@ LLVM's libc++ is also supported, so you can:
export CXXFLAGS="-std=c++11 -stdlib=libc++"
make
If you target 32-bit IA-32 machines (i386, i586 or i686), then the makefile forgoes -fPIC due to register pressures. You should add -fPIC yourself in this case:
If you are using the library on OS X with XCode then you should add LLVM's libc++. You can do so by modifying CXXFLAGS, or you can modify the GNUmakefile. To modify the GNUmakefile, open it and find the line for OS X builds around line 150:
ifneq ($(IS_DARWIN),0)
CXX ?= c++
CRYPTOPP_CXXFLAGS += -stdlib=libc++
AR = libtool
ARFLAGS = -static -o
endif
If you target 32-bit IA-32 machines (i386, i586 or i686), then the makefile forgoes -fPIC due to register pressures. You should add -fPIC yourself, if needed:
CXXFLAGS="-DNDEBUG -g2 -O3 -fPIC" make
@ -78,10 +95,27 @@ You can also override a variable so that only your flags are present. That is, t
make CXXFLAGS="-std=c++11"
Crypto++ does not enagage Specter remediations at this time. You can build with Specter resistance with the following flags:
Crypto++ does not engage Specter remediations at this time. You can build with Specter resistance with the following flags:
CXXFLAGS="-DNDEBUG -g2 -O3 -mfunction-return=thunk -mindirect-branch=thunk" make
The library does not support out-of-tree builds. You must cd to the Crypto++ directory before building. `make distclean` will return the Crypto++ directory to a pristine state.
BUILDING WITH VCPKG
-------------------
You can download and install cryptopp using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install cryptopp
The cryptopp port in vcpkg is kept up to date by Microsoft team members and community contributors.
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
ALTERNATE BUILD SYSTEMS
-----------------------
@ -124,7 +158,7 @@ The following are some of the targets provided by the GNU makefile.
`make cryptest.exe` builds the library test harness.
`make test` and `make check` are the same recipe and invoke the test harness with the the validation option. That is, it executes `cryptest.exe v`.
`make test` and `make check` are the same recipe and invoke the test harness with the validation option. That is, it executes `cryptest.exe v`.
`make install` installs the library. By default, the makefile copies into `/usr/local` by default.
@ -147,18 +181,16 @@ The Crypto++ embraces tools like Undefined Behavior sanitizer (UBsan), Address s
UBsan and Asan are mutually exclusive options, so you can perform only one of these at a time:
make ubsan
./cryptest.exe v 2>&1 | egrep "(error|FAILED)"
./cryptest.exe tv all 2>&1 | egrep "(error|FAILED)"
./cryptest.exe v 2>&1 | grep -E "(error:|FAILED)"
./cryptest.exe tv all 2>&1 | grep -E "(error:|FAILED)"
Or:
make asan
./cryptest.exe v 2>&1 | egrep "(error|FAILED)"
./cryptest.exe tv all 2>&1 | egrep "(error|FAILED)"
./cryptest.exe v 2>&1 | grep -E "(error:|FAILED)"
./cryptest.exe tv all 2>&1 | grep -E "(error:|FAILED)"
If you experience self test failures or see reports of undefined behavior, then you should ensure CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is defined in config.h. CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is not defined due to historical purposes.
If you experience failures under Asan, then gather more information with:
If you experience failures under Asan, then gather more information with asan_symbolize. You may not need asan_symbolize nowadays:
./cryptest.exe v 2>&1 | asan_symbolize
@ -185,25 +217,25 @@ Fifth, the test harness provides a "validation" option which performs basic syst
./cryptest.exe v
...
All tests passed!
Test ended at Sun Jul 26 02:10:57 2015
Seed used was: 1437891055
Seed used was 1612313449
Test started at Tue Feb 2 19:50:49 2021
Test ended at Tue Feb 2 19:50:52 2021
Sixth, the test harness provides a "test vector" option which uses many known test vectors, even those published by other people (like Brian Gladman for AES). You run the test vectors as shown below. The tail of the output should indicate 0 failed tests.
./cryptest.exe tv all
...
Testing SymmetricCipher algorithm MARS/ECB.
.................
Tests complete. Total tests = 4094. Failed tests = 0.
Testing SymmetricCipher algorithm AES/XTS.
.....................
Tests complete. Total tests = 11260. Failed tests = 0.
The library also offers its test script for those who want to use it. The test script is names cryptest.sh, and it repeatedly builds the library and exectues the tests under various configurations. It takes 2 to 4 hours to run on a semi-modern desktop or server; and days to run on an IoT gadget. Also see http://github.com/weidai11/cryptopp/blob/master/cryptest.sh and http://cryptopp.com/wiki/Cryptest.sh.
The library also offers its test script for those who want to use it. The test script is names cryptest.sh, and it repeatedly builds the library and exectues the tests under various configurations. It takes about 4 hours to run on a semi-modern desktop or server; and several days to run on an IoT gadget. Also see http://github.com/weidai11/cryptopp/blob/master/cryptest.sh and http://cryptopp.com/wiki/Cryptest.sh.
REPORTING PROBLEMS
------------------
Dirty compiles and failures in the validation suite or test vectors should be reported at the Crypto++ User Group. The User Group is located at http://groups.google.com/forum/#!forum/cryptopp-users.
Build failures, dirty compiles and failures in the validation suite or test vectors should be reported at the Crypto++ User Group. The User Group is located at http://groups.google.com/forum/#!forum/cryptopp-users.
The library uses Wei Dai's GitHub to track issues. The tracker is located at http://github.com/weidai11/cryptopp/issues. Please do not ask questions in the bug tracker; ask questions on the mailing list instead. Also see http://www.cryptopp.com/wiki/Bug_Report.

View File

@ -29,8 +29,9 @@ Daniel J. Bernstein, Jack Lloyd - chacha.cpp, chacha_simd.cpp, chacha_avx.cpp
Andrew Moon - ed25519, x25519, donna_32.cpp, donna_64.cpp, donna_sse.cpp
The Crypto++ Library uses portions of Andy Polyakov's CRYPTOGAMS for Poly1305
scalar multiplication and aes_armv4.S. CRYPTOGAMS is dual licensed with a
permissive BSD-style license. The CRYPTOGAMS license is reproduced below.
scalar multiplication, aes_armv4.S, sha1_armv4.S and sha256_armv4.S. CRYPTOGAMS
is dual licensed with a permissive BSD-style license. The CRYPTOGAMS license is
reproduced below.
The Crypto++ Library uses portions of Jack Lloyd's Botan for ChaCha SSE2 and
AVX. Botan placed the code in public domain for Crypto++ to use.

View File

@ -1,5 +1,5 @@
Crypto++: free C++ Class Library of Cryptographic Schemes
Version 8.2 - APR/28/2019
Version 8.5 - March 7, 2021
Crypto++ Library is a free C++ class library of cryptographic schemes.
Currently the library contains the following algorithms:
@ -22,7 +22,7 @@ Currently the library contains the following algorithms:
Triple-DES (DES-EDE2 and DES-EDE3), TEA, XTEA
block cipher modes of operation ECB, CBC, CBC ciphertext stealing (CTS),
CFB, OFB, counter mode (CTR)
CFB, OFB, counter mode (CTR), XTS
message authentication codes BLAKE2s, BLAKE2b, CMAC, CBC-MAC, DMAC, GMAC, HMAC,
Poly1305, Poly1305 (IETF), SipHash, Two-Track-MAC,
@ -33,7 +33,7 @@ Currently the library contains the following algorithms:
SHAKE (128/256), SipHash, SM3, Tiger,
RIPEMD (128/160/256/320), WHIRLPOOL
RSA, DSA, Determinsitic DSA, ElGamal,
RSA, DSA, Deterministic DSA, ElGamal,
public-key cryptography Nyberg-Rueppel (NR), Rabin-Williams (RW), LUC,
LUCELG, EC-based German Digital Signature (ECGDSA),
DLIES (variants of DHAES), ESIGN
@ -45,7 +45,7 @@ Currently the library contains the following algorithms:
key agreement schemes Menezes-Qu-Vanstone (MQV), Hashed MQV (HMQV),
Fully Hashed MQV (FHMQV), LUCDIF, XTR-DH
elliptic curve cryptography ECDSA, Determinsitic ECDSA, ed25519, ECNR, ECIES,
elliptic curve cryptography ECDSA, Deterministic ECDSA, ed25519, ECNR, ECIES,
ECDH, ECMQV, x25519
insecure or obsolescent MD2, MD4, MD5, Panama Hash, DES, ARC4, SEAL
@ -84,21 +84,21 @@ Other features include:
+ ARM-32, Aarch32 and Aarch64 provides NEON, ASIMD and ARMv8 implementations
+ Power8 provides in-core AES using NX Crypto Acceleration
The Crypto++ library was orginally written by Wei Dai. The library is now
The Crypto++ library was originally written by Wei Dai. The library is now
maintained by several team members and the community. You are welcome to use it
for any purpose without paying anyone, but see License.txt for the fine print.
The following compilers are supported for this release. Please visit
http://www.cryptopp.com the most up to date build instructions and porting notes.
* Visual Studio 2003 - 2017
* GCC 3.3 - 9.0
* Apple Clang 4.3 - 9.3
* LLVM Clang 2.9 - 7.0
* Visual Studio 2003 - 2019
* GCC 3.3 - 10.1
* Apple Clang 4.3 - 12.0
* LLVM Clang 2.9 - 11.0
* C++ Builder 2015
* Intel C++ Compiler 9 - 16.0
* Sun Studio 12u1 - 12.6
* IBM XL C/C++ 10.0 - 13.3
* IBM XL C/C++ 10.0 - 14.0
*** Important Usage Notes ***
@ -205,23 +205,28 @@ library in your programs to help avoid unwanted redirections.
*** Side Channel Attacks ***
Crypto++ attempts to resist side channel attacks using various remediations. We
believe the library is mostly hardened but the remdiations may be incomplete. The
first line of defense uses hardware instructions when possible for block ciphers,
hashes and other primitives. Hardware acceleration remediates many timing attacks.
The library also uses cache-aware algoirthms and access patterns to minimize leakage.
Crypto++ attempts to resist side channel attacks using various remediations.
The remdiations are applied as a best effort but are probably incomplete. They
are incomplete due to cpu speculation bugs like Spectre, Meltdown, Foreshadow.
The attacks target both cpu caches and internal buffers. Intel generally refers
to internal buffer attacks as "Microarchitectural Data Sampling" (MDS).
Some of the public key algorithms have branches and some of the branches depend on
data that can be private or secret. The branching occurs in some field operations
like exponentiation over integers and elliptic curves. The branching has been
minimized but not completely eliminated.
The library uses hardware instructions when possible for block ciphers, hashes
and other operations. The hardware acceleration remediates some timing
attacks. The library also uses cache-aware algoirthms and access patterns
to minimize leakage cache evictions.
Crypto++ does not enagage Specter remediations at this time. The GCC options for
Specter are -mfunction-return=thunk and -mindirect-branch=thunk, and the library
uses them during testing. If you want the Specter workarounds then add the GCC
options to your CXXFLAGS when building the library.
Elliptic curves over binary fields are believed to leak information. The task is a
work in progress. We don't believe binary fields are used in production, so we feel it
is a low risk at the moment.
If you suspect or find an information leak then please report it.
Crypto++ does not enagage Specter remediations at this time. The GCC options
for Specter are -mfunction-return=thunk and -mindirect-branch=thunk, and the
library uses them during testing. If you want the Specter workarounds then add
the GCC options to your CXXFLAGS when building the library.
To help resist attacks you should disable hyperthreading on cpus. If you
suspect or find an information leak then please report it.
*** Documentation and Support ***
@ -243,7 +248,7 @@ The source code and its planned changes are available at the following locations
* The Crypto++ GitHub repository allows you to view the latest (unreleased)
Crypto++ source code via the Linux kernel's git beginning around June 2015.
Its also serves as an incubator to nuture and grow the library.
Its also serves as an incubator to nurture and grow the library.
* The former Crypto++ SourceForge repository allows you to view the Crypto++
source code via Apache's subversion until about July 2015. At that time,
SourceForge had infrastructure problems and a cutover to GutHub was performed.
@ -290,6 +295,68 @@ documentation is one of the highest returns on investment.
The items in this section comprise the most recent history. Please see History.txt
for the record back to Crypto++ 1.0.
8.5.0 - March 7, 2021
- minor release, no recompile of programs required
- expanded community input and support
* 70 unique contributors as of this release
- port to Apple M1
8.4.0 - January 2, 2021
- minor release, recompile of programs required
- expanded community input and support
* 67 unique contributors as of this release
- fix SIGILL on POWER8 when compiling with GCC 10
- fix potential out-of-bounds write in FixedSizeAllocatorWithCleanup
- fix compile on AIX POWER7 with IBM XLC 12.01
- fix compile on Solaris with SunCC 12.6
- revert changes for constant-time elliptic curve algorithms
- fix makefile clean and distclean recipes
8.3.0 - December 20, 2020
- minor release, recompile of programs required
- expanded community input and support
* 66 unique contributors as of this release
- fix use of macro CRYPTOPP_ALIGN_DATA
- fix potential out-of-bounds read in ECDSA
- fix std::bad_alloc when using ByteQueue in pipeline
- fix missing CRYPTOPP_CXX17_EXCEPTIONS with Clang
- fix potential out-of-bounds read in GCM mode
- add configure.sh when preprocessor macros fail
- fix potential out-of-bounds read in SipHash
- fix compile error on POWER9 due to vec_xl_be
- fix K233 curve on POWER8
- add Cirrus CI testing
- fix broken encryption for some 64-bit ciphers
- fix Android cpu-features.c using C++ compiler
- disable RDRAND and RDSEED for some AMD processors
- fix BLAKE2 hash calculation using Salt and Personalization
- refresh Android and iOS build scripts
- add XTS mode
- fix circular dependency between misc.h and secblock.h
- add Certificate interface
- fix recursion in AES::Encryption without AESNI
- add missing OID for ElGamal encryption
- fix missing override in KeyDerivationFunction-derived classes
- fix RDSEED assemble under MSVC
- fix elliptic curve timing leaks (CVE-2019-14318)
- add link-library variable to Makefiles
- fix SIZE_MAX definition in misc.h
- add GetWord64 and PutWord64 to BufferedTransformation
- use HKDF in AutoSeededX917RNG::Reseed
- fix Asan finding in VMAC on i686 in inline asm
- fix undeclared identifier _mm_roti_epi64 on Gentoo
- fix ECIES and GetSymmetricKeyLength
- fix possible divide by zero in PKCS5_PBKDF2_HMAC
- refine ASN.1 encoders and decoders
- disable BMI2 code paths in Integer class
- fix use of CRYPTOPP_CLANG_VERSION
- add NEON SHA1, SHA256 and SHA512 from Cryptogams
- add ARM SHA1, SHA256 and SHA512 from Cryptogams
- make config.h more autoconf friendly
- handle Clang triplet armv8l-unknown-linux-gnueabihf
- fix reference binding to misaligned address in xed25519
- clear asserts in TestDataNameValuePairs
8.2.0 - April 28, 2019
- minor release, no recompile of programs required
- expanded community input and support
@ -337,64 +404,6 @@ for the record back to Crypto++ 1.0.
- add ARM AES asm implementation from Cryptogams
- remove CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS support
7.0.0 - April 8, 2018
- major release, recompile of programs required
- expanded community input and support
* 48 unique contributors as of this release
- fix incorrect result when using Integer::ModInverse
* may be CVE worthy, but request was not submitted
- fix ARIA/CTR bus error on Sparc64
- fix incorrect result when using a_exp_b_mod_c
- fix undeclared identifier uint32_t on early Visual Studio
- fix iPhoneSimulator build on i386
- fix incorrect adler32 in ZlibDecompressor
- fix Power7 test using PPC_FEATURE_ARCH_2_06
- workaround incorrect Glibc sysconf return value on ppc64-le
- add KeyDerivationFunction interface
- add scrypt key derivation function
- add Salsa20_Core transform callable from outside class
- add sbyte, sword16, sword32 and sword64
- remove s_nullNameValuePairs from unnamed namespace
- ported to MSVC 2017, Xcode 9.3, Sun Studio 12.5, GCC 8.0.1,
MacPorts GCC 7.0, Clang 4.0, Intel C++ 17.00, IBM XL C/C++ 13.1
6.1.0 - February 22, 2018
- minor release, maintenance items
- expanded community input and support
* 46 unique contributors as of this release
- use 2048-bit modulus default for DSA
- fix build under Linuxbrew
- use /bin/sh in GNUmakefile
- fix missing flags for SIMON and SPECK in GNUMakefile-cross
- fix ARM and MinGW misdetection
- port setenv-android.sh to latest NDK
- fix Clang check for C++11 lambdas
- Simon and Speck to little-endian implementation
- use LIB_MAJOR for ABI compatibility
- fix ODR violation in AdvancedProcessBlocks_{ARCH} templates
- handle C++17 std::uncaught_exceptions
- ported to MSVC 2017, Xcode 8.1, Sun Studio 12.5, GCC 8.0.1,
MacPorts GCC 7.0, Clang 4.0, Intel C++ 17.00, IBM XL C/C++ 13.1
6.0.0 - January 22, 2018
- major release, recompile of programs required
- expanded community input and support
* 43 unique contributors as of this release
- fixed CVE-2016-9939 (Issue 346, transient DoS)
- fixed CVE-2017-9434 (Issue 414, misidentified memory error)
- converted to BASE+SIMD implementation
* BASE provides an architecture neutral C++ implementation
* SIMD provides architecture specific hardware acceleration
- improved PowerPC Power4, Power7 and Power8 support
- added ARIA, EC German DSA, Deterministic signatures (RFC 6979),
Kalyna, NIST Hash and HMAC DRBG, Padlock RNG, Poly1305, SipHash,
Simon, Speck, SM3, SM4, Threefish algorithms
- added NaCl interface from the compact library
* x25519 key exhange and ed25519 signing provided through NaCl interface
- improved Testing and QA
- ported to MSVC 2017, Xcode 8.1, Sun Studio 12.5, GCC 7.3,
MacPorts GCC 7.0, Clang 4.0, Intel C++ 17.00, IBM XL C/C++ 13.1
June 2015 - Changing of the guard. Wei Dai turned the library over to the
community. The first community release was Crypto++ 5.6.3. Wei is
no longer involved with the daily operations of the project. Wei

View File

@ -0,0 +1,15 @@
# Security Policy
## Supported Versions
We support modern versions of the Crypto++ library. Modern versions include the tip of Master and the latest release.
We also support versions of the library supplied by distributions such as Debian, Fedora, Red Hat and Ubuntu. We don't leave distros unsupported simply because we have released a new version of the library. And we don't expect a package maintainer to fix our bugs for us.
## Reporting a Vulnerability
You can report a security related bug in the [GitHub bug tracker](https://github.com/weidai11/cryptopp) or at the [mailing list](https://groups.google.com/g/cryptopp-users).
If we receive a report of a security related bug then we will ensure a Github issue is opened and we will make an announcement on the mailing list. If you corresponded by private email then we will open the Github issue and make the announcement.
All information will be made public. We do not withhold information from users because stake holders need accurate information to access risk and place controls to remediate the risk.

View File

@ -0,0 +1 @@
3081C80201003081A406072A8648CE3D0201308198020101302006072A8648CE3D0101021500FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF302C0414FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC04141C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA450429044A96B5688EF573284664698968C38BB913CBFC8223A628553168947D59DCC912042351377AC5FB3202150100000000000000000001F4C8F927AED3CA752257020101041C301A02010104150023A68821ABB99DBB8429ED2320D61A8EA4C6D81B

View File

@ -0,0 +1 @@
3081D10201003081AD06072A8648CE3D02013081A1020101302506072A8648CE3D0102301A020200A306092A8648CE3D010203033009020103020106020107302E041507B6882CAAEFA84F9554FF8428BD88E246D2782AE204150713612DCDDCB40AAB946BDA29CA91F73AF958AFD9042B040369979697AB43897789566789567F787A7876A65400435EDB42EFAFB2989D51FEFCE3C80988F41FF883021503FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B020102041C301A02010104150003693AB4D83EE8B544548BE7647AEA0EA64E8211

View File

@ -1 +1 @@
308201A40201003082011706072A8648CE3804013082010A028181008B333697371663F8869E3EC80A414E46BBAFE41F6D40E754A01ADA60FE7D12ACD16DE311C4115293114F6B92A54195909276380F04BCD4ED5CD993ED7F516DF7A752B928E5035E0D3A1A979A1CDE8387734338793C02001D59B662D4FC8F2BF0EABB1F553F9F46F57E74BCABCBA4E458812DB601FCD04609D435317181236B9702818045999B4B9B8B31FC434F1F640520A7235DD7F20FB6A073AA500D6D307F3E895668B6F188E208A94988A7B5C952A0CAC8493B1C07825E6A76AE6CC9F6BFA8B6FBD3A95C947281AF069D0D4BCD0E6F41C3B9A19C3C9E01000EACDB316A7E4795F8755D8FAA9FCFA37ABF3A5E55E5D2722C4096DB00FE682304EA1A98B8C091B5CB02010204818302818045999B4B9B8B31FC434F1F640520A7235DD7F20FB6A073AA500D6D307F3E895668B6F188E208A94988A7B5C952A0CAC8493B1C07825E6A76AE6CC9F6BFA8B6FBD3A95C947281AF069D0D4BCD0E6F41C3B9A19C3C9E01000EACDB316A7E4795F8755D8FAA9FCFA37ABF3A5E2958F40032EF29CB145C7481380458812D62F09287
308201360201003082011606062B0E070201013082010A02818100D18892CC35AD9E532C53810019E525CDE08882E6344D6787C366B171D68948F53D74F7923B148E0A0B4C9B956D695384DE24AC3034000B3C4AD4C8226470BBD88B5B053BCCB01E608B1352D6ED16324745253BDB204308E065368CB9D75ACDB290E671BD4CA1608500BFACD758E6E9EFAC8CCBAD83BE7E397A62E4F55634FC3B02818068C449661AD6CF299629C0800CF292E6F04441731A26B3C3E1B358B8EB44A47A9EBA7BC91D8A470505A64DCAB6B4A9C26F1256181A00059E256A641132385DEC45AD829DE6580F304589A96B768B1923A2929DED90218470329B465CEBAD66D9487338DEA650B042805FD66BAC7374F7D64665D6C1DF3F1CBD31727AAB1A7E1D0201030417021504ED7AED68B1A5EFDE11262210D9F1121D4A119CE8

View File

@ -0,0 +1,214 @@
// dump2def.cxx - Written and placed in public domain by Jeffrey Walton
// Create a module definitions file from a dumpbin file.
// dump2def can be used to create a list of exports from
// a static library. Then, the exports can used to build
// a dynamic link library with the same exports.
//
// If you wish to compile this source file using cl.exe, then:
// cl.exe /DNDEBUG /Oi /Oy /O2 /Zi /TP /GR /EHsc /MT dump2def.cxx
//
// The intended workflow in Crypto++ is:
//
// 1. Open a Developer Prompt
// 2. CD to cryptopp/ directory
// 3. nmake /f cryptest.nmake cryptopp.dll
//
// The cryptopp.dll recipe first builds cryptlib.lib. Then it calls
// dumpbin.exe to export all symbols from cryptlib.lib and writes them
// to cryptopp.dump. The recipe then calls dump2def.exe to create a
// module definition file. Finally, the recipe builds cryptopp.dll
// using the module definition file cryptopp.def. The linker creates
// the import lib cryptopp.lib and export cryptopp.exp automatically.
//
// This is only "half the problem solved" for those who wish to use
// a DLL. The program must import the import lib cryptopp.lib. Then
// the program must ensure the library headers export the symbol or
// class with CRYPTOPP_DLL. CRYPTOPP_DLL is only present on some classes
// because the FIPS module only allowed approved algorithms like AES and
// SHA. Other classes like Base64Encoder and HexEncoder lack CRYPTOPP_DLL.
//
// CRYPTOPP_DLL simply adds declspec(dllimport) when CRYPTOPP_IMPORTS is
// defined. The limitation of requiring declspec(dllimport) is imposed by
// Microsoft. Microsoft does not allow a program to "import everything".
//
// If you would like to read more about the FIPS module and the pain it
// causes then see https://www.cryptopp.com/wiki/FIPS_DLL. In fact we
// recommend you delete the CryptDll and DllTest projects from the
// Visual Studio solution file.
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
// Friendly name
#define LIBRARY_DESC "Crypto++ Library"
typedef std::set<std::string> SymbolMap;
const int ErrorSuccess = 0;
const int ErrorDumpExtension = 1;
const int ErrorTooFewOpts = 2;
const int ErrorTooManyOpts = 3;
const int ErrorOpenInputFailed = 4;
const int ErrorOpenOutputFailed = 5;
const int ErrorReadException = 6;
const int ErrorWriteException = 7;
void PrintHelpAndExit(int code)
{
std::cout << "dump2def - create a module definitions file from a dumpbin file" << std::endl;
std::cout << " Written and placed in public domain by Jeffrey Walton" << std::endl;
std::cout << std::endl;
switch (code)
{
case ErrorDumpExtension:
std::cout << "Error: input file is missing \".dump\" extension.\n" << std::endl;
break;
case ErrorTooFewOpts:
std::cout << "Error: Too few options were supplied.\n" << std::endl;
break;
case ErrorTooManyOpts:
std::cout << "Error: Too many options were supplied.\n" << std::endl;
break;
case ErrorOpenInputFailed:
std::cout << "Error: Failed to open input file.\n" << std::endl;
break;
case ErrorOpenOutputFailed:
std::cout << "Error: Failed to open output file.\n" << std::endl;
break;
default:
;;
}
std::cout << "Usage: " << std::endl;
std::cout << " dump2def <infile>" << std::endl;
std::cout << " - Create a def file from <infile> and write it to a file with" << std::endl;
std::cout << " the same name as <infile> but using the .def extension" << std::endl;
std::cout << " dump2def <infile> <outfile>" << std::endl;
std::cout << " - Create a def file from <infile> and write it to <outfile>" << std::endl;
std::exit((code == ErrorSuccess ? 0 : 1));
}
int main(int argc, char* argv[])
{
// ******************** Handle Options ******************** //
// Convenience item
std::vector<std::string> opts;
for (size_t i=0; i<argc; ++i)
opts.push_back(argv[i]);
// Look for help
std::string opt = (opts.size() > 1 ? opts[1].substr(0,2) : "");
if (opt == "/h" || opt == "-h" || opt == "/?" || opt == "-?")
PrintHelpAndExit(ErrorSuccess);
// Add <outfile> as needed
if (opts.size() == 2)
{
std::string outfile = opts[1];
std::string::size_type pos = outfile.length() < 5 ? std::string::npos : outfile.length() - 5;
if (pos == std::string::npos || outfile.substr(pos) != ".dump")
PrintHelpAndExit(ErrorDumpExtension);
outfile.replace(pos, 5, ".def");
opts.push_back(outfile);
}
// Check or exit
if (opts.size() < 2)
PrintHelpAndExit(ErrorTooFewOpts);
if (opts.size() > 3)
PrintHelpAndExit(ErrorTooManyOpts);
// ******************** Read MAP file ******************** //
SymbolMap symbols;
try
{
std::ifstream infile(opts[1].c_str());
if (infile.is_open() == false)
PrintHelpAndExit(ErrorOpenInputFailed);
std::string::size_type pos;
std::string line;
// Find start of the symbol table
while (std::getline(infile, line))
{
pos = line.find("public symbols");
if (pos == std::string::npos) { continue; }
// Eat the whitespace after the table heading
infile >> std::ws;
break;
}
while (std::getline(infile, line))
{
// End of table
if (line.empty()) { break; }
std::istringstream iss(line);
std::string address, symbol;
iss >> address >> symbol;
symbols.insert(symbol);
}
}
catch (const std::exception& ex)
{
std::cerr << "Unexpected exception:" << std::endl;
std::cerr << ex.what() << std::endl;
std::cerr << std::endl;
PrintHelpAndExit(ErrorReadException);
}
// ******************** Write DEF file ******************** //
try
{
std::ofstream outfile(opts[2].c_str());
if (outfile.is_open() == false)
PrintHelpAndExit(ErrorOpenOutputFailed);
// Library name, cryptopp.dll
std::string name = opts[2];
std::string::size_type pos = name.find_last_of(".");
if (pos != std::string::npos)
name.erase(pos);
outfile << "LIBRARY " << name << std::endl;
outfile << "DESCRIPTION \"" << LIBRARY_DESC << "\"" << std::endl;
outfile << "EXPORTS" << std::endl;
outfile << std::endl;
outfile << "\t;; " << symbols.size() << " symbols" << std::endl;
// Symbols from our object files
SymbolMap::const_iterator it = symbols.begin();
for ( ; it != symbols.end(); ++it)
outfile << "\t" << *it << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Unexpected exception:" << std::endl;
std::cerr << ex.what() << std::endl;
std::cerr << std::endl;
PrintHelpAndExit(ErrorWriteException);
}
return 0;
}

View File

@ -1,4 +1,5 @@
#include <arm_acle.h>
int main(int argc, char* argv[])
{
return 0;

View File

@ -1,10 +1,8 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif

View File

@ -1,10 +1,8 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif

View File

@ -1,10 +1,8 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif

View File

@ -1,5 +1,7 @@
#include <arm_neon.h>
#include <stdint.h>
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
int main(int argc, char* argv[])
{

View File

@ -0,0 +1,6 @@
#include <arm_neon.h>
int main(int argc, char* argv[])
{
return 0;
}

View File

@ -1,10 +1,8 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif

View File

@ -1,21 +0,0 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
# include <arm_acle.h>
#endif
int main(int argc, char* argv[])
{
uint32x4_t y = {0};
y=vsha1cq_u32(y,0,y);
y=vsha1mq_u32(y,1,y);
y=vsha1pq_u32(y,2,y);
y=vsha256hq_u32(y, y, y);
y=vsha256h2q_u32(y, y, y);
y=vsha256su1q_u32(y, y, y);
return 0;
}

View File

@ -0,0 +1,16 @@
#include <stdint.h>
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif
int main(int argc, char* argv[])
{
uint32x4_t y = {0};
y=vsha1cq_u32(y,0,y);
y=vsha1mq_u32(y,1,y);
y=vsha1pq_u32(y,2,y);
return 0;
}

View File

@ -0,0 +1,16 @@
#include <stdint.h>
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif
int main(int argc, char* argv[])
{
uint32x4_t y = {0};
y=vsha256hq_u32(y, y, y);
y=vsha256h2q_u32(y, y, y);
y=vsha256su1q_u32(y, y, y);
return 0;
}

View File

@ -1,10 +1,8 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif

View File

@ -1,10 +1,8 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif

View File

@ -1,10 +1,8 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif

View File

@ -1,10 +1,8 @@
#include <arm_neon.h>
#include <stdint.h>
// test_acle.h determines if this is available. Then,
// -DCRYPTOPP_ARM_ACLE_AVAILABLE=0 is added to CXXFLAGS
// if the ACLE header is not available.
#if (CRYPTOPP_ARM_ACLE_AVAILABLE)
#ifdef CRYPTOPP_ARM_NEON_HEADER
# include <arm_neon.h>
#endif
#ifdef CRYPTOPP_ARM_ACLE_HEADER
# include <arm_acle.h>
#endif

View File

@ -0,0 +1,31 @@
// Most Clang cannot handle mixed asm with positional arguments, where the
// body is Intel style with no prefix and the templates are AT&T style.
// Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
#include <cstddef>
int main(int argc, char* argv[])
{
size_t ret = 1, N = 1;
asm __volatile__
(
#if defined(__amd64__) || defined(__x86_64__)
".intel_syntax noprefix ;\n"
"xor rsi, rsi ;\n"
"neg %1 ;\n"
"inc %1 ;\n"
"push %1 ;\n"
"pop rax ;\n"
".att_syntax prefix ;\n"
: "=a" (ret) : "c" (N) : "%rsi"
#else
".intel_syntax noprefix ;\n"
"xor esi, esi ;\n"
"neg %1 ;\n"
"inc %1 ;\n"
"push %1 ;\n"
"pop eax ;\n"
".att_syntax prefix ;\n"
: "=a" (ret) : "c" (N) : "%esi"
#endif
);
return (int)ret;
}

View File

@ -0,0 +1,11 @@
// Real C++11 libraries provide <forward_list>
#include <forward_list>
int main(int argc, char* argv[])
{
#if __cplusplus >= 201103L
std::forward_list<int> x;
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,5 @@
int main(int argc, char* argv[])
{
alignas(8) unsigned char x[16];
return 0;
}

View File

@ -0,0 +1,6 @@
#include <cstddef>
int main (int argc, char* argv[])
{
std::size_t n = alignof(int);
return 0;
}

View File

@ -0,0 +1,10 @@
// https://en.cppreference.com/w/cpp/feature_test
int main(int argc, char* argv[])
{
#if __cpp_static_assert >= 200410L
int x[1];
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,7 @@
#include <atomic>
int main(int argc, char* argv[])
{
std::atomic_flag f = ATOMIC_FLAG_INIT;
std::atomic<bool> g (false);
return 0;
}

View File

@ -0,0 +1,5 @@
int main(int argc, char* argv[])
{
auto a = 1 + 2;
return 0;
}

View File

@ -0,0 +1,10 @@
constexpr int fact(int n)
{
return n <= 1 ? 1 : (n * fact(n - 1));
}
int main(int argc, char* argv[])
{
fact(4);
return 0;
}

View File

@ -0,0 +1,10 @@
struct S {
S() = delete;
explicit S(int n) { }
};
int main (int argc, char* rgv[])
{
S s(1);
return 0;
}

View File

@ -0,0 +1,7 @@
#include <cstddef>
int main(int argc, char* argv[])
{
enum Size : std::size_t { Zero=0, One=1, Two=2 };
Size s(Size::Zero);
return 0;
}

View File

@ -0,0 +1,6 @@
#include <vector>
int main(int argc, char* argv[])
{
std::vector<int> v{0,1,2,3,4};
return 0;
}

View File

@ -0,0 +1,10 @@
// https://en.cppreference.com/w/cpp/feature_test
int main(int argc, char* argv[])
{
#if __cpp_lambdas >= 200907L
int x[1];
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,29 @@
#if defined(__GNUC__)
# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
#endif
#if defined(__clang__) && defined(__apple_build_version__)
# undef GNUC_VERSION
# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
#elif defined(__clang__)
# undef GNUC_VERSION
# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
#endif
#if (GNUC_VERSION >= 7030)
# pragma GCC diagnostic ignored "-Wterminate"
#endif
#include <stdexcept>
void f(int n) noexcept(false)
{
if (n > 2)
throw std::runtime_error("Oops");
}
int main(int argc, char* argv[])
{
f(argc);
return 0;
}

View File

@ -0,0 +1,6 @@
#include <cstddef>
int main(int argc, char* argv[])
{
int* p = nullptr;
return 0;
}

View File

@ -0,0 +1,11 @@
// https://en.cppreference.com/w/cpp/feature_test
// Apple bug https://bugs.llvm.org/show_bug.cgi?id=47012.
int main(int argc, char* argv[])
{
#if __cpp_threadsafe_static_init >= 200806L
int x[1];
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,7 @@
#include <mutex>
int main(int argc, char* argv[])
{
std::mutex m;
std::lock_guard<std::mutex> l(m);
return 0;
}

View File

@ -0,0 +1,9 @@
int main(int argc, char* argv[])
{
#if __cpp_variadic_templates >= 200704L
int x[1];
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,9 @@
int main(int argc, char* argv[])
{
#if __cplusplus >= 201402L
int x[1];
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,9 @@
int main(int argc, char* argv[])
{
#if __cplusplus >= 201703L
int x[1];
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,10 @@
// https://en.cppreference.com/w/cpp/feature_test
int main(int argc, char* argv[])
{
#if __cpp_static_assert >= 201411L
int x[1];
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,11 @@
// https://en.cppreference.com/w/cpp/feature_test
#include <exception>
int main(int argc, char* argv[])
{
#if __cpp_lib_uncaught_exceptions >= 201411L
int x = std::uncaught_exceptions();
#else
int x[-1];
#endif
return 0;
}

View File

@ -0,0 +1,12 @@
#include <exception>
struct S {
S() {}
virtual ~S() {
bool b = std::uncaught_exception();
}
};
int main(int argc, char* argv[])
{
S s;
return 0;
}

View File

@ -0,0 +1,8 @@
#include <string>
int main(int argc, char* argv[])
{
#ifndef __GLIBCXX__
int x[-1];
#endif
return 0;
}

View File

@ -1,31 +0,0 @@
// Most Clang cannot handle mixed asm with positional arguments, where the
// body is Intel style with no prefix and the templates are AT&T style.
// Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .
#include <cstddef>
int main(int argc, char* argv[])
{
size_t ret = 1, N = 1;
asm __volatile__
(
#if defined(__amd64__) || defined(__x86_64__)
".intel_syntax noprefix ;\n"
"xor rsi, rsi ;\n"
"neg %1 ;\n"
"inc %1 ;\n"
"push %1 ;\n"
"pop rax ;\n"
".att_syntax prefix ;\n"
: "=a" (ret) : "c" (N) : "%rsi"
#else
".intel_syntax noprefix ;\n"
"xor esi, esi ;\n"
"neg %1 ;\n"
"inc %1 ;\n"
"push %1 ;\n"
"pop eax ;\n"
".att_syntax prefix ;\n"
: "=a" (ret) : "c" (N) : "%esi"
#endif
);
return (int)ret;
}

View File

@ -2,7 +2,7 @@
int main(int argc, char* argv[])
{
#ifndef __NEWLIB__
XXX
int x[-1];
#endif
return 0;
}

View File

@ -1,3 +1,8 @@
#define GNUC_VERSION (__GNUC__*1000 + __GNUC_MAJOR__*10)
#if (GNUC_VERSION >= 4060) || defined(__clang__)
# pragma GCC diagnostic ignored "-Wdeprecated"
#endif
#include <altivec.h>
int main(int argc, char* argv[])
{

View File

@ -1,41 +1,44 @@
#if defined(__GNUC__)
# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
#endif
#if defined(__clang__) && defined(__apple_build_version__)
# undef GNUC_VERSION
# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
#elif defined(__clang__)
# undef GNUC_VERSION
# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
#endif
#if (GNUC_VERSION >= 4060) || (LLVM_VERSION >= 1070) || (APPLE_VERSION >= 2000)
# pragma GCC diagnostic ignored "-Wdeprecated"
#endif
// XL C++ on AIX does not define VSX and does not
// provide an option to set it. We have to set it
// for the code below. This define must stay in
// sync with the define in test_ppc_power7.cxx.
#if defined(_AIX) && defined(_ARCH_PWR7) && defined(__xlC__)
# define __VSX__ 1
#endif
#include <altivec.h>
// This follows ppc_simd.h. XLC compilers for POWER7 use vec_xlw4 and
// vec_xstw4. Some XLC compilers for POWER7 and above use vec_xl and
// vec_xst. The way to tell the difference is, XLC compilers version
// 13.0 and earlier use use vec_xlw4 and vec_xstw4 XLC compilers 13.1
// and later are use vec_xl and vec_xst. The open question is, how to
// handle early Clang compilers for POWER7. We know the latest Clang
// compilers support vec_xl and vec_xst. Also see
// https://www-01.ibm.com/support/docview.wss?uid=swg21683541
#if defined(__xlc__) && (__xlc__ < 0x0d01)
# define __early_xlc__ 1
#endif
#if defined(__xlC__) && (__xlC__ < 0x0d01)
# define __early_xlC__ 1
#endif
int main(int argc, char* argv[])
{
__vector unsigned char x;
unsigned char res[16];
#if defined(_ARCH_PWR7) && defined(__VSX__)
// PWR7
__vector unsigned int a = {1,2,3,4};
__vector unsigned int b = vec_ld(0, (unsigned int*)argv[0]);
__vector unsigned int c = vec_xor(a, b);
#if defined(_ARCH_PWR7) && (defined(__early_xlc__) || defined(__early_xlC__))
x=vec_xlw4(0, (unsigned char*)argv[0]);
x=vec_add(x,x);
vec_xstw4(x, 0, res);
#elif defined(_ARCH_PWR7) && (defined(__xlc__) || defined(__xlC__) || defined(__clang__))
x=vec_xl(0, (unsigned char*)argv[0]);
x=vec_add(x,x);
vec_xst(x, 0, res);
#elif defined(_ARCH_PWR7) && defined(__GNUC__)
x=vec_vsx_ld(0, (unsigned char*)argv[0]);
x=vec_add(x,x);
vec_vsx_st(x, 0, res);
// VSX
__vector unsigned int x = {5,6,7,8};
__vector unsigned int y = vec_xl(0, (unsigned int*)argv[0]);
__vector unsigned int z = vec_xor(x, y);
__vector unsigned long long xx = {1,2};
__vector unsigned long long yy = (__vector unsigned long long)y;
#else
int XXX[-1];
int x[-1];
#endif
return 0;
}

View File

@ -1,7 +1,46 @@
#if defined(__GNUC__)
# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
#endif
#if defined(__clang__) && defined(__apple_build_version__)
# undef GNUC_VERSION
# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
#elif defined(__clang__)
# undef GNUC_VERSION
# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
#endif
#if (GNUC_VERSION >= 4060) || (LLVM_VERSION >= 1070) || (APPLE_VERSION >= 2000)
# pragma GCC diagnostic ignored "-Wdeprecated"
#endif
// XL C++ on AIX does not define CRYPTO and does not
// provide an option to set it. We have to set it
// for the code below. This define must stay in
// sync with the define in test_ppc_power8.cxx
#if defined(_AIX) && defined(_ARCH_PWR8) && defined(__xlC__)
# define __CRYPTO__ 1
#endif
#include <altivec.h>
int main(int argc, char* argv[])
{
__vector unsigned long long z = {1, 2};
z=vec_add(z,z);
#if defined(_ARCH_PWR8)
__vector unsigned long long r = {1, 2};
__vector unsigned int s = vec_xl(0, (unsigned int*)argv[0]); // Power7
__vector unsigned long long w = (__vector unsigned long long)r;
__vector unsigned long long x = (__vector unsigned long long)s;
__vector unsigned long long y = vec_xor(w, x);
__vector unsigned long long z = vec_add(y, vec_add(w, x));
# if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__))
__vector unsigned long long u = __vpmsumd (y, z);
# elif defined(__clang__)
__vector unsigned long long u = __builtin_altivec_crypto_vpmsumd (y, z);
# else
__vector unsigned long long u = __builtin_crypto_vpmsumd (y, z);
# endif
#else
int x[-1];
#endif
return 0;
}

View File

@ -1,30 +1,27 @@
// The problem we have here is, it appears only GCC 7.0 and above
// support Power9 builtins. Clang 7.0 has support for some (all?)
// assembly instructions but we don't see builtin support. We can't
// determine the state of XLC. Searching IBM's website for
// terms like 'darn' 'random number' is returning irrelevant hits.
// Searching with Google from the outside returns 0 hits.
//
// The support disconnect means we may report Power9 as unavailable
// and support DARN at the same time. We get into that state because
// we use inline asm to detect DARN availablity in the compiler.
// Also see cpu.cpp and the two query functions; and ppc_power9.cpp
// and the two probe functions.
#if defined(__GNUC__)
# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
#endif
#if defined(__clang__) && defined(__apple_build_version__)
# undef GNUC_VERSION
# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
#elif defined(__clang__)
# undef GNUC_VERSION
# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
#endif
#if (GNUC_VERSION >= 4060) || (LLVM_VERSION >= 1070) || (APPLE_VERSION >= 2000)
# pragma GCC diagnostic ignored "-Wdeprecated"
#endif
#include <altivec.h>
int main(int argc, char* argv[])
{
#if 0
const unsigned char b = (unsigned char)argc;
const unsigned int r = (0xf << 24) | (0x3 << 16) | (0xf << 8) | (0x3 << 0);
#if defined(__clang__)
bool x = __builtin_altivec_byte_in_range(b, r);
#elif defined(__GNUC__)
bool x = __builtin_byte_in_range(b, r);
#if defined(_ARCH_PWR9)
__vector unsigned int v = vec_xl_be(0, (unsigned int*)argv[0]);
#else
int XXX[-1];
#endif
#endif
#if defined(__GNUC__) || defined(__IBM_GCC_ASM)
unsigned int y = __builtin_darn_32();

View File

@ -1,7 +1,9 @@
#include <immintrin.h>
int main(int argc, char* argv[])
{
__m256i x = _mm256_setzero_si256();
x=_mm256_add_epi64 (x,x);
// _mm256_broadcastsi128_si256 due to Clang
__m128i x = _mm_setzero_si128 ();
__m256i y = _mm256_broadcastsi128_si256 (x);
y = _mm256_add_epi64 (y,y);
return 0;
}

View File

@ -0,0 +1,10 @@
#include <immintrin.h>
#if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
# include <x86intrin.h>
#endif
int main(int argc, char* argv[])
{
unsigned int x=0;
(void)_rdrand32_step (&x);
return x == 0 ? 0 : 0;
}

View File

@ -0,0 +1,10 @@
#include <immintrin.h>
#if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
# include <x86intrin.h>
#endif
int main(int argc, char* argv[])
{
unsigned int x=0;
(void)_rdseed32_step (&x);
return x == 0 ? 0 : 0;
}

View File

@ -0,0 +1,39 @@
// TODO: cut-in xcrypt-ecb
#include <cstdlib>
int main(int argc, char* argv[])
{
unsigned int msr=0;
unsigned int divisor=2;
unsigned int buffer;
__asm__ __volatile__
(
#if defined(__x86_64__) || defined(__amd64__)
"mov %1, %%rdi ;\n"
"movl %2, %%edx ;\n"
#else
"mov %1, %%edi ;\n"
"movl %2, %%edx ;\n"
#endif
// xstore-rng
".byte 0x0f, 0xa7, 0xc0 ;\n"
#if defined(__x86_64__) || defined(__amd64__)
"andq %%rax, 0x1f ;\n"
"movl %%eax, %0 ;\n"
#else
"andl %%eax, 0x1f ;\n"
"movl %%eax, %0 ;\n"
#endif
: "=g" (msr) : "g" (buffer), "g" (divisor)
#if defined(__x86_64__) || defined(__amd64__)
: "rax", "rdx", "rdi", "cc"
#else
: "eax", "edx", "edi", "cc"
#endif
);
return 0;
}

View File

@ -0,0 +1,38 @@
#include <cstdlib>
int main(int argc, char* argv[])
{
unsigned int msr=0;
unsigned int divisor=2;
unsigned int buffer;
__asm__ __volatile__
(
#if defined(__x86_64__) || defined(__amd64__)
"mov %1, %%rdi ;\n"
"movl %2, %%edx ;\n"
#else
"mov %1, %%edi ;\n"
"movl %2, %%edx ;\n"
#endif
// xstore-rng
".byte 0x0f, 0xa7, 0xc0 ;\n"
#if defined(__x86_64__) || defined(__amd64__)
"andq %%rax, 0x1f ;\n"
"movl %%eax, %0 ;\n"
#else
"andl %%eax, 0x1f ;\n"
"movl %%eax, %0 ;\n"
#endif
: "=g" (msr) : "g" (buffer), "g" (divisor)
#if defined(__x86_64__) || defined(__amd64__)
: "rax", "rdx", "rdi", "cc"
#else
: "eax", "edx", "edi", "cc"
#endif
);
return 0;
}

View File

@ -0,0 +1,39 @@
// TODO: cut-in xsha1
#include <cstdlib>
int main(int argc, char* argv[])
{
unsigned int msr=0;
unsigned int divisor=2;
unsigned int buffer;
__asm__ __volatile__
(
#if defined(__x86_64__) || defined(__amd64__)
"mov %1, %%rdi ;\n"
"movl %2, %%edx ;\n"
#else
"mov %1, %%edi ;\n"
"movl %2, %%edx ;\n"
#endif
// xstore-rng
".byte 0x0f, 0xa7, 0xc0 ;\n"
#if defined(__x86_64__) || defined(__amd64__)
"andq %%rax, 0x1f ;\n"
"movl %%eax, %0 ;\n"
#else
"andl %%eax, 0x1f ;\n"
"movl %%eax, %0 ;\n"
#endif
: "=g" (msr) : "g" (buffer), "g" (divisor)
#if defined(__x86_64__) || defined(__amd64__)
: "rax", "rdx", "rdi", "cc"
#else
: "eax", "edx", "edi", "cc"
#endif
);
return 0;
}

View File

@ -1,17 +1,29 @@
#!/usr/bin/env bash
# Use this script to switch back to the previous Crypto++ version before
#############################################################################
#
# This script switches back to the previous Crypto++ version before
# building the docs. Before running the script, copy it to the root
# directory. After running this script, you can 'make docs'
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See https://www.cryptopp.com/wiki/Release_Versioning for more details
#
#############################################################################
sed 's|Library 8.2 API|Library 8.1 API|g' cryptlib.h > cryptlib.h.new
sed 's|Library 8.4 API|Library 8.3 API|g' cryptlib.h > cryptlib.h.new
mv cryptlib.h.new cryptlib.h
sed 's|= 8.2|= 8.1|g' Doxyfile > Doxyfile.new
sed 's|= 8.4|= 8.3|g' Doxyfile > Doxyfile.new
mv Doxyfile.new Doxyfile
sed 's|CRYPTOPP_MINOR 2|CRYPTOPP_MINOR 1|g' config.h > config.h.new
mv config.h.new config.h
sed 's|CRYPTOPP_MINOR 4|CRYPTOPP_MINOR 3|g' config_ver.h > config_ver.h.new
mv config_ver.h.new config_ver.h
sed 's|CRYPTOPP_VERSION 820|CRYPTOPP_VERSION 810|g' config.h > config.h.new
mv config.h.new config.h
sed 's|CRYPTOPP_VERSION 840|CRYPTOPP_VERSION 830|g' config_ver.h > config_ver.h.new
mv config_ver.h.new config_ver.h

View File

@ -0,0 +1,930 @@
#!/usr/bin/env bash
# Written and placed in public domain by Jeffrey Walton
#
# This script attempts to update various config_xxx.h files based on the
# current toolchain. It fills a gap where some features are misdetected based
# on compiler version and associated macros, but the feature is (or is not)
# present. For example, modern Android toolchains should be AES-NI and AVX
# capable, but the project removes the feature support.
#
# Use the same compiler and environment to run configure and the makefile.
#
# To use the script, copy the script to the root of the Crypto++ directory.
# Set the environment, and then run the tool:
#
# export CXX="..."
# export CXXFLAGS="..."
# export LDFLAGS="..."
# ./configure.sh
#
# Android and iOS would use the following if you are using setenv-android.sh
# or setenv-ios.sh to set the environment. Otherwise the script expects
# CXX and CXXFLAGS to be set properly for Android or iOS.
#
# export CXXFLAGS="$IOS_CXXFLAGS --sysroot=$IOS_SYSROOT"
# or
# export CXXFLAGS="${ANDROID_CXXFLAGS} --sysroot=${ANDROID_SYSROOT}"
#
# Do not use this script for a multiarch environment unless the cpu features
# are the same for each arch. For example, -arch i386 -arch x86_64 could
# cause problems if x86 only included SSE4.2, while x64 included AVX.
#
# A wiki page is available for this script at
# https://www.cryptopp.com/wiki/Configure.sh
#
# This script was added at Crypto++ 8.3. Also see GH #850. This script will
# work with earlier versions of the library that use config_xxx.h files.
# The monolithic config.h was split into config_xxx.h in May 2019 at
# Crypto++ 8.3. Also see GH #835, PR #836.
# shellcheck disable=SC2086
# Verify the file exists and is writeable.
if [[ ! -f ./config_asm.h ]]; then
echo "WARNING:"
echo "WARNING: Unable to locate config_asm.h"
echo "WARNING:"
elif [[ ! -w ./config_asm.h ]]; then
echo "WARNING:"
echo "WARNING: Unable to write to config_asm.h"
echo "WARNING:"
fi
TMPDIR="${TMPDIR:-$HOME/tmp}"
TPROG="${TPROG:-TestPrograms/test_cxx.cxx}"
TOUT="${TOUT:-a.out}"
CXX="${CXX:-c++}"
LD="${LD:-ld}"
CXXFLAGS="${CXXFLAGS:--DNDEBUG -g2 -O3}"
GREP="${GREP:-grep}"
if [[ -z "$(command -v ${CXX} 2>/dev/null)" ]]; then
echo "Compiler is not valid. Please install a compiler"
exit 1
fi
if [[ -z "$(command -v ${LD} 2>/dev/null)" ]]; then
echo "Linker is not valid. Please install a linker"
exit 1
fi
# Solaris fixup
if [[ -d /usr/gnu/bin ]]; then
GREP=/usr/gnu/bin/grep
fi
# Initialize these once
IS_X86=0
IS_X64=0
IS_IA32=0
IS_ARM32=0
IS_ARMV8=0
IS_PPC=0
IS_PPC64=0
# Determine compiler
GCC_COMPILER=$(${CXX} --version 2>/dev/null | ${GREP} -i -c -E '(^g\+\+|GNU)')
SUN_COMPILER=$(${CXX} -V 2>/dev/null | ${GREP} -i -c -E 'CC: (Sun|Oracle) Studio')
XLC_COMPILER=$(${CXX} -qversion 2>/dev/null | ${GREP} -i -c "IBM XL C/C++")
CLANG_COMPILER=$(${CXX} --version 2>/dev/null | ${GREP} -i -c -E 'clang|llvm')
if [[ "$SUN_COMPILER" -ne 0 ]]
then
# TODO: fix use of uname for SunCC
IS_X86=$(uname -m 2>&1 | ${GREP} -c -E 'i386|i486|i585|i686')
IS_X64=$(uname -m 2>&1 | ${GREP} -c -E 'i86pc|x86_64|amd64')
elif [[ "$XLC_COMPILER" -ne 0 ]]
then
IS_PPC=$(${CXX} ${CXXFLAGS} -qshowmacros -E ${TPROG} | ${GREP} -i -c -E '__PPC__|__POWERPC__')
IS_PPC64=$(${CXX} ${CXXFLAGS} -qshowmacros -E ${TPROG} | ${GREP} -i -c -E '__PPC64__|__POWERPC64__')
elif [[ "$CLANG_COMPILER" -ne 0 ]]
then
IS_X86=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'i386|i486|i585|i686')
IS_X64=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'i86pc|x86_64|amd64')
IS_ARM32=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'arm|armhf|armv7|eabihf|armv8')
IS_ARMV8=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'aarch32|aarch64|arm64')
IS_PPC=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -i -c -E 'ppc|powerpc')
IS_PPC64=$(${CXX} ${CXXFLAGS} -dM -E ${TPROG} | ${GREP} -c -E 'ppc64|powerpc64')
else
IS_X86=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'i386|i486|i585|i686')
IS_X64=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'x86_64|amd64')
IS_ARM32=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'arm|armhf|armv7|eabihf|armv8')
IS_ARMV8=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'aarch32|aarch64|arm64')
IS_PPC=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'ppc|powerpc')
IS_PPC64=$(${CXX} ${CXXFLAGS} -dumpmachine 2>&1 | ${GREP} -i -c -E 'ppc64|powerpc64')
fi
# One check for intel compatibles
if [[ "${IS_X86}" -ne 0 || "${IS_X64}" -ne 0 ]]; then IS_IA32=1; fi
# A 64-bit platform often matches the 32-bit variant due to appending '64'
if [[ "${IS_X64}" -ne 0 ]]; then IS_X86=0; fi
if [[ "${IS_ARMV8}" -ne 0 ]]; then IS_ARM32=0; fi
if [[ "${IS_PPC64}" -ne 0 ]]; then IS_PPC=0; fi
# Default values for setenv-*.sh scripts
IS_IOS="${IS_IOS:-0}"
IS_ANDROID="${IS_ANDROID:-0}"
TIMESTAMP=$(date "+%A, %B %d %Y, %I:%M %p")
# ===========================================================================
# =================================== Info ==================================
# ===========================================================================
if [[ "${IS_X86}" -ne 0 ]]; then echo "Configuring for x86"; fi
if [[ "${IS_X64}" -ne 0 ]]; then echo "Configuring for x86_64"; fi
if [[ "${IS_ARM32}" -ne 0 ]]; then echo "Configuring for ARM32"; fi
if [[ "${IS_ARMV8}" -ne 0 ]]; then echo "Configuring for Aarch64"; fi
if [[ "${IS_PPC}" -ne 0 ]]; then echo "Configuring for PowerPC"; fi
if [[ "${IS_PPC64}" -ne 0 ]]; then echo "Configuring for PowerPC64"; fi
echo "Compiler: $(command -v ${CXX})"
echo "Linker: $(command -v ${LD})"
# ===========================================================================
# =============================== config_asm.h ==============================
# ===========================================================================
rm -f config_asm.h.new
# ====================================================
# =================== common header ==================
# ====================================================
{
echo '// config_asm.h rewritten by configure.sh script'
echo '//' "${TIMESTAMP}"
echo '// Also see https://www.cryptopp.com/wiki/configure.sh'
echo ''
echo '#ifndef CRYPTOPP_CONFIG_ASM_H'
echo '#define CRYPTOPP_CONFIG_ASM_H'
echo ''
} >> config_asm.h.new
#############################################################################
# Pickup CRYPTOPP_DISABLE_ASM
disable_asm=$($GREP -c '\-DCRYPTOPP_DISABLE_ASM' <<< "${CPPFLAGS} ${CXXFLAGS}")
if [[ "$disable_asm" -ne 0 ]];
then
# Shell redirection
{
echo ''
echo '// Set in CPPFLAGS or CXXFLAGS'
echo '#define CRYPTOPP_DISABLE_ASM 1'
} >> config_asm.h.new
fi
#############################################################################
# Intel x86-based machines
if [[ "$disable_asm" -eq 0 && "$IS_IA32" -ne 0 ]];
then
if [[ "${SUN_COMPILER}" -ne 0 ]]; then
SSE2_FLAG=-xarch=sse2
SSE3_FLAG=-xarch=sse3
SSSE3_FLAG=-xarch=ssse3
SSE41_FLAG=-xarch=sse4_1
SSE42_FLAG=-xarch=sse4_2
CLMUL_FLAG=-xarch=aes
AESNI_FLAG=-xarch=aes
RDRAND_FLAG=-xarch=avx_i
RDSEED_FLAG=-xarch=avx2_i
AVX_FLAG=-xarch=avx
AVX2_FLAG=-xarch=avx2
SHANI_FLAG=-xarch=sha
else
SSE2_FLAG=-msse2
SSE3_FLAG=-msse3
SSSE3_FLAG=-mssse3
SSE41_FLAG=-msse4.1
SSE42_FLAG=-msse4.2
CLMUL_FLAG=-mpclmul
AESNI_FLAG=-maes
RDRAND_FLAG=-mrdrnd
RDSEED_FLAG=-mrdseed
AVX_FLAG=-mavx
AVX2_FLAG=-mavx2
SHANI_FLAG=-msha
fi
# Shell redirection
{
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE2_FLAG} TestPrograms/test_x86_sse2.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -ne 0 ]]; then
echo '#define CRYPTOPP_DISABLE_ASM 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE2_FLAG} TestPrograms/test_asm_sse2.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_X86_ASM_AVAILABLE 1'
if [[ "${IS_X64}" -ne 0 ]]; then
echo '#define CRYPTOPP_X64_ASM_AVAILABLE 1'
echo '#define CRYPTOPP_SSE2_ASM_AVAILABLE 1'
fi
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE2_FLAG} TestPrograms/test_x86_sse2.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
have_sse2=1
echo '#define CRYPTOPP_SSE2_INTRIN_AVAILABLE 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE3_FLAG} TestPrograms/test_x86_sse3.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
have_sse3=1
echo '#define CRYPTOPP_SSE3_AVAILABLE 1'
else
have_sse3=0
echo '#define CRYPTOPP_DISABLE_SSE3 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSSE3_FLAG} TestPrograms/test_x86_ssse3.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse3" -ne 0 ]]; then
have_ssse3=1
echo '#define CRYPTOPP_SSSE3_ASM_AVAILABLE 1'
echo '#define CRYPTOPP_SSSE3_AVAILABLE 1'
else
have_ssse3=0
echo '#define CRYPTOPP_DISABLE_SSSE3 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE41_FLAG} TestPrograms/test_x86_sse41.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_ssse3" -ne 0 ]]; then
have_sse41=1
echo '#define CRYPTOPP_SSE41_AVAILABLE 1'
else
have_sse41=0
echo '#define CRYPTOPP_DISABLE_SSE4 1'
echo '#define CRYPTOPP_DISABLE_SSE41 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SSE42_FLAG} TestPrograms/test_x86_sse42.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse41" -ne 0 ]]; then
have_sse42=1
echo '#define CRYPTOPP_SSE42_AVAILABLE 1'
else
have_sse42=0
echo '#define CRYPTOPP_DISABLE_SSE4 1'
echo '#define CRYPTOPP_DISABLE_SSE42 1'
fi
########################################################
# AES, CLMUL, RDRAND, RDSEED, SHA and AVX tied to SSE4.2
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${CLMUL_FLAG} TestPrograms/test_x86_clmul.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_CLMUL_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_CLMUL 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${AESNI_FLAG} TestPrograms/test_x86_aes.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_AESNI_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_AESNI 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${RDRAND_FLAG} TestPrograms/test_x86_rdrand.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_RDRAND_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_RDRAND 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${RDSEED_FLAG} TestPrograms/test_x86_rdseed.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_RDSEED_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_RDSEED 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${SHANI_FLAG} TestPrograms/test_x86_sha.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
echo '#define CRYPTOPP_SHANI_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_SHANI 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${AVX_FLAG} TestPrograms/test_x86_avx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_sse42" -ne 0 ]]; then
have_avx=1
echo '#define CRYPTOPP_AVX_AVAILABLE 1'
else
have_avx=0
echo '#define CRYPTOPP_DISABLE_AVX 1'
fi
#####################
# AVX2 depends on AVX
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${AVX2_FLAG} TestPrograms/test_x86_avx2.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_avx" -ne 0 ]]; then
have_avx2=1
echo '#define CRYPTOPP_AVX2_AVAILABLE 1'
else
have_avx2=0
echo '#define CRYPTOPP_DISABLE_AVX2 1'
fi
# No flags, requires inline ASM
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_x86_via_rng.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_PADLOCK_RNG_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_PADLOCK_RNG 1'
fi
# No flags, requires inline ASM
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_x86_via_aes.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_PADLOCK_AES_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_PADLOCK_AES 1'
fi
# No flags, requires inline ASM
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_x86_via_sha.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_PADLOCK_SHA_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_PADLOCK_SHA 1'
fi
# Clang workaround
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_asm_mixed.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -ne 0 ]]; then
echo '#define CRYPTOPP_DISABLE_MIXED_ASM 1'
fi
if [[ "${SUN_COMPILER}" -ne 0 ]]; then
echo ''
echo '// Fixup for SunCC 12.1-12.4. Bad code generation in AES_Encrypt and friends.'
echo '#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5130)'
echo '# undef CRYPTOPP_AESNI_AVAILABLE'
echo '#endif'
echo ''
echo '// Fixup for SunCC 12.1-12.6. Compiler crash on GCM_Reduce_CLMUL.'
echo '// http://github.com/weidai11/cryptopp/issues/226'
echo '#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5150)'
echo '# undef CRYPTOPP_CLMUL_AVAILABLE'
echo '#endif'
fi
} >> config_asm.h.new
fi
#############################################################################
# ARM 32-bit machines
if [[ "$disable_asm" -eq 0 && "$IS_ARM32" -ne 0 ]];
then
# IS_IOS is set when ./setenv-ios is run
if [[ "$IS_IOS" -ne 0 ]]; then
ARMV7_FLAG="-arch arm"
NEON_FLAG="-arch arm"
elif [[ "$CLANG_COMPILER" -ne 0 ]]; then
ARMV7_FLAG="-march=armv7"
NEON_FLAG="-march=armv7 -mfpu=neon"
else
ARMV7_FLAG="-march=armv7"
NEON_FLAG="-mfpu=neon"
fi
# Shell redirection
{
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${NEON_FLAG} TestPrograms/test_arm_neon_header.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_NEON_HEADER 1'
HDRFLAGS="-DCRYPTOPP_ARM_NEON_HEADER=1"
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV7_FLAG} TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_ARMV7_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_ARMV7 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${NEON_FLAG} TestPrograms/test_arm_neon.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_NEON_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_NEON 1'
fi
# Cryptogams is special. Attempt to compile the actual source files
# TestPrograms/test_cxx.cxx is needed for main().
CXX_RESULT=$(${CXX} ${CXXFLAGS} aes_armv4.S TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOGAMS_ARM_AES 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} sha1_armv4.S TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOGAMS_ARM_SHA1 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} sha256_armv4.S TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOGAMS_ARM_SHA256 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} sha512_armv4.S TestPrograms/test_cxx.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOGAMS_ARM_SHA512 1'
fi
} >> config_asm.h.new
fi
#############################################################################
# ARM 64-bit machines
if [[ "$disable_asm" -eq 0 && "$IS_ARMV8" -ne 0 ]];
then
# IS_IOS is set when ./setenv-ios is run
if [[ "$IS_IOS" -ne 0 ]]; then
ARMV8_FLAG="-arch arm64"
ARMV81_CRC_FLAG="-arch arm64"
ARMV81_CRYPTO_FLAG="-arch arm64"
ARMV84_CRYPTO_FLAG="-arch arm64"
else
ARMV8_FLAG="-march=armv8-a"
ARMV81_CRC_FLAG="-march=armv8-a+crc"
ARMV81_CRYPTO_FLAG="-march=armv8-a+crypto"
ARMV84_CRYPTO_FLAG="-march=armv8.4-a+crypto"
fi
# Shell redirection
{
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_arm_neon_header.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_NEON_HEADER 1'
HDRFLAGS="-DCRYPTOPP_ARM_NEON_HEADER=1"
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} TestPrograms/test_arm_acle_header.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_ACLE_HEADER 1'
HDRFLAGS="${HDRFLAGS} -DCRYPTOPP_ARM_ACLE_HEADER=1"
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} TestPrograms/test_arm_neon.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_NEON_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_NEON 1'
fi
# This should be an unneeded test. ASIMD on Aarch64 is NEON on A32 and T32
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} TestPrograms/test_arm_asimd.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_ASIMD_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_ASIMD 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRC_FLAG} TestPrograms/test_arm_crc.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_CRC32_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_CRC32 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRYPTO_FLAG} TestPrograms/test_arm_aes.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_AES_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_AES 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRYPTO_FLAG} TestPrograms/test_arm_pmull.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_PMULL_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_PMULL 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRYPTO_FLAG} TestPrograms/test_arm_sha1.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SHA_AVAILABLE 1'
echo '#define CRYPTOPP_ARM_SHA1_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SHA 1'
echo '#define CRYPTOPP_DISABLE_ARM_SHA1 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV81_CRYPTO_FLAG} TestPrograms/test_arm_sha256.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SHA2_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SHA2 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV84_CRYPTO_FLAG} TestPrograms/test_arm_sha3.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SHA3_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SHA3 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV84_CRYPTO_FLAG} TestPrograms/test_arm_sha512.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SHA512_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SHA512 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV84_CRYPTO_FLAG} TestPrograms/test_arm_sm3.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SM3_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SM3 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${HDRFLAGS} ${ARMV84_CRYPTO_FLAG} TestPrograms/test_arm_sm4.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_ARM_SM4_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_ARM_SM4 1'
fi
} >> config_asm.h.new
fi
#############################################################################
# PowerPC machines
if [[ "$disable_asm" -eq 0 && ("$IS_PPC" -ne 0 || "$IS_PPC64" -ne 0) ]];
then
# IBM XL C/C++ has the -qaltivec flag really screwed up. We can't seem
# to get it enabled without an -qarch= option. And -qarch= produces an
# error on later versions of the compiler. The only thing that seems
# to work consistently is -qarch=auto.
if [[ "${XLC_COMPILER}" -ne 0 ]]; then
POWER9_FLAG="-qarch=pwr9 -qaltivec"
POWER8_FLAG="-qarch=pwr8 -qaltivec"
POWER7_VSX_FLAG="-qarch=pwr7 -qvsx -qaltivec"
POWER7_PWR_FLAG="-qarch=pwr7 -qaltivec"
ALTIVEC_FLAG="-qarch=auto -qaltivec"
else
POWER9_FLAG="-mcpu=power9"
POWER8_FLAG="-mcpu=power8"
POWER7_VSX_FLAG="-mcpu=power7 -mvsx"
POWER7_PWR_FLAG="-mcpu=power7"
ALTIVEC_FLAG="-maltivec"
fi
# Shell redirection
{
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${ALTIVEC_FLAG} TestPrograms/test_ppc_altivec.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
have_altivec=1
echo '#define CRYPTOPP_ALTIVEC_AVAILABLE 1'
else
have_altivec=0
echo '#define CRYPTOPP_DISABLE_ALTIVEC 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER7_PWR_FLAG} TestPrograms/test_ppc_power7.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_altivec" -ne 0 ]]; then
have_power7=1
echo '#define CRYPTOPP_POWER7_AVAILABLE 1'
else
have_power7=0
echo '#define CRYPTOPP_DISABLE_POWER7 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER8_FLAG} TestPrograms/test_ppc_power8.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power7" -ne 0 ]]; then
have_power8=1
echo '#define CRYPTOPP_POWER8_AVAILABLE 1'
else
have_power8=0
echo '#define CRYPTOPP_DISABLE_POWER8 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER9_FLAG} TestPrograms/test_ppc_power9.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power8" -ne 0 ]]; then
have_power9=1
echo '#define CRYPTOPP_POWER9_AVAILABLE 1'
else
have_power9=0
echo '#define CRYPTOPP_DISABLE_POWER9 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER8_FLAG} TestPrograms/test_ppc_aes.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power8" -ne 0 ]]; then
echo '#define CRYPTOPP_POWER8_AES_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_POWER8_AES 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER8_FLAG} TestPrograms/test_ppc_vmull.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power8" -ne 0 ]]; then
echo '#define CRYPTOPP_POWER8_VMULL_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_POWER8_VMULL 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} ${POWER8_FLAG} TestPrograms/test_ppc_sha.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 && "$have_power8" -ne 0 ]]; then
echo '#define CRYPTOPP_POWER8_SHA_AVAILABLE 1'
else
echo '#define CRYPTOPP_DISABLE_POWER8_SHA 1'
fi
} >> config_asm.h.new
fi
# ====================================================
# =================== common footer ==================
# ====================================================
{
echo ''
echo '#endif // CRYPTOPP_CONFIG_ASM_H'
echo ''
} >> config_asm.h.new
if [[ -e config_asm.h ]]; then
cp config_asm.h config_asm.h.old
mv config_asm.h.new config_asm.h
fi
echo 'Done writing config_asm.h'
# ===========================================================================
# =============================== config_cxx.h ==============================
# ===========================================================================
rm -f config_cxx.h.new
# ====================================================
# =================== common header ==================
# ====================================================
{
echo '// config_cxx.h rewritten by configure.sh script'
echo '//' "${TIMESTAMP}"
echo '// Also see https://www.cryptopp.com/wiki/configure.sh'
echo ''
echo '#ifndef CRYPTOPP_CONFIG_CXX_H'
echo '#define CRYPTOPP_CONFIG_CXX_H'
} >> config_cxx.h.new
# Shell redirection
{
echo ''
echo '// ***************** C++98 and C++03 ********************'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx98_exception.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '// Ancient Crypto++ define, dating back to C++98.'
echo '#define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 1'
echo '#define CRYPTOPP_CXX98_UNCAUGHT_EXCEPTION 1'
else
echo '// Ancient Crypto++ define, dating back to C++98.'
echo '// #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE 1'
echo '// #define CRYPTOPP_CXX98_UNCAUGHT_EXCEPTION 1'
fi
echo ''
echo '// ***************** C++11 and above ********************'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11 1'
else
echo '// test_cxx11.cxx returned non-zero result'
echo '// #define CRYPTOPP_CXX11 1'
fi
echo ''
echo '#if defined(CRYPTOPP_CXX11)'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_atomic.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_ATOMIC 1'
else
echo '// #define CRYPTOPP_CXX11_ATOMIC 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_auto.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_AUTO 1'
else
echo '// #define CRYPTOPP_CXX11_AUTO 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_sync.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_SYNCHRONIZATION 1'
else
echo '// #define CRYPTOPP_CXX11_SYNCHRONIZATION 1'
fi
# CRYPTOPP_CXX11_DYNAMIC_INIT is old name
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_staticinit.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_STATIC_INIT 1'
echo '#define CRYPTOPP_CXX11_DYNAMIC_INIT 1'
else
echo '// #define CRYPTOPP_CXX11_STATIC_INIT 1'
echo '// #define CRYPTOPP_CXX11_DYNAMIC_INIT 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_deletefn.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_DELETED_FUNCTIONS 1'
else
echo '// #define CRYPTOPP_CXX11_DELETED_FUNCTIONS 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_alignas.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_ALIGNAS 1'
else
echo '// #define CRYPTOPP_CXX11_ALIGNAS 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_alignof.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_ALIGNOF 1'
else
echo '// #define CRYPTOPP_CXX11_ALIGNOF 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_initializer.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_INITIALIZER_LIST 1'
else
echo '// #define CRYPTOPP_CXX11_INITIALIZER_LIST 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_lambda.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_LAMBDA 1'
else
echo '// #define CRYPTOPP_CXX11_LAMBDA 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_noexcept.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_NOEXCEPT 1'
else
echo '// #define CRYPTOPP_CXX11_NOEXCEPT 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_vartemplates.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1'
else
echo '// #define CRYPTOPP_CXX11_VARIADIC_TEMPLATES 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_constexpr.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_CONSTEXPR 1'
else
echo '// #define CRYPTOPP_CXX11_CONSTEXPR 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_enumtype.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_STRONG_ENUM 1'
else
echo '// #define CRYPTOPP_CXX11_STRONG_ENUM 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_nullptr.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_NULLPTR 1'
else
echo '// #define CRYPTOPP_CXX11_NULLPTR 1'
fi
# 2-argument static assert
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_assert.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_ASSERT 1'
else
echo '// #define CRYPTOPP_CXX11_ASSERT 1'
fi
echo ''
echo '#endif // CRYPTOPP_CXX11'
echo ''
echo '// ***************** C++14 and above ********************'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx14.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX14 1'
else
echo '// test_cxx14.cxx returned non-zero result'
echo '// #define CRYPTOPP_CXX14 1'
fi
echo ''
echo '#if defined(CRYPTOPP_CXX14)'
echo ''
echo '// No dead bodies here. Move on...'
echo ''
echo '#endif // CRYPTOPP_CXX14'
echo ''
echo '// ***************** C++17 and above ********************'
echo ''
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx17.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX17 1'
else
echo '// test_cxx17.cxx returned non-zero result'
echo '// #define CRYPTOPP_CXX17 1'
fi
echo ''
echo '#if defined(CRYPTOPP_CXX17)'
echo ''
# 1-argument static assert
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx17_assert.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX17_ASSERT 1'
else
echo '// #define CRYPTOPP_CXX17_ASSERT 1'
fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx17_exceptions.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1'
else
echo '// #define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1'
fi
echo ''
echo '#endif // CRYPTOPP_CXX17'
echo ''
echo '// ***************** C++ fixups ********************'
echo ''
echo '#if defined(CRYPTOPP_CXX11_NOEXCEPT)'
echo '# define CRYPTOPP_THROW noexcept(false)'
echo '# define CRYPTOPP_NO_THROW noexcept(true)'
echo '#else'
echo '# define CRYPTOPP_THROW'
echo '# define CRYPTOPP_NO_THROW'
echo '#endif // CRYPTOPP_CXX11_NOEXCEPT'
echo ''
echo '// C++11 nullptr_t type safety and analysis'
echo '#if defined(CRYPTOPP_CXX11_NULLPTR) && !defined(NULLPTR)'
echo '# define NULLPTR nullptr'
echo '#elif !defined(NULLPTR)'
echo '# define NULLPTR NULL'
echo '#endif // CRYPTOPP_CXX11_NULLPTR'
} >> config_cxx.h.new
# ====================================================
# =================== common footer ==================
# ====================================================
{
echo ''
echo '#endif // CRYPTOPP_CONFIG_CXX_H'
echo ''
} >> config_cxx.h.new
if [[ -e config_cxx.h ]]; then
cp config_cxx.h config_cxx.h.old
mv config_cxx.h.new config_cxx.h
fi
echo 'Done writing config_cxx.h'
rm -f "${TOUT}"
exit 0

View File

@ -0,0 +1,126 @@
#!/usr/bin/env bash
#############################################################################
#
# This script tests the cryptopp-android-mk gear using ndk-build. The
# source files include Application.mk and Android.mk.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/Android.mk_(Command_Line) for more details
#
#############################################################################
# Error checking
if [ ! -d "${ANDROID_NDK_ROOT}" ]; then
echo "ERROR: ANDROID_NDK_ROOT is not a valid path for ${USER}. Please set it."
echo "ANDROID_NDK_ROOT is '${ANDROID_NDK_ROOT}'"
exit 1
fi
# Error checking
if [ ! -d "${ANDROID_SDK_ROOT}" ]; then
echo "ERROR: ANDROID_SDK_ROOT is not a valid path for ${USER}. Please set it."
echo "ANDROID_SDK_ROOT is '${ANDROID_SDK_ROOT}'"
exit 1
fi
# Error checking
if [ -z "$(command -v ndk-build 2>/dev/null)" ]; then
echo "ERROR: ndk-build is not on-path for ${USER}. Please set it."
echo "PATH is '${PATH}'"
exit 1
fi
# Temp directory
if [[ -z "${TMPDIR}" ]]; then
TMPDIR="$HOME/tmp"
mkdir -p "${TMPDIR}"
if [ -n "${SUDO_USER}" ]; then
chown -R "${SUDO_USER}" "${TMPDIR}"
fi
fi
# Sane default
if [[ -z "${MAKE_JOBS}" ]]; then
MAKE_JOBS=4
fi
# Fixup for sed and "illegal byte sequence"
IS_DARWIN=$(uname -s 2>/dev/null | grep -i -c darwin)
if [[ "${IS_DARWIN}" -ne 0 ]] && [[ -z "${LC_ALL}" ]]; then
export LC_ALL=C
fi
# Cleanup old artifacts
rm -rf "${TMPDIR}/build.failed" 2>/dev/null
rm -rf "${TMPDIR}/build.log" 2>/dev/null
#############################################################################
files=(Android.mk Application.mk make_neon.sh test_shared.hxx test_shared.cxx)
for file in "${files[@]}"; do
echo "Downloading $file"
if ! curl -L -s -o "${file}" "https://raw.githubusercontent.com/noloader/cryptopp-android-mk/master/${file}"; then
echo "${file} download failed"
exit 1
fi
# Permissions
chmod u=rw,go=r "${file}"
# Throttle
sleep 1
done
# Fix permissions and quarantine
chmod u=rwx,go=rx make_neon.sh
if [[ "${IS_DARWIN}" -ne 0 ]] && [[ $(command -v xattr 2>/dev/null) ]]; then
echo "Removing make_neon.sh quarantine"
xattr -d "com.apple.quarantine" make_neon.sh &>/dev/null
fi
# Fix missing *neon files
echo "Adding NEON files for armeabi-v7a"
bash make_neon.sh
#############################################################################
# Paydirt
NDK_PROJECT_PATH="$PWD"
NDK_APPLICATION_MK="$PWD/Application.mk"
PLATFORMS=(armeabi-v7a arm64-v8a x86 x86_64)
# Clean all past artifacts
ndk-build APP_ABI=all NDK_PROJECT_PATH="${NDK_PROJECT_PATH}" NDK_APPLICATION_MK="${NDK_APPLICATION_MK}" distclean &>/dev/null
for platform in "${PLATFORMS[@]}"
do
echo ""
echo "===================================================================="
echo "Building for ${platform}..."
if ndk-build -j "${MAKE_JOBS}" APP_ABI="${platform}" NDK_PROJECT_PATH="${NDK_PROJECT_PATH}" NDK_APPLICATION_MK="${NDK_APPLICATION_MK}" V=1;
then
echo "${platform} ==> SUCCESS" >> "${TMPDIR}/build.log"
else
echo "${platform} ==> FAILURE" >> "${TMPDIR}/build.log"
touch "${TMPDIR}/build.failed"
fi
done
echo
echo "===================================================================="
cat "${TMPDIR}/build.log"
# let the script fail if any of the builds failed
if [ -f "${TMPDIR}/build.failed" ]; then
exit 1
fi
exit 0

View File

@ -1,75 +1,115 @@
#!/usr/bin/env bash
# ====================================================================
# Tests Android cross-compiles
#############################################################################
#
# This script tests Android cross-compiles using setenv-android.sh script.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
# ====================================================================
set +e
#
#############################################################################
if [ -z $(command -v ./setenv-android-gcc.sh) ]; then
echo "Failed to locate setenv-android-gcc.sh"
ls -Al *.sh
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
# Error checking
if [ -z "$(command -v ./setenv-android.sh 2>/dev/null)" ]; then
echo "Failed to locate setenv-android.sh."
exit 1
fi
if [ -z "${PLATFORM-}" ]; then
PLATFORMS=(armeabi armeabi-v7a armv7a-neon aarch64 mipsel mipsel64 x86 x86_64)
else
PLATFORMS=(${PLATFORM})
# Error checking
if [ ! -d "${ANDROID_NDK_ROOT}" ]; then
echo "ERROR: ANDROID_NDK_ROOT is not a valid path for ${USER}. Please set it."
echo "ANDROID_NDK_ROOT is '${ANDROID_NDK_ROOT}'"
exit 1
fi
RUNTIMES=(gnu-static gnu-shared stlport-static stlport-shared) #llvm-static llvm-shared
for platform in ${PLATFORMS[@]}
do
for runtime in ${RUNTIMES[@]}
# Error checking
if [ ! -d "${ANDROID_SDK_ROOT}" ]; then
echo "ERROR: ANDROID_SDK_ROOT is not a valid path for ${USER}. Please set it."
echo "ANDROID_SDK_ROOT is '${ANDROID_SDK_ROOT}'"
exit 1
fi
# Error checking
if [ -z "$(command -v ndk-build 2>/dev/null)" ]; then
echo "ERROR: ndk-build is not on-path for ${USER}. Please set it."
echo "PATH is '${PATH}'"
exit 1
fi
# Temp directory
if [[ -z "${TMPDIR}" ]]; then
TMPDIR="$HOME/tmp"
mkdir -p "${TMPDIR}"
if [ -n "${SUDO_USER}" ]; then
chown -R "${SUDO_USER}" "${TMPDIR}"
fi
fi
# Sane default
if [[ -z "${MAKE_JOBS}" ]]; then
MAKE_JOBS=4
fi
# Cleanup old artifacts
rm -rf "${TMPDIR}/build.failed" 2>/dev/null
rm -rf "${TMPDIR}/build.log" 2>/dev/null
#############################################################################
PLATFORMS=(armv7a aarch64 x86 x86_64)
for platform in "${PLATFORMS[@]}"
do
# setenv-android.sh reads these two variables for configuration info.
# Android 5.0 is 21. Android 6.0 is 23.
export ANDROID_API="21"
export ANDROID_CPU="${platform}"
make -f GNUmakefile-cross distclean > /dev/null 2>&1
echo
echo "===================================================================="
echo "Testing for Android support of $platform using $runtime"
echo "Testing for Android support of ${platform}"
# Test if we can set the environment for the platform
./setenv-android-gcc.sh "$platform" "$runtime"
if [ "$?" -ne "0" ];
if ! ./setenv-android.sh > /dev/null 2>&1;
then
echo
echo "There were problems testing $platform with $runtime"
echo "$platform:$runtime ==> FAILURE" >> /tmp/build.log
echo "There were problems testing ${platform}"
echo "${platform} ==> SKIPPED" >> "${TMPDIR}/build.log"
touch /tmp/build.failed
continue
fi
echo
echo "Building for $platform using $runtime..."
echo
echo "===================================================================="
echo "Building for ${platform}..."
# run in subshell to not keep any env vars
# run in subshell to not keep any envars
(
source ./setenv-android-gcc.sh "$platform" "$runtime" > /dev/null 2>&1
make -f GNUmakefile-cross static dynamic cryptest.exe
if [ "$?" -eq "0" ]; then
echo "$platform:$runtime ==> SUCCESS" >> /tmp/build.log
source ./setenv-android.sh
if make -k -j "${MAKE_JOBS}" -f GNUmakefile-cross static dynamic cryptest.exe;
then
echo "${platform} ==> SUCCESS" >> "${TMPDIR}/build.log"
else
echo "$platform:$runtime ==> FAILURE" >> /tmp/build.log
touch /tmp/build.failed
echo "${platform} ==> FAILURE" >> "${TMPDIR}/build.log"
touch "${TMPDIR}/build.failed"
fi
)
done
done
cat /tmp/build.log
echo
echo "====================================================="
cat "${TMPDIR}/build.log"
# let the script fail if any of the builds failed
if [ -f /tmp/build.failed ]; then
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
if [ -f "${TMPDIR}/build.failed" ]; then
exit 1
fi
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0
exit 0

View File

@ -1,77 +1,74 @@
#!/usr/bin/env bash
PWD_DIR=$(pwd)
function cleanup {
cd "$PWD_DIR"
}
trap cleanup EXIT
#############################################################################
#
# This script tests the Autotools gear.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See https://www.cryptopp.com/wiki/Autotools for more details
#
#############################################################################
# Default tools
GREP=grep
SED=sed
AWK=awk
MAKE=make
# Fixup ancient Bash
# https://unix.stackexchange.com/q/468579/56041
if [[ -z "$BASH_SOURCE" ]]; then
BASH_SOURCE="$0"
fi
#############################################################################
# Fixup, Solaris and friends
if [[ (-d /usr/xpg4/bin) ]]; then
if [[ -d /usr/xpg4/bin ]]; then
SED=/usr/xpg4/bin/sed
AWK=/usr/xpg4/bin/awk
GREP=/usr/xpg4/bin/grep
elif [[ (-d /usr/bin/posix) ]]; then
elif [[ -d /usr/bin/posix ]]; then
SED=/usr/bin/posix/sed
AWK=/usr/bin/posix/awk
GREP=/usr/bin/posix/grep
fi
# Fixup for sed and "illegal byte sequence"
IS_DARWIN=$(uname -s | "$GREP" -i -c darwin)
IS_DARWIN=$(uname -s 2>/dev/null | "$GREP" -i -c darwin)
if [[ "$IS_DARWIN" -ne 0 ]]; then
export LC_ALL=C
fi
# Fixup for Solaris and BSDs
# Fixup for Solaris and BSDs
if [[ ! -z $(command -v gmake) ]]; then
if [[ -n "$(command -v gmake 2>/dev/null)" ]]; then
MAKE=gmake
else
MAKE=make
fi
# Fixup for missing libtool
if [[ ! -z $(command -v libtoolize) ]]; then
LIBTOOLIZE=$(command -v libtoolize)
elif [[ ! -z $(command -v glibtoolize) ]]; then
LIBTOOLIZE=$(command -v glibtoolize)
elif [[ ! -z $(command -v libtool) ]]; then
LIBTOOLIZE=$(command -v libtool)
elif [[ ! -z $(command -v glibtool) ]]; then
LIBTOOLIZE=$(command -v glibtool)
if [[ ! -z $(command -v glibtoolize 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v glibtoolize)
elif [[ ! -z $(command -v libtoolize 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v libtoolize)
elif [[ ! -z $(command -v glibtool 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v glibtool)
elif [[ ! -z $(command -v libtool 2>/dev/null) ]]; then
export LIBTOOLIZE=$(command -v libtool)
fi
# Fecth the three required files
if ! wget --no-check-certificate 'https://raw.githubusercontent.com/noloader/cryptopp-autotools/master/Makefile.am' -O Makefile.am; then
echo "Makefile.am download failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
# In case libtool is located in /opt, like under MacPorts or Compile Farm
if [[ -z $(command -v glibtoolize 2>/dev/null) ]]; then
export LIBTOOLIZE=$(find /opt -name libtool 2>/dev/null | head -n 1)
fi
if ! wget --no-check-certificate 'https://raw.githubusercontent.com/noloader/cryptopp-autotools/master/configure.ac' -O configure.ac; then
echo "configure.ac download failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
#############################################################################
if [[ -z $(command -v aclocal 2>/dev/null) ]]; then
echo "Cannot find aclocal. Things may fail."
fi
if ! wget --no-check-certificate 'https://raw.githubusercontent.com/noloader/cryptopp-autotools/master/libcryptopp.pc.in' -O libcryptopp.pc.in; then
echo "libcryptopp.pc.in download failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
mkdir -p m4/
if [[ -z $(command -v autoupdate) ]]; then
if [[ -z $(command -v autoupdate 2>/dev/null) ]]; then
echo "Cannot find autoupdate. Things may fail."
fi
@ -79,77 +76,137 @@ if [[ -z "$LIBTOOLIZE" ]]; then
echo "Cannot find libtoolize. Things may fail."
fi
if [[ -z $(command -v autoreconf) ]]; then
if [[ -z $(command -v automake 2>/dev/null) ]]; then
echo "Cannot find automake. Things may fail."
fi
if [[ -z $(command -v autoreconf 2>/dev/null) ]]; then
echo "Cannot find autoreconf. Things may fail."
fi
echo "Running autoupdate"
if ! autoupdate 2>/dev/null; then
echo "autoupdate failed."
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
if [[ -z $(command -v curl 2>/dev/null) ]]; then
echo "Cannot find cURL. Things may fail."
fi
echo "Running libtoolize"
if ! "$LIBTOOLIZE" 2>/dev/null; then
echo "libtoolize failed."
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
#############################################################################
files=(configure.ac Makefile.am libcryptopp.pc.in)
for file in "${files[@]}"; do
echo "Downloading $file"
if ! curl -L -s -o "$file" "https://raw.githubusercontent.com/noloader/cryptopp-autotools/master/$file"; then
echo "$file download failed"
exit 1
fi
# Throttle
sleep 1
done
mkdir -p m4/
#############################################################################
echo "Running aclocal"
if ! aclocal &>/dev/null; then
echo "aclocal failed."
exit 1
fi
echo "Running autoupdate"
if ! autoupdate &>/dev/null; then
echo "autoupdate failed."
exit 1
fi
# Run autoreconf twice on failure. Also see
# https://github.com/tracebox/tracebox/issues/57
echo "Running autoreconf"
if ! autoreconf 2>/dev/null; then
if ! autoreconf --force --install &>/dev/null; then
echo "autoreconf failed, running again."
if ! autoreconf -fi; then
if ! autoreconf --force --install; then
echo "autoreconf failed, again."
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
fi
# Sparc need +w
if [[ -e config.sub ]]; then
chmod +w config.sub
fi
if [[ -e config.guess ]]; then
chmod +w config.guess
fi
#############################################################################
# Update config.sub config.guess. GNU recommends using the latest for all projects.
echo "Updating config.sub"
wget --no-check-certificate 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub' -O config.sub
curl -L -s -o config.sub.new 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub'
if [[ -e config.sub ]]; then
chmod +x config.sub
# Solaris removes +w, can't overwrite
chmod +w build-aux/config.sub
mv config.sub.new build-aux/config.sub
chmod +x build-aux/config.sub
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr 2>/dev/null) ]]; then
echo "Removing config.sub quarantine"
xattr -d "com.apple.quarantine" build-aux/config.sub &>/dev/null
fi
echo "Updating config.guess"
wget --no-check-certificate 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess' -O config.guess
curl -L -s -o config.guess.new 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess'
if [[ -e config.guess ]]; then
chmod +x config.guess
# Solaris removes +w, can't overwrite
chmod +w build-aux/config.guess
mv config.guess.new build-aux/config.guess
chmod +x build-aux/config.guess
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr 2>/dev/null) ]]; then
echo "Removing config.guess quarantine"
xattr -d "com.apple.quarantine" build-aux/config.guess &>/dev/null
fi
#############################################################################
echo "Running configure"
echo ""
if ! ./configure; then
echo "configure failed."
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
"$MAKE" clean 2>/dev/null
#############################################################################
echo ""
echo "Building test artifacts"
echo ""
"$MAKE" clean &>/dev/null
if ! "$MAKE" -j2 -f Makefile; then
echo "make failed."
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
#############################################################################
echo ""
echo "Testing library"
echo ""
if ! ./cryptest v; then
echo "cryptest v failed."
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
if ! ./cryptest tv all; then
echo "cryptest tv all failed."
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
#############################################################################
echo ""
echo "Building tarball"
echo ""
if ! make dist; then
echo "make dist failed."
exit 1
fi
# Return success
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0
exit 0

View File

@ -1,10 +1,18 @@
#!/usr/bin/env bash
PWD_DIR=$(pwd)
function cleanup {
cd "$PWD_DIR"
}
trap cleanup EXIT
#############################################################################
#
# This script tests the CMake gear.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See https://www.cryptopp.com/wiki/CMake for more details
#
#############################################################################
# Fixup ancient Bash
# https://unix.stackexchange.com/q/468579/56041
@ -24,50 +32,69 @@ if [[ -z "$CMAKE" ]]; then
CMAKE=cmake
fi
# Feth the three required files
if ! wget --no-check-certificate https://raw.githubusercontent.com/noloader/cryptopp-cmake/master/CMakeLists.txt -O CMakeLists.txt; then
echo "CMakeLists.txt download failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
#############################################################################
if [[ -z $(command -v "$CMAKE") ]]; then
echo "Cannot find $CMAKE. Things may fail."
fi
if ! wget --no-check-certificate https://github.com/noloader/cryptopp-cmake/blob/master/cryptopp-config.cmake -O cryptopp-config.cmake; then
echo "cryptopp-config.cmake download failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
if [[ -z $(command -v curl) ]]; then
echo "Cannot find cURL. Things may fail."
fi
rm -rf "$PWD_DIR/cmake_build"
mkdir -p "$PWD_DIR/cmake_build"
cd "$PWD_DIR/cmake_build"
#############################################################################
if [[ ! -z "$CXX" ]];
files=(CMakeLists.txt cryptopp-config.cmake)
for file in "${files[@]}"; do
echo "Downloading $file"
if ! curl -L -s -o "$file" "https://raw.githubusercontent.com/noloader/cryptopp-cmake/master/$file"; then
echo "$file download failed"
exit 1
fi
# Throttle
sleep 1
done
rm -rf "$(pwd)/cmake_build"
mkdir -p "$(pwd)/cmake_build"
cd "$(pwd)/cmake_build" || exit 1
#############################################################################
echo ""
echo "Building test artifacts"
echo ""
if [[ -n "$CXX" ]];
then
if ! CXX="$CXX" "$CMAKE" -DCMAKE_CXX_COMPILER="$CXX" ../; then
echo "cmake failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
else
if ! "$CMAKE" ../; then
echo "cmake failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
fi
"$MAKE" clean 2>/dev/null
"$MAKE" clean &>/dev/null
if ! "$MAKE" -j2 -f Makefile VERBOSE=1; then
echo "make failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
if ! ./cryptest.exe v; then
echo "cryptest.exe v failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
if ! ./cryptest.exe tv all; then
echo "cryptest.exe v failed"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
# Return success
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0
exit 0

View File

@ -1,70 +1,105 @@
#!/usr/bin/env bash
# ====================================================================
# Tests iOS cross-compiles
#############################################################################
#
# This script tests the cryptopp-ios gear.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/iOS_(Command_Line) for more details
# ====================================================================
#############################################################################
if [ -z $(command -v ./setenv-ios.sh) ]; then
if [ -z "$(command -v ./setenv-ios.sh)" ]; then
echo "Failed to locate setenv-ios.sh"
ls -Al *.sh
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
exit 1
fi
if [ -z "${PLATFORM-}" ]; then
PLATFORMS=(iPhoneOS iPhoneSimulator Arm64 WatchOS WatchSimulator AppleTVOS AppleTVSimulator)
else
PLATFORMS=(${PLATFORM})
# Temp directory
if [[ -z "${TMPDIR}" ]]; then
TMPDIR="$HOME/tmp"
mkdir "${TMPDIR}"
fi
for platform in ${PLATFORMS[@]}
# Sane default
if [[ -z "${MAKE_JOBS}" ]]; then
MAKE_JOBS=4
fi
# Cleanup old artifacts
rm -rf "${TMPDIR}/build.failed" 2>/dev/null
rm -rf "${TMPDIR}/build.log" 2>/dev/null
#############################################################################
# Hack a Bash data structure...
PLATFORMS=()
PLATFORMS+=("iPhoneOS:armv7")
PLATFORMS+=("iPhoneOS:arm64")
PLATFORMS+=("AppleTVOS:armv7")
PLATFORMS+=("AppleTVOS:arm64")
PLATFORMS+=("WatchOS:armv7")
PLATFORMS+=("WatchOS:arm64")
PLATFORMS+=("iPhoneSimulator:i386")
PLATFORMS+=("iPhoneSimulator:x86_64")
PLATFORMS+=("AppleTVSimulator:i386")
PLATFORMS+=("AppleTVSimulator:x86_64")
PLATFORMS+=("WatchSimulator:i386")
PLATFORMS+=("WatchSimulator:x86_64")
for platform in "${PLATFORMS[@]}"
do
sdk=$(echo "${platform[@]}" | awk -F':' '{print $1}')
cpu=$(echo "${platform[@]}" | awk -F':' '{print $2}')
# setenv-ios.sh reads these two variables for configuration info.
export IOS_SDK="$sdk"
export IOS_CPU="$cpu"
make -f GNUmakefile-cross distclean > /dev/null 2>&1
echo
echo "====================================================="
echo "Testing for iOS support of $platform"
echo "Testing for iOS support of ${platform}"
# Test if we can set the environment for the platform
./setenv-ios.sh "$platform"
if [ "$?" -ne "0" ];
if ! ./setenv-ios.sh > /dev/null 2>&1;
then
echo
echo "$platform not supported by Xcode"
echo "$platform ==> FAILURE" >> /tmp/build.log
echo "${platform} not supported by Xcode"
echo "${platform} ==> SKIPPED" >> "${TMPDIR}/build.log"
touch /tmp/build.failed
continue
fi
echo
echo "Building for $platform using $runtime..."
echo
echo "====================================================="
echo "Building for ${platform}..."
# run in subshell to not keep any env vars
# run in subshell to not keep any envars
(
source ./setenv-ios.sh "$platform" > /dev/null 2>&1
make -f GNUmakefile-cross static dynamic cryptest.exe
if [ "$?" -eq "0" ]; then
echo "$platform ==> SUCCESS" >> /tmp/build.log
source ./setenv-ios.sh
if make -k -j "${MAKE_JOBS}" -f GNUmakefile-cross static dynamic cryptest.exe;
then
echo "${platform} ==> SUCCESS" >> "${TMPDIR}/build.log"
else
echo "$platform ==> FAILURE" >> /tmp/build.log
touch /tmp/build.failed
echo "${platform} ==> FAILURE" >> "${TMPDIR}/build.log"
touch "${TMPDIR}/build.failed"
fi
)
done
cat /tmp/build.log
echo
echo "====================================================="
cat "${TMPDIR}/build.log"
# let the script fail if any of the builds failed
if [ -f /tmp/build.failed ]; then
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
if [ -f "${TMPDIR}/build.failed" ]; then
exit 1
fi
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0
exit 0

View File

@ -0,0 +1,111 @@
#!/usr/bin/env bash
#############################################################################
#
# This script tests the cryptopp-pem gear.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
#############################################################################
GREP=grep
SED=sed
AWK=awk
MAKE=make
# Fixup, Solaris and friends
if [[ (-d /usr/xpg4/bin) ]]; then
SED=/usr/xpg4/bin/sed
AWK=/usr/xpg4/bin/awk
GREP=/usr/xpg4/bin/grep
elif [[ (-d /usr/bin/posix) ]]; then
SED=/usr/bin/posix/sed
AWK=/usr/bin/posix/awk
GREP=/usr/bin/posix/grep
fi
# Fixup for sed and "illegal byte sequence"
IS_DARWIN=$(uname -s | "$GREP" -i -c darwin)
if [[ "$IS_DARWIN" -ne 0 ]]; then
export LC_ALL=C
fi
# Fixup for Solaris and BSDs
if [[ ! -z $(command -v gmake) ]]; then
MAKE=gmake
else
MAKE=make
fi
#############################################################################
if [[ -z $(command -v "$MAKE") ]]; then
echo "Cannot find $MAKE. Things may fail."
fi
if [[ -z $(command -v curl) ]]; then
echo "Cannot find cURL. Things may fail."
fi
if [[ -z $(command -v openssl) ]]; then
echo "Cannot find openssl. Things may fail."
fi
#############################################################################
files=(pem_create.sh pem_verify.sh pem_test.cxx pem_eol.cxx
pem.h pem_common.cpp pem_common.h pem_read.cpp pem_write.cpp
x509cert.h x509cert.cpp)
for file in "${files[@]}"; do
echo "Downloading $file"
if ! curl -L -s -o "$file" "https://raw.githubusercontent.com/noloader/cryptopp-pem/master/$file"; then
echo "$file download failed"
exit 1
fi
# Throttle
sleep 1
done
# Add execute to scripts
chmod +x *.sh
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr) ]]; then
echo "Removing pem_create.sh pem_verify.sh quarantine"
xattr -d "com.apple.quarantine" pem_create.sh pem_verify.sh &>/dev/null
fi
#############################################################################
echo ""
echo "Building test artifacts"
echo ""
"$MAKE" clean &>/dev/null
if ! "$MAKE" -j 2; then
echo "make failed."
exit 1
fi
if ! ./cryptest.exe v; then
echo "cryptest v failed."
exit 1
fi
if ! ./pem_create.sh; then
echo "pem_create.sh failed."
exit 1
fi
if ! ./pem_verify.sh; then
echo "pem_verify.sh failed."
exit 1
fi
# Return success
exit 0

View File

@ -1,60 +1,53 @@
#!/usr/bin/env bash
# cryptest.sh - written and placed in public domain by Jeffrey Walton and Uri
# Blumenthal.
#############################################################################
#
# This is a test script that can be used on some Linux/Unix/Apple machines to
# automate testing of the shared object to ensure linking and symbols don't go
# missing from release to release.
#
# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/Android.mk_(Command_Line) for more details
#
#############################################################################
# Fixup ancient Bash
# https://unix.stackexchange.com/q/468579/56041
if [[ -z "$BASH_SOURCE" ]]; then
BASH_SOURCE="$0"
fi
############################################
# Cleanup
PWD_DIR=$(pwd)
function cleanup {
rm -f adhoc.cpp *.a *.o *.so *.dylib GNUmakefile-symbols
cd "$PWD_DIR"
}
trap cleanup EXIT
############################################
#############################################################################
# Tags to test
OLD_VERSION_TAG=CRYPTOPP_8_1_0
OLD_VERSION_TAG=CRYPTOPP_8_3_0
NEW_VERSION_TAG=master
############################################
#############################################################################
# If local repo is dirty, then promt first
DIRTY=$(git diff --shortstat 2> /dev/null | tail -1)
if [[ ! (-z "$DIRTY") ]]; then
if [[ ! -z "$DIRTY" ]]; then
echo
echo "The local repo is dirty. Continuing will reset the repo and lose changes."
read -p "Type 'Y' to proceed or 'N' to exit. Proceed? " -n 1 -r
echo # (optional) move to a new line
if [[ !($REPLY =~ ^[Yy]$) ]]; then
[[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0
exit 0
fi
else
echo
echo "The local repo is clean. Proceeding..."
fi
############################################
#############################################################################
echo
echo "****************************************************************"
echo "Testing '$NEW_VERSION_TAG' against '$OLD_VERSION_TAG'"
echo "****************************************************************"
############################################
#############################################################################
# Setup tools and platforms
GREP=grep
@ -64,118 +57,55 @@ AWK=awk
CXXFILT=c++filt
THIS_SYSTEM=$(uname -s 2>&1)
IS_DARWIN=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c darwin)
IS_LINUX=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c linux)
IS_CYGWIN=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c cygwin)
IS_MINGW=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c mingw)
IS_OPENBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c openbsd)
IS_FREEBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c freebsd)
IS_NETBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c netbsd)
IS_SOLARIS=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c sunos)
IS_DARWIN=$("${GREP}" -i -c darwin <<< "${THIS_SYSTEM}")
IS_LINUX=$("${GREP}" -i -c linux <<< "${THIS_SYSTEM}")
IS_CYGWIN=$("${GREP}" -i -c cygwin <<< "${THIS_SYSTEM}")
IS_MINGW=$("${GREP}" -i -c mingw <<< "${THIS_SYSTEM}")
IS_OPENBSD=$("${GREP}" -i -c openbsd <<< "${THIS_SYSTEM}")
IS_FREEBSD=$("${GREP}" -i -c freebsd <<< "${THIS_SYSTEM}")
IS_NETBSD=$("${GREP}" -i -c netbsd <<< "${THIS_SYSTEM}")
IS_SOLARIS=$("${GREP}" -i -c sunos <<< "${THIS_SYSTEM}")
THIS_MACHINE=$(uname -m 2>&1)
IS_X86=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(i386|i486|i586|i686)")
IS_X64=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(amd64|x86_64)")
IS_PPC=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(Power|PPC)")
IS_ARM32=$(echo -n "$THIS_MACHINE" | "$GREP" -v "64" | "$EGREP" -i -c "(arm|aarch32)")
IS_ARM64=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(arm64|aarch64)")
IS_S390=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "s390")
IS_X32=0
IS_X86=$("${EGREP}" -i -c 'i386|i486|i586|i686' <<< "${THIS_MACHINE}")
IS_X64=$("${EGREP}" -i -c "amd64|x86_64" <<< "${THIS_MACHINE}")
IS_PPC32=$("${EGREP}" -i -c "PowerPC|PPC" <<< "${THIS_MACHINE}")
IS_PPC64=$("${EGREP}" -i -c "PowerPC64|PPC64" <<< "${THIS_MACHINE}")
IS_ARM32=$("${EGREP}" -i -c "arm|aarch32" <<< "${THIS_MACHINE}")
IS_ARMV8=$("${EGREP}" -i -c "arm64|aarch64" <<< "${THIS_MACHINE}")
IS_S390=$("${EGREP}" -i -c "s390" <<< "${THIS_MACHINE}")
if [[ "${IS_X64}" -eq 1 ]]; then IS_X86=0; fi
if [[ "${IS_ARMV8}" -eq 1 ]]; then IS_ARM32=0; fi
if [[ "${IS_PPC64}" -eq 1 ]]; then IS_PPC32=0; fi
# Fixup
if [[ "$IS_SOLARIS" -ne "0" ]]; then
IS_X64=$(isainfo 2>/dev/null | "$GREP" -i -c "amd64")
if [[ "$IS_X64" -ne "0" ]]; then
IS_X86=0
fi
# Need something more powerful than the Posix versions
if [[ (-e "/usr/gnu/bin/grep") ]]; then
GREP=/usr/gnu/bin/grep
fi
if [[ (-e "/usr/gnu/bin/egrep") ]]; then
EGREP=/usr/gnu/bin/egrep
fi
if [[ (-e "/usr/gnu/bin/sed") ]]; then
SED=/usr/gnu/bin/sed
fi
if [[ (-e "/usr/gnu/bin/c++filt") ]]; then
CXXFILT=/usr/gnu/bin/c++filt
fi
if [[ (-e "/usr/gnu/bin/awk") ]]; then
AWK=/usr/gnu/bin/awk
else
AWK=nawk;
fi
fi
if [[ "$IS_DARWIN" -ne "0" ]]; then
SED_OPTS=(-i '')
else
SED_OPTS=(-i)
fi
# Fixup
if [[ ("$IS_FREEBSD" -ne "0" || "$IS_OPENBSD" -ne "0" || "$IS_NETBSD" -ne "0") ]]; then
if [[ "$IS_FREEBSD" -ne "0" || "$IS_OPENBSD" -ne "0" || "$IS_NETBSD" -ne "0" ]]; then
MAKE=gmake
elif [[ ("$IS_SOLARIS" -ne "0") ]]; then
MAKE=$(which gmake 2>/dev/null | "$GREP" -v "no gmake" | head -1)
if [[ (-z "$MAKE") && (-e "/usr/sfw/bin/gmake") ]]; then
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
MAKE=$(command -v gmake 2>/dev/null | "${GREP}" -v "no gmake" | head -1)
if [[ -z "$MAKE" && -e "/usr/sfw/bin/gmake" ]]; then
MAKE=/usr/sfw/bin/gmake
fi
else
MAKE=make
fi
# We need to use the C++ compiler to determine feature availablility. Otherwise
# mis-detections occur on a number of platforms.
if [[ ((-z "$CXX") || ("$CXX" == "gcc")) ]]; then
if [[ ("$CXX" == "gcc") ]]; then
CXX=g++
elif [[ "$IS_DARWIN" -ne "0" ]]; then
CXX=c++
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
if [[ (-e "/opt/developerstudio12.5/bin/CC") ]]; then
CXX=/opt/developerstudio12.5/bin/CC
elif [[ (-e "/opt/solarisstudio12.4/bin/CC") ]]; then
CXX=/opt/solarisstudio12.4/bin/CC
elif [[ (-e "/opt/solarisstudio12.3/bin/CC") ]]; then
CXX=/opt/solarisstudio12.3/bin/CC
elif [[ (-e "/opt/solstudio12.2/bin/CC") ]]; then
CXX=/opt/solstudio12.2/bin/CC
elif [[ (-e "/opt/solstudio12.1/bin/CC") ]]; then
CXX=/opt/solstudio12.1/bin/CC
elif [[ (-e "/opt/solstudio12.0/bin/CC") ]]; then
CXX=/opt/solstudio12.0/bin/CC
elif [[ (! -z $(which CC 2>/dev/null | "$GREP" -v "no CC" | head -1)) ]]; then
CXX=$(which CC | head -1)
elif [[ (! -z $(which g++ 2>/dev/null | "$GREP" -v "no g++" | head -1)) ]]; then
CXX=$(which g++ | head -1)
if [[ "$IS_DARWIN" -ne "0" ]]; then
LINK_LIBRARY=libcryptopp.dylib
else
CXX=CC
fi
elif [[ ($(which g++ 2>&1 | "$GREP" -v "no g++" | "$GREP" -i -c g++) -ne "0") ]]; then
CXX=g++
else
CXX=c++
fi
LINK_LIBRARY=libcryptopp.so
fi
SUN_COMPILER=$("$CXX" -V 2>&1 | "$EGREP" -i -c "CC: (Sun|Studio)")
GCC_COMPILER=$("$CXX" --version 2>&1 | "$GREP" -i -v "clang" | "$EGREP" -i -c "(gcc|g\+\+)")
INTEL_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "\(icc\)")
MACPORTS_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "MacPorts")
CLANG_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "clang")
if [[ -z "${CXX}" ]]; then CXX=c++; fi
if [[ ("$SUN_COMPILER" -eq "0") ]]; then
AMD64=$("$CXX" -dM -E - </dev/null 2>/dev/null | "$EGREP" -c "(__x64_64__|__amd64__)")
ILP32=$("$CXX" -dM -E - </dev/null 2>/dev/null | "$EGREP" -c "(__ILP32__|__ILP32)")
if [[ ("$AMD64" -ne "0") && ("$ILP32" -ne "0") ]]; then
IS_X32=1
fi
fi
SUN_COMPILER=$("${CXX}" -V 2>&1 | "${EGREP}" -i -c "CC: (Sun|Studio)")
GCC_COMPILER=$("${CXX}" --version 2>&1 | "${EGREP}" -i -c "^(gcc|g\+\+)")
INTEL_COMPILER=$("${CXX}" --version 2>&1 | "${GREP}" -i -c "icc")
MACPORTS_COMPILER=$("${CXX}" --version 2>&1 | "${GREP}" -i -c "MacPorts")
CLANG_COMPILER=$("${CXX}" --version 2>&1 | "${GREP}" -i -c "clang")
############################################
#############################################################################
# CPU is logical count, memory is in MiB. Low resource boards have
# fewer than 4 cores and 1GB or less memory. We use this to
@ -183,25 +113,25 @@ fi
CPU_COUNT=1
MEM_SIZE=512
if [[ (-e "/proc/cpuinfo") && (-e "/proc/meminfo") ]]; then
CPU_COUNT=$(cat /proc/cpuinfo | "$GREP" -c '^processor')
MEM_SIZE=$(cat /proc/meminfo | "$GREP" "MemTotal" | "$AWK" '{print $2}')
if [[ -e "/proc/cpuinfo" && -e "/proc/meminfo" ]]; then
CPU_COUNT=$(cat /proc/cpuinfo | "${GREP}" -c '^processor')
MEM_SIZE=$(cat /proc/meminfo | "${GREP}" "MemTotal" | "${AWK}" '{print $2}')
MEM_SIZE=$(($MEM_SIZE/1024))
elif [[ "$IS_DARWIN" -ne "0" ]]; then
CPU_COUNT=$(sysctl -a 2>&1 | "$GREP" 'hw.availcpu' | "$AWK" '{print $3; exit}')
MEM_SIZE=$(sysctl -a 2>&1 | "$GREP" 'hw.memsize' | "$AWK" '{print $3; exit;}')
CPU_COUNT=$(sysctl -a 2>&1 | "${GREP}" 'hw.availcpu' | "${AWK}" '{print $3; exit}')
MEM_SIZE=$(sysctl -a 2>&1 | "${GREP}" 'hw.memsize' | "${AWK}" '{print $3; exit;}')
MEM_SIZE=$(($MEM_SIZE/1024/1024))
elif [[ "$IS_SOLARIS" -ne "0" ]]; then
CPU_COUNT=$(psrinfo 2>/dev/null | wc -l | "$AWK" '{print $1}')
MEM_SIZE=$(prtconf 2>/dev/null | "$GREP" Memory | "$AWK" '{print $3}')
CPU_COUNT=$(psrinfo 2>/dev/null | wc -l | "${AWK}" '{print $1}')
MEM_SIZE=$(prtconf 2>/dev/null | "${GREP}" Memory | "${AWK}" '{print $3}')
fi
# Some ARM devboards cannot use 'make -j N', even with multiple cores and RAM
# An 8-core Cubietruck Plus with 2GB RAM experiences OOM kills with '-j 2'.
HAVE_SWAP=1
if [[ "$IS_LINUX" -ne "0" ]]; then
if [[ (-e "/proc/meminfo") ]]; then
SWAP_SIZE=$(cat /proc/meminfo | "$GREP" "SwapTotal" | "$AWK" '{print $2}')
if [[ -e "/proc/meminfo" ]]; then
SWAP_SIZE=$(cat /proc/meminfo | "${GREP}" "SwapTotal" | "${AWK}" '{print $2}')
if [[ "$SWAP_SIZE" -eq "0" ]]; then
HAVE_SWAP=0
fi
@ -210,41 +140,20 @@ if [[ "$IS_LINUX" -ne "0" ]]; then
fi
fi
if [[ ("$CPU_COUNT" -ge "2" && "$MEM_SIZE" -ge "1280" && "$HAVE_SWAP" -ne "0") ]]; then
if [[ ("$WANT_NICE" -eq "1") ]]; then
CPU_COUNT=$(echo -n "$CPU_COUNT 2" | "$AWK" '{print int($1/$2)}')
fi
if [[ "$CPU_COUNT" -ge "2" && "$MEM_SIZE" -ge "1280" && "$HAVE_SWAP" -ne "0" ]]; then
MAKEARGS=(-j "$CPU_COUNT")
fi
###############################################################################
###############################################################################
"$MAKE" distclean &>/dev/null
rm -f GNUmakefile-symbols
#############################################################################
#############################################################################
"${MAKE}" distclean &>/dev/null && cleanup &>/dev/null
git checkout master -f &>/dev/null
cp GNUmakefile GNUmakefile-symbols
git checkout "$OLD_VERSION_TAG" -f &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "Failed to checkout $OLD_VERSION_TAG"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo
echo "****************************************************************"
echo "Patching makefile for dynamic linking by cryptest.exe"
echo "****************************************************************"
if [[ "$IS_DARWIN" -ne "0" ]]; then
"$SED" "$SED_OPTS" -e 's|libcryptopp.a $(TESTOBJS)|libcryptopp.dylib $(TESTOBJS)|g' GNUmakefile-symbols
"$SED" "$SED_OPTS" -e 's|$(TESTOBJS) ./libcryptopp.a |$(TESTOBJS) ./libcryptopp.dylib |g' GNUmakefile-symbols
else
"$SED" "$SED_OPTS" -e 's|libcryptopp.a $(TESTOBJS)|libcryptopp.so $(TESTOBJS)|g' GNUmakefile-symbols
"$SED" "$SED_OPTS" -e 's|$(TESTOBJS) ./libcryptopp.a |$(TESTOBJS) ./libcryptopp.so |g' GNUmakefile-symbols
exit 1
fi
echo
@ -253,30 +162,11 @@ echo "Building dynamic library for $OLD_VERSION_TAG"
echo "****************************************************************"
echo
"$MAKE" "${MAKEARGS[@]}" -f GNUmakefile-symbols dynamic
LINK_LIBRARY="$LINK_LIBRARY" "$MAKE" "${MAKEARGS[@]}" -f GNUmakefile cryptest.exe dynamic
if [[ "$IS_DARWIN" -ne "0" ]]; then
LIBNAME=libcryptopp.dylib
else
LIBNAME=libcryptopp.so
fi
if [[ ! -f "$LIBNAME" ]]; then
if [[ ! -f "$LINK_LIBRARY" ]]; then
echo "Failed to make $OLD_VERSION_TAG library"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo
echo "****************************************************************"
echo "Building cryptest.exe for $OLD_VERSION_TAG"
echo "****************************************************************"
echo
"$MAKE" "${MAKEARGS[@]}" -f GNUmakefile-symbols cryptest.exe
if [[ ! -f "cryptest.exe" ]]; then
echo "Failed to make cryptest.exe"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
exit 1
fi
echo
@ -286,26 +176,15 @@ echo "****************************************************************"
echo
if [[ "$IS_DARWIN" -ne "0" ]]; then
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT"
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT"
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" ./cryptest.exe v 2>&1 | "$CXXFILT"
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" ./cryptest.exe tv all 2>&1 | "$CXXFILT"
else
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT"
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT"
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe v 2>&1 | "$CXXFILT"
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe tv all 2>&1 | "$CXXFILT"
fi
echo
echo "****************************************************************"
echo "Removing dynamic library and artifacts for $OLD_VERSION_TAG"
echo "****************************************************************"
rm -f adhoc.cpp *.a *.o *.so *.dylib
git checkout "$NEW_VERSION_TAG" -f &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "Failed to checkout $OLD_VERSION_TAG"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
# Stash away old cryptest.exe
cp cryptest.exe cryptest.exe.saved
echo
echo "****************************************************************"
@ -313,13 +192,20 @@ echo "Building dynamic library for $NEW_VERSION_TAG"
echo "****************************************************************"
echo
"$MAKE" "${MAKEARGS[@]}" -f GNUmakefile-symbols dynamic
"${MAKE}" distclean &>/dev/null && cleanup &>/dev/null
git checkout master -f &>/dev/null
git checkout "$NEW_VERSION_TAG" -f &>/dev/null
if [[ ! -f "$LIBNAME" ]]; then
LINK_LIBRARY="$LINK_LIBRARY" "$MAKE" "${MAKEARGS[@]}" -f GNUmakefile cryptest.exe dynamic
if [[ ! -f "$LINK_LIBRARY" ]]; then
echo "Failed to make $NEW_VERSION_TAG library"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
exit 1
fi
# Fetch old cryptest.exe
cp cryptest.exe.saved cryptest.exe
echo
echo "****************************************************************"
echo "Running $OLD_VERSION_TAG cryptest.exe using $NEW_VERSION_TAG library"
@ -327,18 +213,14 @@ echo "****************************************************************"
echo
if [[ "$IS_DARWIN" -ne "0" ]]; then
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT"
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT"
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" ./cryptest.exe v 2>&1 | "$CXXFILT"
DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" ./cryptest.exe tv all 2>&1 | "$CXXFILT"
else
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT"
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT"
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe v 2>&1 | "$CXXFILT"
LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe tv all 2>&1 | "$CXXFILT"
fi
"${MAKE}" distclean &>/dev/null && cleanup &>/dev/null
git checkout master -f &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "Failed to checkout Master"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
[[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0
exit 0

View File

@ -1,5 +1,17 @@
#!/usr/bin/env bash
#############################################################################
#
# This script invokes clang-tidy on source files.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
#############################################################################
for file in $(find . -maxdepth 1 -type f -name '*.cpp'); do
echo "Tidying $file"
clang-tidy $file -checks=-clang-analyzer-optin.cplusplus.VirtualCall -- -std=c++03

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,37 @@
#!/usr/bin/env bash
#############################################################################
#
# This scripts queries and modifies CPU scaling frequencies to produce more
# accurate benchmark results. To move from a low energy state C-state to a
# higher one, run 'governor.sh performance'. To move back to a low power state
# run 'governor.sh powersave' or reboot. The script is based on code by
# Andy Polyakov, http://www.openssl.org/~appro/cryptogams/.
# accurate benchmark results. To move from a low power state to a higher
# one, run 'governor.sh performance'. To move back to a low power state
# run 'governor.sh powersave' or 'governor.sh ondemand' or reboot.
#
# Written and placed in public domain by Jeffrey Walton. The script based on
# code by Andy Polyakov, http://www.openssl.org/~appro/cryptogams/.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See https://www.cryptopp.com/wiki/Benchmarks for more details
#
#############################################################################
# Fixup ancient Bash
# https://unix.stackexchange.com/q/468579/56041
if [[ -z "$BASH_SOURCE" ]]; then
if [[ -z "${BASH_SOURCE[0]}" ]]; then
BASH_SOURCE="$0"
fi
if [[ "$EUID" -ne 0 ]]; then
echo "This script must be run as root"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
if [ "x$1" = "x" ]; then
echo "usage: $0 on[demand]|pe[rformance]|po[wersave]|us[erspace]?"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
# "on demand" may result in a "invalid write argument" or similar
@ -27,40 +39,41 @@ case $1 in
on*|de*) governor="ondemand";;
po*|pw*) governor="powersave";;
pe*) governor="performance";;
co*) governor="conservative";;
us*) governor="userspace";;
\?) ;;
*) echo "$1: unrecognized governor";;
esac
if [ -z "$governor" ]; then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
cpus=$(ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 2>/dev/null)
if [ -z "$cpus" ]; then
echo "Failed to read CPU system device tree"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi
echo "Current CPU governor scaling settings:"
count=0
for cpu in $cpus; do
echo " CPU $count:" $(cat "$cpu")
echo " CPU $count: $(cat "$cpu")"
((count++))
done
if [ "x$governor" != "x" ]; then
for cpu in $cpus; do
echo $governor > $cpu
echo "$governor" > "$cpu"
done
fi
echo "New CPU governor scaling settings:"
count=0
for cpu in $cpus; do
echo " CPU $count:" $(cat "$cpu")
echo " CPU $count: $(cat "$cpu")"
((count++))
done
[[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -e
# install android deps
sudo apt-get -qq update
sudo apt-get -qq install --no-install-recommends openjdk-8-jdk unzip
# android skd/ndk
curl -Lo /tmp/android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
unzip -qq /tmp/android-sdk.zip -d "$ANDROID_SDK"
rm -f /tmp/android-sdk.zip
echo y | "$ANDROID_SDK/tools/bin/sdkmanager" --update > /dev/null
for package in "ndk-bundle"; do
echo install android $package
echo y | "$ANDROID_SDK/tools/bin/sdkmanager" "$package" > /dev/null
done

View File

@ -0,0 +1,207 @@
#!/usr/bin/env bash
#############################################################################
# Tests Android cross-compiles
#
# This script installs a SDK and NDK to test Android cross-compiles.
#
# Written and placed in public domain by Jeffrey Walton
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
#############################################################################
# NDK-r19: https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip
# SDK for r19: https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
# SDK for Mac: https://dl.google.com/android/repository/sdk-tools-mac-4333796.zip
# NDK-r20: https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip
# SDK for r20: https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
# SDK for Mac: https://dl.google.com/android/repository/commandlinetools-mac-6200805_latest.zip
# NDK-r21: https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip
# SDK for r21: https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
# SDK for Mac: https://dl.google.com/android/repository/commandlinetools-mac-6200805_latest.zip
# NDK-r22: https://dl.google.com/android/repository/android-ndk-r22-linux-x86_64.zip
# SDK for r22: https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip
# SDK for Mac: https://dl.google.com/android/repository/commandlinetools-mac-6858069_latest.zip
# Platform tools
# Linux: https://dl.google.com/android/repository/platform-tools-latest-linux.zip
# Mac: https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
# Windows: https://dl.google.com/android/repository/platform-tools-latest-windows.zip
function cleanup {
# Cleanup downloads
rm -f android-sdk.zip android-ndk.zip platform-tools.zip
}
trap cleanup EXIT
if [ -z "${ANDROID_SDK_ROOT}" ]; then
echo "ERROR: ANDROID_SDK_ROOT is not set for ${USER}. Please set it."
exit 1
fi
if [ -z "${ANDROID_NDK_ROOT}" ]; then
echo "ERROR: ANDROID_NDK_ROOT is not set for ${USER}. Please set it."
exit 1
fi
# Temp directory
if [[ -z "${TMPDIR}" ]]; then
TMPDIR="$HOME/tmp"
mkdir -p "${TMPDIR}"
if [ -n "${SUDO_USER}" ]; then
chown -R "${SUDO_USER}" "${TMPDIR}"
fi
fi
# Install Android deps
if [[ -z "$(command -v java 2>/dev/null)" && -n "$(command -v apt-get 2>/dev/null)" ]]; then
apt-get -qq update 2>/dev/null || true
apt-get -qq install --no-install-recommends unzip curl wget 2>/dev/null || true
if [[ -n "$(apt-cache search openjdk-13-jdk 2>/dev/null | head -n 1)" ]]; then
apt-get -qq install --no-install-recommends openjdk-13-jdk 2>/dev/null || true
elif [[ -n "$(apt-cache search openjdk-8-jdk 2>/dev/null | head -n 1)" ]]; then
apt-get -qq install --no-install-recommends openjdk-8-jdk 2>/dev/null || true
fi
elif [[ -z "$(command -v java 2>/dev/null)" && -n "$(command -v dnf 2>/dev/null)" ]]; then
dnf update 2>/dev/null || true
dnf install unzip curl wget 2>/dev/null || true
if [[ -n "$(dnf search java-latest-openjdk-devel 2>/dev/null | head -n 1)" ]]; then
dnf install java-latest-openjdk-devel 2>/dev/null || true
elif [[ -n "$(dnf search java-11-openjdk-devel 2>/dev/null | head -n 1)" ]]; then
dnf install java-11-openjdk-devel 2>/dev/null || true
fi
elif [[ -z "$(command -v java 2>/dev/null)" && -n "$(command -v yum 2>/dev/null)" ]]; then
yum update 2>/dev/null || true
yum install unzip curl wget 2>/dev/null || true
if [[ -n "$(yum search java-latest-openjdk-devel 2>/dev/null | head -n 1)" ]]; then
yum install java-latest-openjdk-devel 2>/dev/null || true
elif [[ -n "$(yum search java-11-openjdk-devel 2>/dev/null | head -n 1)" ]]; then
yum install java-11-openjdk-devel 2>/dev/null || true
fi
fi
# User feedback
#echo "ANDROID_NDK_ROOT is '${ANDROID_NDK_ROOT}'"
#echo "ANDROID_SDK_ROOT is '${ANDROID_SDK_ROOT}'"
IS_DARWIN=$(uname -s 2>/dev/null | grep -i -c darwin)
IS_LINUX=$(uname -s 2>/dev/null | grep -i -c linux)
# Change NDK_NAME as required
NDK_NAME=android-ndk-r20b
NDK_TOP=$(dirname "${ANDROID_NDK_ROOT}")
# Keep this in sync with the move at the end.
if [ "$IS_LINUX" -eq 1 ]; then
NDK_URL=https://dl.google.com/android/repository/${NDK_NAME}-linux-x86_64.zip
SDK_URL=https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
TOOLS_URL=https://dl.google.com/android/repository/platform-tools-latest-linux.zip
elif [ "$IS_DARWIN" -eq 1 ]; then
NDK_URL=https://dl.google.com/android/repository/${NDK_NAME}-darwin-x86_64.zip
SDK_URL=https://dl.google.com/android/repository/commandlinetools-mac-6200805_latest.zip
TOOLS_URL=https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
else
echo "Unknown platform: \"$(uname -s 2>/dev/null)\". Please fix this script."
fi
echo "Downloading SDK"
if ! curl -L -s -o android-sdk.zip "${SDK_URL}";
then
echo "Failed to download SDK"
exit 1
fi
echo "Downloading NDK"
if ! curl -L -s -o android-ndk.zip "${NDK_URL}";
then
echo "Failed to download NDK"
exit 1
fi
echo "Downloading Platform Tools"
if ! curl -L -s -o platform-tools.zip "${TOOLS_URL}";
then
echo "Failed to download Platform Tools"
exit 1
fi
# Android SDK does not include a top level directory
echo "Unpacking SDK to ${ANDROID_SDK_ROOT}"
if ! unzip -u -qq android-sdk.zip -d "${ANDROID_SDK_ROOT}";
then
echo "Failed to unpack SDK"
exit 1
fi
# Android NDK includes top level NDK_NAME directory
echo "Unpacking NDK to ${NDK_TOP}/${NDK_NAME}"
if ! unzip -u -qq android-ndk.zip -d "${NDK_TOP}";
then
echo "Failed to unpack NDK"
exit 1
fi
echo "Unpacking Platform Tools to ${ANDROID_SDK_ROOT}"
if ! unzip -u -qq platform-tools.zip -d "${ANDROID_SDK_ROOT}";
then
echo "Failed to unpack Platform Tools"
exit 1
fi
# Unlink as needed
if [[ -e "${ANDROID_NDK_ROOT}" ]]; then
ls_output=$(ls -l "${ANDROID_NDK_ROOT}" 2>/dev/null | head -n 1)
# Only remove soft links
if [[ ${ls_output:0:1} == "l" ]]; then
unlink "${ANDROID_NDK_ROOT}"
fi
fi
# Create softlink
(
echo "Symlinking ${NDK_NAME} to android-ndk"
cd ${NDK_TOP} || exit 1
if ! ln -s "${NDK_NAME}" android-ndk; then
echo "Failed to link ${NDK_NAME} to android-ndk"
fi
)
# We don't set ANDROID_HOME to ANDROID_SDK_ROOT.
# https://stackoverflow.com/a/47028911/608639
touch "${ANDROID_SDK_ROOT}/repositories.cfg"
# And https://stackoverflow.com/q/43433542
mkdir -p "${HOME}/.android"
touch "${HOME}/.android/repositories.cfg"
if [[ -n "${SUDO_USER}" ]]; then
chown -R "${SUDO_USER}" "${HOME}/.android"
fi
count=$(ls -1 "${ANDROID_SDK_ROOT}" 2>/dev/null | wc -l)
if [[ "${count}" -lt 2 ]]; then
echo "ANDROID_SDK_ROOT appears empty. The contents are listed."
echo "$(ls "${ANDROID_SDK_ROOT}")"
exit 1
fi
count=$(ls -1 "${ANDROID_NDK_ROOT}" 2>/dev/null | wc -l)
if [[ "${count}" -lt 2 ]]; then
echo "ANDROID_NDK_ROOT appears empty. The contents are listed."
echo "$(ls "${ANDROID_NDK_ROOT}")"
exit 1
fi
echo "Finished installing SDK and NDK"
exit 0

View File

@ -1,14 +1,21 @@
#!/usr/bin/env bash
# make-benchmarks - Scan build submission instructions for Unix and Linux.
# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal.
# Copyright assigned to Crypto++ project.
#############################################################################
#
# The following builds the benchmarks under 5.6.2, 5.6.4 and Master. The results can then be
# compared to ensure an speed penalty is not inadvertently taken. Crypto++ 5.6.2 is significant
# because its the last version Wei worked on before turning the library over to the community.
###############################################################################
# The following builds the benchmarks under 5.6.2, 5.6.4 and Master. The
# results can then be compared to ensure an speed penalty is not inadvertently
# taken. Crypto++ 5.6.2 is significant because its the last version Wei worked
# on before turning the library over to the community.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See https://www.cryptopp.com/wiki/Benchmarks for more details
#
#############################################################################
# Set to suite your taste. Speed is in GiHz
@ -25,16 +32,16 @@ echo "Using CPU frequency of $CPU_FREQ GiHz."
echo "Please modify this script if its not correct"
echo
###############################################################################
#############################################################################
current=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
git fetch --all &>/dev/null &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "$PWD does not appear to be a Git repository"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
exit 1
fi
###############################################################################
#############################################################################
# Try to find a fast option
OPT=
@ -79,7 +86,7 @@ if [[ -z "$OPT" ]]; then
fi
fi
##################################################################
#############################################################################
echo "***************************************************"
echo "**************** Crypto++ 5.6.2 *******************"
@ -105,7 +112,7 @@ else
fi
fi
##################################################################
#############################################################################
echo "***************************************************"
echo "**************** Crypto++ 5.6.4 *******************"
@ -131,7 +138,7 @@ else
fi
fi
##################################################################
#############################################################################
echo "***************************************************"
echo "*************** Crypto++ Master *******************"
@ -157,10 +164,10 @@ else
fi
fi
##################################################################
#############################################################################
if [[ ! -z "$current" ]]; then
git checkout -f "$current"
fi
[[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0
exit 0

View File

@ -2,6 +2,13 @@
# Use this script to reset a fork to Wei Dai's master
# https://stackoverflow.com/questions/9646167/clean-up-a-fork-and-restart-it-from-the-upstream
#
# Written and placed in public domain by Jeffrey Walton
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
git remote add upstream https://github.com/weidai11/cryptopp 2>/dev/null
git fetch upstream

View File

@ -1,449 +0,0 @@
#!/usr/bin/env bash
# ====================================================================
# Sets the cross compile environment for Android
# Based upon OpenSSL's setenv-android.sh (by TH, JW, and SM).
# Updated by Skycoder42 to the latest NDK.
# These changes are based on the current recommendations for Android
# for their "Unified Headers". Details can be found at:
# https://android.googlesource.com/platform/ndk.git/+/HEAD/docs/UnifiedHeaders.md
# https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
# ====================================================================
# set -eu
unset IS_CROSS_COMPILE
unset IS_IOS
unset IS_ANDROID
unset IS_ARM_EMBEDDED
# Variables used in GNUmakefile-cross
unset AOSP_FLAGS
unset AOSP_SYSROOT
unset AOSP_LD_SYSROOT
unset AOSP_SYS_ARCH_INC
unset AOSP_STL_INC
unset AOSP_STL_LIB
unset AOSP_BITS_INC
# Tools set by this script
unset CPP CC CXX LD AS AR RANLIB STRIP
# Similar to a "make clean"
if [ x"${1-}" = "xunset" ]; then
echo "Unsetting script variables. PATH may remain tainted"
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0
fi
# Set AOSP_TOOLCHAIN_SUFFIX to your preference of tools and STL library.
# Note: 4.9 is required for the latest architectures, like ARM64/AARCH64.
# AOSP_TOOLCHAIN_SUFFIX=4.8
# AOSP_TOOLCHAIN_SUFFIX=4.9
if [ -z "${AOSP_TOOLCHAIN_SUFFIX-}" ]; then
AOSP_TOOLCHAIN_SUFFIX=4.9
fi
# Set AOSP_API_VERSION to the API you want to use. 'armeabi' and 'armeabi-v7a' need
# API 3 (or above), 'mips' and 'x86' need API 9 (or above), etc.
# AOSP_API_VERSION="3" # Android 1.5 and above
# AOSP_API_VERSION="4" # Android 1.6 and above
# AOSP_API_VERSION="5" # Android 2.0 and above
# AOSP_API_VERSION="8" # Android 2.2 and above
# AOSP_API_VERSION="9" # Android 2.3 and above
# AOSP_API_VERSION="14" # Android 4.0 and above
# AOSP_API_VERSION="18" # Android 4.3 and above
# AOSP_API_VERSION="19" # Android 4.4 and above
# AOSP_API_VERSION="21" # Android 5.0 and above
# AOSP_API_VERSION="23" # Android 6.0 and above
if [ -z "${AOSP_API_VERSION-}" ]; then
AOSP_API_VERSION="21"
fi
if [ -z "${AOSP_API-}" ]; then
AOSP_API="android-${AOSP_API_VERSION}"
else
echo "WARNING: Using AOSP_API has been deprecated. Please use AOSP_API_VERSION instead."
echo "If you set for example AOSP_API=android-23 then now instead set AOSP_API_VERSION=23"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
#####################################################################
# ANDROID_NDK_ROOT should always be set by the user (even when not running this script)
# http://groups.google.com/group/android-ndk/browse_thread/thread/a998e139aca71d77.
# If the user did not specify the NDK location, try and pick it up. We expect something
# like ANDROID_NDK_ROOT=/opt/android-ndk-r10e or ANDROID_NDK_ROOT=/usr/local/android-ndk-r10e.
if [ -z "${ANDROID_NDK_ROOT-}" ]; then
ANDROID_NDK_ROOT=$(find /opt -maxdepth 1 -type d -name android-ndk* 2>/dev/null | tail -1)
if [ -z "$ANDROID_NDK_ROOT" ]; then
ANDROID_NDK_ROOT=$(find /usr/local -maxdepth 1 -type d -name android-ndk* 2>/dev/null | tail -1)
fi
if [ -z "$ANDROID_NDK_ROOT" ]; then
ANDROID_NDK_ROOT=$(find $HOME -maxdepth 1 -type d -name android-ndk* 2>/dev/null | tail -1)
fi
if [ -d "$HOME/Library/Android/sdk/ndk-bundle" ]; then
ANDROID_NDK_ROOT="$HOME/Library/Android/sdk/ndk-bundle"
fi
fi
# Error checking
if [ ! -d "$ANDROID_NDK_ROOT/toolchains" ]; then
echo "ERROR: ANDROID_NDK_ROOT is not a valid path. Please set it."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
#####################################################################
if [ "$#" -lt 1 ]; then
THE_ARCH=armv7a-neon
else
THE_ARCH=$(tr [A-Z] [a-z] <<< "$1")
fi
# https://developer.android.com/ndk/guides/abis.html
case "$THE_ARCH" in
arm|armv5|armv6|armv7|armeabi)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi"
AOSP_ARCH="arch-arm"
AOSP_FLAGS="-march=armv5te -mtune=xscale -mthumb -msoft-float -DCRYPTOPP_DISABLE_ASM -funwind-tables -fexceptions -frtti"
;;
armv7a|armv7-a|armeabi-v7a)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
AOSP_FLAGS="-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -DCRYPTOPP_DISABLE_ASM -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
;;
hard|armv7a-hard|armeabi-v7a-hard)
echo hard, armv7a-hard and armeabi-v7a-hard are not supported, as android uses softfloats
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
#TOOLCHAIN_ARCH="arm-linux-androideabi"
#TOOLCHAIN_NAME="arm-linux-androideabi"
#AOSP_ABI="armeabi-v7a"
#AOSP_ARCH="arch-arm"
#AOSP_FLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfpu=vfpv3-d16 -DCRYPTOPP_DISABLE_ASM -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti -Wl,--no-warn-mismatch -Wl,-lm_hard"
;;
neon|armv7a-neon)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
AOSP_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
;;
armv8|armv8a|aarch64|arm64|arm64-v8a)
TOOLCHAIN_ARCH="aarch64-linux-android"
TOOLCHAIN_NAME="aarch64-linux-android"
AOSP_ABI="arm64-v8a"
AOSP_ARCH="arch-arm64"
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
;;
mips|mipsel)
TOOLCHAIN_ARCH="mipsel-linux-android"
TOOLCHAIN_NAME="mipsel-linux-android"
AOSP_ABI="mips"
AOSP_ARCH="arch-mips"
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
;;
mips64|mipsel64|mips64el)
TOOLCHAIN_ARCH="mips64el-linux-android"
TOOLCHAIN_NAME="mips64el-linux-android"
AOSP_ABI="mips64"
AOSP_ARCH="arch-mips64"
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
;;
x86)
TOOLCHAIN_ARCH="x86"
TOOLCHAIN_NAME="i686-linux-android"
AOSP_ABI="x86"
AOSP_ARCH="arch-x86"
AOSP_FLAGS="-mtune=intel -mssse3 -mfpmath=sse -funwind-tables -fexceptions -frtti"
;;
x86_64|x64)
TOOLCHAIN_ARCH="x86_64"
TOOLCHAIN_NAME="x86_64-linux-android"
AOSP_ABI="x86_64"
AOSP_ARCH="arch-x86_64"
AOSP_FLAGS="-march=x86-64 -msse4.2 -mpopcnt -mtune=intel -funwind-tables -fexceptions -frtti"
;;
*)
echo "ERROR: Unknown architecture $1"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
;;
esac
#####################################################################
# add missing android API version flag as of https://android.googlesource.com/platform/ndk.git/+/HEAD/docs/UnifiedHeaders.md
AOSP_FLAGS="-D__ANDROID_API__=$AOSP_API_VERSION $AOSP_FLAGS"
# GNUmakefile-cross expects these to be set. They are also used in the tests below.
export IS_ANDROID=1
export AOSP_FLAGS
export CPP="$TOOLCHAIN_NAME-cpp"
export CC="$TOOLCHAIN_NAME-gcc"
export CXX="$TOOLCHAIN_NAME-g++"
export LD="$TOOLCHAIN_NAME-ld"
export AS="$TOOLCHAIN_NAME-as"
export AR="$TOOLCHAIN_NAME-ar"
export RANLIB="$TOOLCHAIN_NAME-ranlib"
export STRIP="$TOOLCHAIN_NAME-strip"
export AOSP_SYS_ARCH_INC="$ANDROID_NDK_ROOT/sysroot/usr/include/$TOOLCHAIN_NAME"
#####################################################################
# Based on ANDROID_NDK_ROOT, try and pick up the path for the tools. We expect something
# like /opt/android-ndk-r10e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin
# Once we locate the tools, we add it to the PATH.
AOSP_TOOLCHAIN_PATH=""
for host in "linux-x86_64" "darwin-x86_64" "linux-x86" "darwin-x86"
do
if [ -d "$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_ARCH-$AOSP_TOOLCHAIN_SUFFIX/prebuilt/$host/bin" ]; then
AOSP_TOOLCHAIN_PATH="$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_ARCH-$AOSP_TOOLCHAIN_SUFFIX/prebuilt/$host/bin"
break
fi
done
# Error checking
if [ -z "$AOSP_TOOLCHAIN_PATH" ] || [ ! -d "$AOSP_TOOLCHAIN_PATH" ]; then
echo "ERROR: AOSP_TOOLCHAIN_PATH is not valid. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CPP" ]; then
echo "ERROR: Failed to find Android cpp. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CC" ]; then
echo "ERROR: Failed to find Android gcc. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CXX" ]; then
echo "ERROR: Failed to find Android g++. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$RANLIB" ]; then
echo "ERROR: Failed to find Android ranlib. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$AR" ]; then
echo "ERROR: Failed to find Android ar. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$AS" ]; then
echo "ERROR: Failed to find Android as. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$LD" ]; then
echo "ERROR: Failed to find Android ld. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Only modify/export PATH if AOSP_TOOLCHAIN_PATH good
if [ -d "$AOSP_TOOLCHAIN_PATH" ]; then
# And only modify PATH if AOSP_TOOLCHAIN_PATH is not present
LEN=${#AOSP_TOOLCHAIN_PATH}
SUBSTR=${PATH:0:$LEN}
if [ "$SUBSTR" != "$AOSP_TOOLCHAIN_PATH" ]; then
export PATH="$AOSP_TOOLCHAIN_PATH":"$PATH"
fi
fi
#####################################################################
# Error checking
if [ ! -d "$ANDROID_NDK_ROOT/platforms/$AOSP_API" ]; then
echo "ERROR: AOSP_API is not valid. Does the NDK support the API? Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
elif [ ! -d "$ANDROID_NDK_ROOT/platforms/$AOSP_API/$AOSP_ARCH" ]; then
echo "ERROR: AOSP_ARCH is not valid. Does the NDK support the architecture? Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Android SYSROOT. It will be used on the command line with --sysroot
# http://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
export AOSP_SYSROOT="$ANDROID_NDK_ROOT/sysroot"
export AOSP_LD_SYSROOT="$ANDROID_NDK_ROOT/platforms/$AOSP_API/$AOSP_ARCH"
#####################################################################
# Android STL. We support GNU, LLVM and STLport out of the box.
if [ "$#" -lt 2 ]; then
THE_STL=gnu-shared
else
THE_STL=$(tr [A-Z] [a-z] <<< "$2")
fi
# LLVM include directory may be different depending on NDK version. Default to new location (latest NDK checked: r16beta1).
LLVM_INCLUDE_DIR="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include"
if [ ! -d "$LLVM_INCLUDE_DIR" ]; then
LLVM_INCLUDE_DIR="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libcxx/include"
fi
case "$THE_STL" in
stlport-static)
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport/"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/$AOSP_ABI/libstlport_static.a"
;;
stlport|stlport-shared)
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport/"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/$AOSP_ABI/libstlport_shared.so"
;;
gabi++-static|gnu-static)
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/include"
AOSP_BITS_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/include"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/libgnustl_static.a"
;;
gnu|gabi++|gnu-shared|gabi++-shared)
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/include"
AOSP_BITS_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/include"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/libgnustl_shared.so"
;;
llvm-static)
echo WARNING: llvm is still in experimental state and migth not work as expected
if [ ! -d "$LLVM_INCLUDE_DIR" ]; then
echo "ERROR: Unable to locate include LLVM directory at $LLVM_INCLUDE_DIR -- has it moved since NDK r16beta1?"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
AOSP_STL_INC="$LLVM_INCLUDE_DIR"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libs/$AOSP_ABI/libc++_static.a"
;;
llvm|llvm-shared)
echo WARNING: llvm is still in experimental state and migth not work as expected
if [ ! -d "$LLVM_INCLUDE_DIR" ]; then
echo "ERROR: Unable to locate LLVM include directory at $LLVM_INCLUDE_DIR -- has it moved since NDK r16beta1?"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
AOSP_STL_INC="$LLVM_INCLUDE_DIR"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libs/$AOSP_ABI/libc++_shared.so"
;;
*)
echo "ERROR: Unknown STL library $2"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
esac
# Error checking
if [ ! -d "$AOSP_STL_INC" ] || [ ! -e "$AOSP_STL_INC/memory" ]; then
echo "ERROR: AOSP_STL_INC is not valid. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_STL_LIB" ]; then
echo "ERROR: AOSP_STL_LIB is not valid. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
export AOSP_STL_INC
export AOSP_STL_LIB
if [ ! -z "$AOSP_BITS_INC" ]; then
export AOSP_BITS_INC
fi
# Now that we are using cpu-features from Android rather than CPU probing, we
# need to copy cpu-features.h and cpu-features.c from the NDK into our source
# directory and then build it.
if [[ ! -e "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" ]]; then
echo "ERROR: Unable to locate cpu-features.h"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
cp "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" .
if [[ ! -e "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" ]]; then
echo "ERROR: Unable to locate cpu-features.c"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
cp "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" .
#####################################################################
VERBOSE=1
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" != "0" ]; then
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
echo "AOSP_TOOLCHAIN_PATH: $AOSP_TOOLCHAIN_PATH"
echo "AOSP_ABI: $AOSP_ABI"
echo "AOSP_API: $AOSP_API"
echo "AOSP_SYSROOT: $AOSP_SYSROOT"
echo "AOSP_LD_SYSROOT: $AOSP_LD_SYSROOT"
echo "AOSP_FLAGS: $AOSP_FLAGS"
echo "AOSP_SYS_ARCH_INC: $AOSP_SYS_ARCH_INC"
echo "AOSP_STL_INC: $AOSP_STL_INC"
echo "AOSP_STL_LIB: $AOSP_STL_LIB"
if [ ! -z "$AOSP_BITS_INC" ]; then
echo "AOSP_BITS_INC: $AOSP_BITS_INC"
fi
if [ -e "cpu-features.h" ] && [ -e "cpu-features.c" ]; then
echo "CPU FEATURES: cpu-features.h and cpu-features.c are present"
fi
fi
#####################################################################
COUNT=$(echo -n "$AOSP_STL_LIB" | egrep -i -c 'libstdc\+\+')
if [[ ("$COUNT" -ne "0") ]]; then
echo
echo "*******************************************************************************"
echo "You are using GNU's runtime and STL library. Please ensure the resulting"
echo "binary meets licensing requirements. If you can't use GNU's runtime"
echo "and STL library, then reconfigure with stlport or llvm. Also see"
echo "http://code.google.com/p/android/issues/detail?id=216331"
echo "*******************************************************************************"
fi
COUNT=$(echo -n "$AOSP_STL_LIB" | grep -i -c 'libstlport')
if [[ ("$COUNT" -ne "0") ]]; then
echo
echo "*******************************************************************************"
echo "You are using STLport's runtime and STL library. STLport could cause problems"
echo "if the resulting binary is used in other environments, like a QT project."
echo "Also see http://code.google.com/p/android/issues/detail?id=216331"
echo "*******************************************************************************"
fi
COUNT=$(echo -n "$AOSP_STL_LIB" | egrep -i -c 'libc\+\+')
if [[ ("$COUNT" -ne "0") ]]; then
echo
echo "*******************************************************************************"
echo "You are using LLVM's runtime and STL library. LLVM could cause problems"
echo "if the resulting binary is used in other environments, like a QT project."
echo "Also see http://code.google.com/p/android/issues/detail?id=216331"
echo "*******************************************************************************"
fi
echo
echo "*******************************************************************************"
echo "It looks the the environment is set correctly. Your next step is build"
echo "the library with 'make -f GNUmakefile-cross'. You can create a versioned"
echo "shared object using 'HAS_SOLIB_VERSION=1 make -f GNUmakefile-cross'"
echo "*******************************************************************************"
echo
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0

View File

@ -1,430 +0,0 @@
#!/usr/bin/env bash
# ====================================================================
# Sets the cross compile environment for Android
# Based upon OpenSSL's setenv-android.sh (by TH, JW, and SM).
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# This script is the one used from about 2012 until late 2017. Sometime in
# 2017 AOSP made some NDK changes that were incompatible with the original
# script. The original setenv-android.sh was renamed to setenv-android-old.sh,
# and it can be used on older NDKs like r9 or r13. setenv-android.sh was then
# reworked for newer NDKs, like r16. setenv-android.sh effectively supports
# the latest NDKs. Also see https://github.com/weidai11/cryptopp/pull/546.
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
# ====================================================================
# set -eu
unset IS_CROSS_COMPILE
unset IS_IOS
unset IS_ANDROID
unset IS_ARM_EMBEDDED
# Variables used in GNUmakefile-cross
unset AOSP_FLAGS
unset AOSP_SYSROOT
unset AOSP_STL_INC
unset AOSP_STL_LIB
unset AOSP_BITS_INC
# Tools set by this script
unset CPP CC CXX LD AS AR RANLIB STRIP
# Similar to a "make clean"
if [ x"${1-}" = "xunset" ]; then
echo "Unsetting script variables. PATH may remain tainted"
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0
fi
# Set AOSP_TOOLCHAIN_SUFFIX to your preference of tools and STL library.
# Note: 4.9 is required for the latest architectures, like ARM64/AARCH64.
# AOSP_TOOLCHAIN_SUFFIX=4.8
# AOSP_TOOLCHAIN_SUFFIX=4.9
if [ -z "${AOSP_TOOLCHAIN_SUFFIX-}" ]; then
AOSP_TOOLCHAIN_SUFFIX=4.9
fi
# Set AOSP_API to the API you want to use. 'armeabi' and 'armeabi-v7a' need
# API 3 (or above), 'mips' and 'x86' need API 9 (or above), etc.
# AOSP_API="android-3" # Android 1.5 and above
# AOSP_API="android-4" # Android 1.6 and above
# AOSP_API="android-5" # Android 2.0 and above
# AOSP_API="android-8" # Android 2.2 and above
# AOSP_API="android-9" # Android 2.3 and above
# AOSP_API="android-14" # Android 4.0 and above
# AOSP_API="android-18" # Android 4.3 and above
# AOSP_API="android-19" # Android 4.4 and above
# AOSP_API="android-21" # Android 5.0 and above
# AOSP_API="android-23" # Android 6.0 and above
if [ -z "${AOSP_API-}" ]; then
AOSP_API="android-21"
fi
#####################################################################
# ANDROID_NDK_ROOT should always be set by the user (even when not running this script)
# http://groups.google.com/group/android-ndk/browse_thread/thread/a998e139aca71d77.
# If the user did not specify the NDK location, try and pick it up. We expect something
# like ANDROID_NDK_ROOT=/opt/android-ndk-r10e or ANDROID_NDK_ROOT=/usr/local/android-ndk-r10e.
if [ -z "${ANDROID_NDK_ROOT-}" ]; then
ANDROID_NDK_ROOT=$(find /opt -maxdepth 1 -type d -name android-ndk* 2>/dev/null | tail -1)
if [ -z "$ANDROID_NDK_ROOT" ]; then
ANDROID_NDK_ROOT=$(find /usr/local -maxdepth 1 -type d -name android-ndk* 2>/dev/null | tail -1)
fi
if [ -z "$ANDROID_NDK_ROOT" ]; then
ANDROID_NDK_ROOT=$(find $HOME -maxdepth 1 -type d -name android-ndk* 2>/dev/null | tail -1)
fi
if [ -d "$HOME/Library/Android/sdk/ndk-bundle" ]; then
ANDROID_NDK_ROOT="$HOME/Library/Android/sdk/ndk-bundle"
fi
fi
# Error checking
if [ ! -d "$ANDROID_NDK_ROOT/toolchains" ]; then
echo "ERROR: ANDROID_NDK_ROOT is not a valid path. Please set it."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
#####################################################################
if [ "$#" -lt 1 ]; then
THE_ARCH=armv7a-neon
else
THE_ARCH=$(tr [A-Z] [a-z] <<< "$1")
fi
# https://developer.android.com/ndk/guides/abis.html
case "$THE_ARCH" in
arm|armv5|armv6|armv7|armeabi)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi"
AOSP_ARCH="arch-arm"
AOSP_FLAGS="-march=armv5te -mtune=xscale -mthumb -msoft-float -DCRYPTOPP_DISABLE_ASM -funwind-tables -fexceptions -frtti"
;;
armv7a|armv7-a|armeabi-v7a)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
AOSP_FLAGS="-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -DCRYPTOPP_DISABLE_ASM -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
;;
hard|armv7a-hard|armeabi-v7a-hard)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
AOSP_FLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfpu=vfpv3-d16 -DCRYPTOPP_DISABLE_ASM -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti -Wl,--no-warn-mismatch -Wl,-lm_hard"
;;
neon|armv7a-neon)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
AOSP_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
;;
armv8|armv8a|aarch64|arm64|arm64-v8a)
TOOLCHAIN_ARCH="aarch64-linux-android"
TOOLCHAIN_NAME="aarch64-linux-android"
AOSP_ABI="arm64-v8a"
AOSP_ARCH="arch-arm64"
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
;;
mips|mipsel)
TOOLCHAIN_ARCH="mipsel-linux-android"
TOOLCHAIN_NAME="mipsel-linux-android"
AOSP_ABI="mips"
AOSP_ARCH="arch-mips"
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
;;
mips64|mipsel64|mips64el)
TOOLCHAIN_ARCH="mips64el-linux-android"
TOOLCHAIN_NAME="mips64el-linux-android"
AOSP_ABI="mips64"
AOSP_ARCH="arch-mips64"
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
;;
x86)
TOOLCHAIN_ARCH="x86"
TOOLCHAIN_NAME="i686-linux-android"
AOSP_ABI="x86"
AOSP_ARCH="arch-x86"
AOSP_FLAGS="-mtune=intel -mssse3 -mfpmath=sse -funwind-tables -fexceptions -frtti"
;;
x86_64|x64)
TOOLCHAIN_ARCH="x86_64"
TOOLCHAIN_NAME="x86_64-linux-android"
AOSP_ABI="x86_64"
AOSP_ARCH="arch-x86_64"
AOSP_FLAGS="-march=x86-64 -msse4.2 -mpopcnt -mtune=intel -funwind-tables -fexceptions -frtti"
;;
*)
echo "ERROR: Unknown architecture $1"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
;;
esac
#####################################################################
# GNUmakefile-cross expects these to be set. They are also used in the tests below.
export IS_ANDROID=1
export AOSP_FLAGS
export CPP="$TOOLCHAIN_NAME-cpp"
export CC="$TOOLCHAIN_NAME-gcc"
export CXX="$TOOLCHAIN_NAME-g++"
export LD="$TOOLCHAIN_NAME-ld"
export AS="$TOOLCHAIN_NAME-as"
export AR="$TOOLCHAIN_NAME-ar"
export RANLIB="$TOOLCHAIN_NAME-ranlib"
export STRIP="$TOOLCHAIN_NAME-strip"
#####################################################################
# Based on ANDROID_NDK_ROOT, try and pick up the path for the tools. We expect something
# like /opt/android-ndk-r10e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin
# Once we locate the tools, we add it to the PATH.
AOSP_TOOLCHAIN_PATH=""
for host in "linux-x86_64" "darwin-x86_64" "linux-x86" "darwin-x86"
do
if [ -d "$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_ARCH-$AOSP_TOOLCHAIN_SUFFIX/prebuilt/$host/bin" ]; then
AOSP_TOOLCHAIN_PATH="$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_ARCH-$AOSP_TOOLCHAIN_SUFFIX/prebuilt/$host/bin"
break
fi
done
# Error checking
if [ -z "$AOSP_TOOLCHAIN_PATH" ] || [ ! -d "$AOSP_TOOLCHAIN_PATH" ]; then
echo "ERROR: AOSP_TOOLCHAIN_PATH is not valid. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CPP" ]; then
echo "ERROR: Failed to find Android cpp. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CC" ]; then
echo "ERROR: Failed to find Android gcc. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CXX" ]; then
echo "ERROR: Failed to find Android g++. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$RANLIB" ]; then
echo "ERROR: Failed to find Android ranlib. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$AR" ]; then
echo "ERROR: Failed to find Android ar. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$AS" ]; then
echo "ERROR: Failed to find Android as. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$LD" ]; then
echo "ERROR: Failed to find Android ld. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Only modify/export PATH if AOSP_TOOLCHAIN_PATH good
if [ -d "$AOSP_TOOLCHAIN_PATH" ]; then
# And only modify PATH if AOSP_TOOLCHAIN_PATH is not present
LEN=${#AOSP_TOOLCHAIN_PATH}
SUBSTR=${PATH:0:$LEN}
if [ "$SUBSTR" != "$AOSP_TOOLCHAIN_PATH" ]; then
export PATH="$AOSP_TOOLCHAIN_PATH":"$PATH"
fi
fi
#####################################################################
# Error checking
if [ ! -d "$ANDROID_NDK_ROOT/platforms/$AOSP_API" ]; then
echo "ERROR: AOSP_API is not valid. Does the NDK support the API? Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
elif [ ! -d "$ANDROID_NDK_ROOT/platforms/$AOSP_API/$AOSP_ARCH" ]; then
echo "ERROR: AOSP_ARCH is not valid. Does the NDK support the architecture? Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Android SYSROOT. It will be used on the command line with --sysroot
# http://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
export AOSP_SYSROOT="$ANDROID_NDK_ROOT/platforms/$AOSP_API/$AOSP_ARCH"
#####################################################################
# Android STL. We support GNU, LLVM and STLport out of the box.
if [ "$#" -lt 2 ]; then
THE_STL=gnu-shared
else
THE_STL=$(tr [A-Z] [a-z] <<< "$2")
fi
# LLVM include directory may be different depending on NDK version. Default to new location (latest NDK checked: r16beta1).
LLVM_INCLUDE_DIR="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include"
if [ ! -d "$LLVM_INCLUDE_DIR" ]; then
LLVM_INCLUDE_DIR="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libcxx/include"
fi
case "$THE_STL" in
stlport-static)
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport/"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/$AOSP_ABI/libstlport_static.a"
;;
stlport|stlport-shared)
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport/"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/$AOSP_ABI/libstlport_shared.so"
;;
gabi++-static|gnu-static)
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/include"
AOSP_BITS_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/include"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/libgnustl_static.a"
;;
gnu|gabi++|gnu-shared|gabi++-shared)
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/include"
AOSP_BITS_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/include"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/libgnustl_shared.so"
;;
llvm-static)
if [ ! -d "$LLVM_INCLUDE_DIR" ]; then
echo "ERROR: Unable to locate include LLVM directory at $LLVM_INCLUDE_DIR -- has it moved since NDK r16beta1?"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
AOSP_STL_INC="$LLVM_INCLUDE_DIR"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libs/$AOSP_ABI/libc++_static.a"
;;
llvm|llvm-shared)
if [ ! -d "$LLVM_INCLUDE_DIR" ]; then
echo "ERROR: Unable to locate LLVM include directory at $LLVM_INCLUDE_DIR -- has it moved since NDK r16beta1?"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
AOSP_STL_INC="$LLVM_INCLUDE_DIR"
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libs/$AOSP_ABI/libc++_shared.so"
;;
*)
echo "ERROR: Unknown STL library $2"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
esac
# Error checking
if [ ! -d "$AOSP_STL_INC" ] || [ ! -e "$AOSP_STL_INC/memory" ]; then
echo "ERROR: AOSP_STL_INC is not valid. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "$AOSP_STL_LIB" ]; then
echo "ERROR: AOSP_STL_LIB is not valid. Please edit this script."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
export AOSP_STL_INC
export AOSP_STL_LIB
if [ ! -z "$AOSP_BITS_INC" ]; then
export AOSP_BITS_INC
fi
# Now that we are using cpu-features from Android rather than CPU probing, we
# need to copy cpu-features.h and cpu-features.c from the NDK into our source
# directory and then build it.
if [[ ! -e "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" ]]; then
echo "ERROR: Unable to locate cpu-features.h"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
cp "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.h" .
if [[ ! -e "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" ]]; then
echo "ERROR: Unable to locate cpu-features.c"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
cp "$ANDROID_NDK_ROOT/sources/android/cpufeatures/cpu-features.c" .
#####################################################################
VERBOSE=1
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" != "0" ]; then
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
echo "AOSP_TOOLCHAIN_PATH: $AOSP_TOOLCHAIN_PATH"
echo "AOSP_ABI: $AOSP_ABI"
echo "AOSP_API: $AOSP_API"
echo "AOSP_SYSROOT: $AOSP_SYSROOT"
echo "AOSP_FLAGS: $AOSP_FLAGS"
echo "AOSP_STL_INC: $AOSP_STL_INC"
echo "AOSP_STL_LIB: $AOSP_STL_LIB"
if [ ! -z "$AOSP_BITS_INC" ]; then
echo "AOSP_BITS_INC: $AOSP_BITS_INC"
fi
if [ -e "cpu-features.h" ] && [ -e "cpu-features.c" ]; then
echo "CPU FEATURES: cpu-features.h and cpu-features.c are present"
fi
fi
#####################################################################
COUNT=$(echo -n "$AOSP_STL_LIB" | egrep -i -c 'libstdc\+\+')
if [[ ("$COUNT" -ne "0") ]]; then
echo
echo "*******************************************************************************"
echo "You are using GNU's runtime and STL library. Please ensure the resulting"
echo "binary meets licensing requirements. If you can't use GNU's runtime"
echo "and STL library, then reconfigure with stlport or llvm. Also see"
echo "http://code.google.com/p/android/issues/detail?id=216331"
echo "*******************************************************************************"
fi
COUNT=$(echo -n "$AOSP_STL_LIB" | grep -i -c 'libstlport')
if [[ ("$COUNT" -ne "0") ]]; then
echo
echo "*******************************************************************************"
echo "You are using STLport's runtime and STL library. STLport could cause problems"
echo "if the resulting binary is used in other environments, like a QT project."
echo "Also see http://code.google.com/p/android/issues/detail?id=216331"
echo "*******************************************************************************"
fi
COUNT=$(echo -n "$AOSP_STL_LIB" | egrep -i -c 'libc\+\+')
if [[ ("$COUNT" -ne "0") ]]; then
echo
echo "*******************************************************************************"
echo "You are using LLVM's runtime and STL library. LLVM could cause problems"
echo "if the resulting binary is used in other environments, like a QT project."
echo "Also see http://code.google.com/p/android/issues/detail?id=216331"
echo "*******************************************************************************"
fi
echo
echo "*******************************************************************************"
echo "It looks the the environment is set correctly. Your next step is build"
echo "the library with 'make -f GNUmakefile-cross'. You can create a versioned"
echo "shared object using 'HAS_SOLIB_VERSION=1 make -f GNUmakefile-cross'"
echo "*******************************************************************************"
echo
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0

View File

@ -0,0 +1,364 @@
#!/usr/bin/env bash
#############################################################################
#
# This script sets the cross-compile environment for Android.
#
# Based upon OpenSSL's setenv-android.sh by TH, JW, and SM.
# Heavily modified by JWW for Crypto++.
# Modified by Skycoder42 Android NDK-r19 and above.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# Also see:
# https://android.googlesource.com/platform/ndk.git/+/HEAD/docs/UnifiedHeaders.md
# https://android.googlesource.com/platform/ndk/+/master/docs/PlatformApis.md
# https://developer.android.com/ndk/guides/abis.html and
# https://developer.android.com/ndk/guides/cpp-support.
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
#############################################################################
#########################################
##### Some validation #####
#########################################
# cryptest-android.sh may run this script without sourcing.
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
echo "setenv-android.sh is usually sourced, but not this time."
fi
# This supports both 'source setenv-android.sh 21 arm64' and
# 'source setenv-android.sh ANDROID_API=21 ANDROID_CPU=arm64'
if [[ -n "$1" ]]
then
arg1=$(echo "$1" | cut -f 1 -d '=')
arg2=$(echo "$1" | cut -f 2 -d '=')
if [[ -n "${arg2}" ]]; then
ANDROID_API="${arg2}"
else
ANDROID_API="${arg1}"
fi
printf "Using positional arg, ANDROID_API=%s\n" "${ANDROID_API}"
fi
# This supports both 'source setenv-android.sh 21 arm64' and
# 'source setenv-android.sh ANDROID_API=21 ANDROID_CPU=arm64'
if [[ -n "$2" ]]
then
arg1=$(echo "$2" | cut -f 1 -d '=')
arg2=$(echo "$2" | cut -f 2 -d '=')
if [[ -n "${arg2}" ]]; then
ANDROID_CPU="${arg2}"
else
ANDROID_CPU="${arg1}"
fi
printf "Using positional arg, ANDROID_CPU=%s\n" "${ANDROID_CPU}"
fi
if [ -z "${ANDROID_API}" ]; then
echo "ANDROID_API is not set. Please set it"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ -z "${ANDROID_CPU}" ]; then
echo "ANDROID_CPU is not set. Please set it"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#########################################
##### Clear old options #####
#########################################
unset IS_IOS
unset IS_ANDROID
unset IS_ARM_EMBEDDED
unset ANDROID_CPPFLAGS
unset ANDROID_CXXFLAGS
unset ANDROID_LDFLAGS
unset ANDROID_SYSROOT
#####################################################################
# ANDROID_NDK_ROOT should always be set by the user (even when not running this script)
# http://groups.google.com/group/android-ndk/browse_thread/thread/a998e139aca71d77.
# If the user did not specify the NDK location, try and pick it up. Something like
# ANDROID_NDK_ROOT=/opt/android-ndk-r19c or ANDROID_NDK_ROOT=/usr/local/android-ndk-r20.
if [ -n "${ANDROID_NDK_ROOT}" ]; then
echo "ANDROID_NDK_ROOT is ${ANDROID_NDK_ROOT}"
else
echo "ANDROID_NDK_ROOT is empty. Searching for the NDK"
ANDROID_NDK_ROOT=$(find /opt -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
if [ -z "${ANDROID_NDK_ROOT}" ]; then
ANDROID_NDK_ROOT=$(find /usr/local -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
fi
if [ -z "${ANDROID_NDK_ROOT}" ]; then
ANDROID_NDK_ROOT=$(find "$HOME" -maxdepth 1 -type d -name "android-ndk*" 2>/dev/null | tail -n -1)
fi
if [ -d "$HOME/Library/Android/sdk/ndk-bundle" ]; then
ANDROID_NDK_ROOT="$HOME/Library/Android/sdk/ndk-bundle"
fi
fi
# Error checking
if [ ! -d "${ANDROID_NDK_ROOT}" ]; then
echo "ERROR: ANDROID_NDK_ROOT is not a valid path for ${USER}. Please set it."
echo "ANDROID_NDK_ROOT is '${ANDROID_NDK_ROOT}'"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -d "${ANDROID_SDK_ROOT}" ]; then
echo "ERROR: ANDROID_SDK_ROOT is not a valid path for ${USER}. Please set it."
echo "ANDROID_SDK_ROOT is '${ANDROID_SDK_ROOT}'"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# User feedback
#echo "ANDROID_NDK_ROOT is '${ANDROID_NDK_ROOT}'"
#echo "ANDROID_SDK_ROOT is '${ANDROID_SDK_ROOT}'"
#####################################################################
# Need to set HOST_TAG to darwin-x86_64, linux-x86_64,
# windows, or windows-x86_64
if [[ "$(uname -s | grep -i -c darwin)" -ne 0 ]]; then
HOST_TAG=darwin-x86_64
elif [[ "$(uname -s | grep -i -c linux)" -ne 0 ]]; then
HOST_TAG=linux-x86_64
else
echo "ERROR: Unknown host"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
ANDROID_TOOLCHAIN="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${HOST_TAG}/bin"
ANDROID_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${HOST_TAG}/sysroot"
# Error checking
if [ ! -d "${ANDROID_TOOLCHAIN}" ]; then
echo "ERROR: ANDROID_TOOLCHAIN is not a valid path. Please set it."
echo "ANDROID_TOOLCHAIN is '${ANDROID_TOOLCHAIN}'"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -d "${ANDROID_SYSROOT}" ]; then
echo "ERROR: ANDROID_SYSROOT is not a valid path. Please set it."
echo "ANDROID_SYSROOT is '${ANDROID_SYSROOT}'"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#####################################################################
THE_ARCH=$(tr '[:upper:]' '[:lower:]' <<< "${ANDROID_CPU}")
# https://developer.android.com/ndk/guides/abis.html and
# https://developer.android.com/ndk/guides/cpp-support.
# Since NDK r16 the only STL available is libc++, so we
# add -std=c++11 -stdlib=libc++ to CXXFLAGS. This is
# consistent with Android.mk and 'APP_STL := c++_shared'.
case "$THE_ARCH" in
armv7*|armeabi*)
CC="armv7a-linux-androideabi${ANDROID_API}-clang"
CXX="armv7a-linux-androideabi${ANDROID_API}-clang++"
LD="arm-linux-androideabi-ld"
AS="arm-linux-androideabi-as"
AR="arm-linux-androideabi-ar"
RANLIB="arm-linux-androideabi-ranlib"
STRIP="arm-linux-androideabi-strip"
# You may need this on older NDKs
# ANDROID_CPPFLAGS="-D__ANDROID__=${ANDROID_API}"
# Android NDK r19 and r20 no longer use -mfloat-abi=softfp. Add it as required.
ANDROID_CXXFLAGS="-target armv7-none-linux-androideabi${ANDROID_API} -std=c++11 -stdlib=libc++"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -march=armv7-a -mthumb"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -fstack-protector-strong -funwind-tables -fexceptions -frtti"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -fno-addrsig -fno-experimental-isel"
;;
armv8*|aarch64|arm64*)
CC="aarch64-linux-android${ANDROID_API}-clang"
CXX="aarch64-linux-android${ANDROID_API}-clang++"
LD="aarch64-linux-android-ld"
AS="aarch64-linux-android-as"
AR="aarch64-linux-android-ar"
RANLIB="aarch64-linux-android-ranlib"
STRIP="aarch64-linux-android-strip"
# You may need this on older NDKs
# ANDROID_CPPFLAGS="-D__ANDROID__=${ANDROID_API}"
ANDROID_CXXFLAGS="-target aarch64-none-linux-android${ANDROID_API}"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -std=c++11 -stdlib=libc++"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -fstack-protector-strong -funwind-tables -fexceptions -frtti"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -fno-addrsig -fno-experimental-isel"
;;
i686|x86)
CC="i686-linux-android${ANDROID_API}-clang"
CXX="i686-linux-android${ANDROID_API}-clang++"
LD="i686-linux-android-ld"
AS="i686-linux-android-as"
AR="i686-linux-android-ar"
RANLIB="i686-linux-android-ranlib"
STRIP="i686-linux-android-strip"
# You may need this on older NDKs
# ANDROID_CPPFLAGS="-D__ANDROID__=${ANDROID_API}"
ANDROID_CXXFLAGS="-target i686-none-linux-android${ANDROID_API}"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -std=c++11 -stdlib=libc++"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -mtune=intel -mssse3 -mfpmath=sse"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -fstack-protector-strong -funwind-tables -fexceptions -frtti"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -fno-addrsig -fno-experimental-isel"
;;
x86_64|x64)
CC="x86_64-linux-android${ANDROID_API}-clang"
CXX="x86_64-linux-android${ANDROID_API}-clang++"
LD="x86_64-linux-android-ld"
AS="x86_64-linux-android-as"
AR="x86_64-linux-android-ar"
RANLIB="x86_64-linux-android-ranlib"
STRIP="x86_64-linux-android-strip"
# You may need this on older NDKs
# ANDROID_CPPFLAGS="-D__ANDROID__=${ANDROID_API}"
ANDROID_CXXFLAGS="-target x86_64-none-linux-android${ANDROID_API}"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -std=c++11 -stdlib=libc++"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -march=x86-64 -msse4.2 -mpopcnt -mtune=intel"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -fstack-protector-strong -funwind-tables -fexceptions -frtti"
ANDROID_CXXFLAGS="${ANDROID_CXXFLAGS} -fno-addrsig -fno-experimental-isel"
;;
*)
echo "ERROR: Unknown architecture ${ANDROID_CPU}"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
;;
esac
#####################################################################
# GNUmakefile-cross and Autotools expect these to be set.
# They are also used in the tests below.
export IS_ANDROID=1
export CPP CC CXX LD AS AR RANLIB STRIP
export ANDROID_CPPFLAGS ANDROID_CXXFLAGS ANDROID_LDFLAGS
export ANDROID_API ANDROID_CPU ANDROID_SYSROOT
# Do NOT use ANDROID_SYSROOT_INC or ANDROID_SYSROOT_LD
# https://github.com/android/ndk/issues/894#issuecomment-470837964
#####################################################################
# Error checking
if [ ! -e "${ANDROID_TOOLCHAIN}/$CC" ]; then
echo "ERROR: Failed to find Android clang. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "${ANDROID_TOOLCHAIN}/$CXX" ]; then
echo "ERROR: Failed to find Android clang++. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "${ANDROID_TOOLCHAIN}/$RANLIB" ]; then
echo "ERROR: Failed to find Android ranlib. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "${ANDROID_TOOLCHAIN}/$AR" ]; then
echo "ERROR: Failed to find Android ar. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "${ANDROID_TOOLCHAIN}/$AS" ]; then
echo "ERROR: Failed to find Android as. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Error checking
if [ ! -e "${ANDROID_TOOLCHAIN}/$LD" ]; then
echo "ERROR: Failed to find Android ld. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#####################################################################
# Add tools to head of path, if not present already
LENGTH=${#ANDROID_TOOLCHAIN}
SUBSTR=${PATH:0:$LENGTH}
if [ "$SUBSTR" != "${ANDROID_TOOLCHAIN}" ]; then
export PATH="${ANDROID_TOOLCHAIN}:$PATH"
fi
#####################################################################
# Now that we are using cpu-features from Android rather than
# CPU probing, we need to copy cpu-features.h and cpu-features.c
# from the NDK into our source directory and then build it.
if [[ ! -e "${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.h" ]]; then
echo "ERROR: Unable to locate cpu-features.h"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [[ ! -e "${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.c" ]]; then
echo "ERROR: Unable to locate cpu-features.c"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
cp "${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.h" .
cp "${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.c" .
# Cleanup the sources for the C++ compiler
# https://github.com/weidai11/cryptopp/issues/926
sed -e 's/= memmem/= (const char*)memmem/g' \
-e 's/= memchr/= (const char*)memchr/g' \
-e 's/= malloc/= (char*)malloc/g' \
cpu-features.c > cpu-features.c.fixed
mv cpu-features.c.fixed cpu-features.c
# Fix permissions. For some reason cpu-features.h is +x.
chmod u=rw,go=r cpu-features.h cpu-features.c
#####################################################################
VERBOSE=${VERBOSE:-1}
if [ "$VERBOSE" -gt 0 ]; then
echo "ANDROID_TOOLCHAIN: ${ANDROID_TOOLCHAIN}"
echo "ANDROID_API: ${ANDROID_API}"
echo "ANDROID_CPU: ${ANDROID_CPU}"
echo "ANDROID_SYSROOT: ${ANDROID_SYSROOT}"
if [ -n "${ANDROID_CPPFLAGS}" ]; then
echo "ANDROID_CPPFLAGS: ${ANDROID_CPPFLAGS}"
fi
echo "ANDROID_CXXFLAGS: ${ANDROID_CXXFLAGS}"
if [ -n "${ANDROID_LDFLAGS}" ]; then
echo "ANDROID_LDFLAGS: ${ANDROID_LDFLAGS}"
fi
if [ -e "cpu-features.h" ] && [ -e "cpu-features.c" ]; then
echo "CPU FEATURES: cpu-features.h and cpu-features.c are present"
fi
fi
#####################################################################
echo
echo "*******************************************************************************"
echo "It looks the the environment is set correctly. Your next step is build"
echo "the library with 'make -f GNUmakefile-cross'."
echo "*******************************************************************************"
echo
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 0 || return 0

View File

@ -1,19 +1,23 @@
#!/usr/bin/env bash
# ====================================================================
# Sets the cross compile environment for ARM Embedded
#############################################################################
#
# Written by Jeffrey Walton, noloader gmail account
# This script sets the cross-compile environment for ARM embedded.
#
# Based upon OpenSSL's setenv-android.sh by TH, JW, and SM.
# Heavily modified by JWW for Crypto++.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# This script only supports Ubuntu at the moment. It does not support Fedora.
# See http://www.cryptopp.com/wiki/ARM_Embedded_(Command_Line) for details.
# ====================================================================
#############################################################################
# set -eu
# cryptest-embedded.sh may run this script without sourcing.
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
echo "setenv-embedded.sh is usually sourced, but not this time."
fi
# Unset old options
@ -29,7 +33,7 @@ fi
if [ ! -d "$ARM_EMBEDDED_TOOLCHAIN" ]; then
echo "ARM_EMBEDDED_TOOLCHAIN is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Fedora
@ -50,37 +54,37 @@ export RANLIB="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-ranlib"
# Test a few of the tools
if [ ! -e "$CPP" ]; then
echo "ERROR: CPP is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$CC" ]; then
echo "ERROR: CC is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$CXX" ]; then
echo "ERROR: CXX is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$AR" ]; then
echo "ERROR: AR is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$AS" ]; then
echo "ERROR: AS is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$RANLIB" ]; then
echo "ERROR: RANLIB is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -e "$LD" ]; then
echo "ERROR: LD is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# The Crypto++ Makefile uses these to disable host settings like
@ -94,7 +98,7 @@ fi
if [ ! -d "$ARM_EMBEDDED_SYSROOT" ]; then
echo "ERROR: ARM_EMBEDDED_SYSROOT is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Fix C++ header paths for Ubuntu
@ -104,12 +108,12 @@ ARM_EMBEDDED_CXX_HEADERS="$ARM_EMBEDDED_SYSROOT/include/c++/$ARM_EMBEDDED_TOOLCH
if [ ! -d "$ARM_EMBEDDED_CXX_HEADERS" ]; then
echo "ERROR: ARM_EMBEDDED_CXX_HEADERS is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ ! -d "$ARM_EMBEDDED_CXX_HEADERS/arm-linux-gnueabi" ]; then
echo "ERROR: ARM_EMBEDDED_CXX_HEADERS is not valid"
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Finally, the flags...
@ -121,8 +125,8 @@ if [ -z "$ARM_EMBEDDED_FLAGS" ]; then
fi
# And print stuff to wow the user...
VERBOSE=1
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" -ne 0 ]; then
VERBOSE=${VERBOSE:-1}
if [ "$VERBOSE" -gt 0 ]; then
echo "CPP: $CPP"
echo "CXX: $CXX"
echo "AR: $AR"
@ -137,9 +141,8 @@ fi
echo
echo "*******************************************************************************"
echo "It looks the the environment is set correctly. Your next step is build"
echo "the library with 'make -f GNUmakefile-cross'. You can create a versioned"
echo "shared object using 'HAS_SOLIB_VERSION=1 make -f GNUmakefile-cross'"
echo "the library with 'make -f GNUmakefile-cross'."
echo "*******************************************************************************"
echo
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 0 || return 0

View File

@ -1,194 +1,230 @@
#!/usr/bin/env bash
# ====================================================================
# Sets the cross compile environment for Xcode/iOS
# Based upon OpenSSL's setenv-ios.sh (by TH, JW, and SM).
#############################################################################
#
# This script sets the cross-compile environment for Xcode/iOS.
#
# Based upon OpenSSL's setenv-android.sh by TH, JW, and SM.
# Heavily modified by JWW for Crypto++.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/iOS_(Command_Line) for more details
# ====================================================================
#############################################################################
# set -eu
#########################################
##### Some validation #####
#########################################
# In the past we could mostly infer arch or cpu from the SDK (and mostly
# vice-versa). Nowadays we need the user to set it for us because Apple
# platforms have both 32-bit or 64-bit variations.
# cryptest-ios.sh may run this script without sourcing.
if [ "$0" = "${BASH_SOURCE[0]}" ]; then
echo "setenv-ios.sh is usually sourced, but not this time."
fi
# This supports 'source setenv-ios.sh iPhone arm64' and
# 'source setenv-ios.sh IOS_SDK=iPhone IOS_CPU=arm64'
if [[ -n "$1" ]]
then
arg1=$(echo "$1" | cut -f 1 -d '=')
arg2=$(echo "$1" | cut -f 2 -d '=')
if [[ -n "${arg2}" ]]; then
IOS_SDK="${arg2}"
else
IOS_SDK="${arg1}"
fi
printf "Using positional arg, IOS_SDK=%s\n" "${IOS_SDK}"
fi
# This supports 'source setenv-ios.sh iPhone arm64' and
# 'source setenv-ios.sh IOS_SDK=iPhone IOS_CPU=arm64'
if [[ -n "$2" ]]
then
arg1=$(echo "$2" | cut -f 1 -d '=')
arg2=$(echo "$2" | cut -f 2 -d '=')
if [[ -n "${arg2}" ]]; then
IOS_CPU="${arg2}"
else
IOS_CPU="${arg1}"
fi
printf "Using positional arg, IOS_CPU=%s\n" "${IOS_CPU}"
fi
if [ -z "$IOS_SDK" ]; then
echo "IOS_SDK is not set. Please set it"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
if [ -z "$IOS_CPU" ]; then
echo "IOS_CPU is not set. Please set it"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#########################################
##### Clear old options #####
#########################################
unset IS_CROSS_COMPILE
unset IS_IOS
unset IS_ANDROID
unset IS_ARM_EMBEDDED
unset IOS_ARCH
unset IOS_FLAGS
unset IOS_CXXFLAGS
unset IOS_SYSROOT
#########################################
##### User configurable options #####
##### Small Fixups, if needed #####
#########################################
# Define SETENV_VERBOSE=1 to print the configuration, including exported variables.
SETENV_VERBOSE=1
if [[ "$IOS_SDK" == "iPhone" ]]; then
IOS_SDK=iPhoneOS
fi
# For various SDKs, see https://groups.google.com/d/msg/cryptopp-users/8Z0qfwAjSbA/nKYbhTNBBgAJ
if [[ "$IOS_SDK" == "iPhoneOSSimulator" ]]; then
IOS_SDK=iPhoneSimulator
fi
if [[ "$IOS_SDK" == "TV" || "$IOS_SDK" == "AppleTV" ]]; then
IOS_SDK=AppleTVOS
fi
if [[ "$IOS_SDK" == "Watch" || "$IOS_SDK" == "AppleWatch" ]]; then
IOS_SDK=WatchOS
fi
if [[ "$IOS_CPU" == "aarch64" || "$IOS_CPU" == "arm64"* || "$IOS_CPU" == "armv8"* ]] ; then
IOS_CPU=arm64
fi
########################################
##### Command line #####
##### Environment #####
########################################
APPLE_SDK=
IOS_ARCH=
BACK_ARCH=
# The flags below were tested with Xcode 8 on Travis. If
# you use downlevel versions of Xcode, then you can push
# xxx-version-min=n lower. For example, Xcode 7 can use
# -miphoneos-version-min=5. However, Xcode 7 lacks
# AppleTVOS and WatchOS support.
for ARG in "$@"
do
CL=$(echo $ARG | tr '[A-Z]' '[a-z]')
# iPhones can be either 32-bit or 64-bit
if [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == "armv7"* ]]; then
MIN_VER=-miphoneos-version-min=6
elif [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == "arm64" ]]; then
MIN_VER=-miphoneos-version-min=6
# i386 (simulator)
if [ "$CL" == "i386" ]; then
BACK_ARCH=i386
APPLE_SDK=iPhoneSimulator
# Fixups for convenience
elif [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == "i386" ]]; then
IOS_SDK=iPhoneSimulator
# MIN_VER=-miphoneos-version-min=6
MIN_VER=-miphonesimulator-version-min=6
elif [[ "$IOS_SDK" == "iPhoneOS" && "$IOS_CPU" == "x86_64" ]]; then
IOS_SDK=iPhoneSimulator
# MIN_VER=-miphoneos-version-min=6
MIN_VER=-miphonesimulator-version-min=6
# Simulator builds
elif [[ "$IOS_SDK" == "iPhoneSimulator" && "$IOS_CPU" == "i386" ]]; then
MIN_VER=-miphonesimulator-version-min=6
elif [[ "$IOS_SDK" == "iPhoneSimulator" && "$IOS_CPU" == "x86_64" ]]; then
MIN_VER=-miphonesimulator-version-min=6
# Apple TV can be 32-bit Intel (1st gen), 32-bit ARM (2nd, 3rd gen) or 64-bit ARM (4th gen)
elif [[ "$IOS_SDK" == "AppleTVOS" && "$IOS_CPU" == "i386" ]]; then
MIN_VER=-mappletvos-version-min=6
elif [[ "$IOS_SDK" == "AppleTVOS" && "$IOS_CPU" == "armv7"* ]]; then
MIN_VER=-mappletvos-version-min=6
elif [[ "$IOS_SDK" == "AppleTVOS" && "$IOS_CPU" == "arm64" ]]; then
MIN_VER=-mappletvos-version-min=6
# Simulator builds
elif [[ "$IOS_SDK" == "AppleTVSimulator" && "$IOS_CPU" == "i386" ]]; then
MIN_VER=-mappletvsimulator-version-min=6
elif [[ "$IOS_SDK" == "AppleTVSimulator" && "$IOS_CPU" == "x86_64" ]]; then
MIN_VER=-mappletvsimulator-version-min=6
# Watch can be either 32-bit or 64-bit ARM. TODO: figure out which
# -mwatchos-version-min=n is needed for arm64. 9 is not enough.
elif [[ "$IOS_SDK" == "WatchOS" && "$IOS_CPU" == "armv7"* ]]; then
MIN_VER=-mwatchos-version-min=6
elif [[ "$IOS_SDK" == "WatchOS" && "$IOS_CPU" == "arm64" ]]; then
MIN_VER=-mwatchos-version-min=10
# Simulator builds. TODO: figure out which -watchos-version-min=n
# is needed for arm64. 6 compiles and links, but is it correct?
elif [[ "$IOS_SDK" == "WatchSimulator" && "$IOS_CPU" == "i386" ]]; then
MIN_VER=-mwatchsimulator-version-min=6
elif [[ "$IOS_SDK" == "WatchSimulator" && "$IOS_CPU" == "x86_64" ]]; then
MIN_VER=-mwatchsimulator-version-min=6
# And the final catch-all
else
echo "IOS_SDK and IOS_CPU are not valid. Please fix them"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# x86_64 (simulator)
if [ "$CL" == "x86_64" ]; then
BACK_ARCH=x86_64
APPLE_SDK=iPhoneSimulator
#####################################################################
# Xcode 6 and below cannot handle -miphonesimulator-version-min
# Fix it so the simulator will compile as expected. This trick
# may work on other platforms, but it was not tested.
if [ -n "$(command -v xcodebuild 2>/dev/null)" ]; then
# Output of xcodebuild is similar to "Xcode 6.2". The first cut gets
# the dotted decimal value. The second cut gets the major version.
XCODE_VERSION=$(xcodebuild -version 2>/dev/null | head -n 1 | cut -f2 -d" " | cut -f1 -d".")
if [ -z "$XCODE_VERSION" ]; then XCODE_VERSION=100; fi
if [ "$XCODE_VERSION" -le 6 ]; then
MIN_VER="${MIN_VER//iphonesimulator/iphoneos}"
fi
fi
# ARMv5
if [ "$CL" == "armv5" ]; then
BACK_ARCH=armv5
APPLE_SDK=iPhoneOS
fi
# ARMv6
if [ "$CL" == "armv6" ]; then
BACK_ARCH=armv6
APPLE_SDK=iPhoneOS
fi
# ARMv7
if [ "$CL" == "armv7" ]; then
BACK_ARCH=armv7
APPLE_SDK=iPhoneOS
fi
# ARMv7s
if [ "$CL" == "armv7s" ]; then
BACK_ARCH=armv7s
APPLE_SDK=iPhoneOS
fi
# ARM64
if [[ ("$CL" == "arm64" || "$CL" == "armv8" || "$CL" == "aarch64") ]]; then
BACK_ARCH=arm64
APPLE_SDK=iPhoneOS
fi
# iPhone
if [[ ("$CL" == "iphone" || "$CL" == "iphoneos") ]]; then
BACK_ARCH=armv7
APPLE_SDK=iPhoneOS
fi
# iPhone Simulator
if [[ ("$CL" == "simulator" || "$CL" == "iphonesimulator") ]]; then
BACK_ARCH=i386
APPLE_SDK=iPhoneSimulator
fi
# Watch
if [[ ("$CL" == "watch" || "$CL" == "watchos" || "$CL" == "applewatch") ]]; then
BACK_ARCH=armv7
APPLE_SDK=WatchOS
fi
# Watch Simulator
if [ "$CL" == "watchsimulator" ]; then
BACK_ARCH=i386
APPLE_SDK=WatchSimulator
fi
# Apple TV
if [[ ("$CL" == "tv" || "$CL" == "appletv" || "$CL" == "appletvos") ]]; then
BACK_ARCH=arm64
APPLE_SDK=AppleTVOS
fi
# Apple TV Simulator
if [[ ("$CL" == "tvsimulator" || "$CL" == "appletvsimulator") ]]; then
BACK_ARCH=x86_64
APPLE_SDK=AppleTVSimulator
fi
done
# Defaults if not set
if [ -z "$APPLE_SDK" ]; then
BACK_ARCH=armv7
APPLE_SDK=iPhoneOS
fi
# Defaults if not set
if [ -z "$IOS_ARCH" ]; then
IOS_ARCH="$BACK_ARCH"
fi
#####################################################################
# Allow a user override? I think we should be doing this. The use case is:
# move /Applications/Xcode somewhere else for a side-by-side installation.
# These sorts of tricks are a required procedure on Apple's gear:
# http://stackoverflow.com/questions/11651773/install-simulator-sdk-4-3-to-xcode-4-4-on-mountain-lion
if [ -z "${XCODE_DEVELOPER-}" ]; then
XCODE_DEVELOPER=$(xcode-select -print-path 2>/dev/null)
fi
if [ ! -d "$XCODE_DEVELOPER" ]; then
echo "ERROR: unable to find XCODE_DEVELOPER directory."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Default toolchain location
XCODE_TOOLCHAIN="$XCODE_DEVELOPER/usr/bin"
# XCODE_DEVELOPER_SDK is the SDK location.
XCODE_DEVELOPER_SDK="$XCODE_DEVELOPER/Platforms/$IOS_SDK.platform"
if [ ! -d "$XCODE_TOOLCHAIN" ]; then
echo "ERROR: unable to find XCODE_TOOLCHAIN directory."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
if [ ! -d "$XCODE_DEVELOPER_SDK" ]; then
echo "ERROR: unable to find XCODE_DEVELOPER_SDK directory."
echo " Is the SDK supported by Xcode and installed?"
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# XCODE_DEVELOPER_TOP is the top of the development tools tree
XCODE_DEVELOPER_TOP="$XCODE_DEVELOPER/Platforms/$APPLE_SDK.platform/Developer"
if [ ! -d "$XCODE_DEVELOPER_TOP" ]; then
echo "ERROR: unable to find XCODE_DEVELOPER_TOP directory."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# IOS_TOOLCHAIN is the location of the actual compiler tools.
# XCODE_TOOLCHAIN is the location of the actual compiler tools.
if [ -d "$XCODE_DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/" ]; then
IOS_TOOLCHAIN="$XCODE_DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
elif [ -d "$XCODE_DEVELOPER_TOP/usr/bin/" ]; then
IOS_TOOLCHAIN="$XCODE_DEVELOPER_TOP/usr/bin/"
XCODE_TOOLCHAIN="$XCODE_DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
elif [ -d "$XCODE_DEVELOPER_SDK/Developer/usr/bin/" ]; then
XCODE_TOOLCHAIN="$XCODE_DEVELOPER_SDK/Developer/usr/bin/"
fi
if [ -z "$IOS_TOOLCHAIN" ] || [ ! -d "$IOS_TOOLCHAIN" ]; then
if [ -z "$XCODE_TOOLCHAIN" ] || [ ! -d "$XCODE_TOOLCHAIN" ]; then
echo "ERROR: unable to find Xcode cross-compiler tools."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
#
# XCODE_SDK is the SDK name/version being used - adjust the list as appropriate.
# For example, remove 4.3, 6.2, and 6.1 if they are not installed. We go back to
# the 1.0 SDKs because Apple WatchOS uses low numbers, like 2.0 and 2.1.
unset XCODE_SDK
for i in $(seq -f "%.1f" 20.0 -0.1 1.0)
XCODE_SDK=""
for i in $(seq -f "%.1f" 30.0 -0.1 1.0)
do
if [ -d "$XCODE_DEVELOPER/Platforms/$APPLE_SDK.platform/Developer/SDKs/$APPLE_SDK$i.sdk" ]; then
XCODE_SDK="$APPLE_SDK$i.sdk"
if [ -d "$XCODE_DEVELOPER_SDK/Developer/SDKs/$IOS_SDK$i.sdk" ]; then
XCODE_SDK="$IOS_SDK$i.sdk"
break
fi
done
@ -196,137 +232,99 @@ done
# Error checking
if [ -z "$XCODE_SDK" ]; then
echo "ERROR: unable to find a SDK."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
IOS_CXXFLAGS="-arch $IOS_CPU $MIN_VER"
# The simulators need to disable ASM. They don't receive arch flags.
# https://github.com/weidai11/cryptopp/issues/635
if [ "$APPLE_SDK" == "iPhoneSimulator" ]; then
IOS_FLAGS="$IOS_FLAGS -DCRYPTOPP_DISABLE_ASM"
if [[ "$IOS_SDK" == "iPhoneSimulator" || "$IOS_SDK" == "AppleTVSimulator" || "$IOS_SDK" == "WatchSimulator" ]]; then
IOS_CXXFLAGS="$IOS_CXXFLAGS -DCRYPTOPP_DISABLE_ASM"
fi
# Simulator fixup. LD fails to link dylib.
if [ "$APPLE_SDK" == "iPhoneSimulator" ] && [ "$IOS_ARCH" == "i386" ]; then
IOS_FLAGS="$IOS_FLAGS -miphoneos-version-min=5"
echo "Configuring for $IOS_SDK ($IOS_CPU)"
IS_IOS=1
IOS_SYSROOT="$XCODE_DEVELOPER_SDK/Developer/SDKs/$XCODE_SDK"
#####################################################################
CPP=cpp; CC=clang; CXX=clang++; LD=ld
AS=as; AR=libtool; RANLIB=ranlib; STRIP=strip
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$CC" ]; then
echo "ERROR: Failed to find iOS clang. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# ARMv7s fixup. Xcode 4/iOS 6
if [ "$IOS_ARCH" == "armv7s" ]; then
IOS_FLAGS="$IOS_FLAGS -miphoneos-version-min=6"
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$CXX" ]; then
echo "ERROR: Failed to find iOS clang++. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# ARM64 fixup. Xcode 5/iOS 7
if [ "$IOS_ARCH" == "arm64" ]; then
IOS_FLAGS="$IOS_FLAGS -miphoneos-version-min=7"
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$RANLIB" ]; then
echo "ERROR: Failed to find iOS ranlib. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Yet another ARM64 fixup.
if [ "$APPLE_SDK" == "AppleTVOS" ]; then
IOS_FLAGS=""
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$AR" ]; then
echo "ERROR: Failed to find iOS ar. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Disable ASM for simulator. We are failing on Travis due to missing _start.
# We may need to link against crt1.o for simulator builds. Also see
# https://stackoverflow.com/q/24841283/608639
# -watchos_simulator_version_min does not work though it is in LLVM sources.
if [ "$APPLE_SDK" == "WatchSimulator" ]; then
IOS_FLAGS="$IOS_FLAGS -DCRYPTOPP_DISABLE_ASM"
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$AS" ]; then
echo "ERROR: Failed to find iOS as. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Disable ASM for simulator. We are failing on Travis due to missing _start.
# We may need to link against crt1.o for simulator builds. Also see
# https://stackoverflow.com/q/24841283/608639
# -tvos_simulator_version_min does not work though it is in LLVM sources.
if [ "$APPLE_SDK" == "AppleTVSimulator" ]; then
IOS_FLAGS="$IOS_FLAGS -tvos_simulator_version_min -DCRYPTOPP_DISABLE_ASM"
# Error checking
if [ ! -e "$XCODE_TOOLCHAIN/$LD" ]; then
echo "ERROR: Failed to find iOS ld. Please edit this script."
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1
fi
# Simulator uses i386 or x86_64, Device uses ARMv5, ARMv6, ARMv7, ARMv7s or ARMv8
#
# Apple deprecated ARMv5 at iOS 4.0, and ARMv6 at iOS 5.0
# http://stackoverflow.com/questions/7488657/how-to-build-for-armv6-and-armv7-architectures-with-ios-5
#####################################################################
echo "Configuring for $APPLE_SDK ($IOS_ARCH)"
# Add tools to head of path, if not present already
LENGTH=${#XCODE_TOOLCHAIN}
SUBSTR=${PATH:0:$LENGTH}
if [ "$SUBSTR" != "$XCODE_TOOLCHAIN" ]; then
export PATH="$XCODE_TOOLCHAIN:$PATH"
fi
# Used by the GNUmakefile-cross
#####################################################################
# GNUmakefile-cross and Autotools expect these to be set.
# They are also used in the tests below.
export IS_IOS=1
export IOS_ARCH
export IOS_FLAGS
export IOS_SYSROOT="$XCODE_DEVELOPER_TOP/SDKs/$XCODE_SDK"
#######################################
##### Verbose #####
#######################################
export CPP CC CXX LD AS AR RANLIB STRIP
export IOS_CXXFLAGS IOS_SDK IOS_CPU IOS_SYSROOT
if [ "$SETENV_VERBOSE" == "1" ]; then
#####################################################################
echo "XCODE_SDK:" $XCODE_SDK
echo "XCODE_DEVELOPER: $XCODE_DEVELOPER"
VERBOSE=${VERBOSE:-1}
if [ "$VERBOSE" -gt 0 ]; then
echo "XCODE_TOOLCHAIN: $XCODE_TOOLCHAIN"
echo "XCODE_DEVELOPER_TOP: $XCODE_DEVELOPER_TOP"
echo "IOS_ARCH: $IOS_ARCH"
echo "IOS_TOOLCHAIN: $IOS_TOOLCHAIN"
echo "IOS_FLAGS: ${IOS_FLAGS-}"
echo "IOS_SYSROOT: ${IOS_SYSROOT-}"
echo "IOS_SDK: $IOS_SDK"
echo "IOS_CPU: $IOS_CPU"
echo "IOS_SYSROOT: $IOS_SYSROOT"
echo "IOS_CXXFLAGS: $IOS_CXXFLAGS"
fi
########################################
##### Path with Toolchains #####
########################################
# Only modify/export PATH if IOS_TOOLCHAIN good
if [ ! -z "$IOS_TOOLCHAIN" ] && [ ! -z "$XCODE_TOOLCHAIN" ]; then
# And only modify PATH if IOS_TOOLCHAIN is not present
TOOL_PATH="$IOS_TOOLCHAIN:$XCODE_TOOLCHAIN"
LEN=${#TOOL_PATH}
SUBSTR=${PATH:0:$LEN}
if [ "$SUBSTR" != "$TOOL_PATH" ]; then
export PATH="$TOOL_PATH":"$PATH"
fi
else
echo "ERROR: unable to set new PATH."
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
########################################
##### Tool Test Time #####
########################################
# Test for various tools needed during cross compilation.
# FOUND_ALL starts high, and pushes low on failure
FOUND_ALL=1
# Apple's embedded g++ cannot compile integer.cpp
TOOLS=(clang clang++ libtool ld)
for tool in ${TOOLS[@]}
do
if [ ! -e "$IOS_TOOLCHAIN/$tool" ] && [ ! -e "$XCODE_TOOLCHAIN/$tool" ]; then
echo "ERROR: unable to find $tool at IOS_TOOLCHAIN or XCODE_TOOLCHAIN"
FOUND_ALL=0
fi
done
if [ "$FOUND_ALL" -eq "0" ]; then
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
fi
# Exports added for Autotools. GNUmakefile-cross does not use them.
# What to do for AR=libtool and ARFLAGS?
export CPP="$IOS_TOOLCHAIN/cpp"
export CC="$IOS_TOOLCHAIN/clang"
export CXX="$IOS_TOOLCHAIN/clang++"
export LD="$IOS_TOOLCHAIN/ld"
export AS="$IOS_TOOLCHAIN/as"
export AR="$IOS_TOOLCHAIN/ar"
export RANLIB="$IOS_TOOLCHAIN/ranlib"
export STRIP="$IOS_TOOLCHAIN/strip"
#####################################################################
echo
echo "*******************************************************************************"
echo "It looks the the environment is set correctly. Your next step is build"
echo "the library with 'make -f GNUmakefile-cross'. You can create a versioned"
echo "shared object using 'HAS_SOLIB_VERSION=1 make -f GNUmakefile-cross'"
echo "the library with 'make -f GNUmakefile-cross'."
echo "*******************************************************************************"
echo
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0
[ "$0" = "${BASH_SOURCE[0]}" ] && exit 0 || return 0

View File

@ -1,18 +0,0 @@
#/usr/bin/env bash
# This file should be source'd when required.
export ANDROID_HOME="$HOME/.android"
export ANDROID_SDK="$HOME/android/sdk/"
export ANDROID_NDK="$HOME/android/sdk/ndk-bundle"
export ANDROID_SDK_ROOT="$ANDROID_SDK"
export ANDROID_NDK_ROOT="$ANDROID_NDK"
mkdir -p "$ANDROID_HOME"
mkdir -p "$ANDROID_SDK_ROOT"
mkdir -p "$ANDROID_NDK_ROOT"
# https://stackoverflow.com/a/47028911/608639
touch "$ANDROID_HOME/repositories.cfg"
[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0

View File

@ -1,47 +0,0 @@
#!/usr/bin/env bash
# Written and placed in public domain by Jeffrey Walton
#
# This script fetches TweetNaCl from Bernstein's site, and then
# prepares it for use in Crypto++ by applying tweetnacl.patch.
# The script should be run from the Crypto++ root directory on a
# Unix machine because of the use of Unix tools like wget.
curl https://tweetnacl.cr.yp.to/20140427/tweetnacl.h > tweetnacl.h
curl https://tweetnacl.cr.yp.to/20140427/tweetnacl.c > tweetnacl.c
# Fix whitespace
sed -e 's/[[:space:]]*$//' tweetnacl.h > tweetnacl.h.fixed
mv tweetnacl.h.fixed tweetnacl.h
sed -e 's/[[:space:]]*$//' tweetnacl.c > tweetnacl.c.fixed
mv tweetnacl.c.fixed tweetnacl.c
if [[ -e "TestScripts/tweetnacl.patch" ]]; then
cp "TestScripts/tweetnacl.patch" .
fi
if [[ ! -e "tweetnacl.patch" ]]; then
echo "Cannot find tweetnacl.patch. Please make sure it exists in the root directory."
echo "It can be created with 'diff -u tweetnacl.c tweetnacl.cpp > tweetnacl.patch'"
[[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0
fi
# Normalize line endings
dos2unix tweetnacl.h tweetnacl.cpp tweetnacl.patch
# Apply patch
patch --unified --binary -p0 < tweetnacl.patch
mv tweetnacl.c tweetnacl.cpp
# Place things where they belong in source control
cp tweetnacl.sh TestScripts/
cp tweetnacl.patch TestScripts/
# Fix whitespace
sed -e 's/[[:space:]]*$//' tweetnacl.h > tweetnacl.h.fixed
mv tweetnacl.h.fixed tweetnacl.h
sed -e 's/[[:space:]]*$//' tweetnacl.cpp > tweetnacl.cpp.fixed
mv tweetnacl.cpp.fixed tweetnacl.cpp
# Convert to MS DOS for source control
unix2dos tweetnacl.h tweetnacl.cpp

View File

@ -239,3 +239,109 @@ Plaintext: r11 006bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5
Key: 2b7e151628aed2a6abf7158809cf4f3c
Ciphertext: ECE71ECD7A4E3C2F643B2B0BFBED32F31C8551B6306D52CF843EC0B85015DC203B1C0B643E2A6BABAF5133DA0EA06616076AA6BBB52ED75DC3A71A9A6E8AC7C9A00D2C39AA68BF4E6FFED9AAEE5AD6914FB3EA77C7B61FF6BF564F2F1225ACB4B5889CB1559888A5817849C382E168482F75381F63868C468E4D1583B1FE71DD808CB94D8150AAB9D530A0FC17CDE748E95545D8A033B2F61F1954D0C0226168022E1CD7E031C57D048AC560F152960F47705E174D956D4BB53AE80BFFCD1BD569ED8EFFA223C00558B702405F33E6E0EDB2D9B0C148A1441CC80D6ABBCE785AA1B9DAB7CB8832F1B12D2EE60EE2DFCA37942CA1724E5602B7B70525AC9662028A22DB234676615DB474538CBC8D197F38C88BCC4F9E8D207538CA18DE5F095420A2E4D5868CEBB8B34A9377DC52D119790B65210F1B346F5E00D9BD00A8847048913D80726B9B745D565E6284B986DBAEA997FFC5A0DE5051527D44B2C1266DBC9130A6EB15F37A0F00B6286D6678CA651C07743BD37F2E8F6A94F5ED8C63428AE4883A9695183807E104BC335C64FEAAC40A605913DF98FF44E0801B31A968CCE5DCAFADE1E017FA711E05FF5A54BFA1999C2C463F97A3A66B30211BD306C8911C98F8EE5EF47A54746A4D16B7C7424A6954B4FC3BCF1A41BDE8A19CE1027AE86A320D0E5E7D3C7E50CFD0C4665B811D86C313F09ADE5B4DBE017231859881E5873E9EDB2011CF5920D2F7277C4DE1AC430A1849F0B870A69ABE701B6D0B5123E5FF53395409177CF84BF41EC33C5E4BCC2CF29258DC7C260471AABDA49FDE62915758EE4E578D0F7698E6456BC144573739D5D508CC76B389359D2A0ECB5B7EE5FCB4C3151D5AF7C71819EA3DD5F36C7B27E551FD2373D07FFDC76A13FC4B10A6F29A83D6F465ACB6960671EACF21A3E1CB4411C4DAA0C2A87DAED28AEE60B7EC0258A9AF125F2DDC80B9877EFE0F372D9B832C786770A84EA1A07CB6E1A9907D651BBD0EFDEF2AFFC3
Test: Encrypt
AlgorithmType: SymmetricCipher
Name: AES/XTS
#
Source: P1619-2007, Appendix B
Comment: Vector 1, XTS-AES applied for a data unit of 32 bytes, 32 bytes key material.
Key: 00000000000000000000000000000000 \
00000000000000000000000000000000
IV: 00000000000000000000000000000000
Plaintext: 0000000000000000000000000000000000000000000000000000000000000000
Ciphertext: 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e
Test: Encrypt
#
Source: P1619-2007, Appendix B
Comment: Vector 2, XTS-AES applied for a data unit of 32 bytes, 32 bytes key material.
Key: 11111111111111111111111111111111 \
22222222222222222222222222222222
IV: 33333333330000000000000000000000
Plaintext: 4444444444444444444444444444444444444444444444444444444444444444
Ciphertext: c454185e6a16936e39334038acef838bfb186fff7480adc4289382ecd6d394f0
Test: Encrypt
#
Source: P1619-2007, Appendix B
Comment: Vector 3, XTS-AES applied for a data unit of 32 bytes, 32 bytes key material.
Key: fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0 \
22222222222222222222222222222222
IV: 33333333330000000000000000000000
Plaintext: 4444444444444444444444444444444444444444444444444444444444444444
Ciphertext: af85336b597afc1a900b2eb21ec949d292df4c047e0b21532186a5971a227a89
Test: Encrypt
#
Source: P1619-2007, Appendix B
Comment: Vector 15, XTS-AES-128 applied for a data unit that is not a multiple of 16 bytes.
Key: fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0 \
bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0
IV: 9a785634120000000000000000000000
Plaintext: 000102030405060708090a0b0c0d0e0f10
Ciphertext: 6c1625db4671522d3d7599601de7ca09ed
Test: Encrypt
#
Source: P1619-2007, Appendix B
Comment: Vector 16, XTS-AES-128 applied for a data unit that is not a multiple of 16 bytes.
Key: fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0 \
bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0
IV: 9a785634120000000000000000000000
Plaintext: 000102030405060708090a0b0c0d0e0f1011
Ciphertext: d069444b7a7e0cab09e24447d24deb1fedbf
Test: Encrypt
#
Source: P1619-2007, Appendix B
Comment: Vector 17, XTS-AES-128 applied for a data unit that is not a multiple of 16 bytes.
Key: fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0 \
bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0
IV: 9a785634120000000000000000000000
Plaintext: 000102030405060708090a0b0c0d0e0f101112
Ciphertext: e5df1351c0544ba1350b3363cd8ef4beedbf9d
Test: Encrypt
#
Source: P1619-2007, Appendix B
Comment: Vector 18, XTS-AES-128 applied for a data unit that is not a multiple of 16 bytes.
Key: fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0 \
bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0
IV: 9a785634120000000000000000000000
Plaintext: 000102030405060708090a0b0c0d0e0f10111213
Ciphertext: 9d84c813f719aa2c7be3f66171c7c5c2edbf9dac
Test: Encrypt
#
Source: P1619-2007, Appendix B
Comment: Vector 19, XTS-AES-128 applied for a data unit that is not a multiple of 16 bytes.
Key: e0e1e2e3e4e5e6e7e8e9eaebecedeeef \
c0c1c2c3c4c5c6c7c8c9cacbcccdcecf
IV: 21436587a90000000000000000000000
Plaintext: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f \
202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f \
404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f \
606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f \
808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f \
a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebf \
c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf \
e0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff \
000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f \
202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f \
404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f \
606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f \
808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f \
a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebf \
c0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedf \
e0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
Ciphertext: 38b45812ef43a05bd957e545907e223b954ab4aaf088303ad910eadf14b42be6 \
8b2461149d8c8ba85f992be970bc621f1b06573f63e867bf5875acafa04e42cc \
bd7bd3c2a0fb1fff791ec5ec36c66ae4ac1e806d81fbf709dbe29e471fad3854 \
9c8e66f5345d7c1eb94f405d1ec785cc6f6a68f6254dd8339f9d84057e01a177 \
41990482999516b5611a38f41bb6478e6f173f320805dd71b1932fc333cb9ee3 \
9936beea9ad96fa10fb4112b901734ddad40bc1878995f8e11aee7d141a2f5d4 \
8b7a4e1e7f0b2c04830e69a4fd1378411c2f287edf48c6c4e5c247a19680f7fe \
41cefbd49b582106e3616cbbe4dfb2344b2ae9519391f3e0fb4922254b1d6d2d \
19c6d4d537b3a26f3bcc51588b32f3eca0829b6a5ac72578fb814fb43cf80d64 \
a233e3f997a3f02683342f2b33d25b492536b93becb2f5e1a8b82f5b88334272 \
9e8ae09d16938841a21a97fb543eea3bbff59f13c1a18449e398701c1ad51648 \
346cbc04c27bb2da3b93a1372ccae548fb53bee476f9e9c91773b1bb19828394 \
d55d3e1a20ed69113a860b6829ffa847224604435070221b257e8dff783615d2 \
cae4803a93aa4334ab482a0afac9c0aeda70b45a481df5dec5df8cc0f423c77a \
5fd46cd312021d4b438862419a791be03bb4d97c0e59578542531ba466a83baf \
92cefc151b5cc1611a167893819b63fb8a6b18e86de60290fa72b797b0ce59f3
Test: Encrypt

View File

@ -60,3 +60,5 @@ Test: TestVectors/ttmac.txt
Test: TestVectors/vmac.txt
Test: TestVectors/wake.txt
Test: TestVectors/whrlpool.txt
Test: TestVectors/xts.txt

View File

@ -436,4 +436,3 @@ Test: Verify
Message: "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"
Digest: FFD4A61F80D55FFA83BA8D2BD62DCFC33148ADE507A8F7F85A5AF2C619E126FF11E9284F12BF3EE6A2B5CBC711FA84C37DA343AB7D29BCDF722DF0171E41297A
Test: Verify

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More