/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-keygen

  • Committer: Teddy Hogeborn
  • Date: 2008-08-24 06:17:02 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080824061702-zxrru4r1vxmx4tuq
* Makefile (PREFIX, CONFDIR, MANDIR): Use $(DESTDIR).
  (install-server, install-client): Use "install --directory" instead
                                    of mkdir.

* mandos-keygen: New options --subtype and --sublength.
  (trap): Added semicolons and backslashes.
  (gpg): Added "--enable-dsa2" to all invocations.

* mandos-keygen.xml: Changed single quotes to double quotes for
                     consistency.
  (/refentry/refentryinfo/copyright) Split copyright holders.
  (SYNOPSIS): Added "--subtype", "--sublength", "-s", and "-L".
  (OPTIONS): Document the subtype and sublength options.
  (SECURITY): Also note the "--subtype" and "--sublength" options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
KEYDIR="/etc/mandos"
26
26
KEYTYPE=DSA
27
27
KEYLENGTH=1024
 
28
SUBKEYTYPE=ELG-E
 
29
SUBKEYLENGTH=2048
28
30
KEYNAME="`hostname --fqdn`"
29
31
KEYEMAIL=""
30
32
KEYCOMMENT="Mandos client key"
48
50
  -t TYPE, --type TYPE  Key type.  Default is DSA.
49
51
  -l BITS, --length BITS
50
52
                        Key length in bits.  Default is 1024.
 
53
  -s TYPE, --subtype TYPE
 
54
                        Subkey type.  Default is ELG-E.
 
55
  -L BITS, --sublength BITS
 
56
                        Subkey length in bits.  Default is 2048.
51
57
  -n NAME, --name NAME  Name of key.  Default is the FQDN.
52
58
  -e EMAIL, --email EMAIL
53
59
                        Email address of key.  Default is empty.
66
72
    case "$1" in
67
73
        -d|--dir) KEYDIR="$2"; shift 2;;
68
74
        -t|--type) KEYTYPE="$2"; shift 2;;
 
75
        -s|--subtype) SUBKEYTYPE="$2"; shift 2;;
69
76
        -l|--length) KEYLENGTH="$2"; shift 2;;
 
77
        -L|--sublength) SUBKEYLENGTH="$2"; shift 2;;
70
78
        -n|--name) KEYNAME="$2"; shift 2;;
71
79
        -e|--email) KEYEMAIL="$2"; shift 2;;
72
80
        -c|--comment) KEYCOMMENT="$2"; shift 2;;
73
 
        -x|--expire) KEYCOMMENT="$2"; shift 2;;
 
81
        -x|--expire) KEYEXPIRE="$2"; shift 2;;
74
82
        -f|--force) FORCE=yes; shift;;
75
83
        -v|--version) echo "$0 $VERSION"; exit;;
76
84
        -h|--help) help; exit;;
142
150
PUBRING="`mktemp -t mandos-gpg-pubring.XXXXXXXXXX`"
143
151
 
144
152
# Remove temporary files on exit
145
 
trap "rm --force $PUBRING $BATCHFILE; shred --remove $SECRING" EXIT
 
153
trap "
 
154
set +e; \
 
155
rm --force $PUBRING $BATCHFILE; \
 
156
shred --remove $SECRING; \
 
157
stty echo; \
 
158
" EXIT
146
159
 
147
160
# Create batch file for GnuPG
148
161
cat >"$BATCHFILE" <<EOF
149
162
Key-Type: $KEYTYPE
150
163
Key-Length: $KEYLENGTH
151
164
#Key-Usage: encrypt,sign,auth
 
165
Subkey-Type: $SUBKEYTYPE
 
166
Subkey-Length: $SUBKEYLENGTH
 
167
#Subkey-Usage: encrypt,sign,auth
152
168
Name-Real: $KEYNAME
153
169
$KEYCOMMENTLINE
154
170
$KEYEMAILLINE
155
171
Expire-Date: $KEYEXPIRE
 
172
#Preferences: <string>
 
173
#Handle: <no-spaces>
156
174
%pubring $PUBRING
157
175
%secring $SECRING
158
176
%commit
162
180
 
163
181
# Generate a new key in the key rings
164
182
gpg --no-random-seed-file --quiet --batch --no-tty \
165
 
    --no-default-keyring --no-options --batch \
 
183
    --no-default-keyring --no-options --enable-dsa2 \
166
184
    --secret-keyring "$SECRING" --keyring "$PUBRING" \
167
185
    --gen-key "$BATCHFILE"
168
186
rm --force "$BATCHFILE"
188
206
 
189
207
# Export keys from key rings to key files
190
208
gpg --no-random-seed-file --quiet --batch --no-tty --armor \
191
 
    --no-default-keyring --secret-keyring "$SECRING" \
192
 
    --keyring "$PUBRING" --export-options export-minimal \
193
 
    --comment "$FILECOMMENT" --output "$SECKEYFILE" \
194
 
    --export-secret-keys
 
209
    --no-default-keyring --no-options --enable-dsa2 \
 
210
    --secret-keyring "$SECRING" --keyring "$PUBRING" \
 
211
    --export-options export-minimal --comment "$FILECOMMENT" \
 
212
    --output "$SECKEYFILE" --export-secret-keys
195
213
gpg --no-random-seed-file --quiet --batch --no-tty --armor \
196
 
    --no-default-keyring --secret-keyring "$SECRING" \
197
 
    --keyring "$PUBRING" --export-options export-minimal \
198
 
    --comment "$FILECOMMENT" --output "$PUBKEYFILE" \
199
 
    --export
 
214
    --no-default-keyring --no-options --enable-dsa2 \
 
215
    --secret-keyring "$SECRING" --keyring "$PUBRING" \
 
216
    --export-options export-minimal --comment "$FILECOMMENT" \
 
217
    --output "$PUBKEYFILE" --export
200
218
 
201
219
trap - EXIT
202
220