Andy Polyakov | 34b537e | 2005-12-28 16:16:56 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | PROG=$1 |
| 4 | |
| 5 | if [ -x $PROG ]; then |
| 6 | if expr "x`$PROG version`" : "xOpenSSL" > /dev/null; then |
| 7 | : |
| 8 | else |
| 9 | echo "$PROG is not OpenSSL executable" |
| 10 | exit 1 |
| 11 | fi |
| 12 | else |
| 13 | echo "$PROG is not executable" |
| 14 | exit 1; |
| 15 | fi |
| 16 | |
| 17 | if $PROG engine padlock | grep -v no-ACE; then |
| 18 | |
| 19 | HASH=`cat $PROG | $PROG dgst -hex` |
| 20 | |
| 21 | ACE_ALGS=" aes-128-ecb aes-192-ecb aes-256-ecb \ |
| 22 | aes-128-cbc aes-192-cbc aes-256-cbc \ |
| 23 | aes-128-cfb aes-192-cfb aes-256-cfb \ |
| 24 | aes-128-ofb aes-192-ofb aes-256-ofb" |
| 25 | |
| 26 | nerr=0 |
| 27 | |
| 28 | for alg in $ACE_ALGS; do |
| 29 | echo $alg |
| 30 | TEST=`( cat $PROG | \ |
Andy Polyakov | b066c3c | 2009-04-27 19:04:23 +0000 | [diff] [blame] | 31 | $PROG enc -e -k "$HASH" -$alg -bufsize 999 -engine padlock | \ |
| 32 | $PROG enc -d -k "$HASH" -$alg | \ |
Andy Polyakov | 34b537e | 2005-12-28 16:16:56 +0000 | [diff] [blame] | 33 | $PROG dgst -hex ) 2>/dev/null` |
Andy Polyakov | b066c3c | 2009-04-27 19:04:23 +0000 | [diff] [blame] | 34 | if [ "$TEST" != "$HASH" ]; then |
Andy Polyakov | 34b537e | 2005-12-28 16:16:56 +0000 | [diff] [blame] | 35 | echo "-$alg encrypt test failed" |
| 36 | nerr=`expr $nerr + 1` |
| 37 | fi |
| 38 | TEST=`( cat $PROG | \ |
Andy Polyakov | b066c3c | 2009-04-27 19:04:23 +0000 | [diff] [blame] | 39 | $PROG enc -e -k "$HASH" -$alg | \ |
| 40 | $PROG enc -d -k "$HASH" -$alg -bufsize 999 -engine padlock | \ |
Andy Polyakov | 34b537e | 2005-12-28 16:16:56 +0000 | [diff] [blame] | 41 | $PROG dgst -hex ) 2>/dev/null` |
Andy Polyakov | b066c3c | 2009-04-27 19:04:23 +0000 | [diff] [blame] | 42 | if [ "$TEST" != "$HASH" ]; then |
Andy Polyakov | 34b537e | 2005-12-28 16:16:56 +0000 | [diff] [blame] | 43 | echo "-$alg decrypt test failed" |
| 44 | nerr=`expr $nerr + 1` |
| 45 | fi |
| 46 | TEST=`( cat $PROG | \ |
Andy Polyakov | b066c3c | 2009-04-27 19:04:23 +0000 | [diff] [blame] | 47 | $PROG enc -e -k "$HASH" -$alg -engine padlock | \ |
| 48 | $PROG enc -d -k "$HASH" -$alg -engine padlock | \ |
Andy Polyakov | 34b537e | 2005-12-28 16:16:56 +0000 | [diff] [blame] | 49 | $PROG dgst -hex ) 2>/dev/null` |
Andy Polyakov | b066c3c | 2009-04-27 19:04:23 +0000 | [diff] [blame] | 50 | if [ "$TEST" != "$HASH" ]; then |
Andy Polyakov | 34b537e | 2005-12-28 16:16:56 +0000 | [diff] [blame] | 51 | echo "-$alg en/decrypt test failed" |
| 52 | nerr=`expr $nerr + 1` |
| 53 | fi |
| 54 | done |
| 55 | |
| 56 | if [ $nerr -gt 0 ]; then |
| 57 | echo "PadLock ACE test failed." |
| 58 | exit 1; |
| 59 | fi |
| 60 | else |
| 61 | echo "PadLock ACE is not available" |
| 62 | fi |
| 63 | |
| 64 | exit 0 |