test_padlock 1.4 KB

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