Skip to content

Instantly share code, notes, and snippets.

@kinichiro
Created April 15, 2015 15:56
Show Gist options
  • Save kinichiro/d2513ac0eccfde00d80b to your computer and use it in GitHub Desktop.
Save kinichiro/d2513ac0eccfde00d80b to your computer and use it in GitHub Desktop.
libressl enc test script
#!/bin/sh
# enctest.sh
openssl_bin=../apps/openssl
if [ -e ../apps/openssl.exe ]; then
openssl_bin=../apps/openssl.exe
fi
export OPENSSL_CONF=../apps/openssl.cnf
test_dir=./test
mkdir -p $test_dir
function start_message {
echo ""
echo "[TEST] $1"
}
function check_exit_status {
status=$1
if [ $status -ne 0 ] ; then
echo ":-< error occurs, exit status = [ $status ]"
#exit $status
else
echo ":-) success."
fi
}
#---------#---------#---------#---------#---------#---------#---------#---------
text="1234567890abcdefghijklmnopqrstuvwxyz"
encfile=$test_dir/encfile.dat
echo $text > $encfile
pass="test-pass-1234"
# get cipher name list
enchelp=$test_dir/enc.help
$openssl_bin enc -help 2> $enchelp
ciphers=`cat $enchelp | sed -e 1,/Valid\ ciphername\ values:/d | awk '{for(i=1;i<NF;++i)printf("%s ",$i);}' -`
echo ""
echo "##### binary ###################################"
for c in $ciphers ; do
start_message "$c"
$openssl_bin enc $c -e -pass pass:$pass -in $encfile -out $encfile-$c.enc
check_exit_status $?
$openssl_bin enc $c -d -pass pass:$pass -in $encfile-$c.enc -out $encfile-$c.dec
check_exit_status $?
diff $encfile $encfile-$c.dec
check_exit_status $?
done
echo ""
echo "##### base64 ###################################"
for c in $ciphers ; do
start_message "$c"
$openssl_bin enc $c -e -base64 -pass pass:$pass -in $encfile -out $encfile-$c-b64.enc
check_exit_status $?
$openssl_bin enc $c -d -base64 -pass pass:$pass -in $encfile-$c-b64.enc -out $encfile-$c-b64.dec
check_exit_status $?
diff $encfile $encfile-$c-b64.dec
check_exit_status $?
done
##### binary ###################################
[TEST] -aes-128-cbc
:-) success.
:-) success.
:-) success.
[TEST] -aes-128-cbc-hmac-sha1
:-) success.
./enctest.sh: line 46: 18980 Segmentation fault (core dumped) $openssl_bin enc $c -d -pass pass:$pass -in $encfile-$c.enc -out $encfile-$c.dec
:-< error occurs, exit status = [ 139 ]
1d0
< 1234567890abcdefghijklmnopqrstuvwxyz
:-< error occurs, exit status = [ 1 ]
[TEST] -aes-128-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -aes-128-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -aes-128-ecb
:-) success.
:-) success.
:-) success.
[TEST] -aes-128-gcm
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -aes-128-xts
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-cbc
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-ecb
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-gcm
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -aes-256-cbc
:-) success.
:-) success.
:-) success.
[TEST] -aes-256-cbc-hmac-sha1
:-) success.
./enctest.sh: line 46: 19332 Segmentation fault (core dumped) $openssl_bin enc $c -d -pass pass:$pass -in $encfile-$c.enc -out $encfile-$c.dec
:-< error occurs, exit status = [ 139 ]
1d0
< 1234567890abcdefghijklmnopqrstuvwxyz
:-< error occurs, exit status = [ 1 ]
[TEST] -aes-256-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -aes-256-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -aes-256-ecb
:-) success.
:-) success.
:-) success.
[TEST] -aes-256-gcm
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -aes-256-xts
:-) success.
:-) success.
:-) success.
[TEST] -aes128
:-) success.
:-) success.
:-) success.
[TEST] -aes256
:-) success.
:-) success.
:-) success.
[TEST] -bf
:-) success.
:-) success.
:-) success.
[TEST] -bf-cfb
:-) success.
:-) success.
:-) success.
[TEST] -bf-ecb
:-) success.
:-) success.
:-) success.
[TEST] -blowfish
:-) success.
:-) success.
:-) success.
[TEST] -camellia-128-cbc
:-) success.
:-) success.
:-) success.
[TEST] -camellia-128-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -camellia-128-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -camellia-128-ofb
:-) success.
:-) success.
:-) success.
[TEST] -camellia-192-cbc
:-) success.
:-) success.
:-) success.
[TEST] -camellia-192-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -camellia-192-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -camellia-192-ofb
:-) success.
:-) success.
:-) success.
[TEST] -camellia-256-cbc
:-) success.
:-) success.
:-) success.
[TEST] -camellia-256-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -camellia-256-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -camellia-256-ofb
:-) success.
:-) success.
:-) success.
[TEST] -camellia128
:-) success.
:-) success.
:-) success.
[TEST] -camellia256
:-) success.
:-) success.
:-) success.
[TEST] -cast
:-) success.
:-) success.
:-) success.
[TEST] -cast5-cbc
:-) success.
:-) success.
:-) success.
[TEST] -cast5-cfb
:-) success.
:-) success.
:-) success.
[TEST] -cast5-ofb
:-) success.
:-) success.
:-) success.
[TEST] -chacha
:-) success.
:-) success.
:-) success.
[TEST] -des-cbc
:-) success.
:-) success.
:-) success.
[TEST] -des-cfb
:-) success.
:-) success.
:-) success.
[TEST] -des-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -des-ecb
:-) success.
:-) success.
:-) success.
[TEST] -des-ede-cbc
:-) success.
:-) success.
:-) success.
[TEST] -des-ede-cfb
:-) success.
:-) success.
:-) success.
[TEST] -des-ede3
:-) success.
:-) success.
:-) success.
[TEST] -des-ede3-cbc
:-) success.
:-) success.
:-) success.
[TEST] -des-ede3-cfb1
:-) success.
:-) success.
Binary files ./test/encfile.dat and ./test/encfile.dat--des-ede3-cfb1.dec differ
:-< error occurs, exit status = [ 2 ]
[TEST] -des-ede3-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -des-ofb
:-) success.
:-) success.
:-) success.
[TEST] -des3
:-) success.
:-) success.
:-) success.
[TEST] -desx-cbc
:-) success.
:-) success.
:-) success.
[TEST] -gost89
:-) success.
:-) success.
:-) success.
[TEST] -gost89-ecb
:-) success.
:-) success.
:-) success.
[TEST] -id-aes128-GCM
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -id-aes256-GCM
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -idea
:-) success.
:-) success.
:-) success.
[TEST] -idea-cfb
:-) success.
:-) success.
:-) success.
[TEST] -idea-ecb
:-) success.
:-) success.
:-) success.
[TEST] -rc2
:-) success.
:-) success.
:-) success.
[TEST] -rc2-40-cbc
:-) success.
:-) success.
:-) success.
[TEST] -rc2-cbc
:-) success.
:-) success.
:-) success.
[TEST] -rc2-cfb
:-) success.
:-) success.
:-) success.
[TEST] -rc2-ofb
:-) success.
:-) success.
:-) success.
[TEST] -rc4
:-) success.
:-) success.
:-) success.
##### base64 ###################################
[TEST] -aes-128-cbc
:-) success.
:-) success.
:-) success.
[TEST] -aes-128-cbc-hmac-sha1
:-) success.
./enctest.sh: line 59: 21015 Segmentation fault (core dumped) $openssl_bin enc $c -d -base64 -pass pass:$pass -in $encfile-$c-b64.enc -out $encfile-$c-b64.dec
:-< error occurs, exit status = [ 139 ]
1d0
< 1234567890abcdefghijklmnopqrstuvwxyz
:-< error occurs, exit status = [ 1 ]
[TEST] -aes-128-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -aes-128-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -aes-128-ecb
:-) success.
:-) success.
:-) success.
[TEST] -aes-128-gcm
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -aes-128-xts
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-cbc
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-ecb
:-) success.
:-) success.
:-) success.
[TEST] -aes-192-gcm
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -aes-256-cbc
:-) success.
:-) success.
:-) success.
[TEST] -aes-256-cbc-hmac-sha1
:-) success.
./enctest.sh: line 59: 21364 Segmentation fault (core dumped) $openssl_bin enc $c -d -base64 -pass pass:$pass -in $encfile-$c-b64.enc -out $encfile-$c-b64.dec
:-< error occurs, exit status = [ 139 ]
1d0
< 1234567890abcdefghijklmnopqrstuvwxyz
:-< error occurs, exit status = [ 1 ]
[TEST] -aes-256-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -aes-256-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -aes-256-ecb
:-) success.
:-) success.
:-) success.
[TEST] -aes-256-gcm
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -aes-256-xts
:-) success.
:-) success.
:-) success.
[TEST] -aes128
:-) success.
:-) success.
:-) success.
[TEST] -aes256
:-) success.
:-) success.
:-) success.
[TEST] -bf
:-) success.
:-) success.
:-) success.
[TEST] -bf-cfb
:-) success.
:-) success.
:-) success.
[TEST] -bf-ecb
:-) success.
:-) success.
:-) success.
[TEST] -blowfish
:-) success.
:-) success.
:-) success.
[TEST] -camellia-128-cbc
:-) success.
:-) success.
:-) success.
[TEST] -camellia-128-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -camellia-128-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -camellia-128-ofb
:-) success.
:-) success.
:-) success.
[TEST] -camellia-192-cbc
:-) success.
:-) success.
:-) success.
[TEST] -camellia-192-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -camellia-192-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -camellia-192-ofb
:-) success.
:-) success.
:-) success.
[TEST] -camellia-256-cbc
:-) success.
:-) success.
:-) success.
[TEST] -camellia-256-cfb1
:-) success.
:-) success.
:-) success.
[TEST] -camellia-256-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -camellia-256-ofb
:-) success.
:-) success.
:-) success.
[TEST] -camellia128
:-) success.
:-) success.
:-) success.
[TEST] -camellia256
:-) success.
:-) success.
:-) success.
[TEST] -cast
:-) success.
:-) success.
:-) success.
[TEST] -cast5-cbc
:-) success.
:-) success.
:-) success.
[TEST] -cast5-cfb
:-) success.
:-) success.
:-) success.
[TEST] -cast5-ofb
:-) success.
:-) success.
:-) success.
[TEST] -chacha
:-) success.
:-) success.
:-) success.
[TEST] -des-cbc
:-) success.
:-) success.
:-) success.
[TEST] -des-cfb
:-) success.
:-) success.
:-) success.
[TEST] -des-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -des-ecb
:-) success.
:-) success.
:-) success.
[TEST] -des-ede-cbc
:-) success.
:-) success.
:-) success.
[TEST] -des-ede-cfb
:-) success.
:-) success.
:-) success.
[TEST] -des-ede3
:-) success.
:-) success.
:-) success.
[TEST] -des-ede3-cbc
:-) success.
:-) success.
:-) success.
[TEST] -des-ede3-cfb1
:-) success.
:-) success.
Binary files ./test/encfile.dat and ./test/encfile.dat--des-ede3-cfb1-b64.dec differ
:-< error occurs, exit status = [ 2 ]
[TEST] -des-ede3-cfb8
:-) success.
:-) success.
:-) success.
[TEST] -des-ofb
:-) success.
:-) success.
:-) success.
[TEST] -des3
:-) success.
:-) success.
:-) success.
[TEST] -desx-cbc
:-) success.
:-) success.
:-) success.
[TEST] -gost89
:-) success.
:-) success.
:-) success.
[TEST] -gost89-ecb
:-) success.
:-) success.
:-) success.
[TEST] -id-aes128-GCM
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -id-aes256-GCM
:-) success.
bad decrypt
:-< error occurs, exit status = [ 1 ]
:-) success.
[TEST] -idea
:-) success.
:-) success.
:-) success.
[TEST] -idea-cfb
:-) success.
:-) success.
:-) success.
[TEST] -idea-ecb
:-) success.
:-) success.
:-) success.
[TEST] -rc2
:-) success.
:-) success.
:-) success.
[TEST] -rc2-40-cbc
:-) success.
:-) success.
:-) success.
[TEST] -rc2-cbc
:-) success.
:-) success.
:-) success.
[TEST] -rc2-cfb
:-) success.
:-) success.
:-) success.
[TEST] -rc2-ofb
:-) success.
:-) success.
:-) success.
[TEST] -rc4
:-) success.
:-) success.
:-) success.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment