~siretart/cryptsetup/debian

« back to all changes in this revision

Viewing changes to debian/scripts/gen-old-ssl-key

  • Committer: Reinhard Tartler
  • Date: 2008-08-06 13:15:36 UTC
  • Revision ID: siretart@tauware.de-20080806131536-52nd1v52wo7ft4zt
import cryptsetup_1.0.6-4.dsc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/bash
2
 
#
3
 
# Compability script to create double encrypted key with 'openssl'.
4
 
# * NOTE * Should not be used for new installs
5
 
#
6
 
# Written by Markus Nass <generalstone@gmx.net>
7
 
# Modified by David Härdeman <david@hardeman.nu>
8
 
 
9
 
set -e
10
 
 
11
 
if [ ! -x /usr/bin/openssl ]; then
12
 
        echo "Please install the 'openssl' package."
13
 
        exit 1
14
 
fi
15
 
 
16
 
if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
17
 
        echo "Usage: $0 <key> [<dsaparam>]"
18
 
        exit 1
19
 
fi
20
 
 
21
 
echo "*NOTE* This key setup should NOT be used for new installs *NOTE*"
22
 
echo -n "Are you sure you want to continue? (y/n): "
23
 
read -n1 REPLY
24
 
echo
25
 
if [ "$REPLY" != "y" ]; then
26
 
        exit 1
27
 
fi
28
 
 
29
 
if [ -n "$2" ]; then
30
 
        DSAPARAM="$2"
31
 
else
32
 
        DSAPARAM=$(tempfile)
33
 
        RAND=$(tempfile)
34
 
        dd if=/dev/urandom of="$RAND" bs=1M count=4
35
 
        openssl dsaparam -out "$DSAPARAM" -rand "$RAND" 4096
36
 
        rm -f "$RAND"
37
 
fi
38
 
 
39
 
rc=1
40
 
DSAKEY=$(tempfile)
41
 
RAND=$(tempfile)
42
 
dd if=/dev/urandom of="$RAND" bs=1M count=4
43
 
if openssl gendsa -aes256 -out "$DSAKEY" -rand "$RAND" "$DSAPARAM" && \
44
 
   openssl enc -aes256 -e -salt -in "$DSAKEY" -out "$1"; then
45
 
        rc=0
46
 
fi
47
 
rm -f "$RAND"
48
 
rm -f "$DSAKEY"
49
 
 
50
 
if [ -z "$2" ]; then
51
 
        rm -f "$DSAPARAM"
52
 
fi
53
 
 
54
 
exit $rc