summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2013-09-05 09:35:23 +0300
committerFathi Boudra <fathi.boudra@linaro.org>2013-09-05 09:35:23 +0300
commitf63b92c89f451edef7d06be0af33181ea163d6e2 (patch)
tree07c14b82a9ac741b05cc4c4d4a054df8d13c7a87
Test openssl-bsaes
Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
-rw-r--r--openssl-bsaes.yaml24
-rwxr-xr-xscripts/openssl-bsaes.sh51
2 files changed, 75 insertions, 0 deletions
diff --git a/openssl-bsaes.yaml b/openssl-bsaes.yaml
new file mode 100644
index 0000000..7307a78
--- /dev/null
+++ b/openssl-bsaes.yaml
@@ -0,0 +1,24 @@
+metadata:
+ name: openssl-bsaes
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Test to verify correctness of the NEON bit sliced AES code in OpenSSL"
+
+install:
+ deps:
+ - bsdmainutils
+
+run:
+ steps:
+ - pwd
+ - find . -type f -name 'openssl-bsaes.sh'
+ - scripts/openssl-bsaes.sh 128 ctr
+ - scripts/openssl-bsaes.sh 192 ctr
+ - scripts/openssl-bsaes.sh 256 ctr
+ - scripts/openssl-bsaes.sh 128 cbc
+ - scripts/openssl-bsaes.sh 192 cbc
+ - scripts/openssl-bsaes.sh 256 cbc
+ - scripts/openssl-bsaes.sh 128 xts
+ - scripts/openssl-bsaes.sh 256 xts
+
+parse:
+ pattern: "(?P<test_case_id>.*-*):\\s+(?P<result>(pass|fail))"
diff --git a/scripts/openssl-bsaes.sh b/scripts/openssl-bsaes.sh
new file mode 100755
index 0000000..b01224c
--- /dev/null
+++ b/scripts/openssl-bsaes.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+##
+## openssl-bsaes.sh - test the NEON bit sliced AES implementation
+## in various sizes and modes
+##
+## 2013-07-09 Ard Biesheuvel <ard.biesheuvel@linaro.org>
+##
+
+set -u
+
+BITS=$1
+MODE=$2
+
+exec 2> /dev/null
+
+KEY=$(dd if=/dev/urandom bs=32 count=1 | hexdump -ve '/1 "%02x"')
+ALG=aes-$BITS-$MODE
+NAME=neon-$ALG
+
+# ctr mode is essentially a stream cipher, so instead of using it for both
+# encrypt and decrypt (which both call encrypt() under the hood), disable NEON
+# for the decrypt case by setting OPENSSL_armcap to zero in the environment
+if [ "$MODE" == "ctr" ]
+then
+ ARMCAP="env OPENSSL_armcap=0"
+fi
+
+TMP=/tmp/bsaestest-$$.md5sum
+
+export KEY
+export ARMCAP
+
+for i in $(seq 100)
+do
+ OUT=$(dd if=/dev/urandom bs=16k count=1 |
+ tee >(md5sum >$TMP) |
+ openssl enc -$ALG -pass env:KEY |
+ ${ARMCAP:-} openssl enc -d -$ALG -pass env:KEY |
+ md5sum)
+
+ if [ "$OUT" != "$(cat $TMP)" ]
+ then
+ echo ${NAME}: fail
+ rm -f $TMP
+ exit 1
+ fi
+done
+
+rm -f $TMP
+echo ${NAME}: pass