File: test_passphrase.sh

package info (click to toggle)
afflib 3.6.6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 5,320 kB
  • sloc: cpp: 21,493; ansic: 14,745; sh: 11,235; makefile: 538; python: 95
file content (68 lines) | stat: -rwxr-xr-x 1,860 bytes parent folder | download
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
#!/bin/sh
#
# test the passphrase tools

export PATH=$srcdir:../tools:../../tools:.:$PATH

echo === testing `affcrypto -V` ===
echo === MAKING THE TEST FILES ==
unset AFFLIB_PASSPHRASE

BLANK_BASE=`mktemp -t blankXXXXX`
BLANK_AFF=$BLANK_BASE.aff
BLANK_ISO=$BLANK_BASE.iso
BLANK_ENCRYPTED_AFF=${BLANK_BASE}_encrypted.aff
WORDS=`mktemp -t wordsXXXX`

rm -f $BLANK_ISO $BLANK_AFF $BLANK_ENCRYPTED_AFF $WORDS
test_make_random_iso.sh $BLANK_ISO || (echo Cannot run test_make_random_iso.sh && exit -1)

if [ ! -r $BLANK_ISO ]; then
  echo CANNOT CREATE $BLANK_ISO
  echo Permission error prevents test from continuing. 
  exit 0
fi

affconvert -o $BLANK_AFF $BLANK_ISO || exit 1
affconvert -o file://:passphrase@/$BLANK_ENCRYPTED_AFF $BLANK_ISO || exit 1

if [ ! -r $BLANK_ENCRYPTED_AFF ]; then
  echo CANNOT CREATE $BLANK_ENCRYPTED_AFF 
  echo Permission error prevents test from continuing. 
  exit 0
fi


# Make sure affcrypto reports properly for with and with no encrypted segments
if (affcrypto $BLANK_AFF | grep " 0 encrypted" > /dev/null ) ; then 
  echo $BLANK_ENCRYPTED_AFF properly created
else  
   echo ENCRYPTED SEGMENTS IN $BLANK_ENCRYPTED_AFF --- STOP
   exit 1 
fi 

# Now test affcrypto
echo Encrypted segment count: `affcrypto -j $BLANK_ENCRYPTED_AFF`
if [ `affcrypto -j $BLANK_ENCRYPTED_AFF` = "0" ]; then 
  echo NO ENCRYPTED SEGMENTS IN $BLANK_ENCRYPTED_AFF --- STOP
  exit 1 
else
  echo $BLANK_ENCRYPTED_AFF properly created
fi

echo "sleepy" > $WORDS
echo "dopey" >> $WORDS
echo "doc" >> $WORDS
echo "passphrase" >> $WORDS
echo "foobar" >> $WORDS
if [ "`affcrypto -k -f $WORDS $BLANK_ENCRYPTED_AFF|grep correct|grep passphrase`"x = x ] ; then
  echo affcrypto did not find the right passphrase
  exit 1
else 
   echo affcrypto found the correct pasphrase 
fi

rm $BLANK_ISO $BLANK_AFF $BLANK_ENCRYPTED_AFF $WORDS

echo ALL TESTS PASS
exit 0