Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| pefs [2010/10/16 09:55] – GlebKurtsov | pefs [2022/06/08 01:05] (current) – Add Category: Project KubilayKocak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | **PEFS (Private Encrypted File System)** is a kernel level stacked cryptographic | ||
| + | filesystem for %%FreeBSD%%. | ||
| + | |||
| + | * [[http:// | ||
| + | * [[https:// | ||
| + | |||
| ====== PEFS crypto primitives ====== | ====== PEFS crypto primitives ====== | ||
| - | //This document was created from text written by Gleb Kurtsou at http:// | + | //This document was created from an [[http:// |
| Supported data encryption algorithms: AES and Camellia (with 128, 192 and 256 bits key sizes). Adding another block cipher with 128 block size should be trivial. | Supported data encryption algorithms: AES and Camellia (with 128, 192 and 256 bits key sizes). Adding another block cipher with 128 block size should be trivial. | ||
| Line 7: | Line 13: | ||
| ===== Filename encryption ===== | ===== Filename encryption ===== | ||
| - | File names are always encrypted using AES-128 in CBC mode with zero IV. Encrypted file name consists of a unique | + | File names are always encrypted using AES-128 in CBC mode with zero IV. Encrypted file name consists of a random |
| < | < | ||
| Line 21: | Line 27: | ||
| Both the checksum and the tweak have 64 bit length. Stronger / larger lengths are not advisable because the filenames are limited by the file system name length limits (255 bytes); with multibyte encodings like UTF-8, the total available space might be very small (e.g. for non-ASCII European languages using 2 bytes per UTF-8 character, the process might leave only 80-90 characters for the actual user-specified filename). | Both the checksum and the tweak have 64 bit length. Stronger / larger lengths are not advisable because the filenames are limited by the file system name length limits (255 bytes); with multibyte encodings like UTF-8, the total available space might be very small (e.g. for non-ASCII European languages using 2 bytes per UTF-8 character, the process might leave only 80-90 characters for the actual user-specified filename). | ||
| - | Filenames are encrypted in AES-CBC mode with zero IV (and padded with zeros to cipher block boundary). First encryption block contains pseudo random tweak which makes all encrypted filenames unique due to CBC mode chaining. | + | Filenames are encrypted in AES-CBC mode with zero IV (and padded with zeros to cipher block boundary). First encryption block contains pseudo random tweak which makes all encrypted filenames unique due to CBC mode chaining. Main reason for not providing alternatives to the name encryption algorithm is to keep the design simple. |
| - | Main reason for not providing alternatives to the name encryption algorithm is to keep the design simple. Data encryption differs from name encryption because the encrypted file data, unlike encrypted file name, is not parsed in any way by pefs and user expects to be able to use secure/ | + | Encrypt-then-Authenticate construction is used. It allows checking if the name was encrypted by a given key without performing decryption. VMAC was chosen because of it performance characteristics and its ability to produce 64 bit MAC (without truncation of original result like in HMAC case). There is no real " |
| - | + | ||
| - | Encrypt-then-Authenticate construction is used. In addition to being most secure variant it allows checking if the name was encrypted by any given key without performing decryption. VMAC was chosen because of it performance characteristics and its ability to produce 64 bit MAC (without truncation of original result like in HMAC case). There is no real " | + | |
| Encrypted directory/ | Encrypted directory/ | ||
| Line 31: | Line 35: | ||
| ===== File data encryption ===== | ===== File data encryption ===== | ||
| - | The idea behind using a tweak is to get unique per file ciphertext. Block ciphers (AES, Camellia) | + | Files are encrypted |
| ===== Other information ===== | ===== Other information ===== | ||
| - | 4 different keys are used with cryptographic primitives: one for name encryption, one for VMAC and two keys for data encryption as required by XTS. All these keys are derived from the 512 bit user supplied key using HKDF algorithm based on HMAC-SHA512 (IETF draft). The kernel part expects cryptographically strong key from userspace. This key is generated with PBKDF on using HMAC-SHA512 from passphrase. | + | 4 different keys are used with cryptographic primitives: one for filename |
| + | |||
| + | Standard implementations of ciphers are used, but not opencrypto framework. Opencrypto is not used mainly because it lacks full support for XTS mode (it is currently not able to encrypt incomplete / " | ||
| + | |||
| + | PEFS supports multiple keys, mixing files encrypted with different keys in single directory, transparent (unencrypted) mode, key chaining (adding a series of keys by entering just one of them) and more. | ||
| + | |||
| + | ====== Key chains ====== | ||
| + | |||
| + | Chain is a series of keys. Chains are stored in a database ('' | ||
| + | |||
| + | Consider the following chain: '' | ||
| + | 4 database entries are used to represent it, ''' | ||
| + | |||
| + | < | ||
| + | (k1 => k2) | ||
| + | (k2 => k3) | ||
| + | (k3 => 0) | ||
| + | </ | ||
| + | |||
| + | If user enters '' | ||
| + | |||
| + | Entering '' | ||
| + | |||
| + | Database may contain independent key chains: | ||
| + | |||
| + | < | ||
| + | a1 -> a2 | ||
| + | b1 -> b2 -> b3 | ||
| + | c1 | ||
| + | </ | ||
| + | |||
| + | Using key chains one can emulate access levels, e.g. in first example '' | ||
| + | |||
| + | All database entries are stored encrypted in a way that child key can be decrypted only by parent key. | ||
| + | |||
| + | ==== Technical details ==== | ||
| + | |||
| + | Technically database is a standard btree(3) database with entries indexed by '' | ||
| + | It may be described as a dictionary of the following form: | ||
| + | |||
| + | < | ||
| + | database[KEYID(key)] = data || mac | ||
| + | data = AES128-CTR(KEK(key), | ||
| + | mac = HMAC-SHA512(KEK(key), | ||
| + | </ | ||
| + | |||
| + | Entry correctness is guarantied by Message Authentication Code ('' | ||
| + | |||
| + | HMAC-SHA512 is used to calculate both Key Encryption Key ('' | ||
| + | |||
| + | < | ||
| + | KEYID(key) = HMAC-SHA512(key, | ||
| + | KEK(key) = HMAC-SHA512(key, | ||
| + | </ | ||
| + | |||
| + | While adding key chain with '' | ||
| + | user provided passphrase: | ||
| + | |||
| + | < | ||
| + | key = PKCS5V2(passphrase) | ||
| + | </ | ||
| + | |||
| + | Child key is than looked up in database: '' | ||
| + | |||
| + | Besides first parent key parameters (algorithm and key size) can also be restored from database entry ('' | ||
| + | |||
| + | ====== Tutorial: Encrypting a directory ====== | ||
| + | |||
| + | Let's encrypt '' | ||
| + | |||
| + | < | ||
| + | # mkdir ~/private ~/ | ||
| + | </ | ||
| + | |||
| + | === 1. Save encryption key === | ||
| + | |||
| + | PEFS doesn' | ||
| + | |||
| + | '' | ||
| + | '' | ||
| + | '' | ||
| + | |||
| + | < | ||
| + | # pefs addchain -f -Z ~/ | ||
| + | Enter parent key passphrase: | ||
| + | Reenter parent key passphrase: | ||
| + | </ | ||
| + | |||
| + | Key chain database file was created: | ||
| + | |||
| + | < | ||
| + | # ls -A ~/ | ||
| + | .pefs.db | ||
| + | </ | ||
| + | |||
| + | === 2. Mount file system with saved encryption key === | ||
| + | |||
| + | PEFS file system doesn' | ||
| + | |||
| + | < | ||
| + | # pefs mount ~/ | ||
| + | </ | ||
| + | |||
| + | '' | ||
| + | |||
| + | < | ||
| + | # pefs addkey -c ~/private | ||
| + | Enter passphrase: | ||
| + | </ | ||
| - | Standard implementations of ciphers are used, but not opencrypto framework, so there is no hardware acceleration available. Opencrypto is not used mainly because it lacks full support for XTS mode (it is currently not able to encrypt incomplete / " | + | ---- |
| - | PEFS supports multiple keys, mixing files encrypted with different keys in single directory, transparent(unencrypted) mode, key chaining (adding a series of keys by entering just one of them) and more. | + | {{tag> |
| + | {{tag> | ||