~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to src/libecryptfs/key_management.c

  • Committer: Dustin Kirkland
  • Date: 2009-01-22 00:58:21 UTC
  • Revision ID: git-v1:d0d0782ff84bd0c8deead3c695a7e13f7874b175
filename encryption userspace support

Recent changes to the ecryptfs kernel code has added support for
filename encryption.

The basic userspace support was a added a few weeks ago.  You can
specify the key in the kernel keyring to use as a mount parameter,
with:
  ecryptfs_fnek_sig=0000000000000000

This patch adds a couple of conveniences, mainly in support of using
encrypting filenames easily with the encrypted-home and
encrypted-private features of ecryptfs.

In these scenarios, the filename encryption key is dynamically
(but programmatically) generated using the mount passphrase.

The mount passphrase is salted, hashed 65536 times using sha512,
converted to hex, and truncated to 16 digits long (128 bits).  This
value is used as the filename encryption passphrase.

Should the filename encryption password be compromised, one would
have to reverse this process.  We have designed this to be
cryptographically very difficult.

The signature of the filename encryption key (often abbreviated
"fnek") should be specified in ~/.ecryptfs/Private_fnek.sig.

If this file exists and contains a valid signature, the
mount.ecryptfs_private helper will specify this key in the mount
options as described above.

The pam_ecryptfs modules will continue to insert the wrapped
passphrase into the kernel keyring.  I have modified the base
library functionality to unconditionally also insert the fnek
passphrase.  THIS SHOULD BE FIXED IN A SUBSEQUENT COMMIT.

Also, the ecryptfs-setup-private utility needs to be enhanced
to write out the Private_fnek.sig file.  This may necessitate
a new binary utility to perform this operation.

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
185
185
        return rc;
186
186
}
187
187
 
 
188
int ecryptfs_add_filename_key_to_keyring(char *auth_tok_sig, char *passphrase,
 
189
                                         char *salt)
 
190
{
 
191
        char fnek[ECRYPTFS_MAX_PASSPHRASE_BYTES + 1] ;
 
192
        int rc;
 
193
 
 
194
        rc = generate_fnek(fnek, ECRYPTFS_DEFAULT_SALT_FNEK_HEX, passphrase);
 
195
        if (rc) {
 
196
                syslog(LOG_ERR, "Error generating fnek; "
 
197
                                "rc = [%d]\n", rc);
 
198
                rc = (rc < 0) ? rc : rc * -1;
 
199
                return rc;
 
200
        }
 
201
        return ecryptfs_add_passphrase_key_to_keyring(auth_tok_sig, fnek, salt);
 
202
}
 
203
 
188
204
/**
189
205
 * This is the common functionality used to put a password generated key into
190
206
 * the keyring, shared by both non-interactive and interactive signature
612
628
        char *salt)
613
629
{
614
630
        char decrypted_passphrase[ECRYPTFS_MAX_PASSPHRASE_BYTES + 1] ;
 
631
        char dummy[ECRYPTFS_SIG_SIZE_HEX + 1];
615
632
        int rc;
616
633
 
617
634
        if ((rc = ecryptfs_unwrap_passphrase(decrypted_passphrase, filename,
621
638
                rc = -EIO;
622
639
                goto out;
623
640
        }
 
641
        if ((rc = ecryptfs_add_filename_key_to_keyring(dummy,
 
642
                                                        decrypted_passphrase,
 
643
                                                        salt))) {
 
644
                syslog(LOG_ERR, "Error attempting to add filename key to "
 
645
                       "user session keyring; rc = [%d]\n", rc);
 
646
        }
624
647
        if ((rc = ecryptfs_add_passphrase_key_to_keyring(auth_tok_sig,
625
648
                                                         decrypted_passphrase,
626
649
                                                         salt))) {
627
650
                syslog(LOG_ERR, "Error attempting to add passphrase key to "
628
651
                       "user session keyring; rc = [%d]\n", rc);
629
 
                goto out;
630
652
        }
631
653
out:
632
654
        return rc;