]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/geom/eli/geli.8
sqlite3: Vendor import of sqlite3 3.41.2
[FreeBSD/FreeBSD.git] / lib / geom / eli / geli.8
1 .\" Copyright (c) 2005-2019 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 18, 2022
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 .No Usage of the Nm
49 utility:
50 .Pp
51 .Nm
52 .Cm init
53 .Op Fl bdgPRTv
54 .Op Fl a Ar aalgo
55 .Op Fl B Ar backupfile
56 .Op Fl e Ar ealgo
57 .Op Fl i Ar iterations
58 .Op Fl J Ar newpassfile
59 .Op Fl K Ar newkeyfile
60 .Op Fl l Ar keylen
61 .Op Fl s Ar sectorsize
62 .Op Fl V Ar version
63 .Ar prov ...
64 .Nm
65 .Cm label - an alias for
66 .Cm init
67 .Nm
68 .Cm attach
69 .Op Fl Cdprv
70 .Op Fl n Ar keyno
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 dRT
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 bBdDgGrRtT
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 and
175 .Nm Camellia-CBC ) .
176 .It
177 Can optionally perform data authentication (integrity verification) utilizing
178 one of the following algorithms:
179 .Nm HMAC/SHA1 ,
180 .Nm HMAC/RIPEMD160 ,
181 .Nm HMAC/SHA256 ,
182 .Nm HMAC/SHA384
183 or
184 .Nm HMAC/SHA512 .
185 .It
186 Can create a User Key from up to two, piecewise components: a passphrase
187 entered via prompt or read from one or more passfiles; a keyfile read from
188 one or more files.
189 .It
190 Allows encryption of the root partition.
191 The user is asked for the passphrase before the root filesystem is mounted.
192 .It
193 Strengthens the passphrase component of the User Key with:
194 .Rs
195 .%A B. Kaliski
196 .%T "PKCS #5: Password-Based Cryptography Specification, Version 2.0."
197 .%R RFC
198 .%N 2898
199 .Re
200 .It
201 Allows the use of two independent User Keys (e.g., a
202 .Qq "user key"
203 and a
204 .Qq "company key" ) .
205 .It
206 It is fast -
207 .Nm
208 performs simple sector-to-sector encryption.
209 .It
210 Allows the encrypted Master Key to be backed up and restored,
211 so that if a user has to quickly destroy key material,
212 it is possible to get the data back by restoring keys from
213 backup.
214 .It
215 Providers can be configured to automatically detach on last close,
216 so users do not have to remember to detach providers after unmounting
217 the filesystems.
218 .It
219 Allows attaching a provider with a random, one-time Master Key,
220 which is useful for swap partitions and temporary filesystems.
221 .It
222 Allows verification of data integrity (data authentication).
223 .It
224 Allows suspending and resuming encrypted devices.
225 .El
226 .Pp
227 The first argument to
228 .Nm
229 indicates an action to be performed:
230 .Bl -tag -width ".Cm configure"
231 .It Cm init
232 Initialize providers which need to be encrypted.
233 If multiple providers are listed as arguments, they will all be initialized
234 with the same passphrase and/or User Key.
235 A unique salt will be randomly generated for each provider to ensure the
236 Master Key for each is unique.
237 Here you can set up the cryptographic algorithm to use, Data Key length,
238 etc.
239 The last sector of the providers 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/SHA1 ,
259 .Nm HMAC/RIPEMD160 ,
260 .Nm HMAC/SHA256 ,
261 .Nm HMAC/SHA384
262 and
263 .Nm HMAC/SHA512 .
264 If the option is not given, there will be no authentication, only encryption.
265 The recommended algorithm is
266 .Nm HMAC/SHA256 .
267 .It Fl b
268 Try to decrypt this partition during boot, before the root partition is mounted.
269 This makes it possible to use an encrypted root partition.
270 One will still need bootable unencrypted storage with a
271 .Pa /boot/
272 directory, which can be a CD-ROM disc or USB pen-drive, that can be removed
273 after boot.
274 .It Fl B Ar backupfile
275 File name to use for metadata backup instead of the default
276 .Pa /var/backups/<prov>.eli .
277 To inhibit backups, you can use
278 .Pa none
279 as the
280 .Ar backupfile .
281 If multiple providers were initialized in the one command, you can use
282 .Pa PROV
283 (all upper-case) in the file name, and it will be replaced with the provider
284 name.
285 If
286 .Pa PROV
287 is not found in the file name and multiple providers were initialized in the
288 one command,
289 .Pa -<prov>
290 will be appended to the end of the file name specified.
291 .It Fl d
292 When entering the passphrase to boot from this encrypted root filesystem, echo
293 .Ql *
294 characters.
295 This makes the length of the passphrase visible.
296 .It Fl e Ar ealgo
297 Encryption algorithm to use.
298 Currently supported algorithms are:
299 .Nm AES-XTS ,
300 .Nm AES-CBC ,
301 .Nm Camellia-CBC ,
302 and
303 .Nm NULL .
304 The default and recommended algorithm is
305 .Nm AES-XTS .
306 .Nm NULL
307 is unencrypted.
308 .It Fl g
309 Enable booting from this encrypted root filesystem.
310 The boot loader prompts for the passphrase and loads
311 .Xr loader 8
312 from the encrypted partition.
313 .It Fl i Ar iterations
314 Number of iterations to use with PKCS#5v2 when processing User Key
315 passphrase component.
316 If this option is not specified,
317 .Nm
318 will find the number of iterations which is equal to 2 seconds of crypto work.
319 If 0 is given, PKCS#5v2 will not be used.
320 PKCS#5v2 processing is performed once, after all parts of the passphrase
321 component have been read.
322 .It Fl J Ar newpassfile
323 Specifies a file which contains the passphrase component of the User Key
324 (or part of it).
325 If
326 .Ar newpassfile
327 is given as -, standard input will be used.
328 Only the first line (excluding new-line character) is taken from the given file.
329 This argument can be specified multiple times, which has the effect of
330 reassembling a single passphrase split across multiple files.
331 Cannot be combined with the
332 .Fl P
333 option.
334 .It Fl K Ar newkeyfile
335 Specifies a file which contains the keyfile component of the User Key
336 (or part of it).
337 If
338 .Ar newkeyfile
339 is given as -, standard input will be used.
340 This argument can be specified multiple times, which has the effect of
341 reassembling a single keyfile split across multiple keyfile parts.
342 .It Fl l Ar keylen
343 Data Key length to use with the given cryptographic algorithm.
344 If the length is not specified, the selected algorithm uses its
345 .Em default
346 key length.
347 .Bl -ohang -offset indent
348 .It Nm AES-XTS
349 .Em 128 ,
350 256
351 .It Nm AES-CBC , Nm Camellia-CBC
352 .Em 128 ,
353 192,
354 256
355 .El
356 .It Fl P
357 Do not use a passphrase as a component of the User Key.
358 Cannot be combined with the
359 .Fl J
360 option.
361 .It Fl s Ar sectorsize
362 Change decrypted provider's sector size.
363 Increasing the sector size allows increased performance,
364 because encryption/decryption which requires an initialization vector
365 is done per sector; fewer sectors means less computational work.
366 .It Fl R
367 Turn off automatic expansion.
368 By default, if the underlying provider grows, the encrypted provider will
369 grow automatically too.
370 The metadata will be moved to the new location.
371 If automatic expansion if turned off and the underlying provider changes
372 size, attaching encrypted provider will no longer be possible as the metadata
373 will no longer be located in the last sector.
374 In this case
375 .Nm GELI
376 will only log the previous size of the underlying provider, so metadata can
377 be found easier, if resize was done by mistake.
378 .It Fl T
379 Don't pass through
380 .Dv BIO_DELETE
381 calls (i.e., TRIM/UNMAP).
382 This can prevent an attacker from knowing how much space you're actually
383 using and which sectors contain live data, but will also prevent the
384 backing store (SSD, etc) from reclaiming space you're not using, which
385 may degrade its performance and lifespan.
386 The underlying provider may or may not actually obliterate the deleted
387 sectors when TRIM is enabled, so it should not be considered to add any
388 security.
389 .It Fl V Ar version
390 Metadata version to use.
391 This option is helpful when creating a provider that may be used by older
392 .Nm FreeBSD/GELI
393 versions.
394 Consult the
395 .Sx HISTORY
396 section to find which metadata version is supported by which
397 .Fx
398 version.
399 Note that using an older version of metadata may limit the number of
400 features available.
401 .El
402 .It Cm attach
403 Attach the given providers.
404 The encrypted Master Keys are loaded from the metadata and decrypted
405 using the given passphrase/keyfile and new GEOM providers are created
406 using the specified provider names.
407 A
408 .Qq .eli
409 suffix is added to the user specified provider names.
410 Multiple providers can only be attached with a single
411 .Cm attach
412 command if they all have the same passphrase and keyfiles.
413 .Pp
414 Additional options include:
415 .Bl -tag -width ".Fl j Ar passfile"
416 .It Fl C
417 Do a dry-run decryption.
418 This is useful to verify passphrase and keyfile without decrypting the device.
419 .It Fl d
420 If specified, the decrypted providers are detached automatically on last close,
421 so the user does not have to remember to detach
422 providers after unmounting the filesystems.
423 This only works when providers were opened for writing, and will not work if
424 the filesystems on the providers were mounted read-only.
425 Probably a better choice is the
426 .Fl l
427 option for the
428 .Cm detach
429 subcommand.
430 .It Fl n Ar keyno
431 Specifies the index number of the Master Key copy to use (could be 0 or 1).
432 If the index number is not provided all keys will be tested.
433 .It Fl j Ar passfile
434 Specifies a file which contains the passphrase component of the User Key
435 (or part of it).
436 For more information see the description of the
437 .Fl J
438 option for the
439 .Cm init
440 subcommand.
441 The same passfiles are used for all listed providers.
442 .It Fl k Ar keyfile
443 Specifies a file which contains the keyfile component of the User Key
444 (or part of it).
445 For more information see the description of the
446 .Fl K
447 option for the
448 .Cm init
449 subcommand.
450 The same keyfiles are used for all listed providers.
451 .It Fl p
452 Do not use a passphrase as a component of the User Keys.
453 Cannot be combined with the
454 .Fl j
455 option.
456 .It Fl r
457 Attach read-only providers.
458 They are not opened for writing.
459 .El
460 .It Cm detach
461 Detach the given providers, which means remove the devfs entry
462 and clear the Master Key and Data Keys from memory.
463 .Pp
464 Additional options include:
465 .Bl -tag -width ".Fl f"
466 .It Fl f
467 Force detach - detach even if the provider is open.
468 .It Fl l
469 Mark provider to detach on last close, after the last filesystem has been
470 unmounted.
471 If this option is specified, the provider will not be detached
472 while it is open, but will be automatically detached when it is closed for the
473 last time even if it was only opened for reading.
474 .El
475 .It Cm onetime
476 Attach the given providers with a random, one-time (ephemeral) Master Key.
477 The command can be used to encrypt swap partitions or temporary filesystems.
478 .Pp
479 Additional options include:
480 .Bl -tag -width ".Fl a Ar sectorsize"
481 .It Fl a Ar aalgo
482 Enable data integrity verification (authentication).
483 For more information, see the description of the
484 .Cm init
485 subcommand.
486 .It Fl e Ar ealgo
487 Encryption algorithm to use.
488 For more information, see the description of the
489 .Cm init
490 subcommand.
491 .It Fl d
492 Detach on last close, after the last filesystem has been unmounted.
493 Note: this option is not usable for temporary filesystems as the provider is
494 detached after the filesystem has been created.
495 It still can, and should, be used for swap partitions.
496 For more information, see the description of the
497 .Cm attach
498 subcommand.
499 .It Fl l Ar keylen
500 Data Key length to use with the given cryptographic algorithm.
501 For more information, see the description of the
502 .Cm init
503 subcommand.
504 .It Fl s Ar sectorsize
505 Change decrypted provider's sector size.
506 For more information, see the description of the
507 .Cm init
508 subcommand.
509 .It Fl R
510 Turn off automatic expansion.
511 For more information, see the description of the
512 .Cm init
513 subcommand.
514 .It Fl T
515 Disable TRIM/UNMAP passthru.
516 For more information, see the description of the
517 .Cm init
518 subcommand.
519 .El
520 .It Cm configure
521 Change configuration of the given providers.
522 .Pp
523 Additional options include:
524 .Bl -tag -width ".Fl b"
525 .It Fl b
526 Set the BOOT flag on the given providers.
527 For more information, see the description of the
528 .Cm init
529 subcommand.
530 .It Fl B
531 Remove the BOOT flag from the given providers.
532 .It Fl d
533 When entering the passphrase to boot from this encrypted root filesystem, echo
534 .Ql *
535 characters.
536 This makes the length of the passphrase visible.
537 .It Fl D
538 Disable echoing of any characters when a passphrase is entered to boot from this
539 encrypted root filesystem.
540 This hides the passphrase length.
541 .It Fl g
542 Enable booting from this encrypted root filesystem.
543 The boot loader prompts for the passphrase and loads
544 .Xr loader 8
545 from the encrypted partition.
546 .It Fl G
547 Deactivate booting from this encrypted root partition.
548 .It Fl r
549 Turn on automatic expansion.
550 For more information, see the description of the
551 .Cm init
552 subcommand.
553 .It Fl R
554 Turn off automatic expansion.
555 .It Fl t
556 Enable TRIM/UNMAP passthru.
557 For more information, see the description of the
558 .Cm init
559 subcommand.
560 .It Fl T
561 Disable TRIM/UNMAP passthru.
562 .El
563 .It Cm setkey
564 Install a copy of the Master Key into the selected slot, encrypted with
565 a new User Key.
566 If the selected slot is populated, replace the existing copy.
567 A provider has one Master Key, which can be stored in one or both slots,
568 each encrypted with an independent User Key.
569 With the
570 .Cm init
571 subcommand, only key number 0 is initialized.
572 The User Key can be changed at any time: for an attached provider,
573 for a detached provider, or on the backup file.
574 When a provider is attached, the user does not have to provide
575 an existing passphrase/keyfile.
576 .Pp
577 Additional options include:
578 .Bl -tag -width ".Fl J Ar newpassfile"
579 .It Fl i Ar iterations
580 Number of iterations to use with PKCS#5v2.
581 If 0 is given, PKCS#5v2 will not be used.
582 To be able to use this option with the
583 .Cm setkey
584 subcommand, only one key has to be defined and this key must be changed.
585 .It Fl j Ar passfile
586 Specifies a file which contains the passphrase component of a current User Key
587 (or part of it).
588 .It Fl J Ar newpassfile
589 Specifies a file which contains the passphrase component of the new User Key
590 (or part of it).
591 .It Fl k Ar keyfile
592 Specifies a file which contains the keyfile component of a current User Key
593 (or part of it).
594 .It Fl K Ar newkeyfile
595 Specifies a file which contains the keyfile component of the new User Key
596 (or part of it).
597 .It Fl n Ar keyno
598 Specifies the index number of the Master Key copy to change (could be 0 or 1).
599 If the provider is attached and no key number is given, the key
600 used for attaching the provider will be changed.
601 If the provider is detached (or we are operating on a backup file)
602 and no key number is given, the first Master Key copy to be successfully
603 decrypted with the provided User Key passphrase/keyfile will be changed.
604 .It Fl p
605 Do not use a passphrase as a component of the current User Key.
606 Cannot be combined with the
607 .Fl j
608 option.
609 .It Fl P
610 Do not use a passphrase as a component of the new User Key.
611 Cannot be combined with the
612 .Fl J
613 option.
614 .El
615 .It Cm delkey
616 Destroy (overwrite with random data) the selected Master Key copy.
617 If one is destroying keys for an attached provider, the provider
618 will not be detached even if all copies of the Master Key are destroyed.
619 It can even be rescued with the
620 .Cm setkey
621 subcommand because the Master Key is still in memory.
622 .Pp
623 Additional options include:
624 .Bl -tag -width ".Fl a Ar keyno"
625 .It Fl a
626 Destroy all copies of the Master Key (does not need
627 .Fl f
628 option).
629 .It Fl f
630 Force key destruction.
631 This option is needed to destroy the last copy of the Master Key.
632 .It Fl n Ar keyno
633 Specifies the index number of the Master Key copy.
634 If the provider is attached and no key number is given, the key
635 used for attaching the provider will be destroyed.
636 If provider is detached (or we are operating on a backup file) the key number
637 has to be given.
638 .El
639 .It Cm kill
640 This command should be used only in emergency situations.
641 It will destroy all copies of the Master Key on a given provider and will
642 detach it forcibly (if it is attached).
643 This is absolutely a one-way command - if you do not have a metadata
644 backup, your data is gone for good.
645 In case the provider was attached with the
646 .Fl r
647 flag, the keys will not be destroyed, only the provider will be detached.
648 .Pp
649 Additional options include:
650 .Bl -tag -width ".Fl a"
651 .It Fl a
652 If specified, all currently attached providers will be killed.
653 .El
654 .It Cm backup
655 Backup metadata from the given provider to the given file.
656 .It Cm restore
657 Restore metadata from the given file to the given provider.
658 .Pp
659 Additional options include:
660 .Bl -tag -width ".Fl f"
661 .It Fl f
662 Metadata contains the size of the provider to ensure that the correct
663 partition or slice is attached.
664 If an attempt is made to restore metadata to a provider that has a different
665 size,
666 .Nm
667 will refuse to restore the data unless the
668 .Fl f
669 switch is used.
670 If the partition or slice has been grown, the
671 .Cm resize
672 subcommand should be used rather than attempting to relocate the metadata
673 through
674 .Cm backup
675 and
676 .Cm restore .
677 .El
678 .It Cm suspend
679 Suspend device by waiting for all inflight requests to finish, clearing all
680 sensitive information such as the Master Key and Data Keys from kernel memory,
681 and blocking all further I/O requests until the
682 .Cm resume
683 subcommand is executed.
684 This functionality is useful for laptops.
685 Suspending a laptop should not leave an encrypted device attached.
686 The
687 .Cm suspend
688 subcommand can be used rather than closing all files and directories from
689 filesystems on the encrypted device, unmounting the filesystem, and
690 detaching the device.
691 Any access to the encrypted device will be blocked until the Master Key is
692 reloaded through the
693 .Cm resume
694 subcommand.
695 Thus there is no need to close nor unmount anything.
696 The
697 .Cm suspend
698 subcommand does not work with devices created with the
699 .Cm onetime
700 subcommand.
701 Please note that sensitive data might still be present in memory locations
702 such as the filesystem cache after suspending an encrypted device.
703 .Pp
704 Additional options include:
705 .Bl -tag -width ".Fl a"
706 .It Fl a
707 Suspend all
708 .Nm
709 devices.
710 .El
711 .It Cm resume
712 Resume previously suspended device.
713 The caller must ensure that executing this subcommand does not access the
714 suspended device, leading to a deadlock.
715 For example, suspending a device which contains the filesystem where the
716 .Nm
717 utility is stored is a bad idea.
718 .Pp
719 Additional options include:
720 .Bl -tag -width ".Fl j Ar passfile"
721 .It Fl j Ar passfile
722 Specifies a file which contains the passphrase component of the User Key,
723 or part of it.
724 For more information see the description of the
725 .Fl J
726 option for the
727 .Cm init
728 subcommand.
729 .It Fl k Ar keyfile
730 Specifies a file which contains the keyfile component of the User Key,
731 or part of it.
732 For more information see the description of the
733 .Fl K
734 option for the
735 .Cm init
736 subcommand.
737 .It Fl p
738 Do not use a passphrase as a component of the User Key.
739 Cannot be combined with the
740 .Fl j
741 option.
742 .El
743 .It Cm resize
744 Inform
745 .Nm
746 that the provider has been resized.
747 The old metadata block is relocated to the correct position at the end of the
748 provider and the provider size is updated.
749 .Pp
750 Additional options include:
751 .Bl -tag -width ".Fl s Ar oldsize"
752 .It Fl s Ar oldsize
753 The size of the provider before it was resized.
754 .El
755 .It Cm version
756 If no arguments are given, the
757 .Cm version
758 subcommand will print the version of
759 .Nm
760 userland utility as well as the version of the
761 .Nm ELI
762 GEOM class.
763 .Pp
764 If GEOM providers are specified, the
765 .Cm version
766 subcommand will print metadata version used by each of them.
767 .It Cm clear
768 Clear metadata from the given providers.
769 .Em WARNING :
770 This will erase with zeros the encrypted Master Key copies stored in the
771 metadata.
772 .It Cm dump
773 Dump metadata stored on the given providers.
774 .It Cm list
775 See
776 .Xr geom 8 .
777 .It Cm status
778 See
779 .Xr geom 8 .
780 .It Cm load
781 See
782 .Xr geom 8 .
783 .It Cm unload
784 See
785 .Xr geom 8 .
786 .El
787 .Pp
788 Additional options include:
789 .Bl -tag -width ".Fl v"
790 .It Fl v
791 Be more verbose.
792 .El
793 .Sh KEY SUMMARY
794 .Ss Master Key
795 Upon
796 .Cm init ,
797 the
798 .Nm
799 utility generates a random Master Key for the provider.
800 The Master Key never changes during the lifetime of the provider.
801 Each copy of the provider metadata, active or backed up to a file, can store
802 up to two, independently-encrypted copies of the Master Key.
803 .Ss User Key
804 Each stored copy of the Master Key is encrypted with a User Key, which
805 is generated by the
806 .Nm
807 utility from a passphrase and/or a keyfile.
808 The
809 .Nm
810 utility first reads all parts of the keyfile in the order specified on the
811 command line, then reads all parts of the stored passphrase in the order
812 specified on the command line.
813 If no passphrase parts are specified, the system prompts the user to enter
814 the passphrase.
815 The passphrase is optionally strengthened by PKCS#5v2.
816 The User Key is a digest computed over the concatenated keyfile and passphrase.
817 .Ss Data Key
818 During operation, one or more Data Keys are deterministically derived by
819 the kernel from the Master Key and cached in memory.
820 The number of Data Keys used by a given provider, and the way they are
821 derived, depend on the GELI version and whether the provider is configured to
822 use data authentication.
823 .Sh SYSCTL VARIABLES
824 The following
825 .Xr sysctl 8
826 variables can be used to control the behavior of the
827 .Nm ELI
828 GEOM class.
829 The default value is shown next to each variable.
830 Some variables can also be set in
831 .Pa /boot/loader.conf .
832 .Bl -tag -width indent
833 .It Va kern.geom.eli.version
834 Version number of the
835 .Nm ELI
836 GEOM class.
837 .It Va kern.geom.eli.debug : No 0
838 Debug level of the
839 .Nm ELI
840 GEOM class.
841 This can be set to a number between 0 and 3 inclusive.
842 If set to 0, minimal debug information is printed.
843 If set to 3, the
844 maximum amount of debug information is printed.
845 .It Va kern.geom.eli.tries : No 3
846 Number of times a user is asked for the passphrase.
847 This is only used for providers which are attached on boot,
848 before the root filesystem is mounted.
849 If set to 0, attaching providers on boot will be disabled.
850 This variable should be set in
851 .Pa /boot/loader.conf .
852 .It Va kern.geom.eli.overwrites : No 5
853 Specifies how many times the Master Key is overwritten
854 with random values when it is destroyed.
855 After this operation it is filled with zeros.
856 .It Va kern.geom.eli.visible_passphrase : No 0
857 If set to 1, the passphrase entered on boot will be visible.
858 This alternative should be used with caution as the entered
859 passphrase can be logged and exposed via
860 .Xr dmesg 8 .
861 This variable should be set in
862 .Pa /boot/loader.conf .
863 .It Va kern.geom.eli.threads : No 0
864 Specifies how many kernel threads should be used for doing software
865 cryptography.
866 Its purpose is to increase performance on SMP systems.
867 If set to 0, a CPU-pinned thread will be started for every active CPU.
868 .It Va kern.geom.eli.batch : No 0
869 When set to 1, can speed-up crypto operations by using batching.
870 Batching reduces the number of interrupts by responding to a group of
871 crypto requests with one interrupt.
872 The crypto card and the driver has to support this feature.
873 .It Va kern.geom.eli.key_cache_limit : No 8192
874 Specifies how many Data Keys to cache.
875 The default limit
876 (8192 keys) will allow caching of all keys for a 4TB provider with 512 byte
877 sectors and will take around 1MB of memory.
878 .It Va kern.geom.eli.key_cache_hits
879 Reports how many times we were looking up a Data Key and it was already in
880 cache.
881 This sysctl is not updated for providers that need fewer Data Keys than
882 the limit specified in
883 .Va kern.geom.eli.key_cache_limit .
884 .It Va kern.geom.eli.key_cache_misses
885 Reports how many times we were looking up a Data Key and it was not in cache.
886 This sysctl is not updated for providers that need fewer Data Keys than the limit
887 specified in
888 .Va kern.geom.eli.key_cache_limit .
889 .Va kern.geom.eli.unmapped_io
890 Enable support for unmapped I/O buffers, currently implemented only on 64-bit
891 platforms.
892 This is an optimization which reduces the overhead of I/O processing.
893 This variable is intended for debugging purposes and must be set in
894 .Pa /boot/loader.conf .
895 .El
896 .Sh EXIT STATUS
897 Exit status is 0 on success, and 1 if the command fails.
898 .Sh EXAMPLES
899 Initialize a provider which is going to be encrypted with a
900 passphrase and random data from a file on the user's pen drive.
901 Use 4kB sector size.
902 Attach the provider, create a filesystem, and mount it.
903 Do the work.
904 Unmount the provider and detach it:
905 .Bd -literal -offset indent
906 # dd if=/dev/random of=/mnt/pendrive/da2.key bs=64 count=1
907 # geli init -s 4096 -K /mnt/pendrive/da2.key /dev/da2
908 Enter new passphrase:
909 Reenter new passphrase:
910 # geli attach -k /mnt/pendrive/da2.key /dev/da2
911 Enter passphrase:
912 # dd if=/dev/random of=/dev/da2.eli bs=1m
913 # newfs /dev/da2.eli
914 # mount /dev/da2.eli /mnt/secret
915 \&...
916 # umount /mnt/secret
917 # geli detach da2.eli
918 .Ed
919 .Pp
920 Create an encrypted provider, but use two User Keys:
921 one for your employee and one for you as the company's security officer
922 (so it is not a tragedy if the employee
923 .Qq accidentally
924 forgets his passphrase):
925 .Bd -literal -offset indent
926 # geli init /dev/da2
927 Enter new passphrase:   (enter security officer's passphrase)
928 Reenter new passphrase:
929 # geli setkey -n 1 /dev/da2
930 Enter passphrase:       (enter security officer's passphrase)
931 Enter new passphrase:   (let your employee enter his passphrase ...)
932 Reenter new passphrase: (... twice)
933 .Ed
934 .Pp
935 You are the security officer in your company.
936 Create an encrypted provider for use by the user, but remember that users
937 forget their passphrases, so backup the Master Key with your own random key:
938 .Bd -literal -offset indent
939 # dd if=/dev/random of=/mnt/pendrive/keys/`hostname` bs=64 count=1
940 # geli init -P -K /mnt/pendrive/keys/`hostname` /dev/ada0s1e
941 # geli backup /dev/ada0s1e /mnt/pendrive/backups/`hostname`
942 (use key number 0, so the encrypted Master Key will be re-encrypted by this)
943 # geli setkey -n 0 -k /mnt/pendrive/keys/`hostname` /dev/ada0s1e
944 (allow the user to enter his passphrase)
945 Enter new passphrase:
946 Reenter new passphrase:
947 .Ed
948 .Pp
949 Encrypted swap partition setup:
950 .Bd -literal -offset indent
951 # dd if=/dev/random of=/dev/ada0s1b bs=1m
952 # geli onetime -d ada0s1b
953 # swapon /dev/ada0s1b.eli
954 .Ed
955 .Pp
956 The example below shows how to configure two providers which will be attached
957 on boot, before the root filesystem is mounted.
958 One of them is using passphrase and three keyfile parts and the other is
959 using only a keyfile in one part:
960 .Bd -literal -offset indent
961 # dd if=/dev/random of=/dev/da0 bs=1m
962 # dd if=/dev/random of=/boot/keys/da0.key0 bs=32k count=1
963 # dd if=/dev/random of=/boot/keys/da0.key1 bs=32k count=1
964 # dd if=/dev/random of=/boot/keys/da0.key2 bs=32k count=1
965 # geli init -b -K /boot/keys/da0.key0 -K /boot/keys/da0.key1 -K /boot/keys/da0.key2 da0
966 Enter new passphrase:
967 Reenter new passphrase:
968 # dd if=/dev/random of=/dev/da1s3a bs=1m
969 # dd if=/dev/random of=/boot/keys/da1s3a.key bs=128k count=1
970 # geli init -b -P -K /boot/keys/da1s3a.key da1s3a
971 .Ed
972 .Pp
973 The providers are initialized, now we have to add these lines to
974 .Pa /boot/loader.conf :
975 .Bd -literal -offset indent
976 geli_da0_keyfile0_load="YES"
977 geli_da0_keyfile0_type="da0:geli_keyfile0"
978 geli_da0_keyfile0_name="/boot/keys/da0.key0"
979 geli_da0_keyfile1_load="YES"
980 geli_da0_keyfile1_type="da0:geli_keyfile1"
981 geli_da0_keyfile1_name="/boot/keys/da0.key1"
982 geli_da0_keyfile2_load="YES"
983 geli_da0_keyfile2_type="da0:geli_keyfile2"
984 geli_da0_keyfile2_name="/boot/keys/da0.key2"
985
986 geli_da1s3a_keyfile0_load="YES"
987 geli_da1s3a_keyfile0_type="da1s3a:geli_keyfile0"
988 geli_da1s3a_keyfile0_name="/boot/keys/da1s3a.key"
989 .Ed
990 .Pp
991 If there is only one keyfile, the index might be omitted:
992 .Bd -literal -offset indent
993 geli_da1s3a_keyfile_load="YES"
994 geli_da1s3a_keyfile_type="da1s3a:geli_keyfile"
995 geli_da1s3a_keyfile_name="/boot/keys/da1s3a.key"
996 .Ed
997 .Pp
998 By convention, these loader variables are called
999 .Sm off
1000 .Va geli_ No < Ar device No > Va _load .
1001 .Sm on
1002 However, the actual name prefix before
1003 .Va _load , _type ,
1004 or
1005 .Va _name
1006 does not matter.
1007 At boot time, the
1008 .Nm
1009 module searches through all
1010 .Sm off
1011 .No < Va prefix No > Va _type No -like
1012 .Sm on
1013 variables that have a value of
1014 .Sm off
1015 .Dq < Ar device No > :geli_keyfile .
1016 .Sm on
1017 The paths to keyfiles are then extracted from
1018 .Sm off
1019 .No < Ar prefix No > Va _name
1020 .Sm on
1021 variables.
1022 In the example above,
1023 .Ar prefix
1024 is
1025 .Dq Li geli_da1s3a_keyfile .
1026 .Pp
1027 Not only configure encryption, but also data integrity verification using
1028 .Nm HMAC/SHA256 .
1029 .Bd -literal -offset indent
1030 # geli init -a hmac/sha256 -s 4096 /dev/da0
1031 Enter new passphrase:
1032 Reenter new passphrase:
1033 # geli attach /dev/da0
1034 Enter passphrase:
1035 # dd if=/dev/random of=/dev/da0.eli bs=1m
1036 # newfs /dev/da0.eli
1037 # mount /dev/da0.eli /mnt/secret
1038 .Ed
1039 .Pp
1040 .Cm geli
1041 writes the metadata backup by default to the
1042 .Pa /var/backups/<prov>.eli
1043 file.
1044 If the metadata is lost in any way (e.g., by accidental overwrite), it can be restored.
1045 Consider the following situation:
1046 .Bd -literal -offset indent
1047 # geli init /dev/da0
1048 Enter new passphrase:
1049 Reenter new passphrase:
1050
1051 Metadata backup can be found in /var/backups/da0.eli and
1052 can be restored with the following command:
1053
1054         # geli restore /var/backups/da0.eli /dev/da0
1055
1056 # geli clear /dev/da0
1057 # geli attach /dev/da0
1058 geli: Cannot read metadata from /dev/da0: Invalid argument.
1059 # geli restore /var/backups/da0.eli /dev/da0
1060 # geli attach /dev/da0
1061 Enter passphrase:
1062 .Ed
1063 .Pp
1064 If an encrypted filesystem is extended, it is necessary to relocate and
1065 update the metadata:
1066 .Bd -literal -offset indent
1067 # gpart create -s GPT ada0
1068 # gpart add -s 1g -t freebsd-ufs -i 1 ada0
1069 # geli init -K keyfile -P ada0p1
1070 # gpart resize -s 2g -i 1 ada0
1071 # geli resize -s 1g ada0p1
1072 # geli attach -k keyfile -p ada0p1
1073 .Ed
1074 .Pp
1075 Initialize provider with the passphrase split into two files.
1076 The provider can be attached using those two files or by entering
1077 .Dq foobar
1078 as the passphrase at the
1079 .Nm
1080 prompt:
1081 .Bd -literal -offset indent
1082 # echo foo > da0.pass0
1083 # echo bar > da0.pass1
1084 # geli init -J da0.pass0 -J da0.pass1 da0
1085 # geli attach -j da0.pass0 -j da0.pass1 da0
1086 # geli detach da0
1087 # geli attach da0
1088 Enter passphrase: foobar
1089 .Ed
1090 .Pp
1091 Suspend all
1092 .Nm
1093 devices on a laptop, suspend the laptop, then resume devices one by one after
1094 resuming the laptop:
1095 .Bd -literal -offset indent
1096 # geli suspend -a
1097 # zzz
1098 <resume your laptop>
1099 # geli resume -p -k keyfile gpt/secret
1100 # geli resume gpt/private
1101 Enter passphrase:
1102 .Ed
1103 .Pp
1104 To create a
1105 .Nm
1106 encrypted filesystem with a file as storage device follow this example.
1107 First a file named private0 is created in
1108 .Pa /usr
1109 and attached as a memory disk like
1110 .Pa /dev/md0
1111 for example.
1112 .Bd -literal -offset indent
1113 # dd if=/dev/zero of=/usr/private0 bs=1m count=256
1114 # chmod 0600 /usr/private0
1115 # mdconfig -t vnode -f /usr/private0
1116 .Ed
1117 .Pp
1118 It is recommended to place the following line in
1119 .Xr rc.conf 5
1120 to have the memory disk automatically created during boot.
1121 .Bd -literal -offset indent
1122 mdconfig_md0="-t vnode -f /usr/private0"
1123 .Ed
1124 .Pp
1125 After
1126 .Pa /dev/md0
1127 is created a random key has to be generated and stored in a secure location,
1128 like
1129 .Pa /root
1130 for example.
1131 This key should be protected by a passphrase, which
1132 is requested when geli init is called.
1133 .Bd -literal -offset indent
1134 # dd if=/dev/random of=/root/private0.key bs=64 count=1
1135 # geli init -K /root/private0.key -s 4096 /dev/md0
1136 Enter new passphrase:
1137 Reenter new passphrase:
1138 # geli attach -k /root/private0.key /dev/md0
1139 Enter passphrase:
1140 # dd if=/dev/random of=/dev/md0.eli bs=1m
1141 .Ed
1142 .Pp
1143 Once the initialization of the
1144 .Pa /dev/md0.eli
1145 device is ready create a UFS filesystem and mount it for example in
1146 .Pa /private .
1147 .Bd -literal -offset indent
1148 # newfs /dev/md0.eli
1149 # mount /dev/md0.eli /private
1150 .Ed
1151 .Pp
1152 After a system reboot the
1153 .Nm
1154 device can be mounted again with the following commands.
1155 The call of geli attach will ask for the passphrase.
1156 It is recommended to do this procedure after the boot, because otherwise
1157 the boot process would be waiting for the passphrase input.
1158 .Bd -literal -offset indent
1159 # geli attach -k /root/private0.key /dev/md0
1160 Enter passphrase:
1161 # mount /dev/md0.eli /private
1162 .Ed
1163 .Sh ENCRYPTION MODES
1164 .Nm
1165 supports two encryption modes:
1166 .Nm XTS ,
1167 which was standardized as
1168 .Nm IEEE P1619
1169 and
1170 .Nm CBC
1171 with unpredictable IV.
1172 The
1173 .Nm CBC
1174 mode used by
1175 .Nm
1176 is very similar to the mode
1177 .Nm ESSIV .
1178 .Sh DATA AUTHENTICATION
1179 .Nm
1180 can verify data integrity when an authentication algorithm is specified.
1181 When data corruption/modification is detected,
1182 .Nm
1183 will not return any data, but instead will return an error
1184 .Pq Er EINVAL .
1185 The offset and size of the corrupted data will be printed on the console.
1186 It is important to know against which attacks
1187 .Nm
1188 provides protection for your data.
1189 If data is modified in-place or copied from one place on the disk
1190 to another even without modification,
1191 .Nm
1192 should be able to detect such a change.
1193 If an attacker can remember the encrypted data, he can overwrite any future
1194 changes with the data he owns without it being noticed.
1195 In other words
1196 .Nm
1197 will not protect your data against replay attacks.
1198 .Pp
1199 It is recommended to write to the whole provider before first use,
1200 in order to make sure that all sectors and their corresponding
1201 checksums are properly initialized into a consistent state.
1202 One can safely ignore data authentication errors that occur immediately
1203 after the first time a provider is attached and before it is
1204 initialized in this way.
1205 .Sh SEE ALSO
1206 .Xr crypto 4 ,
1207 .Xr gbde 4 ,
1208 .Xr geom 4 ,
1209 .Xr loader.conf 5 ,
1210 .Xr gbde 8 ,
1211 .Xr geom 8 ,
1212 .Xr crypto 9
1213 .Sh HISTORY
1214 The
1215 .Nm
1216 utility appeared in
1217 .Fx 6.0 .
1218 Support for the
1219 .Nm Camellia
1220 block cipher was implemented by Yoshisato Yanagisawa in
1221 .Fx 7.0 .
1222 .Pp
1223 Highest
1224 .Nm GELI
1225 metadata version supported by the given
1226 .Fx
1227 version:
1228 .Bl -column -offset indent ".Sy FreeBSD" ".Sy version"
1229 .It Sy FreeBSD Ta Sy GELI
1230 .It Sy version Ta Sy version
1231 .Pp
1232 .It Li 6.0 Ta 0
1233 .It Li 6.1 Ta 0
1234 .It Li 6.2 Ta 3
1235 .It Li 6.3 Ta 3
1236 .It Li 6.4 Ta 3
1237 .Pp
1238 .It Li 7.0 Ta 3
1239 .It Li 7.1 Ta 3
1240 .It Li 7.2 Ta 3
1241 .It Li 7.3 Ta 3
1242 .It Li 7.4 Ta 3
1243 .Pp
1244 .It Li 8.0 Ta 3
1245 .It Li 8.1 Ta 3
1246 .It Li 8.2 Ta 5
1247 .Pp
1248 .It Li 9.0 Ta 6
1249 .Pp
1250 .It Li 10.0 Ta 7
1251 .El
1252 .Sh AUTHORS
1253 .An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org