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