policy.c (d4e0045c4ed300781d2d4cbab57d05ed5e665a37) policy.c (b7e7cf7a66a27e62c5f873a0068cee34094bf5d7)
1/*
2 * Encryption policy functions for per-file encryption support.
3 *
4 * Copyright (C) 2015, Google, Inc.
5 * Copyright (C) 2015, Motorola Mobility.
6 *
7 * Written by Michael Halcrow, 2015.
8 * Modified by Jaegeuk Kim, 2015.

--- 24 unchanged lines hidden (view full) ---

33 const struct fscrypt_policy *policy)
34{
35 struct fscrypt_context ctx;
36
37 ctx.format = FS_ENCRYPTION_CONTEXT_FORMAT_V1;
38 memcpy(ctx.master_key_descriptor, policy->master_key_descriptor,
39 FS_KEY_DESCRIPTOR_SIZE);
40
1/*
2 * Encryption policy functions for per-file encryption support.
3 *
4 * Copyright (C) 2015, Google, Inc.
5 * Copyright (C) 2015, Motorola Mobility.
6 *
7 * Written by Michael Halcrow, 2015.
8 * Modified by Jaegeuk Kim, 2015.

--- 24 unchanged lines hidden (view full) ---

33 const struct fscrypt_policy *policy)
34{
35 struct fscrypt_context ctx;
36
37 ctx.format = FS_ENCRYPTION_CONTEXT_FORMAT_V1;
38 memcpy(ctx.master_key_descriptor, policy->master_key_descriptor,
39 FS_KEY_DESCRIPTOR_SIZE);
40
41 if (!fscrypt_valid_contents_enc_mode(
42 policy->contents_encryption_mode))
41 if (!fscrypt_valid_enc_modes(policy->contents_encryption_mode,
42 policy->filenames_encryption_mode))
43 return -EINVAL;
44
43 return -EINVAL;
44
45 if (!fscrypt_valid_filenames_enc_mode(
46 policy->filenames_encryption_mode))
47 return -EINVAL;
48
49 if (policy->flags & ~FS_POLICY_FLAGS_VALID)
50 return -EINVAL;
51
52 ctx.contents_encryption_mode = policy->contents_encryption_mode;
53 ctx.filenames_encryption_mode = policy->filenames_encryption_mode;
54 ctx.flags = policy->flags;
55 BUILD_BUG_ON(sizeof(ctx.nonce) != FS_KEY_DERIVATION_NONCE_SIZE);
56 get_random_bytes(ctx.nonce, FS_KEY_DERIVATION_NONCE_SIZE);

--- 213 unchanged lines hidden ---
45 if (policy->flags & ~FS_POLICY_FLAGS_VALID)
46 return -EINVAL;
47
48 ctx.contents_encryption_mode = policy->contents_encryption_mode;
49 ctx.filenames_encryption_mode = policy->filenames_encryption_mode;
50 ctx.flags = policy->flags;
51 BUILD_BUG_ON(sizeof(ctx.nonce) != FS_KEY_DERIVATION_NONCE_SIZE);
52 get_random_bytes(ctx.nonce, FS_KEY_DERIVATION_NONCE_SIZE);

--- 213 unchanged lines hidden ---