|
0
|
1 #!/bin/bash
|
|
|
2 # usage: decrypt [-p passwd] [-m method] keyFile xmlFile
|
|
|
3 # If no passwd, will prompt
|
|
|
4 # method defaults to pkcs12
|
|
|
5 method=pkcs12
|
|
|
6 while [ "x$1" != "x${1##-}" ]
|
|
|
7 do
|
|
|
8 case "$1" in
|
|
|
9 -p) passwd="$2"; shift; shift ;;
|
|
|
10 -m) method=$2; shift; shift ;;
|
|
|
11 *) echo bad switch "$1" -- usage: decrypt [-p passwd] [-m method] keyFile xmlFile; exit 1 ;;
|
|
|
12 esac
|
|
|
13 done
|
|
|
14 if [ $# -gt 0 ]
|
|
|
15 then
|
|
|
16 keyfile="$1"
|
|
|
17 shift
|
|
|
18 else
|
|
|
19 echo keyFile required -- usage: decrypt [-p passwd] [-m method] keyFile xmlFile; exit 1
|
|
|
20 fi
|
|
|
21 if [ $# -gt 0 ]
|
|
|
22 then
|
|
|
23 xmlfile="$1"
|
|
|
24 else
|
|
|
25 xmlfile=/tmp/dec$$
|
|
|
26 cat > $xmlfile
|
|
|
27 cl="t"
|
|
|
28 fi
|
|
|
29 pwd=${passwd:-`read -s -p "Password for $keyfile: " pw && echo $pw`}
|
|
|
30 kf="`cygpath -w \"$keyfile\"`"
|
|
|
31 xf="`cygpath -w \"$xmlfile\"`"
|
|
|
32 /c/Program\ Files/xmlsec/xmlsec decrypt --$method "$kf" --pwd "$pwd" "$xf"
|
|
|
33 if [ "$cl" ]
|
|
|
34 then
|
|
|
35 rm -f "$xmlfile"
|
|
|
36 fi
|