File: decrypt_ssl

package info (click to toggle)
cryptsetup 2%3A1.0.4%2Bsvn26-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,572 kB
  • ctags: 418
  • sloc: sh: 10,706; ansic: 3,187; makefile: 329; python: 90; perl: 40; sed: 16
file content (27 lines) | stat: -rw-r--r-- 550 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
#!/bin/sh
#
# Script to decrypt the key which is encrypted with openssl.
# See /usr/share/doc/cryptsetup/examples/gen-ssl-key to create such a key.
#

decrypt_ssl () {
	local tries maxtries
	maxtries=3
	tries=0

	echo -e "\nDecrypting ssl key $1..." >&2
	while [ $tries -lt $maxtries ]; do
		if /usr/bin/openssl enc -aes-256-cbc -d -salt -in $1 2> /dev/null 2>&1; then
			break
		fi
		tries=$(( $tries + 1))
	done
	rm -f $tmpkey

	if [ $tries -eq $maxtries ]; then
		echo -e "\nMaximum number of attempts exceeded" >&2
		exit 1
	fi
}

decrypt_ssl $1