From eda2da323524e0f94b96531e386e412a18356d67 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Mon, 27 Apr 2009 15:46:32 +0000 Subject: [PATCH] aesni-x86.pl: fix another typo and add test script. --- crypto/aes/asm/aesni-x86.pl | 2 +- test/test_aesni | 73 +++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100755 test/test_aesni diff --git a/crypto/aes/asm/aesni-x86.pl b/crypto/aes/asm/aesni-x86.pl index 4e3af02db2..fe0cbe0b5e 100644 --- a/crypto/aes/asm/aesni-x86.pl +++ b/crypto/aes/asm/aesni-x86.pl @@ -348,7 +348,7 @@ if ($PREFIX eq "aesni") { &lea ($inp,&DWP(0x30,$inp)); &pxor ($inout0,$ivec); &pxor ($inout1,$in0); - &movups ($ivec,&QWP(0x20,$inp)); + &movups ($ivec,&QWP(-0x10,$inp)); &pxor ($inout2,$in1); &movups (&QWP(0,$out),$inout0); &mov ($rounds,$rounds_) # restore $rounds diff --git a/test/test_aesni b/test/test_aesni new file mode 100755 index 0000000000..87f5da191e --- /dev/null +++ b/test/test_aesni @@ -0,0 +1,73 @@ +#!/bin/sh + +PROG=$1 + +if [ -x $PROG ]; then + if expr "x`$PROG version`" : "xOpenSSL" > /dev/null; then + : + else + echo "$PROG is not OpenSSL executable" + exit 1 + fi +else + echo "$PROG is not executable" + exit 1; +fi + +if $PROG engine aesni | grep aesni; then + + HASH=`cat $PROG | $PROG dgst -hex` + + ACE_ALGS=" aes-128-ecb aes-192-ecb aes-256-ecb \ + aes-128-cbc aes-192-cbc aes-256-cbc \ + aes-128-cfb aes-192-cfb aes-256-cfb \ + aes-128-ofb aes-192-ofb aes-256-ofb" + BUFSIZE="16 32 48 64 80 96 128 999" + ACE_ALGS=" aes-128-cbc aes-192-cbc aes-256-cbc \ + aes-128-cfb aes-192-cfb aes-256-cfb \ + aes-128-ofb aes-192-ofb aes-256-ofb" + BUFSIZE="48 64 80 96 128 999" + + nerr=0 + + for alg in $ACE_ALGS; do + echo $alg + for bufsize in $BUFSIZE; do + TEST=`( cat $PROG | \ + $PROG enc -e -k "$HASH" -$alg -bufsize $bufsize -engine aesni | \ + $PROG enc -d -k "$HASH" -$alg | \ + $PROG dgst -hex ) 2>/dev/null` + if [ "$TEST" != "$HASH" ]; then + echo "-$alg/$bufsize encrypt test failed" + nerr=`expr $nerr + 1` + fi + done + for bufsize in $BUFSIZE; do + TEST=`( cat $PROG | \ + $PROG enc -e -k "$HASH" -$alg | \ + $PROG enc -d -k "$HASH" -$alg -bufsize $bufsize -engine aesni | \ + $PROG dgst -hex ) 2>/dev/null` + if [ "$TEST" != "$HASH" ]; then + echo "-$alg/$bufsize decrypt test failed" + nerr=`expr $nerr + 1` + fi + done + TEST=`( cat $PROG | \ + $PROG enc -e -k "$HASH" -$alg -engine aesni | \ + $PROG enc -d -k "$HASH" -$alg -engine aesni | \ + $PROG dgst -hex ) 2>/dev/null` + if [ "$TEST" != "$HASH" ]; then + echo "-$alg en/decrypt test failed" + nerr=`expr $nerr + 1` + fi + done + + if [ $nerr -gt 0 ]; then + echo "AESNI engine test failed." + exit 1; + fi +else + echo "AESNI engine is not available" +fi + +exit 0