3 # Copyright (c) 2005 Zmanda Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # Contact information: Zmanda Inc, 505 N Mathlida Ave, Suite 120
20 # Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
24 # wrapper script to use aespipe
25 # based on bz2aespipe distributed by aespipe from
26 # http://loop-aes.sourceforge.net/
28 # 10 bytes: constant string 'bz2aespipe'
29 # 10 bytes: itercountk digits
30 # 1 byte: '0' = AES128, '1' = AES192, '2' = AES256
31 # 1 byte: '0' = SHA256, '1' = SHA384, '2' = SHA512, '3' = RMD160
32 # 24 bytes: random seed string
33 # remaining bytes are aespipe encrypted
35 # These definitions are only used when encrypting.
36 # Decryption will autodetect these definitions from archive.
41 AMANDA_HOME=~@CLIENT_LOGIN@
42 GPGKEY="$AMANDA_HOME/.gnupg/am_key.gpg"
45 PATH=/usr/bin:/usr/local/bin:/sbin:/usr/sbin
48 if test x$1 = x-d ; then
50 n=`head -c 10 - | tr -d -c 0-9a-zA-Z`
51 if test x${n} != xbz2aespipe ; then
52 echo "bz2aespipe: wrong magic - aborted" >/dev/tty
55 itercountk=`head -c 10 - | tr -d -c 0-9`
56 if test x${itercountk} = x ; then itercountk=0; fi
57 n=`head -c 1 - | tr -d -c 0-9`
59 if test x${n} = x1 ; then encryption=AES192; fi
60 if test x${n} = x2 ; then encryption=AES256; fi
61 n=`head -c 1 - | tr -d -c 0-9`
63 if test x${n} = x1 ; then hashfunc=SHA384; fi
64 if test x${n} = x2 ; then hashfunc=SHA512; fi
65 if test x${n} = x3 ; then hashfunc=RMD160; fi
66 seedstr=`head -c 24 - | tr -d -c 0-9a-zA-Z+/`
67 aespipe -K ${GPGKEY} -p ${FDNUMBER} -e ${encryption} -H ${hashfunc} -S ${seedstr} -C ${itercountk} -d
71 echo ${ITERCOUNTK} | awk '{printf "%10u", $1;}'
72 n=`echo ${ENCRYPTION} | tr -d -c 0-9`
74 if test x${n} = x192 ; then aesstr=1; fi
75 if test x${n} = x256 ; then aesstr=2; fi
76 n=`echo ${HASHFUNC} | tr -d -c 0-9`
78 if test x${n} = x384 ; then hashstr=1; fi
79 if test x${n} = x512 ; then hashstr=2; fi
80 if test x${n} = x160 ; then hashstr=3; fi
81 seedstr=`head -c 18 /dev/urandom | uuencode -m - | head -n 2 | tail -n 1`
82 echo -n ${aesstr}${hashstr}${seedstr}
83 aespipe -K ${GPGKEY} -p ${FDNUMBER} -e ${ENCRYPTION} -H ${HASHFUNC} -S ${seedstr} -C ${ITERCOUNTK} -w ${WAITSECONDS}