summaryrefslogtreecommitdiff
path: root/app/openssl/import_openssl.sh
diff options
context:
space:
mode:
Diffstat (limited to 'app/openssl/import_openssl.sh')
-rwxr-xr-xapp/openssl/import_openssl.sh90
1 files changed, 82 insertions, 8 deletions
diff --git a/app/openssl/import_openssl.sh b/app/openssl/import_openssl.sh
index 02d2ab1c..f16596bc 100755
--- a/app/openssl/import_openssl.sh
+++ b/app/openssl/import_openssl.sh
@@ -128,7 +128,16 @@ function default_asm_file () {
function gen_asm_arm () {
local OUT
OUT=$(default_asm_file "$@")
- $PERL_EXE "$1" > "$OUT"
+ $PERL_EXE "$1" void "$OUT" > "$OUT"
+}
+
+# Generate an ARMv8 64-bit assembly file.
+# $1: generator (perl script)
+# $2: [optional] output file name
+function gen_asm_arm64 () {
+ local OUT
+ OUT=$(default_asm_file "$@")
+ $PERL_EXE "$1" linux64 "$OUT" > "$OUT"
}
function gen_asm_mips () {
@@ -177,6 +186,54 @@ function print_autogenerated_header() {
echo "#"
}
+function run_verbose() {
+ echo Running: $@
+ $@
+}
+
+function scan_opensslconf_for_flags() {
+ for flag in "$@"; do
+ awk "/^#define ${flag}$/ { print \$2 }" crypto/opensslconf.h
+ done
+}
+
+CRYPTO_CONF_FLAGS=(
+OPENSSL_CPUID_OBJ
+DES_LONG
+DES_PTR
+DES_RISC1
+DES_RISC2
+DES_UNROLL
+RC4_INT
+RC4_CHUNK
+RC4_INDEX
+)
+
+function check_asm_flags() {
+ local arch="$1"
+ local target="$2"
+ local unsorted_flags
+ local expected_flags
+ local actual_flags
+ local defines="OPENSSL_CRYPTO_DEFINES_$arch"
+
+ PERL=/usr/bin/perl run_verbose ./Configure $CONFIGURE_ARGS $target
+
+ unsorted_flags="$(awk '/^CFLAG=/ { sub(/^CFLAG= .*-Wall /, ""); gsub(/-D/, ""); print; }' Makefile)"
+ unsorted_flags="$unsorted_flags $(scan_opensslconf_for_flags "${CRYPTO_CONF_FLAGS[@]}")"
+
+ expected_flags="$(echo $unsorted_flags | tr ' ' '\n' | sort | tr '\n' ' ')"
+ actual_flags="$(echo ${!defines} | tr ' ' '\n' | sort | tr '\n' ' ')"
+
+ if [[ $actual_flags != $expected_flags ]]; then
+ echo ${defines} is wrong!
+ echo " $actual_flags"
+ echo Please update to:
+ echo " $expected_flags"
+ exit 1
+ fi
+}
+
# Run Configure and generate headers
# $1: 32 for 32-bit arch, 64 for 64-bit arch, trusty for Trusty
# $2: 1 if building for static version
@@ -192,9 +249,9 @@ function generate_build_config_headers() {
fi
if [[ $1 == trusty ]] ; then
- PERL=/usr/bin/perl ./Configure $CONFIGURE_ARGS_TRUSTY
+ PERL=/usr/bin/perl run_verbose ./Configure $CONFIGURE_ARGS_TRUSTY
else
- PERL=/usr/bin/perl ./Configure $CONFIGURE_ARGS ${!configure_args_bits} ${!configure_args_stat}
+ PERL=/usr/bin/perl run_verbose ./Configure $CONFIGURE_ARGS ${!configure_args_bits} ${!configure_args_stat}
fi
rm -f apps/CA.pl.bak crypto/opensslconf.h.bak
@@ -424,8 +481,16 @@ function import() {
declare -r OPENSSL_SOURCE=$1
untar $OPENSSL_SOURCE readonly
applypatches $OPENSSL_DIR
+ convert_iso8859_to_utf8 $OPENSSL_DIR
cd $OPENSSL_DIR
+
+ # Check the ASM flags for each arch
+ check_asm_flags arm linux-armv4
+ check_asm_flags arm64 linux-aarch64
+ check_asm_flags x86 linux-elf
+ check_asm_flags x86_64 linux-x86_64
+
generate_build_config_mk
generate_opensslconf_h
@@ -443,14 +508,23 @@ function import() {
# Generate arm asm
gen_asm_arm crypto/aes/asm/aes-armv4.pl
+ gen_asm_arm crypto/aes/asm/aesv8-armx.pl
gen_asm_arm crypto/aes/asm/bsaes-armv7.pl
gen_asm_arm crypto/bn/asm/armv4-gf2m.pl
gen_asm_arm crypto/bn/asm/armv4-mont.pl
gen_asm_arm crypto/modes/asm/ghash-armv4.pl
+ gen_asm_arm crypto/modes/asm/ghashv8-armx.pl
gen_asm_arm crypto/sha/asm/sha1-armv4-large.pl
gen_asm_arm crypto/sha/asm/sha256-armv4.pl
gen_asm_arm crypto/sha/asm/sha512-armv4.pl
+ # Generate armv8 asm
+ gen_asm_arm64 crypto/aes/asm/aesv8-armx.pl crypto/aes/asm/aesv8-armx-64.S
+ gen_asm_arm64 crypto/modes/asm/ghashv8-armx.pl crypto/modes/asm/ghashv8-armx-64.S
+ gen_asm_arm64 crypto/sha/asm/sha1-armv8.pl
+ gen_asm_arm64 crypto/sha/asm/sha512-armv8.pl crypto/sha/asm/sha256-armv8.S
+ gen_asm_arm64 crypto/sha/asm/sha512-armv8.pl
+
# Generate mips asm
gen_asm_mips crypto/aes/asm/aes-mips.pl
gen_asm_mips crypto/bn/asm/mips.pl crypto/bn/asm/bn-mips.S
@@ -585,7 +659,6 @@ function untar() {
# Process new source
tar -zxf $OPENSSL_SOURCE
- convert_iso8859_to_utf8 $OPENSSL_DIR
cp -RfP $OPENSSL_DIR $OPENSSL_DIR_ORIG
if [ ! -z $readonly ]; then
find $OPENSSL_DIR_ORIG -type f -print0 | xargs -0 chmod a-w
@@ -610,12 +683,13 @@ function applypatches () {
cd $dir
# Apply appropriate patches
- for i in $OPENSSL_PATCHES; do
- if [ ! "$skip_patch" = "patches/$i" ]; then
+ patches=(../patches/[0-9][0-9][0-9][0-9]-*.patch)
+ for i in "${patches[@]}"; do
+ if [[ $skip_patch != ${i##*/} ]]; then
echo "Applying patch $i"
- patch -p1 < ../patches/$i || die "Could not apply patches/$i. Fix source and run: $0 regenerate patches/$i"
+ patch -p1 < $i || die "Could not apply $i. Fix source and run: $0 regenerate patches/${i##*/}"
else
- echo "Skiping patch $i"
+ echo "Skiping patch ${i##*/}"
fi
done