summaryrefslogtreecommitdiff
path: root/ubuntu
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2013-09-05 13:17:58 +0300
committerFathi Boudra <fathi.boudra@linaro.org>2013-09-05 13:17:58 +0300
commit800229d66126e670ac7286488d1bd8798fedad62 (patch)
tree653bb81f0e8a9ff59a69ebc666bda4bcc22b2a32 /ubuntu
parent77a72395592f261635de41384e9fd6b0d31a55ab (diff)
Add test to verify correctness of NEON bit sliced AES code in OpenSSL
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Fathi Boudra <fathi.boudra@linaro.org>
Diffstat (limited to 'ubuntu')
-rw-r--r--ubuntu/openssl-bsaes.yaml22
-rwxr-xr-xubuntu/scripts/openssl-bsaes.sh51
2 files changed, 73 insertions, 0 deletions
diff --git a/ubuntu/openssl-bsaes.yaml b/ubuntu/openssl-bsaes.yaml
new file mode 100644
index 0000000..8c21011
--- /dev/null
+++ b/ubuntu/openssl-bsaes.yaml
@@ -0,0 +1,22 @@
+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:
+ - ./ubuntu/scripts/openssl-bsaes.sh 128 ctr
+ - ./ubuntu/scripts/openssl-bsaes.sh 192 ctr
+ - ./ubuntu/scripts/openssl-bsaes.sh 256 ctr
+ - ./ubuntu/scripts/openssl-bsaes.sh 128 cbc
+ - ./ubuntu/scripts/openssl-bsaes.sh 192 cbc
+ - ./ubuntu/scripts/openssl-bsaes.sh 256 cbc
+ - ./ubuntu/scripts/openssl-bsaes.sh 128 xts
+ - ./ubuntu/scripts/openssl-bsaes.sh 256 xts
+
+parse:
+ pattern: "(?P<test_case_id>.*-*):\\s+(?P<result>(pass|fail))"
diff --git a/ubuntu/scripts/openssl-bsaes.sh b/ubuntu/scripts/openssl-bsaes.sh
new file mode 100755
index 0000000..b01224c
--- /dev/null
+++ b/ubuntu/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