blob: a735dcd08802d7b63fd870e8f0d11177d29e5119 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/bin/sh
#
# openssl-bsaes.sh - test the NEON bit sliced AES implementation in various sizes and modes
#
# Copyright (C) 2010 - 2014, Linaro Limited.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Author: Ard Biesheuvel <ard.biesheuvel@linaro.org> 2013-07-09
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
TMPFIFO=mktemp
mkfifo $TMPFIFO
touch $TMP
md5sum $TMPFIFO | awk '{ print $1 }' > $TMP &
OUT=$(dd if=/dev/urandom bs=65 count=$i |
tee $TMPFIFO |
openssl enc -$ALG -pass env:KEY |
${ARMCAP:-} openssl enc -d -$ALG -pass env:KEY |
md5sum | awk '{ print $1 }' )
while [ "x$OUT" = "x" ] || [ "x$(cat $TMP)" = "x" ]
do
:
done
rm $TMPFIFO
if [ "$OUT" != "$(cat $TMP)" ]
then
echo ${NAME}: fail
rm -f $TMP
exit 1
fi
done
rm -f $TMP
echo ${NAME}: pass
|