1 .\" $NetBSD: cgdconfig.8,v 1.28 2008/09/12 16:51:55 christos Exp $
3 .\" Copyright (c) 2002, The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Roland C. Dowdeswell.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd configuration utility for the cryptographic disk driver
45 .Op Fl f Ar configfile
49 .Op Fl f Ar configfile
79 is used to configure and unconfigure cryptographic disk devices (cgds)
80 and to maintain the configuration files that are associated with them.
81 For more information about cryptographic disk devices see
84 The options are as follows:
85 .Bl -tag -width configfilexxxx
87 Configure all the devices listed in the cgd configuration file.
88 .It Fl f Ar configfile
89 Specify the configuration file explicitly, rather than using the default
91 .Pa /etc/cgd/cgd.conf .
93 Generate a new paramsfile (to stdout) using the values from
95 which will generate the same key.
96 This may need to prompt for multiple passphrases.
98 Generate a paramsfile (to stdout).
100 Specify the IV method (default: encblkno1).
102 Specify the key generation method (default: pkcs5_pbkdf2/sha1).
104 Do not actually configure or unconfigure a cryptographic disk
105 device, but instead report the steps that would be taken.
112 Read all passphrases from stdin rather than
114 Passphrases are separated by newlines.
115 Users of this flag must be able to predict the order in which passphrases
117 If this flag is specified then verification errors will cause the device
118 in question to be unconfigured rather than prompting for the passphrase
121 Read the key from stdin.
123 Unconfigure all the devices listed in the cgd configuration file.
127 Specify the verification method (default: none).
130 May be specified multiple times.
133 For more information about the cryptographic algorithms and IV methods
134 supported, please refer to
136 .Ss Key Generation Methods
137 To generate the key which it will use,
139 evaluates all of the key generation methods in the parameters file
140 and uses the exclusive-or of the outputs of all the methods.
141 The methods and descriptions are as follows:
142 .Bl -tag -width indentxxxxxxxxxxx
143 .It pkcs5_pbkdf2/sha1
144 This method requires a passphrase which is entered at configuration
146 It is a salted hmac-based scheme detailed in
147 .Dq PKCS#5 v2.0: Password-Based Cryptography Standard ,
148 RSA Laboratories, March 25, 1999, pages 8-10.
149 PKCS #5 was also republished as RFC 2898.
151 This is an earlier, slightly incorrect and deprecated implementation
152 of the above algorithm.
153 It is retained for backwards compatibility with existing parameters
154 files, and will be removed.
155 Existing parameters files should be
156 converted to use the correct method using the
158 option, and a new passphrase.
160 This method stores its key in the parameters file.
162 The method simply reads
164 and uses the resulting bits as the key.
165 It does not require a passphrase to be entered.
166 This method is typically used to present disk devices that do not
167 need to survive a reboot, such as the swap partition.
168 It is also handy to facilitate overwriting the contents of
169 a disk volume with meaningless data prior to use.
171 The method simply reads
173 and uses the resulting bits as the key. This is similar to the
175 method, but it guarantees that cgdconfig will not stall waiting for
176 hard-random bits (useful when configuring a cgd for swap at boot time).
177 Note, however, that some or all of the bits used to generate the
178 key may be obtained from a pseudo-random number generator,
179 which may not be as secure as the entropy based hard-random
182 This method executes a shell command via
184 and reads the key from stdout.
186 .Ss Verification Method
187 The verification method is how
189 determines if the generated key is correct.
190 If the newly configured disk fails to verify, then
192 will regenerate the key and re-configure the device.
193 It only makes sense to specify a verification method if at least of the
194 key generation methods is error prone, e.g., uses a user-entered passphrase.
195 The following verification methods are supported:
197 .Bl -tag -width indentxxx -compact
199 perform no verification.
201 scan for a valid disklabel.
203 scan for a valid FFS file system.
205 prompt for passphrase twice, and ensure entered passphrases are
207 This method only works with the pkcs5_pbkdf2/sha1 and pkcs5_pbkdf2 key
210 .Ss /etc/cgd/cgd.conf
212 .Pa /etc/cgd/cgd.conf
220 Each line of the file is composed of either two or three
221 tokens: cgd, target, and optional paramsfile.
225 character is interpreted as a comment and indicates that the
226 rest of the line should be ignored.
229 at the end of a line indicates that the next line is a continuation of
235 .Pa /etc/cgd/cgd.conf .
237 The Parameters File contains the required information to generate the
238 key and configure a device.
239 These files are typically generated by the
241 flag and not edited by hand.
242 When a device is configured the default parameters file is constructed
243 by taking the basename of the target disk and prepending
246 E.g., if the target is
248 then the default parameters file will be
251 It is possible to have more than one parameters file for a given
252 disk which use different key generation methods but will generate
254 To create a parameters file that is equivalent to an existing parameters
262 for an example of this usage.
264 The parameters file contains a list of statements each terminated
266 Some statements can contain statement-blocks which are either a
267 single unadorned statement, or a brace-enclosed list of semicolon
268 terminated statements.
269 Three types of data are understood:
271 .Bl -tag -compact -width integerxx
273 a 32 bit signed integer.
277 a length-encoded base64 string.
280 The following statements are defined:
281 .Bl -tag -width indentxx
282 .It algorithm Ar string
283 Defines the cryptographic algorithm.
284 .It iv-method Ar string
285 Defines the IV generation method.
286 .It keylength Ar integer
287 Defines the length of the key.
288 .It verify_method Ar string
289 Defines the verification method.
290 .It keygen Ar string Ar statement_block
291 Defines a key generation method.
294 contains statements that are specific to the key generation method.
297 The keygen statement's statement block may contain the following statements:
298 .Bl -tag -width indentxx
301 Only used for the storedkey key generation method.
303 The command to execute.
304 Only used for the shell_cmd key generation method.
305 .It iterations Ar integer
306 The number of iterations.
307 Only used for pkcs5_pbkdf2/sha1 and pkcs5_pbkdf2.
310 Only used for pkcs5_pbkdf2/sha1 and pkcs5_pbkdf2.
313 .Bl -tag -width indentxxxxxxxxxxxxxxxxxx -compact
315 configuration directory, used to store paramsfiles.
316 .It Pa /etc/cgd/cgd.conf
317 cgd configuration file.
320 To set up and configure a cgd that uses AES with a 192 bit key
321 in CBC mode with the IV Method
323 (encrypted block number):
325 # cgdconfig -g -o /etc/cgd/wd0e aes-cbc 192
326 # cgdconfig cgd0 /dev/wd0e
327 /dev/wd0e's passphrase:
330 When using verification methods, the first time that we configure the
331 disk the verification method will fail.
332 We overcome this by supplying
334 when we configure the first time to set up the disk.
336 sequence of commands that is recommended:
338 # cgdconfig -g -o /etc/cgd/wd0e -V disklabel aes-cbc
339 # cgdconfig -V re-enter cgd0 /dev/wd0e
340 /dev/wd0e's passphrase:
341 re-enter device's passphrase:
342 # disklabel -e -I cgd0
344 # cgdconfig cgd0 /dev/wd0e
345 /dev/wd0e's passphrase:
348 To create a new parameters file that will generate the same key as an old
351 # cgdconfig -G -o newparamsfile oldparamsfile
352 old file's passphrase:
353 new file's passphrase:
356 To configure a cgd that uses Blowfish with a 200 bit key that it
359 # cgdconfig -s cgd0 /dev/sd0h blowfish-cbc 200
362 An example parameters file which uses PKCS#5 PBKDF2:
368 keygen pkcs5_pbkdf2/sha1 {
370 salt AAAAgMoHiYonye6Kog \\
375 An example parameters file which stores its key locally:
381 keygen storedkey key AAABAK3QO6d7xzLfrXTdsgg4 \\
382 ly2TdxkFqOkYYcbyUKu/f60L;
386 .Pa /etc/cgd/cgd.conf :
390 # Configuration file for cryptographic disk devices
393 # cgd target [paramsfile]
395 cgd1 /dev/sd0h /usr/local/etc/cgd/sd0h
398 Note that this will store the parameters file as
400 And use the entered passphrase to generate the key.
403 .It "cgdconfig: could not calibrate pkcs5_pbkdf2"
404 An error greater than 5% in calibration occured.
405 This could be the result of dynamic processor frequency scaling technology.
406 Ensure that the processor clock frequency remains static throughout the
412 .Dq PKCS #5 v2.0: Password-Based Cryptography Standard ,
413 RSA Laboratories, March 25, 1999.
424 to read in the passphrase, it is limited to 128 characters.