big_key.c (bdd1d2d3d251c65b74ac4493e08db18971c09240) big_key.c (e13ec939e96b13e664bb6cee361cc976a0ee621a)
1/* Large capacity key type
2 *
3 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version

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

142
143 if (datalen > BIG_KEY_FILE_THRESHOLD) {
144 /* Create a shmem file to store the data in. This will permit the data
145 * to be swapped out if needed.
146 *
147 * File content is stored encrypted with randomly generated key.
148 */
149 size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher));
1/* Large capacity key type
2 *
3 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version

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

142
143 if (datalen > BIG_KEY_FILE_THRESHOLD) {
144 /* Create a shmem file to store the data in. This will permit the data
145 * to be swapped out if needed.
146 *
147 * File content is stored encrypted with randomly generated key.
148 */
149 size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher));
150 loff_t pos = 0;
150
151 /* prepare aligned data to encrypt */
152 data = kmalloc(enclen, GFP_KERNEL);
153 if (!data)
154 return -ENOMEM;
155
156 memcpy(data, prep->data, datalen);
157 memset(data + datalen, 0x00, enclen - datalen);

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

174
175 /* save aligned data to file */
176 file = shmem_kernel_file_setup("", enclen, 0);
177 if (IS_ERR(file)) {
178 ret = PTR_ERR(file);
179 goto err_enckey;
180 }
181
151
152 /* prepare aligned data to encrypt */
153 data = kmalloc(enclen, GFP_KERNEL);
154 if (!data)
155 return -ENOMEM;
156
157 memcpy(data, prep->data, datalen);
158 memset(data + datalen, 0x00, enclen - datalen);

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

175
176 /* save aligned data to file */
177 file = shmem_kernel_file_setup("", enclen, 0);
178 if (IS_ERR(file)) {
179 ret = PTR_ERR(file);
180 goto err_enckey;
181 }
182
182 written = kernel_write(file, data, enclen, 0);
183 written = kernel_write(file, data, enclen, &pos);
183 if (written != enclen) {
184 ret = written;
185 if (written >= 0)
186 ret = -ENOMEM;
187 goto err_fput;
188 }
189
190 /* Pin the mount and dentry to the key so that we can open it again

--- 200 unchanged lines hidden ---
184 if (written != enclen) {
185 ret = written;
186 if (written >= 0)
187 ret = -ENOMEM;
188 goto err_fput;
189 }
190
191 /* Pin the mount and dentry to the key so that we can open it again

--- 200 unchanged lines hidden ---