View | Details | Raw Unified | Return to bug 165668
Collapse All | Expand All

(-)src/sbin/geom/class/eli/geli.8 (-67 / +67 lines)
Lines 29-45 Link Here
29
.Os
29
.Os
30
.Sh NAME
30
.Sh NAME
31
.Nm geli
31
.Nm geli
32
.Nd "control utility for cryptographic GEOM class"
32
.Nd "control utility for the cryptographic GEOM class"
33
.Sh SYNOPSIS
33
.Sh SYNOPSIS
34
To compile GEOM_ELI into your kernel, place the following lines in your kernel
34
To compile GEOM_ELI into your kernel, add the following lines to your kernel
35
configuration file:
35
configuration file:
36
.Bd -ragged -offset indent
36
.Bd -ragged -offset indent
37
.Cd "device crypto"
37
.Cd "device crypto"
38
.Cd "options GEOM_ELI"
38
.Cd "options GEOM_ELI"
39
.Ed
39
.Ed
40
.Pp
40
.Pp
41
Alternately, to load the GEOM_ELI module at boot time, place the following line
41
Alternatively, to load the GEOM_ELI module at boot time, add the following line
42
in your
42
to your
43
.Xr loader.conf 5 :
43
.Xr loader.conf 5 :
44
.Bd -literal -offset indent
44
.Bd -literal -offset indent
45
geom_eli_load="YES"
45
geom_eli_load="YES"
Lines 189-195 Link Here
189
Can create a key from a couple of components (user entered passphrase, random
189
Can create a key from a couple of components (user entered passphrase, random
190
bits from a file, etc.).
190
bits from a file, etc.).
191
.It
191
.It
192
Allows to encrypt the root partition - the user will be asked for the
192
Allows encryption of the root partition - the user will be asked for the
193
passphrase before the root file system is mounted.
193
passphrase before the root file system is mounted.
194
.It
194
.It
195
The passphrase of the user is strengthened with:
195
The passphrase of the user is strengthened with:
Lines 200-206 Link Here
200
.%N 2898
200
.%N 2898
201
.Re
201
.Re
202
.It
202
.It
203
Allows to use two independent keys (e.g.
203
Allows the use of two independent keys (e.g.
204
.Qq "user key"
204
.Qq "user key"
205
and
205
and
206
.Qq "company key" ) .
206
.Qq "company key" ) .
Lines 209-228 Link Here
209
.Nm
209
.Nm
210
performs simple sector-to-sector encryption.
210
performs simple sector-to-sector encryption.
211
.It
211
.It
212
Allows to backup/restore Master Keys, so when a user has to quickly
212
Allows the backup and restoration of Master Keys, so when a user has to quickly
213
destroy his keys,
213
destroy his keys, it is possible to get the data back by restoring keys from
214
it is possible to get the data back by restoring keys from the backup.
214
backup.
215
.It
215
.It
216
Providers can be configured to automatically detach on last close
216
Providers can be configured to automatically detach on last close
217
(so users do not have to remember to detach providers after unmounting
217
(so users do not have to remember to detach providers after unmounting
218
the file systems).
218
the file systems).
219
.It
219
.It
220
Allows to attach a provider with a random, one-time key - useful for swap
220
Allows attaching a provider with a random, one-time key - useful for swap
221
partitions and temporary file systems.
221
partitions and temporary file systems.
222
.It
222
.It
223
Allows to verify data integrity (data authentication).
223
Allows verification of data integrity (data authentication).
224
.It
224
.It
225
Allows to suspend and resume encrypted devices.
225
Allows suspending and resuming encrypted devices.
226
.El
226
.El
227
.Pp
227
.Pp
228
The first argument to
228
The first argument to
Lines 230-241 Link Here
230
indicates an action to be performed:
230
indicates an action to be performed:
231
.Bl -tag -width ".Cm configure"
231
.Bl -tag -width ".Cm configure"
232
.It Cm init
232
.It Cm init
233
Initialize provider which needs to be encrypted.
233
Initialize the provider which needs to be encrypted.
234
Here you can set up the cryptographic algorithm to use, key length, etc.
234
Here you can set up the cryptographic algorithm to use, key length, etc.
235
The last provider's sector is used to store metadata.
235
The last sector of the provider is used to store metadata.
236
The
236
The
237
.Cm init
237
.Cm init
238
subcommand also automatically backups metadata in
238
subcommand also automatically writes metadata backup to
239
.Pa /var/backups/<prov>.eli
239
.Pa /var/backups/<prov>.eli
240
file.
240
file.
241
The metadata can be recovered with the
241
The metadata can be recovered with the
Lines 246-252 Link Here
246
.Bl -tag -width ".Fl J Ar newpassfile"
246
.Bl -tag -width ".Fl J Ar newpassfile"
247
.It Fl a Ar aalgo
247
.It Fl a Ar aalgo
248
Enable data integrity verification (authentication) using the given algorithm.
248
Enable data integrity verification (authentication) using the given algorithm.
249
This will reduce size of available storage and also reduce speed.
249
This will reduce the size of available storage and also reduce speed.
250
For example, when using 4096 bytes sector and
250
For example, when using 4096 bytes sector and
251
.Nm HMAC/SHA256
251
.Nm HMAC/SHA256
252
algorithm, 89% of the original provider storage will be available for use.
252
algorithm, 89% of the original provider storage will be available for use.
Lines 320-327 Link Here
320
Do not use passphrase as the key component.
320
Do not use passphrase as the key component.
321
.It Fl s Ar sectorsize
321
.It Fl s Ar sectorsize
322
Change decrypted provider's sector size.
322
Change decrypted provider's sector size.
323
Increasing sector size allows to increase performance, because we need to
323
Increasing sector size allows increased performance, because we need to
324
generate an IV and do encrypt/decrypt for every single sector - less number
324
generate an IV and do encrypt/decrypt for every single sector - fewer numbers
325
of sectors means less work to do.
325
of sectors means less work to do.
326
.It Fl V Ar version
326
.It Fl V Ar version
327
Metadata version to use.
327
Metadata version to use.
Lines 345-351 Link Here
345
.Bl -tag -width ".Fl j Ar passfile"
345
.Bl -tag -width ".Fl j Ar passfile"
346
.It Fl d
346
.It Fl d
347
If specified, a decrypted provider will be detached automatically on last close.
347
If specified, a decrypted provider will be detached automatically on last close.
348
This can help with short memory - user does not have to remember to detach the
348
This can help with scarce memory - user does not have to remember to detach the
349
provider after unmounting the file system.
349
provider after unmounting the file system.
350
It only works when the provider was opened for writing, so it will not work if
350
It only works when the provider was opened for writing, so it will not work if
351
the file system on the provider is mounted read-only.
351
the file system on the provider is mounted read-only.
Lines 385-393 Link Here
385
.It Fl l
385
.It Fl l
386
Mark provider to detach on last close.
386
Mark provider to detach on last close.
387
If this option is specified, the provider will not be detached
387
If this option is specified, the provider will not be detached
388
until it is open, but when it will be closed last time, it will
388
while it is open, but will be automatically detached when it is closed for the
389
be automatically detached (even
389
last time even if it was only opened for reading.
390
if it was only opened for reading).
391
.El
390
.El
392
.It Cm onetime
391
.It Cm onetime
393
Attach the given providers with random, one-time keys.
392
Attach the given providers with random, one-time keys.
Lines 407-413 Link Here
407
subcommand.
406
subcommand.
408
.It Fl d
407
.It Fl d
409
Detach on last close.
408
Detach on last close.
410
Note, the option is not usable for temporary file systems as the provider will
409
Note: this option is not usable for temporary file systems as the provider will
411
be detached after creating the file system on it.
410
be detached after creating the file system on it.
412
It still can (and should be) used for swap partitions.
411
It still can (and should be) used for swap partitions.
413
For more information, see the description of the
412
For more information, see the description of the
Lines 444-450 Link Here
444
.Cm init
443
.Cm init
445
subcommand, only key number 0 is initialized.
444
subcommand, only key number 0 is initialized.
446
The key can always be changed: for an attached provider,
445
The key can always be changed: for an attached provider,
447
for a detached provider or on the backup file.
446
for a detached provider, or on the backup file.
448
When a provider is attached, the user does not have to provide
447
When a provider is attached, the user does not have to provide
449
an old passphrase/keyfile.
448
an old passphrase/keyfile.
450
.Pp
449
.Pp
Lines 453-461 Link Here
453
.It Fl i Ar iterations
452
.It Fl i Ar iterations
454
Number of iterations to use with PKCS#5v2.
453
Number of iterations to use with PKCS#5v2.
455
If 0 is given, PKCS#5v2 will not be used.
454
If 0 is given, PKCS#5v2 will not be used.
456
To be able to use this option with
455
To be able to use this option with the
457
.Cm setkey
456
.Cm setkey
458
subcommand, only one key have to be defined and this key has to be changed.
457
subcommand, only one key has to be defined and this key must be changed.
459
.It Fl j Ar passfile
458
.It Fl j Ar passfile
460
Specifies a file which contains the old passphrase or its part.
459
Specifies a file which contains the old passphrase or its part.
461
.It Fl J Ar newpassfile
460
.It Fl J Ar newpassfile
Lines 479-486 Link Here
479
.It Cm delkey
478
.It Cm delkey
480
Destroy (overwrite with random data) the selected key.
479
Destroy (overwrite with random data) the selected key.
481
If one is destroying keys for an attached provider, the provider
480
If one is destroying keys for an attached provider, the provider
482
will not be detached even if all keys will be destroyed.
481
will not be detached even if all keys are destroyed.
483
It can be even rescued with the
482
It can even be rescued with the
484
.Cm setkey
483
.Cm setkey
485
subcommand.
484
subcommand.
486
.Pp
485
.Pp
Lines 501-508 Link Here
501
has to be given.
500
has to be given.
502
.El
501
.El
503
.It Cm kill
502
.It Cm kill
504
This command should be used in emergency situations.
503
This command should be used only in emergency situations.
505
It will destroy all keys on the given provider and will detach it forcibly
504
It will destroy all the keys on a given provider and will detach it forcibly
506
(if it is attached).
505
(if it is attached).
507
This is absolutely a one-way command - if you do not have a metadata
506
This is absolutely a one-way command - if you do not have a metadata
508
backup, your data is gone for good.
507
backup, your data is gone for good.
Lines 540-568 Link Here
540
.Cm restore .
539
.Cm restore .
541
.El
540
.El
542
.It Cm suspend
541
.It Cm suspend
543
Suspend device by waiting for all inflight request to finish, clearing all
542
Suspend device by waiting for all inflight requests to finish, clearing all
544
sensitive informations (like keys) from the kernel memory and blocking all
543
sensitive information (like keys) from the kernel memory, and blocking all
545
further I/O requests until the
544
further I/O requests until the
546
.Cm resume
545
.Cm resume
547
subcommand is executed.
546
subcommand is executed.
548
This functionality is useful for eg. laptops - when one wants to suspend a
547
This functionality is useful for laptops: when one wants to suspend a
549
laptop, one does not want to leave encrypted device attached.
548
laptop, one does not want to leave an encrypted device attached.
550
Instead of closing all files and directories opened from a file system placed
549
Instead of closing all files and directories opened from a file system located
551
on an encrypted device, unmounting the file system and detaching the device,
550
on an encrypted device, unmounting the file system, and detaching the device,
552
the
551
the
553
.Cm suspend
552
.Cm suspend
554
subcommand can be used.
553
subcommand can be used.
555
Any access to the encrypted device will be blocked until the keys are
554
Any access to the encrypted device will be blocked until the keys are
556
recovered through
555
recovered through the
557
.Cm resume
556
.Cm resume
558
subcommand, thus there is no need to close nor unmount anything.
557
subcommand.
558
Thus there is no need to close nor unmount anything.
559
The
559
The
560
.Cm suspend
560
.Cm suspend
561
subcommand does not work with devices created with the
561
subcommand does not work with devices created with the
562
.Cm onetime
562
.Cm onetime
563
subcommand.
563
subcommand.
564
Please note that sensitive data might still be present in memory after
564
Please note that sensitive data might still be present in memory after
565
suspending encrypted device, because of file system cache, etc.
565
suspending an encrypted device due to the file system cache, etc.
566
.Pp
566
.Pp
567
Additional options include:
567
Additional options include:
568
.Bl -tag -width ".Fl a"
568
.Bl -tag -width ".Fl a"
Lines 573-581 Link Here
573
.El
573
.El
574
.It Cm resume
574
.It Cm resume
575
Resume previously suspended device.
575
Resume previously suspended device.
576
The caller must ensure that executing this subcommand won't try to access
576
The caller must ensure that executing this subcommand doesn't access the
577
suspended device, which will lead to a deadlock.
577
suspended device, leading to a deadlock.
578
For example suspending device, which contains file system where the
578
For example suspending a device, which contains the file system where the
579
.Nm
579
.Nm
580
utility is stored is bad idea.
580
utility is stored is bad idea.
581
.Pp
581
.Pp
Lines 669-675 Link Here
669
maximum amount of debug information is printed.
669
maximum amount of debug information is printed.
670
.It Va kern.geom.eli.tries : No 3
670
.It Va kern.geom.eli.tries : No 3
671
Number of times a user is asked for the passphrase.
671
Number of times a user is asked for the passphrase.
672
This is only used for providers which should be attached on boot
672
This is only used for providers which are attached on boot
673
(before the root file system is mounted).
673
(before the root file system is mounted).
674
If set to 0, attaching providers on boot will be disabled.
674
If set to 0, attaching providers on boot will be disabled.
675
This variable should be set in
675
This variable should be set in
Lines 681-687 Link Here
681
.It Va kern.geom.eli.visible_passphrase : No 0
681
.It Va kern.geom.eli.visible_passphrase : No 0
682
If set to 1, the passphrase entered on boot (before the root
682
If set to 1, the passphrase entered on boot (before the root
683
file system is mounted) will be visible.
683
file system is mounted) will be visible.
684
This possibility should be used with caution as the entered
684
This alternative should be used with caution as the entered
685
passphrase can be logged and exposed via
685
passphrase can be logged and exposed via
686
.Xr dmesg 8 .
686
.Xr dmesg 8 .
687
This variable should be set in
687
This variable should be set in
Lines 691-708 Link Here
691
cryptography.
691
cryptography.
692
Its purpose is to increase performance on SMP systems.
692
Its purpose is to increase performance on SMP systems.
693
If hardware acceleration is available, only one thread will be started.
693
If hardware acceleration is available, only one thread will be started.
694
If set to 0, CPU-bound thread will be started for every active CPU.
694
If set to 0, a CPU-bound thread will be started for every active CPU.
695
.It Va kern.geom.eli.batch : No 0
695
.It Va kern.geom.eli.batch : No 0
696
When set to 1, can speed-up crypto operations by using batching.
696
When set to 1, can speed-up crypto operations by using batching.
697
Batching allows to reduce number of interrupts by responding on a group of
697
Batching reduces the number of interrupts by responding to a group of
698
crypto requests with one interrupt.
698
crypto requests with one interrupt.
699
The crypto card and the driver has to support this feature.
699
The crypto card and the driver has to support this feature.
700
.It Va kern.geom.eli.key_cache_limit : No 8192
700
.It Va kern.geom.eli.key_cache_limit : No 8192
701
Specifies how many encryption keys to cache.
701
Specifies how many encryption keys to cache.
702
The default limit
702
The default limit
703
.No ( 8192
703
.No ( 8192
704
keys) will allow to cache all keys for 4TB provider with 512 bytes sectors and
704
keys) will allow caching of all keys for a 4TB provider with 512 byte
705
will take around 1MB of memory.
705
sectors and will take around 1MB of memory.
706
.It Va kern.geom.eli.key_cache_hits
706
.It Va kern.geom.eli.key_cache_hits
707
Reports how many times we were looking up a key and it was already in cache.
707
Reports how many times we were looking up a key and it was already in cache.
708
This sysctl is not updated for providers that need less keys than the limit
708
This sysctl is not updated for providers that need less keys than the limit
Lines 710-716 Link Here
710
.Va kern.geom.eli.key_cache_limit .
710
.Va kern.geom.eli.key_cache_limit .
711
.It Va kern.geom.eli.key_cache_misses
711
.It Va kern.geom.eli.key_cache_misses
712
Reports how many times we were looking up a key and it was not in cache.
712
Reports how many times we were looking up a key and it was not in cache.
713
This sysctl is not updated for providers that need less keys than the limit
713
This sysctl is not updated for providers that need fewer keys than the limit
714
specified in
714
specified in
715
.Va kern.geom.eli.key_cache_limit .
715
.Va kern.geom.eli.key_cache_limit .
716
.El
716
.El
Lines 720-726 Link Here
720
Initialize a provider which is going to be encrypted with a
720
Initialize a provider which is going to be encrypted with a
721
passphrase and random data from a file on the user's pen drive.
721
passphrase and random data from a file on the user's pen drive.
722
Use 4kB sector size.
722
Use 4kB sector size.
723
Attach the provider, create a file system and mount it.
723
Attach the provider, create a file system, and mount it.
724
Do the work.
724
Do the work.
725
Unmount the provider and detach it:
725
Unmount the provider and detach it:
726
.Bd -literal -offset indent
726
.Bd -literal -offset indent
Lines 739-766 Link Here
739
.Ed
739
.Ed
740
.Pp
740
.Pp
741
Create an encrypted provider, but use two keys:
741
Create an encrypted provider, but use two keys:
742
one for your employee and one for you as company's security officer
742
one for your employee and one for you as the company's security officer
743
(so there is no tragedy if the employee
743
(so it's not a tragedy if the employee
744
.Qq accidentally
744
.Qq accidentally
745
forgets his passphrase):
745
forgets his passphrase):
746
.Bd -literal -offset indent
746
.Bd -literal -offset indent
747
# geli init /dev/da2
747
# geli init /dev/da2
748
Enter new passphrase:	(enter security officer passphrase)
748
Enter new passphrase:	(enter security officer's passphrase)
749
Reenter new passphrase:
749
Reenter new passphrase:
750
# geli setkey -n 1 /dev/da2
750
# geli setkey -n 1 /dev/da2
751
Enter passphrase:	(enter security officer passphrase)
751
Enter passphrase:	(enter security officer's passphrase)
752
Enter new passphrase:	(let your employee enter his passphrase ...)
752
Enter new passphrase:	(let your employee enter his passphrase ...)
753
Reenter new passphrase:	(... twice)
753
Reenter new passphrase:	(... twice)
754
.Ed
754
.Ed
755
.Pp
755
.Pp
756
You are the security-person in your company.
756
You are the security officer in your company.
757
Create an encrypted provider for use by the user, but remember that users
757
Create an encrypted provider for use by the user, but remember that users
758
forget their passphrases, so back Master Key up with your own random key:
758
forget their passphrases, so backup the Master Key with your own random key:
759
.Bd -literal -offset indent
759
.Bd -literal -offset indent
760
# dd if=/dev/random of=/mnt/pendrive/keys/`hostname` bs=64 count=1
760
# dd if=/dev/random of=/mnt/pendrive/keys/`hostname` bs=64 count=1
761
# geli init -P -K /mnt/pendrive/keys/`hostname` /dev/ad0s1e
761
# geli init -P -K /mnt/pendrive/keys/`hostname` /dev/ad0s1e
762
# geli backup /dev/ad0s1e /mnt/pendrive/backups/`hostname`
762
# geli backup /dev/ad0s1e /mnt/pendrive/backups/`hostname`
763
(use key number 0, so the encrypted Master Key by you will be overwritten)
763
(use key number 0, so the encrypted Master Key will be overwritten by this)
764
# geli setkey -n 0 -k /mnt/pendrive/keys/`hostname` /dev/ad0s1e
764
# geli setkey -n 0 -k /mnt/pendrive/keys/`hostname` /dev/ad0s1e
765
(allow the user to enter his passphrase)
765
(allow the user to enter his passphrase)
766
Enter new passphrase:
766
Enter new passphrase:
Lines 791-797 Link Here
791
# geli init -b -P -K /boot/keys/da1s3a.key da1s3a
791
# geli init -b -P -K /boot/keys/da1s3a.key da1s3a
792
.Ed
792
.Ed
793
.Pp
793
.Pp
794
The providers are initialized, now we have to add those lines to
794
The providers are initialized, now we have to add these lines to
795
.Pa /boot/loader.conf :
795
.Pa /boot/loader.conf :
796
.Bd -literal -offset indent
796
.Bd -literal -offset indent
797
geli_da0_keyfile0_load="YES"
797
geli_da0_keyfile0_load="YES"
Lines 823-832 Link Here
823
.Ed
823
.Ed
824
.Pp
824
.Pp
825
.Cm geli
825
.Cm geli
826
backups metadata by default to the
826
writes the metadata backup by default to the
827
.Pa /var/backups/<prov>.eli
827
.Pa /var/backups/<prov>.eli
828
file.
828
file.
829
If metadata is lost in any way (eg. by accidental overwrite), it can be restored.
829
If the metadata is lost in any way (eg. by accidental overwrite), it can be restored.
830
Consider the following situation:
830
Consider the following situation:
831
.Bd -literal -offset indent
831
.Bd -literal -offset indent
832
# geli init /dev/da0
832
# geli init /dev/da0
Lines 857-866 Link Here
857
# geli attach -k keyfile -p ada0p1
857
# geli attach -k keyfile -p ada0p1
858
.Ed
858
.Ed
859
.Pp
859
.Pp
860
Initialize provider with passphrase split into two files.
860
Initialize provider with the passphrase split into two files.
861
The provider can be attached by giving those two files or by giving
861
The provider can be attached using those two files or by entering
862
.Dq foobar
862
.Dq foobar
863
passphrase on
863
as the passphrase at the
864
.Nm
864
.Nm
865
prompt:
865
prompt:
866
.Bd -literal -offset indent
866
.Bd -literal -offset indent
Lines 875-882 Link Here
875
.Pp
875
.Pp
876
Suspend all
876
Suspend all
877
.Nm
877
.Nm
878
devices, suspend a laptop, then resume devices one by one after resuming a
878
devices on a laptop, suspend the laptop, then resume devices one by one after
879
laptop:
879
resuming the laptop:
880
.Bd -literal -offset indent
880
.Bd -literal -offset indent
881
# geli suspend -a
881
# geli suspend -a
882
# zzz
882
# zzz
Lines 916-927 Link Here
916
.Nm
916
.Nm
917
should be able to detect such a change.
917
should be able to detect such a change.
918
If an attacker can remember the encrypted data, he can overwrite any future
918
If an attacker can remember the encrypted data, he can overwrite any future
919
changes with the data he owns without notice.
919
changes with the data he owns without it being noticed.
920
In other words
920
In other words
921
.Nm
921
.Nm
922
will not protect your data against replay attacks.
922
will not protect your data against replay attacks.
923
.Pp
923
.Pp
924
It is recommended to write the whole provider before the first use,
924
It is recommended to write to the whole provider before first use,
925
in order to make sure that all sectors and their corresponding
925
in order to make sure that all sectors and their corresponding
926
checksums are properly initialized into a consistent state.
926
checksums are properly initialized into a consistent state.
927
.Sh SEE ALSO
927
.Sh SEE ALSO

Return to bug 165668