]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/geom/class/eli/geli.8
Introduce dry run option for attaching the device.
[FreeBSD/FreeBSD.git] / sbin / geom / class / eli / geli.8
1 .\" Copyright (c) 2005-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd April 10, 2018
28 .Dt GELI 8
29 .Os
30 .Sh NAME
31 .Nm geli
32 .Nd "control utility for the cryptographic GEOM class"
33 .Sh SYNOPSIS
34 To compile GEOM_ELI into your kernel, add the following lines to your kernel
35 configuration file:
36 .Bd -ragged -offset indent
37 .Cd "device crypto"
38 .Cd "options GEOM_ELI"
39 .Ed
40 .Pp
41 Alternatively, to load the GEOM_ELI module at boot time, add the following line
42 to your
43 .Xr loader.conf 5 :
44 .Bd -literal -offset indent
45 geom_eli_load="YES"
46 .Ed
47 .Pp
48 Usage of the
49 .Nm
50 utility:
51 .Pp
52 .Nm
53 .Cm init
54 .Op Fl bdgPTv
55 .Op Fl a Ar aalgo
56 .Op Fl B Ar backupfile
57 .Op Fl e Ar ealgo
58 .Op Fl i Ar iterations
59 .Op Fl J Ar newpassfile
60 .Op Fl K Ar newkeyfile
61 .Op Fl l Ar keylen
62 .Op Fl s Ar sectorsize
63 .Op Fl V Ar version
64 .Ar prov
65 .Nm
66 .Cm label - an alias for
67 .Cm init
68 .Nm
69 .Cm attach
70 .Op Fl dnprv
71 .Op Fl j Ar passfile
72 .Op Fl k Ar keyfile
73 .Ar prov
74 .Nm
75 .Cm detach
76 .Op Fl fl
77 .Ar prov ...
78 .Nm
79 .Cm stop - an alias for
80 .Cm detach
81 .Nm
82 .Cm onetime
83 .Op Fl dT
84 .Op Fl a Ar aalgo
85 .Op Fl e Ar ealgo
86 .Op Fl l Ar keylen
87 .Op Fl s Ar sectorsize
88 .Ar prov
89 .Nm
90 .Cm configure
91 .Op Fl bBdDgGtT
92 .Ar prov ...
93 .Nm
94 .Cm setkey
95 .Op Fl pPv
96 .Op Fl i Ar iterations
97 .Op Fl j Ar passfile
98 .Op Fl J Ar newpassfile
99 .Op Fl k Ar keyfile
100 .Op Fl K Ar newkeyfile
101 .Op Fl n Ar keyno
102 .Ar prov
103 .Nm
104 .Cm delkey
105 .Op Fl afv
106 .Op Fl n Ar keyno
107 .Ar prov
108 .Nm
109 .Cm kill
110 .Op Fl av
111 .Op Ar prov ...
112 .Nm
113 .Cm backup
114 .Op Fl v
115 .Ar prov
116 .Ar file
117 .Nm
118 .Cm restore
119 .Op Fl fv
120 .Ar file
121 .Ar prov
122 .Nm
123 .Cm suspend
124 .Op Fl v
125 .Fl a | Ar prov ...
126 .Nm
127 .Cm resume
128 .Op Fl pv
129 .Op Fl j Ar passfile
130 .Op Fl k Ar keyfile
131 .Ar prov
132 .Nm
133 .Cm resize
134 .Op Fl v
135 .Fl s Ar oldsize
136 .Ar prov
137 .Nm
138 .Cm version
139 .Op Ar prov ...
140 .Nm
141 .Cm clear
142 .Op Fl v
143 .Ar prov ...
144 .Nm
145 .Cm dump
146 .Op Fl v
147 .Ar prov ...
148 .Nm
149 .Cm list
150 .Nm
151 .Cm status
152 .Nm
153 .Cm load
154 .Nm
155 .Cm unload
156 .Sh DESCRIPTION
157 The
158 .Nm
159 utility is used to configure encryption on GEOM providers.
160 .Pp
161 The following is a list of the most important features:
162 .Pp
163 .Bl -bullet -offset indent -compact
164 .It
165 Utilizes the
166 .Xr crypto 9
167 framework, so when there is crypto hardware available,
168 .Nm
169 will make use of it automatically.
170 .It
171 Supports many cryptographic algorithms (currently
172 .Nm AES-XTS ,
173 .Nm AES-CBC ,
174 .Nm Blowfish-CBC ,
175 .Nm Camellia-CBC
176 and
177 .Nm 3DES-CBC ) .
178 .It
179 Can optionally perform data authentication (integrity verification) utilizing
180 one of the following algorithms:
181 .Nm HMAC/MD5 ,
182 .Nm HMAC/SHA1 ,
183 .Nm HMAC/RIPEMD160 ,
184 .Nm HMAC/SHA256 ,
185 .Nm HMAC/SHA384
186 or
187 .Nm HMAC/SHA512 .
188 .It
189 Can create a User Key from up to two, piecewise components: a passphrase
190 entered via prompt or read from one or more passfiles; a keyfile read from
191 one or more files.
192 .It
193 Allows encryption of the root partition.
194 The user will be asked for the
195 passphrase before the root file system is mounted.
196 .It
197 Strengthens the passphrase component of the User Key with:
198 .Rs
199 .%A B. Kaliski
200 .%T "PKCS #5: Password-Based Cryptography Specification, Version 2.0."
201 .%R RFC
202 .%N 2898
203 .Re
204 .It
205 Allows the use of two independent User Keys (e.g., a
206 .Qq "user key"
207 and a
208 .Qq "company key" ) .
209 .It
210 It is fast -
211 .Nm
212 performs simple sector-to-sector encryption.
213 .It
214 Allows the encrypted Master Key to be backed up and restored,
215 so that if a user has to quickly destroy key material,
216 it is possible to get the data back by restoring keys from
217 backup.
218 .It
219 Providers can be configured to automatically detach on last close
220 (so users do not have to remember to detach providers after unmounting
221 the file systems).
222 .It
223 Allows attaching a provider with a random, one-time Master Key -
224 useful for swap partitions and temporary file systems.
225 .It
226 Allows verification of data integrity (data authentication).
227 .It
228 Allows suspending and resuming encrypted devices.
229 .El
230 .Pp
231 The first argument to
232 .Nm
233 indicates an action to be performed:
234 .Bl -tag -width ".Cm configure"
235 .It Cm init
236 Initialize the provider which needs to be encrypted.
237 Here you can set up the cryptographic algorithm to use, Data Key length,
238 etc.
239 The last sector of the provider is used to store metadata.
240 The
241 .Cm init
242 subcommand also automatically writes metadata backups to
243 .Pa /var/backups/<prov>.eli
244 file.
245 The metadata can be recovered with the
246 .Cm restore
247 subcommand described below.
248 .Pp
249 Additional options include:
250 .Bl -tag -width ".Fl J Ar newpassfile"
251 .It Fl a Ar aalgo
252 Enable data integrity verification (authentication) using the given algorithm.
253 This will reduce the size of storage available and also reduce speed.
254 For example, when using 4096 bytes sector and
255 .Nm HMAC/SHA256
256 algorithm, 89% of the original provider storage will be available for use.
257 Currently supported algorithms are:
258 .Nm HMAC/MD5 ,
259 .Nm HMAC/SHA1 ,
260 .Nm HMAC/RIPEMD160 ,
261 .Nm HMAC/SHA256 ,
262 .Nm HMAC/SHA384
263 and
264 .Nm HMAC/SHA512 .
265 If the option is not given, there will be no authentication, only encryption.
266 The recommended algorithm is
267 .Nm HMAC/SHA256 .
268 .It Fl b
269 Try to decrypt this partition during boot, before the root partition is mounted.
270 This makes it possible to use an encrypted root partition.
271 One will still need bootable unencrypted storage with a
272 .Pa /boot/
273 directory, which can be a CD-ROM disc or USB pen-drive, that can be removed
274 after boot.
275 .It Fl B Ar backupfile
276 File name to use for metadata backup instead of the default
277 .Pa /var/backups/<prov>.eli .
278 To inhibit backups, you can use
279 .Pa none
280 as the
281 .Ar backupfile .
282 .It Fl d
283 When entering the passphrase to boot from this encrypted root filesystem, echo
284 .Ql *
285 characters.
286 This makes the length of the passphrase visible.
287 .It Fl e Ar ealgo
288 Encryption algorithm to use.
289 Currently supported algorithms are:
290 .Nm AES-XTS ,
291 .Nm AES-CBC ,
292 .Nm Blowfish-CBC ,
293 .Nm Camellia-CBC ,
294 .Nm 3DES-CBC ,
295 and
296 .Nm NULL .
297 The default and recommended algorithm is
298 .Nm AES-XTS .
299 .Nm NULL
300 is unencrypted.
301 .It Fl g
302 Enable booting from this encrypted root filesystem.
303 The boot loader prompts for the passphrase and loads
304 .Xr loader 8
305 from the encrypted partition.
306 .It Fl i Ar iterations
307 Number of iterations to use with PKCS#5v2 when processing User Key
308 passphrase component.
309 If this option is not specified,
310 .Nm
311 will find the number of iterations which is equal to 2 seconds of crypto work.
312 If 0 is given, PKCS#5v2 will not be used.
313 PKCS#5v2 processing is performed once, after all parts of the passphrase
314 component have been read.
315 .It Fl J Ar newpassfile
316 Specifies a file which contains the passphrase component of the User Key
317 (or part of it).
318 If
319 .Ar newpassfile
320 is given as -, standard input will be used.
321 Only the first line (excluding new-line character) is taken from the given file.
322 This argument can be specified multiple times, which has the effect of
323 reassembling a single passphrase split across multiple files.
324 Cannot be combined with the
325 .Fl P
326 option.
327 .It Fl K Ar newkeyfile
328 Specifies a file which contains the keyfile component of the User Key
329 (or part of it).
330 If
331 .Ar newkeyfile
332 is given as -, standard input will be used.
333 This argument can be specified multiple times, which has the effect of
334 reassembling a single keyfile split across multiple keyfile parts.
335 .It Fl l Ar keylen
336 Data Key length to use with the given cryptographic algorithm.
337 If the length is not specified, the selected algorithm uses its
338 .Em default
339 key length.
340 .Bl -ohang -offset indent
341 .It Nm AES-XTS
342 .Em 128 ,
343 256
344 .It Nm AES-CBC , Nm Camellia-CBC
345 .Em 128 ,
346 192,
347 256
348 .It Nm Blowfish-CBC
349 .Em 128
350 + n * 32, for n=[0..10]
351 .It Nm 3DES-CBC
352 .Em 192
353 .El
354 .It Fl P
355 Do not use a passphrase as a component of the User Key.
356 Cannot be combined with the
357 .Fl J
358 option.
359 .It Fl s Ar sectorsize
360 Change decrypted provider's sector size.
361 Increasing the sector size allows increased performance,
362 because encryption/decryption which requires an initialization vector
363 is done per sector; fewer sectors means less computational work.
364 .It Fl T
365 Don't pass through
366 .Dv BIO_DELETE
367 calls (i.e., TRIM/UNMAP).
368 This can prevent an attacker from knowing how much space you're actually
369 using and which sectors contain live data, but will also prevent the
370 backing store (SSD, etc) from reclaiming space you're not using, which
371 may degrade its performance and lifespan.
372 The underlying provider may or may not actually obliterate the deleted
373 sectors when TRIM is enabled, so it should not be considered to add any
374 security.
375 .It Fl V Ar version
376 Metadata version to use.
377 This option is helpful when creating a provider that may be used by older
378 .Nm FreeBSD/GELI
379 versions.
380 Consult the
381 .Sx HISTORY
382 section to find which metadata version is supported by which FreeBSD version.
383 Note that using an older version of metadata may limit the number of
384 features available.
385 .El
386 .It Cm attach
387 Attach the given provider.
388 The encrypted Master Key will be loaded from the metadata and decrypted
389 using the given passphrase/keyfile and a new GEOM provider will be created
390 using the given provider's name with an
391 .Qq .eli
392 suffix.
393 .Pp
394 Additional options include:
395 .Bl -tag -width ".Fl j Ar passfile"
396 .It Fl d
397 If specified, a decrypted provider will be detached automatically on last close.
398 This can help with scarce memory so the user does not have to remember to detach the
399 provider after unmounting the file system.
400 It only works when the provider was opened for writing, so it will not work if
401 the file system on the provider is mounted read-only.
402 Probably a better choice is the
403 .Fl l
404 option for the
405 .Cm detach
406 subcommand.
407 .It Fl j Ar passfile
408 Specifies a file which contains the passphrase component of the User Key
409 (or part of it).
410 For more information see the description of the
411 .Fl J
412 option for the
413 .Cm init
414 subcommand.
415 .It Fl k Ar keyfile
416 Specifies a file which contains the keyfile component of the User Key
417 (or part of it).
418 For more information see the description of the
419 .Fl K
420 option for the
421 .Cm init
422 subcommand.
423 .It Fl n
424 Do a dry-run decryption.
425 This is useful to verify passphrase and keyfile without decrypting the device.
426 .It Fl p
427 Do not use a passphrase as a component of the User Key.
428 Cannot be combined with the
429 .Fl j
430 option.
431 .It Fl r
432 Attach read-only provider.
433 It will not be opened for writing.
434 .El
435 .It Cm detach
436 Detach the given providers, which means remove the devfs entry
437 and clear the Master Key and Data Keys from memory.
438 .Pp
439 Additional options include:
440 .Bl -tag -width ".Fl f"
441 .It Fl f
442 Force detach - detach even if the provider is open.
443 .It Fl l
444 Mark provider to detach on last close.
445 If this option is specified, the provider will not be detached
446 while it is open, but will be automatically detached when it is closed for the
447 last time even if it was only opened for reading.
448 .El
449 .It Cm onetime
450 Attach the given providers with a random, one-time (ephemeral) Master Key.
451 The command can be used to encrypt swap partitions or temporary file systems.
452 .Pp
453 Additional options include:
454 .Bl -tag -width ".Fl a Ar sectorsize"
455 .It Fl a Ar aalgo
456 Enable data integrity verification (authentication).
457 For more information, see the description of the
458 .Cm init
459 subcommand.
460 .It Fl e Ar ealgo
461 Encryption algorithm to use.
462 For more information, see the description of the
463 .Cm init
464 subcommand.
465 .It Fl d
466 Detach on last close.
467 Note: this option is not usable for temporary file systems as the provider will
468 be detached after creating the file system on it.
469 It still can (and should be) used for swap partitions.
470 For more information, see the description of the
471 .Cm attach
472 subcommand.
473 .It Fl l Ar keylen
474 Data Key length to use with the given cryptographic algorithm.
475 For more information, see the description of the
476 .Cm init
477 subcommand.
478 .It Fl s Ar sectorsize
479 Change decrypted provider's sector size.
480 For more information, see the description of the
481 .Cm init
482 subcommand.
483 .It Fl T
484 Disable TRIM/UNMAP passthru.
485 For more information, see the description of the
486 .Cm init
487 subcommand.
488 .El
489 .It Cm configure
490 Change configuration of the given providers.
491 .Pp
492 Additional options include:
493 .Bl -tag -width ".Fl b"
494 .It Fl b
495 Set the BOOT flag on the given providers.
496 For more information, see the description of the
497 .Cm init
498 subcommand.
499 .It Fl B
500 Remove the BOOT flag from the given providers.
501 .It Fl d
502 When entering the passphrase to boot from this encrypted root filesystem, echo
503 .Ql *
504 characters.
505 This makes the length of the passphrase visible.
506 .It Fl D
507 Disable echoing of any characters when a passphrase is entered to boot from this
508 encrypted root filesystem.
509 This hides the passphrase length.
510 .It Fl g
511 Enable booting from this encrypted root filesystem.
512 The boot loader prompts for the passphrase and loads
513 .Xr loader 8
514 from the encrypted partition.
515 .It Fl G
516 Deactivate booting from this encrypted root partition.
517 .It Fl t
518 Enable TRIM/UNMAP passthru.
519 For more information, see the description of the
520 .Cm init
521 subcommand.
522 .It Fl T
523 Disable TRIM/UNMAP passthru.
524 .El
525 .It Cm setkey
526 Install a copy of the Master Key into the selected slot, encrypted with
527 a new User Key.
528 If the selected slot is populated, replace the existing copy.
529 A provider has one Master Key, which can be stored in one or both slots,
530 each encrypted with an independent User Key.
531 With the
532 .Cm init
533 subcommand, only key number 0 is initialized.
534 The User Key can be changed at any time: for an attached provider,
535 for a detached provider, or on the backup file.
536 When a provider is attached, the user does not have to provide
537 an existing passphrase/keyfile.
538 .Pp
539 Additional options include:
540 .Bl -tag -width ".Fl J Ar newpassfile"
541 .It Fl i Ar iterations
542 Number of iterations to use with PKCS#5v2.
543 If 0 is given, PKCS#5v2 will not be used.
544 To be able to use this option with the
545 .Cm setkey
546 subcommand, only one key has to be defined and this key must be changed.
547 .It Fl j Ar passfile
548 Specifies a file which contains the passphrase component of a current User Key
549 (or part of it).
550 .It Fl J Ar newpassfile
551 Specifies a file which contains the passphrase component of the new User Key
552 (or part of it).
553 .It Fl k Ar keyfile
554 Specifies a file which contains the keyfile component of a current User Key
555 (or part of it).
556 .It Fl K Ar newkeyfile
557 Specifies a file which contains the keyfile component of the new User Key
558 (or part of it).
559 .It Fl n Ar keyno
560 Specifies the index number of the Master Key copy to change (could be 0 or 1).
561 If the provider is attached and no key number is given, the key
562 used for attaching the provider will be changed.
563 If the provider is detached (or we are operating on a backup file)
564 and no key number is given, the first Master Key copy to be successfully
565 decrypted with the provided User Key passphrase/keyfile will be changed.
566 .It Fl p
567 Do not use a passphrase as a component of the current User Key.
568 Cannot be combined with the
569 .Fl j
570 option.
571 .It Fl P
572 Do not use a passphrase as a component of the new User Key.
573 Cannot be combined with the
574 .Fl J
575 option.
576 .El
577 .It Cm delkey
578 Destroy (overwrite with random data) the selected Master Key copy.
579 If one is destroying keys for an attached provider, the provider
580 will not be detached even if all copies of the Master Key are destroyed.
581 It can even be rescued with the
582 .Cm setkey
583 subcommand because the Master Key is still in memory.
584 .Pp
585 Additional options include:
586 .Bl -tag -width ".Fl a Ar keyno"
587 .It Fl a
588 Destroy all copies of the Master Key (does not need
589 .Fl f
590 option).
591 .It Fl f
592 Force key destruction.
593 This option is needed to destroy the last copy of the Master Key.
594 .It Fl n Ar keyno
595 Specifies the index number of the Master Key copy.
596 If the provider is attached and no key number is given, the key
597 used for attaching the provider will be destroyed.
598 If provider is detached (or we are operating on a backup file) the key number
599 has to be given.
600 .El
601 .It Cm kill
602 This command should be used only in emergency situations.
603 It will destroy all copies of the Master Key on a given provider and will
604 detach it forcibly (if it is attached).
605 This is absolutely a one-way command - if you do not have a metadata
606 backup, your data is gone for good.
607 In case the provider was attached with the
608 .Fl r
609 flag, the keys will not be destroyed, only the provider will be detached.
610 .Pp
611 Additional options include:
612 .Bl -tag -width ".Fl a"
613 .It Fl a
614 If specified, all currently attached providers will be killed.
615 .El
616 .It Cm backup
617 Backup metadata from the given provider to the given file.
618 .It Cm restore
619 Restore metadata from the given file to the given provider.
620 .Pp
621 Additional options include:
622 .Bl -tag -width ".Fl f"
623 .It Fl f
624 Metadata contains the size of the provider to ensure that the correct
625 partition or slice is attached.
626 If an attempt is made to restore metadata to a provider that has a different
627 size,
628 .Nm
629 will refuse to restore the data unless the
630 .Fl f
631 switch is used.
632 If the partition or slice has been grown, the
633 .Cm resize
634 subcommand should be used rather than attempting to relocate the metadata
635 through
636 .Cm backup
637 and
638 .Cm restore .
639 .El
640 .It Cm suspend
641 Suspend device by waiting for all inflight requests to finish, clearing all
642 sensitive information (like the Master Key and Data Keys) from kernel memory,
643 and blocking all further I/O requests until the
644 .Cm resume
645 subcommand is executed.
646 This functionality is useful for laptops: when one wants to suspend a
647 laptop, one does not want to leave an encrypted device attached.
648 Instead of closing all files and directories opened from a file system located
649 on an encrypted device, unmounting the file system, and detaching the device,
650 the
651 .Cm suspend
652 subcommand can be used.
653 Any access to the encrypted device will be blocked until the Master Key is
654 reloaded through the
655 .Cm resume
656 subcommand.
657 Thus there is no need to close nor unmount anything.
658 The
659 .Cm suspend
660 subcommand does not work with devices created with the
661 .Cm onetime
662 subcommand.
663 Please note that sensitive data might still be present in memory after
664 suspending an encrypted device due to the file system cache, etc.
665 .Pp
666 Additional options include:
667 .Bl -tag -width ".Fl a"
668 .It Fl a
669 Suspend all
670 .Nm
671 devices.
672 .El
673 .It Cm resume
674 Resume previously suspended device.
675 The caller must ensure that executing this subcommand does not access the
676 suspended device, leading to a deadlock.
677 For example suspending a device which contains the file system where the
678 .Nm
679 utility is stored is bad idea.
680 .Pp
681 Additional options include:
682 .Bl -tag -width ".Fl j Ar passfile"
683 .It Fl j Ar passfile
684 Specifies a file which contains the passphrase component of the User Key
685 (or part of it).
686 For more information see the description of the
687 .Fl J
688 option for the
689 .Cm init
690 subcommand.
691 .It Fl k Ar keyfile
692 Specifies a file which contains the keyfile component of the User Key
693 (or part of it).
694 For more information see the description of the
695 .Fl K
696 option for the
697 .Cm init
698 subcommand.
699 .It Fl p
700 Do not use a passphrase as a component of the User Key.
701 Cannot be combined with the
702 .Fl j
703 option.
704 .El
705 .It Cm resize
706 Inform
707 .Nm
708 that the provider has been resized.
709 The old metadata block is relocated to the correct position at the end of the
710 provider and the provider size is updated.
711 .Pp
712 Additional options include:
713 .Bl -tag -width ".Fl s Ar oldsize"
714 .It Fl s Ar oldsize
715 The size of the provider before it was resized.
716 .El
717 .It Cm version
718 If no arguments are given, the
719 .Cm version
720 subcommand will print the version of
721 .Nm
722 userland utility as well as the version of the
723 .Nm ELI
724 GEOM class.
725 .Pp
726 If GEOM providers are specified, the
727 .Cm version
728 subcommand will print metadata version used by each of them.
729 .It Cm clear
730 Clear metadata from the given providers.
731 .Em WARNING :
732 This will erase with zeros the encrypted Master Key copies stored in the
733 metadata.
734 .It Cm dump
735 Dump metadata stored on the given providers.
736 .It Cm list
737 See
738 .Xr geom 8 .
739 .It Cm status
740 See
741 .Xr geom 8 .
742 .It Cm load
743 See
744 .Xr geom 8 .
745 .It Cm unload
746 See
747 .Xr geom 8 .
748 .El
749 .Pp
750 Additional options include:
751 .Bl -tag -width ".Fl v"
752 .It Fl v
753 Be more verbose.
754 .El
755 .Sh KEY SUMMARY
756 .Ss Master Key
757 Upon
758 .Cm init ,
759 the
760 .Nm
761 utility generates a random Master Key for the provider.
762 The Master Key never changes during the lifetime of the provider.
763 Each copy of the provider metadata, active or backed up to a file, can store
764 up to two, independently-encrypted copies of the Master Key.
765 .Ss User Key
766 Each stored copy of the Master Key is encrypted with a User Key, which
767 is generated by the
768 .Nm
769 utility from a passphrase and/or a keyfile.
770 The
771 .Nm
772 utility first reads all parts of the keyfile in the order specified on the
773 command line, then reads all parts of the stored passphrase in the order
774 specified on the command line.
775 If no passphrase parts are specified, the system prompts the user to enter
776 the passphrase.
777 The passphrase is optionally strengthened by PKCS#5v2.
778 The User Key is a digest computed over the concatenated keyfile and passphrase.
779 .Ss Data Key
780 During operation, one or more Data Keys are deterministically derived by
781 the kernel from the Master Key and cached in memory.
782 The number of Data Keys used by a given provider, and the way they are
783 derived, depend on the GELI version and whether the provider is configured to
784 use data authentication.
785 .Sh SYSCTL VARIABLES
786 The following
787 .Xr sysctl 8
788 variables can be used to control the behavior of the
789 .Nm ELI
790 GEOM class.
791 The default value is shown next to each variable.
792 Some variables can also be set in
793 .Pa /boot/loader.conf .
794 .Bl -tag -width indent
795 .It Va kern.geom.eli.version
796 Version number of the
797 .Nm ELI
798 GEOM class.
799 .It Va kern.geom.eli.debug : No 0
800 Debug level of the
801 .Nm ELI
802 GEOM class.
803 This can be set to a number between 0 and 3 inclusive.
804 If set to 0, minimal debug information is printed.
805 If set to 3, the
806 maximum amount of debug information is printed.
807 .It Va kern.geom.eli.tries : No 3
808 Number of times a user is asked for the passphrase.
809 This is only used for providers which are attached on boot
810 (before the root file system is mounted).
811 If set to 0, attaching providers on boot will be disabled.
812 This variable should be set in
813 .Pa /boot/loader.conf .
814 .It Va kern.geom.eli.overwrites : No 5
815 Specifies how many times the Master Key will be overwritten
816 with random values when it is destroyed.
817 After this operation it is filled with zeros.
818 .It Va kern.geom.eli.visible_passphrase : No 0
819 If set to 1, the passphrase entered on boot (before the root
820 file system is mounted) will be visible.
821 This alternative should be used with caution as the entered
822 passphrase can be logged and exposed via
823 .Xr dmesg 8 .
824 This variable should be set in
825 .Pa /boot/loader.conf .
826 .It Va kern.geom.eli.threads : No 0
827 Specifies how many kernel threads should be used for doing software
828 cryptography.
829 Its purpose is to increase performance on SMP systems.
830 If set to 0, a CPU-pinned thread will be started for every active CPU.
831 .It Va kern.geom.eli.batch : No 0
832 When set to 1, can speed-up crypto operations by using batching.
833 Batching reduces the number of interrupts by responding to a group of
834 crypto requests with one interrupt.
835 The crypto card and the driver has to support this feature.
836 .It Va kern.geom.eli.key_cache_limit : No 8192
837 Specifies how many Data Keys to cache.
838 The default limit
839 (8192 keys) will allow caching of all keys for a 4TB provider with 512 byte
840 sectors and will take around 1MB of memory.
841 .It Va kern.geom.eli.key_cache_hits
842 Reports how many times we were looking up a Data Key and it was already in
843 cache.
844 This sysctl is not updated for providers that need fewer Data Keys than
845 the limit specified in
846 .Va kern.geom.eli.key_cache_limit .
847 .It Va kern.geom.eli.key_cache_misses
848 Reports how many times we were looking up a Data Key and it was not in cache.
849 This sysctl is not updated for providers that need fewer Data Keys than the limit
850 specified in
851 .Va kern.geom.eli.key_cache_limit .
852 .El
853 .Sh EXIT STATUS
854 Exit status is 0 on success, and 1 if the command fails.
855 .Sh EXAMPLES
856 Initialize a provider which is going to be encrypted with a
857 passphrase and random data from a file on the user's pen drive.
858 Use 4kB sector size.
859 Attach the provider, create a file system, and mount it.
860 Do the work.
861 Unmount the provider and detach it:
862 .Bd -literal -offset indent
863 # dd if=/dev/random of=/mnt/pendrive/da2.key bs=64 count=1
864 # geli init -s 4096 -K /mnt/pendrive/da2.key /dev/da2
865 Enter new passphrase:
866 Reenter new passphrase:
867 # geli attach -k /mnt/pendrive/da2.key /dev/da2
868 Enter passphrase:
869 # dd if=/dev/random of=/dev/da2.eli bs=1m
870 # newfs /dev/da2.eli
871 # mount /dev/da2.eli /mnt/secret
872 \&...
873 # umount /mnt/secret
874 # geli detach da2.eli
875 .Ed
876 .Pp
877 Create an encrypted provider, but use two User Keys:
878 one for your employee and one for you as the company's security officer
879 (so it is not a tragedy if the employee
880 .Qq accidentally
881 forgets his passphrase):
882 .Bd -literal -offset indent
883 # geli init /dev/da2
884 Enter new passphrase:   (enter security officer's passphrase)
885 Reenter new passphrase:
886 # geli setkey -n 1 /dev/da2
887 Enter passphrase:       (enter security officer's passphrase)
888 Enter new passphrase:   (let your employee enter his passphrase ...)
889 Reenter new passphrase: (... twice)
890 .Ed
891 .Pp
892 You are the security officer in your company.
893 Create an encrypted provider for use by the user, but remember that users
894 forget their passphrases, so backup the Master Key with your own random key:
895 .Bd -literal -offset indent
896 # dd if=/dev/random of=/mnt/pendrive/keys/`hostname` bs=64 count=1
897 # geli init -P -K /mnt/pendrive/keys/`hostname` /dev/ada0s1e
898 # geli backup /dev/ada0s1e /mnt/pendrive/backups/`hostname`
899 (use key number 0, so the encrypted Master Key will be re-encrypted by this)
900 # geli setkey -n 0 -k /mnt/pendrive/keys/`hostname` /dev/ada0s1e
901 (allow the user to enter his passphrase)
902 Enter new passphrase:
903 Reenter new passphrase:
904 .Ed
905 .Pp
906 Encrypted swap partition setup:
907 .Bd -literal -offset indent
908 # dd if=/dev/random of=/dev/ada0s1b bs=1m
909 # geli onetime -d -e 3des ada0s1b
910 # swapon /dev/ada0s1b.eli
911 .Ed
912 .Pp
913 The example below shows how to configure two providers which will be attached
914 on boot (before the root file system is mounted).
915 One of them is using passphrase and three keyfile parts and the other is
916 using only a keyfile in one part:
917 .Bd -literal -offset indent
918 # dd if=/dev/random of=/dev/da0 bs=1m
919 # dd if=/dev/random of=/boot/keys/da0.key0 bs=32k count=1
920 # dd if=/dev/random of=/boot/keys/da0.key1 bs=32k count=1
921 # dd if=/dev/random of=/boot/keys/da0.key2 bs=32k count=1
922 # geli init -b -K /boot/keys/da0.key0 -K /boot/keys/da0.key1 -K /boot/keys/da0.key2 da0
923 Enter new passphrase:
924 Reenter new passphrase:
925 # dd if=/dev/random of=/dev/da1s3a bs=1m
926 # dd if=/dev/random of=/boot/keys/da1s3a.key bs=128k count=1
927 # geli init -b -P -K /boot/keys/da1s3a.key da1s3a
928 .Ed
929 .Pp
930 The providers are initialized, now we have to add these lines to
931 .Pa /boot/loader.conf :
932 .Bd -literal -offset indent
933 geli_da0_keyfile0_load="YES"
934 geli_da0_keyfile0_type="da0:geli_keyfile0"
935 geli_da0_keyfile0_name="/boot/keys/da0.key0"
936 geli_da0_keyfile1_load="YES"
937 geli_da0_keyfile1_type="da0:geli_keyfile1"
938 geli_da0_keyfile1_name="/boot/keys/da0.key1"
939 geli_da0_keyfile2_load="YES"
940 geli_da0_keyfile2_type="da0:geli_keyfile2"
941 geli_da0_keyfile2_name="/boot/keys/da0.key2"
942
943 geli_da1s3a_keyfile0_load="YES"
944 geli_da1s3a_keyfile0_type="da1s3a:geli_keyfile0"
945 geli_da1s3a_keyfile0_name="/boot/keys/da1s3a.key"
946 .Ed
947 .Pp
948 If there is only one keyfile, the index might be omitted:
949 .Bd -literal -offset indent
950 geli_da1s3a_keyfile_load="YES"
951 geli_da1s3a_keyfile_type="da1s3a:geli_keyfile"
952 geli_da1s3a_keyfile_name="/boot/keys/da1s3a.key"
953 .Ed
954 .Pp
955 Not only configure encryption, but also data integrity verification using
956 .Nm HMAC/SHA256 .
957 .Bd -literal -offset indent
958 # geli init -a hmac/sha256 -s 4096 /dev/da0
959 Enter new passphrase:
960 Reenter new passphrase:
961 # geli attach /dev/da0
962 Enter passphrase:
963 # dd if=/dev/random of=/dev/da0.eli bs=1m
964 # newfs /dev/da0.eli
965 # mount /dev/da0.eli /mnt/secret
966 .Ed
967 .Pp
968 .Cm geli
969 writes the metadata backup by default to the
970 .Pa /var/backups/<prov>.eli
971 file.
972 If the metadata is lost in any way (e.g., by accidental overwrite), it can be restored.
973 Consider the following situation:
974 .Bd -literal -offset indent
975 # geli init /dev/da0
976 Enter new passphrase:
977 Reenter new passphrase:
978
979 Metadata backup can be found in /var/backups/da0.eli and
980 can be restored with the following command:
981
982         # geli restore /var/backups/da0.eli /dev/da0
983
984 # geli clear /dev/da0
985 # geli attach /dev/da0
986 geli: Cannot read metadata from /dev/da0: Invalid argument.
987 # geli restore /var/backups/da0.eli /dev/da0
988 # geli attach /dev/da0
989 Enter passphrase:
990 .Ed
991 .Pp
992 If an encrypted file system is extended, it is necessary to relocate and
993 update the metadata:
994 .Bd -literal -offset indent
995 # gpart create -s GPT ada0
996 # gpart add -s 1g -t freebsd-ufs -i 1 ada0
997 # geli init -K keyfile -P ada0p1
998 # gpart resize -s 2g -i 1 ada0
999 # geli resize -s 1g ada0p1
1000 # geli attach -k keyfile -p ada0p1
1001 .Ed
1002 .Pp
1003 Initialize provider with the passphrase split into two files.
1004 The provider can be attached using those two files or by entering
1005 .Dq foobar
1006 as the passphrase at the
1007 .Nm
1008 prompt:
1009 .Bd -literal -offset indent
1010 # echo foo > da0.pass0
1011 # echo bar > da0.pass1
1012 # geli init -J da0.pass0 -J da0.pass1 da0
1013 # geli attach -j da0.pass0 -j da0.pass1 da0
1014 # geli detach da0
1015 # geli attach da0
1016 Enter passphrase: foobar
1017 .Ed
1018 .Pp
1019 Suspend all
1020 .Nm
1021 devices on a laptop, suspend the laptop, then resume devices one by one after
1022 resuming the laptop:
1023 .Bd -literal -offset indent
1024 # geli suspend -a
1025 # zzz
1026 <resume your laptop>
1027 # geli resume -p -k keyfile gpt/secret
1028 # geli resume gpt/private
1029 Enter passphrase:
1030 .Ed
1031 .Sh ENCRYPTION MODES
1032 .Nm
1033 supports two encryption modes:
1034 .Nm XTS ,
1035 which was standardized as
1036 .Nm IEEE P1619
1037 and
1038 .Nm CBC
1039 with unpredictable IV.
1040 The
1041 .Nm CBC
1042 mode used by
1043 .Nm
1044 is very similar to the mode
1045 .Nm ESSIV .
1046 .Sh DATA AUTHENTICATION
1047 .Nm
1048 can verify data integrity when an authentication algorithm is specified.
1049 When data corruption/modification is detected,
1050 .Nm
1051 will not return any data, but instead will return an error
1052 .Pq Er EINVAL .
1053 The offset and size of the corrupted data will be printed on the console.
1054 It is important to know against which attacks
1055 .Nm
1056 provides protection for your data.
1057 If data is modified in-place or copied from one place on the disk
1058 to another even without modification,
1059 .Nm
1060 should be able to detect such a change.
1061 If an attacker can remember the encrypted data, he can overwrite any future
1062 changes with the data he owns without it being noticed.
1063 In other words
1064 .Nm
1065 will not protect your data against replay attacks.
1066 .Pp
1067 It is recommended to write to the whole provider before first use,
1068 in order to make sure that all sectors and their corresponding
1069 checksums are properly initialized into a consistent state.
1070 One can safely ignore data authentication errors that occur immediately
1071 after the first time a provider is attached and before it is
1072 initialized in this way.
1073 .Sh SEE ALSO
1074 .Xr crypto 4 ,
1075 .Xr gbde 4 ,
1076 .Xr geom 4 ,
1077 .Xr loader.conf 5 ,
1078 .Xr gbde 8 ,
1079 .Xr geom 8 ,
1080 .Xr crypto 9
1081 .Sh HISTORY
1082 The
1083 .Nm
1084 utility appeared in
1085 .Fx 6.0 .
1086 Support for the
1087 .Nm Camellia
1088 block cipher is implemented by Yoshisato Yanagisawa in
1089 .Fx 7.0 .
1090 .Pp
1091 Highest
1092 .Nm GELI
1093 metadata version supported by the given FreeBSD version:
1094 .Bl -column -offset indent ".Sy FreeBSD" ".Sy version"
1095 .It Sy FreeBSD Ta Sy GELI
1096 .It Sy version Ta Sy version
1097 .Pp
1098 .It Li 6.0 Ta 0
1099 .It Li 6.1 Ta 0
1100 .It Li 6.2 Ta 3
1101 .It Li 6.3 Ta 3
1102 .It Li 6.4 Ta 3
1103 .Pp
1104 .It Li 7.0 Ta 3
1105 .It Li 7.1 Ta 3
1106 .It Li 7.2 Ta 3
1107 .It Li 7.3 Ta 3
1108 .It Li 7.4 Ta 3
1109 .Pp
1110 .It Li 8.0 Ta 3
1111 .It Li 8.1 Ta 3
1112 .It Li 8.2 Ta 5
1113 .Pp
1114 .It Li 9.0 Ta 6
1115 .Pp
1116 .It Li 10.0 Ta 7
1117 .El
1118 .Sh AUTHORS
1119 .An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org