From 800229d66126e670ac7286488d1bd8798fedad62 Mon Sep 17 00:00:00 2001 From: Fathi Boudra Date: Thu, 5 Sep 2013 13:17:58 +0300 Subject: Add test to verify correctness of NEON bit sliced AES code in OpenSSL Signed-off-by: Ard Biesheuvel Acked-by: Fathi Boudra --- ubuntu/openssl-bsaes.yaml | 22 ++++++++++++++++++ ubuntu/scripts/openssl-bsaes.sh | 51 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 ubuntu/openssl-bsaes.yaml create mode 100755 ubuntu/scripts/openssl-bsaes.sh (limited to 'ubuntu') 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.*-*):\\s+(?P(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 +## + +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 -- cgit v1.2.3