]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/geom/class/eli/geli.8
Merge llvm, clang, lld and lldb release_40 branch r292009. Also update
[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 August 3, 2016
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 bgPTv
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 dprv
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 bBgGtT
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 e Ar ealgo
283 Encryption algorithm to use.
284 Currently supported algorithms are:
285 .Nm AES-XTS ,
286 .Nm AES-CBC ,
287 .Nm Blowfish-CBC ,
288 .Nm Camellia-CBC ,
289 .Nm 3DES-CBC ,
290 and
291 .Nm NULL .
292 The default and recommended algorithm is
293 .Nm AES-XTS .
294 .Nm NULL
295 is unencrypted.
296 .It Fl g
297 Enable booting from this encrypted root filesystem.
298 The boot loader prompts for the passphrase and loads
299 .Xr loader 8
300 from the encrypted partition.
301 .It Fl i Ar iterations
302 Number of iterations to use with PKCS#5v2 when processing User Key
303 passphrase component.
304 If this option is not specified,
305 .Nm
306 will find the number of iterations which is equal to 2 seconds of crypto work.
307 If 0 is given, PKCS#5v2 will not be used.
308 PKCS#5v2 processing is performed once, after all parts of the passphrase
309 component have been read.
310 .It Fl J Ar newpassfile
311 Specifies a file which contains the passphrase component of the User Key
312 (or part of it).
313 If
314 .Ar newpassfile
315 is given as -, standard input will be used.
316 Only the first line (excluding new-line character) is taken from the given file.
317 This argument can be specified multiple times, which has the effect of
318 reassembling a single passphrase split across multiple files.
319 Cannot be combined with the
320 .Fl P
321 option.
322 .It Fl K Ar newkeyfile
323 Specifies a file which contains the keyfile component of the User Key
324 (or part of it).
325 If
326 .Ar newkeyfile
327 is given as -, standard input will be used.
328 This argument can be specified multiple times, which has the effect of
329 reassembling a single keyfile split across multiple keyfile parts.
330 .It Fl l Ar keylen
331 Data Key length to use with the given cryptographic algorithm.
332 If the length is not specified, the selected algorithm uses its
333 .Em default
334 key length.
335 .Bl -ohang -offset indent
336 .It Nm AES-XTS
337 .Em 128 ,
338 256
339 .It Nm AES-CBC , Nm Camellia-CBC
340 .Em 128 ,
341 192,
342 256
343 .It Nm Blowfish-CBC
344 .Em 128
345 + n * 32, for n=[0..10]
346 .It Nm 3DES-CBC
347 .Em 192
348 .El
349 .It Fl P
350 Do not use a passphrase as a component of the User Key.
351 Cannot be combined with the
352 .Fl J
353 option.
354 .It Fl s Ar sectorsize
355 Change decrypted provider's sector size.
356 Increasing the sector size allows increased performance,
357 because encryption/decryption which requires an initialization vector
358 is done per sector; fewer sectors means less computational work.
359 .It Fl T
360 Don't pass through
361 .Dv BIO_DELETE
362 calls (i.e., TRIM/UNMAP).
363 This can prevent an attacker from knowing how much space you're actually
364 using and which sectors contain live data, but will also prevent the
365 backing store (SSD, etc) from reclaiming space you're not using, which
366 may degrade its performance and lifespan.
367 The underlying provider may or may not actually obliterate the deleted
368 sectors when TRIM is enabled, so it should not be considered to add any
369 security.
370 .It Fl V Ar version
371 Metadata version to use.
372 This option is helpful when creating a provider that may be used by older
373 .Nm FreeBSD/GELI
374 versions.
375 Consult the
376 .Sx HISTORY
377 section to find which metadata version is supported by which FreeBSD version.
378 Note that using an older version of metadata may limit the number of
379 features available.
380 .El
381 .It Cm attach
382 Attach the given provider.
383 The encrypted Master Key will be loaded from the metadata and decrypted
384 using the given passphrase/keyfile and a new GEOM provider will be created
385 using the given provider's name with an
386 .Qq .eli
387 suffix.
388 .Pp
389 Additional options include:
390 .Bl -tag -width ".Fl j Ar passfile"
391 .It Fl d
392 If specified, a decrypted provider will be detached automatically on last close.
393 This can help with scarce memory so the user does not have to remember to detach the
394 provider after unmounting the file system.
395 It only works when the provider was opened for writing, so it will not work if
396 the file system on the provider is mounted read-only.
397 Probably a better choice is the
398 .Fl l
399 option for the
400 .Cm detach
401 subcommand.
402 .It Fl j Ar passfile
403 Specifies a file which contains the passphrase component of the User Key
404 (or part of it).
405 For more information see the description of the
406 .Fl J
407 option for the
408 .Cm init
409 subcommand.
410 .It Fl k Ar keyfile
411 Specifies a file which contains the keyfile component of the User Key
412 (or part of it).
413 For more information see the description of the
414 .Fl K
415 option for the
416 .Cm init
417 subcommand.
418 .It Fl p
419 Do not use a passphrase as a component of the User Key.
420 Cannot be combined with the
421 .Fl j
422 option.
423 .It Fl r
424 Attach read-only provider.
425 It will not be opened for writing.
426 .El
427 .It Cm detach
428 Detach the given providers, which means remove the devfs entry
429 and clear the Master Key and Data Keys from memory.
430 .Pp
431 Additional options include:
432 .Bl -tag -width ".Fl f"
433 .It Fl f
434 Force detach - detach even if the provider is open.
435 .It Fl l
436 Mark provider to detach on last close.
437 If this option is specified, the provider will not be detached
438 while it is open, but will be automatically detached when it is closed for the
439 last time even if it was only opened for reading.
440 .El
441 .It Cm onetime
442 Attach the given providers with a random, one-time (ephemeral) Master Key.
443 The command can be used to encrypt swap partitions or temporary file systems.
444 .Pp
445 Additional options include:
446 .Bl -tag -width ".Fl a Ar sectorsize"
447 .It Fl a Ar aalgo
448 Enable data integrity verification (authentication).
449 For more information, see the description of the
450 .Cm init
451 subcommand.
452 .It Fl e Ar ealgo
453 Encryption algorithm to use.
454 For more information, see the description of the
455 .Cm init
456 subcommand.
457 .It Fl d
458 Detach on last close.
459 Note: this option is not usable for temporary file systems as the provider will
460 be detached after creating the file system on it.
461 It still can (and should be) used for swap partitions.
462 For more information, see the description of the
463 .Cm attach
464 subcommand.
465 .It Fl l Ar keylen
466 Data Key length to use with the given cryptographic algorithm.
467 For more information, see the description of the
468 .Cm init
469 subcommand.
470 .It Fl s Ar sectorsize
471 Change decrypted provider's sector size.
472 For more information, see the description of the
473 .Cm init
474 subcommand.
475 .It Fl T
476 Disable TRIM/UNMAP passthru.
477 For more information, see the description of the
478 .Cm init
479 subcommand.
480 .El
481 .It Cm configure
482 Change configuration of the given providers.
483 .Pp
484 Additional options include:
485 .Bl -tag -width ".Fl b"
486 .It Fl b
487 Set the BOOT flag on the given providers.
488 For more information, see the description of the
489 .Cm init
490 subcommand.
491 .It Fl B
492 Remove the BOOT flag from the given providers.
493 .It Fl g
494 Enable booting from this encrypted root filesystem.
495 The boot loader prompts for the passphrase and loads
496 .Xr loader 8
497 from the encrypted partition.
498 .It Fl G
499 Deactivate booting from this encrypted root partition.
500 .It Fl t
501 Enable TRIM/UNMAP passthru.
502 For more information, see the description of the
503 .Cm init
504 subcommand.
505 .It Fl T
506 Disable TRIM/UNMAP passthru.
507 .El
508 .It Cm setkey
509 Install a copy of the Master Key into the selected slot, encrypted with
510 a new User Key.
511 If the selected slot is populated, replace the existing copy.
512 A provider has one Master Key, which can be stored in one or both slots,
513 each encrypted with an independent User Key.
514 With the
515 .Cm init
516 subcommand, only key number 0 is initialized.
517 The User Key can be changed at any time: for an attached provider,
518 for a detached provider, or on the backup file.
519 When a provider is attached, the user does not have to provide
520 an existing passphrase/keyfile.
521 .Pp
522 Additional options include:
523 .Bl -tag -width ".Fl J Ar newpassfile"
524 .It Fl i Ar iterations
525 Number of iterations to use with PKCS#5v2.
526 If 0 is given, PKCS#5v2 will not be used.
527 To be able to use this option with the
528 .Cm setkey
529 subcommand, only one key has to be defined and this key must be changed.
530 .It Fl j Ar passfile
531 Specifies a file which contains the passphrase component of a current User Key
532 (or part of it).
533 .It Fl J Ar newpassfile
534 Specifies a file which contains the passphrase component of the new User Key
535 (or part of it).
536 .It Fl k Ar keyfile
537 Specifies a file which contains the keyfile component of a current User Key
538 (or part of it).
539 .It Fl K Ar newkeyfile
540 Specifies a file which contains the keyfile component of the new User Key
541 (or part of it).
542 .It Fl n Ar keyno
543 Specifies the index number of the Master Key copy to change (could be 0 or 1).
544 If the provider is attached and no key number is given, the key
545 used for attaching the provider will be changed.
546 If the provider is detached (or we are operating on a backup file)
547 and no key number is given, the first Master Key copy to be successfully
548 decrypted with the provided User Key passphrase/keyfile will be changed.
549 .It Fl p
550 Do not use a passphrase as a component of the current User Key.
551 Cannot be combined with the
552 .Fl j
553 option.
554 .It Fl P
555 Do not use a passphrase as a component of the new User Key.
556 Cannot be combined with the
557 .Fl J
558 option.
559 .El
560 .It Cm delkey
561 Destroy (overwrite with random data) the selected Master Key copy.
562 If one is destroying keys for an attached provider, the provider
563 will not be detached even if all copies of the Master Key are destroyed.
564 It can even be rescued with the
565 .Cm setkey
566 subcommand because the Master Key is still in memory.
567 .Pp
568 Additional options include:
569 .Bl -tag -width ".Fl a Ar keyno"
570 .It Fl a
571 Destroy all copies of the Master Key (does not need
572 .Fl f
573 option).
574 .It Fl f
575 Force key destruction.
576 This option is needed to destroy the last copy of the Master Key.
577 .It Fl n Ar keyno
578 Specifies the index number of the Master Key copy.
579 If the provider is attached and no key number is given, the key
580 used for attaching the provider will be destroyed.
581 If provider is detached (or we are operating on a backup file) the key number
582 has to be given.
583 .El
584 .It Cm kill
585 This command should be used only in emergency situations.
586 It will destroy all copies of the Master Key on a given provider and will
587 detach it forcibly (if it is attached).
588 This is absolutely a one-way command - if you do not have a metadata
589 backup, your data is gone for good.
590 In case the provider was attached with the
591 .Fl r
592 flag, the keys will not be destroyed, only the provider will be detached.
593 .Pp
594 Additional options include:
595 .Bl -tag -width ".Fl a"
596 .It Fl a
597 If specified, all currently attached providers will be killed.
598 .El
599 .It Cm backup
600 Backup metadata from the given provider to the given file.
601 .It Cm restore
602 Restore metadata from the given file to the given provider.
603 .Pp
604 Additional options include:
605 .Bl -tag -width ".Fl f"
606 .It Fl f
607 Metadata contains the size of the provider to ensure that the correct
608 partition or slice is attached.
609 If an attempt is made to restore metadata to a provider that has a different
610 size,
611 .Nm
612 will refuse to restore the data unless the
613 .Fl f
614 switch is used.
615 If the partition or slice has been grown, the
616 .Cm resize
617 subcommand should be used rather than attempting to relocate the metadata
618 through
619 .Cm backup
620 and
621 .Cm restore .
622 .El
623 .It Cm suspend
624 Suspend device by waiting for all inflight requests to finish, clearing all
625 sensitive information (like the Master Key and Data Keys) from kernel memory,
626 and blocking all further I/O requests until the
627 .Cm resume
628 subcommand is executed.
629 This functionality is useful for laptops: when one wants to suspend a
630 laptop, one does not want to leave an encrypted device attached.
631 Instead of closing all files and directories opened from a file system located
632 on an encrypted device, unmounting the file system, and detaching the device,
633 the
634 .Cm suspend
635 subcommand can be used.
636 Any access to the encrypted device will be blocked until the Master Key is
637 reloaded through the
638 .Cm resume
639 subcommand.
640 Thus there is no need to close nor unmount anything.
641 The
642 .Cm suspend
643 subcommand does not work with devices created with the
644 .Cm onetime
645 subcommand.
646 Please note that sensitive data might still be present in memory after
647 suspending an encrypted device due to the file system cache, etc.
648 .Pp
649 Additional options include:
650 .Bl -tag -width ".Fl a"
651 .It Fl a
652 Suspend all
653 .Nm
654 devices.
655 .El
656 .It Cm resume
657 Resume previously suspended device.
658 The caller must ensure that executing this subcommand does not access the
659 suspended device, leading to a deadlock.
660 For example suspending a device which contains the file system where the
661 .Nm
662 utility is stored is bad idea.
663 .Pp
664 Additional options include:
665 .Bl -tag -width ".Fl j Ar passfile"
666 .It Fl j Ar passfile
667 Specifies a file which contains the passphrase component of the User Key
668 (or part of it).
669 For more information see the description of the
670 .Fl J
671 option for the
672 .Cm init
673 subcommand.
674 .It Fl k Ar keyfile
675 Specifies a file which contains the keyfile component of the User Key
676 (or part of it).
677 For more information see the description of the
678 .Fl K
679 option for the
680 .Cm init
681 subcommand.
682 .It Fl p
683 Do not use a passphrase as a component of the User Key.
684 Cannot be combined with the
685 .Fl j
686 option.
687 .El
688 .It Cm resize
689 Inform
690 .Nm
691 that the provider has been resized.
692 The old metadata block is relocated to the correct position at the end of the
693 provider and the provider size is updated.
694 .Pp
695 Additional options include:
696 .Bl -tag -width ".Fl s Ar oldsize"
697 .It Fl s Ar oldsize
698 The size of the provider before it was resized.
699 .El
700 .It Cm version
701 If no arguments are given, the
702 .Cm version
703 subcommand will print the version of
704 .Nm
705 userland utility as well as the version of the
706 .Nm ELI
707 GEOM class.
708 .Pp
709 If GEOM providers are specified, the
710 .Cm version
711 subcommand will print metadata version used by each of them.
712 .It Cm clear
713 Clear metadata from the given providers.
714 .Em WARNING :
715 This will erase with zeros the encrypted Master Key copies stored in the
716 metadata.
717 .It Cm dump
718 Dump metadata stored on the given providers.
719 .It Cm list
720 See
721 .Xr geom 8 .
722 .It Cm status
723 See
724 .Xr geom 8 .
725 .It Cm load
726 See
727 .Xr geom 8 .
728 .It Cm unload
729 See
730 .Xr geom 8 .
731 .El
732 .Pp
733 Additional options include:
734 .Bl -tag -width ".Fl v"
735 .It Fl v
736 Be more verbose.
737 .El
738 .Sh KEY SUMMARY
739 .Ss Master Key
740 Upon
741 .Cm init ,
742 the
743 .Nm
744 utility generates a random Master Key for the provider.
745 The Master Key never changes during the lifetime of the provider.
746 Each copy of the provider metadata, active or backed up to a file, can store
747 up to two, independently-encrypted copies of the Master Key.
748 .Ss User Key
749 Each stored copy of the Master Key is encrypted with a User Key, which
750 is generated by the
751 .Nm
752 utility from a passphrase and/or a keyfile.
753 The
754 .Nm
755 utility first reads all parts of the keyfile in the order specified on the
756 command line, then reads all parts of the stored passphrase in the order
757 specified on the command line.
758 If no passphrase parts are specified, the system prompts the user to enter
759 the passphrase.
760 The passphrase is optionally strengthened by PKCS#5v2.
761 The User Key is a digest computed over the concatenated keyfile and passphrase.
762 .Ss Data Key
763 During operation, one or more Data Keys are deterministically derived by
764 the kernel from the Master Key and cached in memory.
765 The number of Data Keys used by a given provider, and the way they are
766 derived, depend on the GELI version and whether the provider is configured to
767 use data authentication.
768 .Sh SYSCTL VARIABLES
769 The following
770 .Xr sysctl 8
771 variables can be used to control the behavior of the
772 .Nm ELI
773 GEOM class.
774 The default value is shown next to each variable.
775 Some variables can also be set in
776 .Pa /boot/loader.conf .
777 .Bl -tag -width indent
778 .It Va kern.geom.eli.version
779 Version number of the
780 .Nm ELI
781 GEOM class.
782 .It Va kern.geom.eli.debug : No 0
783 Debug level of the
784 .Nm ELI
785 GEOM class.
786 This can be set to a number between 0 and 3 inclusive.
787 If set to 0, minimal debug information is printed.
788 If set to 3, the
789 maximum amount of debug information is printed.
790 .It Va kern.geom.eli.tries : No 3
791 Number of times a user is asked for the passphrase.
792 This is only used for providers which are attached on boot
793 (before the root file system is mounted).
794 If set to 0, attaching providers on boot will be disabled.
795 This variable should be set in
796 .Pa /boot/loader.conf .
797 .It Va kern.geom.eli.overwrites : No 5
798 Specifies how many times the Master Key will be overwritten
799 with random values when it is destroyed.
800 After this operation it is filled with zeros.
801 .It Va kern.geom.eli.visible_passphrase : No 0
802 If set to 1, the passphrase entered on boot (before the root
803 file system is mounted) will be visible.
804 This alternative should be used with caution as the entered
805 passphrase can be logged and exposed via
806 .Xr dmesg 8 .
807 This variable should be set in
808 .Pa /boot/loader.conf .
809 .It Va kern.geom.eli.threads : No 0
810 Specifies how many kernel threads should be used for doing software
811 cryptography.
812 Its purpose is to increase performance on SMP systems.
813 If set to 0, a CPU-pinned thread will be started for every active CPU.
814 .It Va kern.geom.eli.batch : No 0
815 When set to 1, can speed-up crypto operations by using batching.
816 Batching reduces the number of interrupts by responding to a group of
817 crypto requests with one interrupt.
818 The crypto card and the driver has to support this feature.
819 .It Va kern.geom.eli.key_cache_limit : No 8192
820 Specifies how many Data Keys to cache.
821 The default limit
822 (8192 keys) will allow caching of all keys for a 4TB provider with 512 byte
823 sectors and will take around 1MB of memory.
824 .It Va kern.geom.eli.key_cache_hits
825 Reports how many times we were looking up a Data Key and it was already in
826 cache.
827 This sysctl is not updated for providers that need fewer Data Keys than
828 the limit specified in
829 .Va kern.geom.eli.key_cache_limit .
830 .It Va kern.geom.eli.key_cache_misses
831 Reports how many times we were looking up a Data Key and it was not in cache.
832 This sysctl is not updated for providers that need fewer Data Keys than the limit
833 specified in
834 .Va kern.geom.eli.key_cache_limit .
835 .El
836 .Sh EXIT STATUS
837 Exit status is 0 on success, and 1 if the command fails.
838 .Sh EXAMPLES
839 Initialize a provider which is going to be encrypted with a
840 passphrase and random data from a file on the user's pen drive.
841 Use 4kB sector size.
842 Attach the provider, create a file system, and mount it.
843 Do the work.
844 Unmount the provider and detach it:
845 .Bd -literal -offset indent
846 # dd if=/dev/random of=/mnt/pendrive/da2.key bs=64 count=1
847 # geli init -s 4096 -K /mnt/pendrive/da2.key /dev/da2
848 Enter new passphrase:
849 Reenter new passphrase:
850 # geli attach -k /mnt/pendrive/da2.key /dev/da2
851 Enter passphrase:
852 # dd if=/dev/random of=/dev/da2.eli bs=1m
853 # newfs /dev/da2.eli
854 # mount /dev/da2.eli /mnt/secret
855 \&...
856 # umount /mnt/secret
857 # geli detach da2.eli
858 .Ed
859 .Pp
860 Create an encrypted provider, but use two User Keys:
861 one for your employee and one for you as the company's security officer
862 (so it is not a tragedy if the employee
863 .Qq accidentally
864 forgets his passphrase):
865 .Bd -literal -offset indent
866 # geli init /dev/da2
867 Enter new passphrase:   (enter security officer's passphrase)
868 Reenter new passphrase:
869 # geli setkey -n 1 /dev/da2
870 Enter passphrase:       (enter security officer's passphrase)
871 Enter new passphrase:   (let your employee enter his passphrase ...)
872 Reenter new passphrase: (... twice)
873 .Ed
874 .Pp
875 You are the security officer in your company.
876 Create an encrypted provider for use by the user, but remember that users
877 forget their passphrases, so backup the Master Key with your own random key:
878 .Bd -literal -offset indent
879 # dd if=/dev/random of=/mnt/pendrive/keys/`hostname` bs=64 count=1
880 # geli init -P -K /mnt/pendrive/keys/`hostname` /dev/ada0s1e
881 # geli backup /dev/ada0s1e /mnt/pendrive/backups/`hostname`
882 (use key number 0, so the encrypted Master Key will be re-encrypted by this)
883 # geli setkey -n 0 -k /mnt/pendrive/keys/`hostname` /dev/ada0s1e
884 (allow the user to enter his passphrase)
885 Enter new passphrase:
886 Reenter new passphrase:
887 .Ed
888 .Pp
889 Encrypted swap partition setup:
890 .Bd -literal -offset indent
891 # dd if=/dev/random of=/dev/ada0s1b bs=1m
892 # geli onetime -d -e 3des ada0s1b
893 # swapon /dev/ada0s1b.eli
894 .Ed
895 .Pp
896 The example below shows how to configure two providers which will be attached
897 on boot (before the root file system is mounted).
898 One of them is using passphrase and three keyfile parts and the other is
899 using only a keyfile in one part:
900 .Bd -literal -offset indent
901 # dd if=/dev/random of=/dev/da0 bs=1m
902 # dd if=/dev/random of=/boot/keys/da0.key0 bs=32k count=1
903 # dd if=/dev/random of=/boot/keys/da0.key1 bs=32k count=1
904 # dd if=/dev/random of=/boot/keys/da0.key2 bs=32k count=1
905 # geli init -b -K /boot/keys/da0.key0 -K /boot/keys/da0.key1 -K /boot/keys/da0.key2 da0
906 Enter new passphrase:
907 Reenter new passphrase:
908 # dd if=/dev/random of=/dev/da1s3a bs=1m
909 # dd if=/dev/random of=/boot/keys/da1s3a.key bs=128k count=1
910 # geli init -b -P -K /boot/keys/da1s3a.key da1s3a
911 .Ed
912 .Pp
913 The providers are initialized, now we have to add these lines to
914 .Pa /boot/loader.conf :
915 .Bd -literal -offset indent
916 geli_da0_keyfile0_load="YES"
917 geli_da0_keyfile0_type="da0:geli_keyfile0"
918 geli_da0_keyfile0_name="/boot/keys/da0.key0"
919 geli_da0_keyfile1_load="YES"
920 geli_da0_keyfile1_type="da0:geli_keyfile1"
921 geli_da0_keyfile1_name="/boot/keys/da0.key1"
922 geli_da0_keyfile2_load="YES"
923 geli_da0_keyfile2_type="da0:geli_keyfile2"
924 geli_da0_keyfile2_name="/boot/keys/da0.key2"
925
926 geli_da1s3a_keyfile0_load="YES"
927 geli_da1s3a_keyfile0_type="da1s3a:geli_keyfile0"
928 geli_da1s3a_keyfile0_name="/boot/keys/da1s3a.key"
929 .Ed
930 .Pp
931 If there is only one keyfile, the index might be omitted:
932 .Bd -literal -offset indent
933 geli_da1s3a_keyfile_load="YES"
934 geli_da1s3a_keyfile_type="da1s3a:geli_keyfile"
935 geli_da1s3a_keyfile_name="/boot/keys/da1s3a.key"
936 .Ed
937 .Pp
938 Not only configure encryption, but also data integrity verification using
939 .Nm HMAC/SHA256 .
940 .Bd -literal -offset indent
941 # geli init -a hmac/sha256 -s 4096 /dev/da0
942 Enter new passphrase:
943 Reenter new passphrase:
944 # geli attach /dev/da0
945 Enter passphrase:
946 # dd if=/dev/random of=/dev/da0.eli bs=1m
947 # newfs /dev/da0.eli
948 # mount /dev/da0.eli /mnt/secret
949 .Ed
950 .Pp
951 .Cm geli
952 writes the metadata backup by default to the
953 .Pa /var/backups/<prov>.eli
954 file.
955 If the metadata is lost in any way (e.g., by accidental overwrite), it can be restored.
956 Consider the following situation:
957 .Bd -literal -offset indent
958 # geli init /dev/da0
959 Enter new passphrase:
960 Reenter new passphrase:
961
962 Metadata backup can be found in /var/backups/da0.eli and
963 can be restored with the following command:
964
965         # geli restore /var/backups/da0.eli /dev/da0
966
967 # geli clear /dev/da0
968 # geli attach /dev/da0
969 geli: Cannot read metadata from /dev/da0: Invalid argument.
970 # geli restore /var/backups/da0.eli /dev/da0
971 # geli attach /dev/da0
972 Enter passphrase:
973 .Ed
974 .Pp
975 If an encrypted file system is extended, it is necessary to relocate and
976 update the metadata:
977 .Bd -literal -offset indent
978 # gpart create -s GPT ada0
979 # gpart add -s 1g -t freebsd-ufs -i 1 ada0
980 # geli init -K keyfile -P ada0p1
981 # gpart resize -s 2g -i 1 ada0
982 # geli resize -s 1g ada0p1
983 # geli attach -k keyfile -p ada0p1
984 .Ed
985 .Pp
986 Initialize provider with the passphrase split into two files.
987 The provider can be attached using those two files or by entering
988 .Dq foobar
989 as the passphrase at the
990 .Nm
991 prompt:
992 .Bd -literal -offset indent
993 # echo foo > da0.pass0
994 # echo bar > da0.pass1
995 # geli init -J da0.pass0 -J da0.pass1 da0
996 # geli attach -j da0.pass0 -j da0.pass1 da0
997 # geli detach da0
998 # geli attach da0
999 Enter passphrase: foobar
1000 .Ed
1001 .Pp
1002 Suspend all
1003 .Nm
1004 devices on a laptop, suspend the laptop, then resume devices one by one after
1005 resuming the laptop:
1006 .Bd -literal -offset indent
1007 # geli suspend -a
1008 # zzz
1009 <resume your laptop>
1010 # geli resume -p -k keyfile gpt/secret
1011 # geli resume gpt/private
1012 Enter passphrase:
1013 .Ed
1014 .Sh ENCRYPTION MODES
1015 .Nm
1016 supports two encryption modes:
1017 .Nm XTS ,
1018 which was standardized as
1019 .Nm IEEE P1619
1020 and
1021 .Nm CBC
1022 with unpredictable IV.
1023 The
1024 .Nm CBC
1025 mode used by
1026 .Nm
1027 is very similar to the mode
1028 .Nm ESSIV .
1029 .Sh DATA AUTHENTICATION
1030 .Nm
1031 can verify data integrity when an authentication algorithm is specified.
1032 When data corruption/modification is detected,
1033 .Nm
1034 will not return any data, but instead will return an error
1035 .Pq Er EINVAL .
1036 The offset and size of the corrupted data will be printed on the console.
1037 It is important to know against which attacks
1038 .Nm
1039 provides protection for your data.
1040 If data is modified in-place or copied from one place on the disk
1041 to another even without modification,
1042 .Nm
1043 should be able to detect such a change.
1044 If an attacker can remember the encrypted data, he can overwrite any future
1045 changes with the data he owns without it being noticed.
1046 In other words
1047 .Nm
1048 will not protect your data against replay attacks.
1049 .Pp
1050 It is recommended to write to the whole provider before first use,
1051 in order to make sure that all sectors and their corresponding
1052 checksums are properly initialized into a consistent state.
1053 One can safely ignore data authentication errors that occur immediately
1054 after the first time a provider is attached and before it is
1055 initialized in this way.
1056 .Sh SEE ALSO
1057 .Xr crypto 4 ,
1058 .Xr gbde 4 ,
1059 .Xr geom 4 ,
1060 .Xr loader.conf 5 ,
1061 .Xr gbde 8 ,
1062 .Xr geom 8 ,
1063 .Xr crypto 9
1064 .Sh HISTORY
1065 The
1066 .Nm
1067 utility appeared in
1068 .Fx 6.0 .
1069 Support for the
1070 .Nm Camellia
1071 block cipher is implemented by Yoshisato Yanagisawa in
1072 .Fx 7.0 .
1073 .Pp
1074 Highest
1075 .Nm GELI
1076 metadata version supported by the given FreeBSD version:
1077 .Bl -column -offset indent ".Sy FreeBSD" ".Sy version"
1078 .It Sy FreeBSD Ta Sy GELI
1079 .It Sy version Ta Sy version
1080 .Pp
1081 .It Li 6.0 Ta 0
1082 .It Li 6.1 Ta 0
1083 .It Li 6.2 Ta 3
1084 .It Li 6.3 Ta 3
1085 .It Li 6.4 Ta 3
1086 .Pp
1087 .It Li 7.0 Ta 3
1088 .It Li 7.1 Ta 3
1089 .It Li 7.2 Ta 3
1090 .It Li 7.3 Ta 3
1091 .It Li 7.4 Ta 3
1092 .Pp
1093 .It Li 8.0 Ta 3
1094 .It Li 8.1 Ta 3
1095 .It Li 8.2 Ta 5
1096 .Pp
1097 .It Li 9.0 Ta 6
1098 .Pp
1099 .It Li 10.0 Ta 7
1100 .El
1101 .Sh AUTHORS
1102 .An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org