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