blob: 1bdb9f226eec269094560fd19474c8e70f47a92f [file] [log] [blame]
Jaegeuk Kim0b81d072015-05-15 16:26:10 -07001/*
2 * This contains functions for filename crypto management
3 *
4 * Copyright (C) 2015, Google, Inc.
5 * Copyright (C) 2015, Motorola Mobility
6 *
7 * Written by Uday Savagaonkar, 2014.
8 * Modified by Jaegeuk Kim, 2015.
9 *
10 * This has not yet undergone a rigorous security audit.
11 */
12
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070013#include <linux/scatterlist.h>
14#include <linux/ratelimit.h>
Eric Biggerseb9c5fd2018-01-05 10:45:00 -080015#include <crypto/skcipher.h>
Jaegeuk Kime6b120d2017-07-10 12:55:09 -070016#include "fscrypt_private.h"
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070017
Eric Biggers0a024722018-01-05 10:44:59 -080018static inline bool fscrypt_is_dot_dotdot(const struct qstr *str)
19{
20 if (str->len == 1 && str->name[0] == '.')
21 return true;
22
23 if (str->len == 2 && str->name[0] == '.' && str->name[1] == '.')
24 return true;
25
26 return false;
27}
28
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070029/**
Eric Biggersef1eb3a2016-09-15 17:25:55 -040030 * fname_encrypt() - encrypt a filename
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070031 *
Eric Biggersb0edc2f2018-01-11 23:30:08 -050032 * The output buffer must be at least as large as the input buffer.
33 * Any extra space is filled with NUL padding before encryption.
Eric Biggersef1eb3a2016-09-15 17:25:55 -040034 *
35 * Return: 0 on success, -errno on failure
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070036 */
Eric Biggersb0edc2f2018-01-11 23:30:08 -050037int fname_encrypt(struct inode *inode, const struct qstr *iname,
38 u8 *out, unsigned int olen)
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070039{
Linus Torvaldsd4075742016-03-21 11:03:02 -070040 struct skcipher_request *req = NULL;
Gilad Ben-Yossef743205f2017-10-18 08:00:44 +010041 DECLARE_CRYPTO_WAIT(wait);
Eric Biggersb0edc2f2018-01-11 23:30:08 -050042 struct crypto_skcipher *tfm = inode->i_crypt_info->ci_ctfm;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070043 int res = 0;
44 char iv[FS_CRYPTO_BLOCK_SIZE];
Eric Biggers3c7018e2016-11-13 20:35:52 -050045 struct scatterlist sg;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070046
Eric Biggers3c7018e2016-11-13 20:35:52 -050047 /*
48 * Copy the filename to the output buffer for encrypting in-place and
49 * pad it with the needed number of NUL bytes.
50 */
Eric Biggersb0edc2f2018-01-11 23:30:08 -050051 if (WARN_ON(olen < iname->len))
Eric Biggersa7e05c72018-01-05 10:45:01 -080052 return -ENOBUFS;
Eric Biggersb0edc2f2018-01-11 23:30:08 -050053 memcpy(out, iname->name, iname->len);
54 memset(out + iname->len, 0, olen - iname->len);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070055
Eric Biggers3c7018e2016-11-13 20:35:52 -050056 /* Initialize the IV */
57 memset(iv, 0, FS_CRYPTO_BLOCK_SIZE);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070058
Eric Biggers3c7018e2016-11-13 20:35:52 -050059 /* Set up the encryption request */
Linus Torvaldsd4075742016-03-21 11:03:02 -070060 req = skcipher_request_alloc(tfm, GFP_NOFS);
Eric Biggers1e04ac82018-04-30 15:51:38 -070061 if (!req)
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070062 return -ENOMEM;
Linus Torvaldsd4075742016-03-21 11:03:02 -070063 skcipher_request_set_callback(req,
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070064 CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP,
Gilad Ben-Yossef743205f2017-10-18 08:00:44 +010065 crypto_req_done, &wait);
Eric Biggersb0edc2f2018-01-11 23:30:08 -050066 sg_init_one(&sg, out, olen);
67 skcipher_request_set_crypt(req, &sg, &sg, olen, iv);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070068
Eric Biggers3c7018e2016-11-13 20:35:52 -050069 /* Do the encryption */
Gilad Ben-Yossef743205f2017-10-18 08:00:44 +010070 res = crypto_wait_req(crypto_skcipher_encrypt(req), &wait);
Linus Torvaldsd4075742016-03-21 11:03:02 -070071 skcipher_request_free(req);
Eric Biggersef1eb3a2016-09-15 17:25:55 -040072 if (res < 0) {
Eric Biggers78275d82018-04-30 15:51:47 -070073 fscrypt_err(inode->i_sb,
74 "Filename encryption failed for inode %lu: %d",
75 inode->i_ino, res);
Eric Biggersef1eb3a2016-09-15 17:25:55 -040076 return res;
77 }
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070078
Eric Biggersef1eb3a2016-09-15 17:25:55 -040079 return 0;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070080}
81
Eric Biggersef1eb3a2016-09-15 17:25:55 -040082/**
83 * fname_decrypt() - decrypt a filename
84 *
85 * The caller must have allocated sufficient memory for the @oname string.
86 *
87 * Return: 0 on success, -errno on failure
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070088 */
89static int fname_decrypt(struct inode *inode,
90 const struct fscrypt_str *iname,
91 struct fscrypt_str *oname)
92{
Linus Torvaldsd4075742016-03-21 11:03:02 -070093 struct skcipher_request *req = NULL;
Gilad Ben-Yossef743205f2017-10-18 08:00:44 +010094 DECLARE_CRYPTO_WAIT(wait);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070095 struct scatterlist src_sg, dst_sg;
Eric Biggerse2a57842018-04-30 15:51:42 -070096 struct crypto_skcipher *tfm = inode->i_crypt_info->ci_ctfm;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070097 int res = 0;
98 char iv[FS_CRYPTO_BLOCK_SIZE];
Jaegeuk Kim0b81d072015-05-15 16:26:10 -070099
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700100 /* Allocate request */
Linus Torvaldsd4075742016-03-21 11:03:02 -0700101 req = skcipher_request_alloc(tfm, GFP_NOFS);
Eric Biggers1e04ac82018-04-30 15:51:38 -0700102 if (!req)
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700103 return -ENOMEM;
Linus Torvaldsd4075742016-03-21 11:03:02 -0700104 skcipher_request_set_callback(req,
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700105 CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP,
Gilad Ben-Yossef743205f2017-10-18 08:00:44 +0100106 crypto_req_done, &wait);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700107
108 /* Initialize IV */
109 memset(iv, 0, FS_CRYPTO_BLOCK_SIZE);
110
111 /* Create decryption request */
112 sg_init_one(&src_sg, iname->name, iname->len);
113 sg_init_one(&dst_sg, oname->name, oname->len);
Linus Torvaldsd4075742016-03-21 11:03:02 -0700114 skcipher_request_set_crypt(req, &src_sg, &dst_sg, iname->len, iv);
Gilad Ben-Yossef743205f2017-10-18 08:00:44 +0100115 res = crypto_wait_req(crypto_skcipher_decrypt(req), &wait);
Linus Torvaldsd4075742016-03-21 11:03:02 -0700116 skcipher_request_free(req);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700117 if (res < 0) {
Eric Biggers78275d82018-04-30 15:51:47 -0700118 fscrypt_err(inode->i_sb,
119 "Filename decryption failed for inode %lu: %d",
120 inode->i_ino, res);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700121 return res;
122 }
123
124 oname->len = strnlen(oname->name, iname->len);
Eric Biggersef1eb3a2016-09-15 17:25:55 -0400125 return 0;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700126}
127
128static const char *lookup_table =
129 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
130
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700131#define BASE64_CHARS(nbytes) DIV_ROUND_UP((nbytes) * 4, 3)
132
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700133/**
134 * digest_encode() -
135 *
136 * Encodes the input digest using characters from the set [a-zA-Z0-9_+].
137 * The encoded string is roughly 4/3 times the size of the input string.
138 */
139static int digest_encode(const char *src, int len, char *dst)
140{
141 int i = 0, bits = 0, ac = 0;
142 char *cp = dst;
143
144 while (i < len) {
145 ac += (((unsigned char) src[i]) << bits);
146 bits += 8;
147 do {
148 *cp++ = lookup_table[ac & 0x3f];
149 ac >>= 6;
150 bits -= 6;
151 } while (bits >= 6);
152 i++;
153 }
154 if (bits)
155 *cp++ = lookup_table[ac & 0x3f];
156 return cp - dst;
157}
158
159static int digest_decode(const char *src, int len, char *dst)
160{
161 int i = 0, bits = 0, ac = 0;
162 const char *p;
163 char *cp = dst;
164
165 while (i < len) {
166 p = strchr(lookup_table, src[i]);
167 if (p == NULL || src[i] == 0)
168 return -2;
169 ac += (p - lookup_table) << bits;
170 bits += 6;
171 if (bits >= 8) {
172 *cp++ = ac & 0xff;
173 ac >>= 8;
174 bits -= 8;
175 }
176 i++;
177 }
178 if (ac)
179 return -1;
180 return cp - dst;
181}
182
Eric Biggers549b2062018-01-11 23:30:08 -0500183bool fscrypt_fname_encrypted_size(const struct inode *inode, u32 orig_len,
184 u32 max_len, u32 *encrypted_len_ret)
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700185{
Eric Biggers549b2062018-01-11 23:30:08 -0500186 int padding = 4 << (inode->i_crypt_info->ci_flags &
187 FS_POLICY_FLAGS_PAD_MASK);
188 u32 encrypted_len;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700189
Eric Biggers549b2062018-01-11 23:30:08 -0500190 if (orig_len > max_len)
191 return false;
192 encrypted_len = max(orig_len, (u32)FS_CRYPTO_BLOCK_SIZE);
193 encrypted_len = round_up(encrypted_len, padding);
194 *encrypted_len_ret = min(encrypted_len, max_len);
195 return true;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700196}
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700197
198/**
Eric Biggersc440b5092018-01-11 23:30:08 -0500199 * fscrypt_fname_alloc_buffer - allocate a buffer for presented filenames
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700200 *
Eric Biggersc440b5092018-01-11 23:30:08 -0500201 * Allocate a buffer that is large enough to hold any decrypted or encoded
202 * filename (null-terminated), for the given maximum encrypted filename length.
203 *
204 * Return: 0 on success, -errno on failure
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700205 */
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700206int fscrypt_fname_alloc_buffer(const struct inode *inode,
Eric Biggersc440b5092018-01-11 23:30:08 -0500207 u32 max_encrypted_len,
208 struct fscrypt_str *crypto_str)
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700209{
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700210 const u32 max_encoded_len =
211 max_t(u32, BASE64_CHARS(FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE),
212 1 + BASE64_CHARS(sizeof(struct fscrypt_digested_name)));
Eric Biggersc440b5092018-01-11 23:30:08 -0500213 u32 max_presented_len;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700214
Eric Biggersc440b5092018-01-11 23:30:08 -0500215 max_presented_len = max(max_encoded_len, max_encrypted_len);
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700216
Eric Biggersc440b5092018-01-11 23:30:08 -0500217 crypto_str->name = kmalloc(max_presented_len + 1, GFP_NOFS);
218 if (!crypto_str->name)
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700219 return -ENOMEM;
Eric Biggersc440b5092018-01-11 23:30:08 -0500220 crypto_str->len = max_presented_len;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700221 return 0;
222}
223EXPORT_SYMBOL(fscrypt_fname_alloc_buffer);
224
225/**
Eric Biggersc440b5092018-01-11 23:30:08 -0500226 * fscrypt_fname_free_buffer - free the buffer for presented filenames
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700227 *
Eric Biggersc440b5092018-01-11 23:30:08 -0500228 * Free the buffer allocated by fscrypt_fname_alloc_buffer().
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700229 */
230void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
231{
232 if (!crypto_str)
233 return;
234 kfree(crypto_str->name);
235 crypto_str->name = NULL;
236}
237EXPORT_SYMBOL(fscrypt_fname_free_buffer);
238
239/**
240 * fscrypt_fname_disk_to_usr() - converts a filename from disk space to user
241 * space
Eric Biggersef1eb3a2016-09-15 17:25:55 -0400242 *
243 * The caller must have allocated sufficient memory for the @oname string.
244 *
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700245 * If the key is available, we'll decrypt the disk name; otherwise, we'll encode
246 * it for presentation. Short names are directly base64-encoded, while long
247 * names are encoded in fscrypt_digested_name format.
248 *
Eric Biggersef1eb3a2016-09-15 17:25:55 -0400249 * Return: 0 on success, -errno on failure
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700250 */
251int fscrypt_fname_disk_to_usr(struct inode *inode,
252 u32 hash, u32 minor_hash,
253 const struct fscrypt_str *iname,
254 struct fscrypt_str *oname)
255{
256 const struct qstr qname = FSTR_TO_QSTR(iname);
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700257 struct fscrypt_digested_name digested_name;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700258
259 if (fscrypt_is_dot_dotdot(&qname)) {
260 oname->name[0] = '.';
261 oname->name[iname->len - 1] = '.';
262 oname->len = iname->len;
Eric Biggersef1eb3a2016-09-15 17:25:55 -0400263 return 0;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700264 }
265
266 if (iname->len < FS_CRYPTO_BLOCK_SIZE)
267 return -EUCLEAN;
268
269 if (inode->i_crypt_info)
270 return fname_decrypt(inode, iname, oname);
271
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700272 if (iname->len <= FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE) {
Eric Biggersef1eb3a2016-09-15 17:25:55 -0400273 oname->len = digest_encode(iname->name, iname->len,
274 oname->name);
275 return 0;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700276 }
277 if (hash) {
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700278 digested_name.hash = hash;
279 digested_name.minor_hash = minor_hash;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700280 } else {
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700281 digested_name.hash = 0;
282 digested_name.minor_hash = 0;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700283 }
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700284 memcpy(digested_name.digest,
285 FSCRYPT_FNAME_DIGEST(iname->name, iname->len),
286 FSCRYPT_FNAME_DIGEST_SIZE);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700287 oname->name[0] = '_';
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700288 oname->len = 1 + digest_encode((const char *)&digested_name,
289 sizeof(digested_name), oname->name + 1);
Eric Biggersef1eb3a2016-09-15 17:25:55 -0400290 return 0;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700291}
292EXPORT_SYMBOL(fscrypt_fname_disk_to_usr);
293
294/**
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700295 * fscrypt_setup_filename() - prepare to search a possibly encrypted directory
296 * @dir: the directory that will be searched
297 * @iname: the user-provided filename being searched for
298 * @lookup: 1 if we're allowed to proceed without the key because it's
299 * ->lookup() or we're finding the dir_entry for deletion; 0 if we cannot
300 * proceed without the key because we're going to create the dir_entry.
301 * @fname: the filename information to be filled in
302 *
303 * Given a user-provided filename @iname, this function sets @fname->disk_name
304 * to the name that would be stored in the on-disk directory entry, if possible.
305 * If the directory is unencrypted this is simply @iname. Else, if we have the
306 * directory's encryption key, then @iname is the plaintext, so we encrypt it to
307 * get the disk_name.
308 *
309 * Else, for keyless @lookup operations, @iname is the presented ciphertext, so
310 * we decode it to get either the ciphertext disk_name (for short names) or the
311 * fscrypt_digested_name (for long names). Non-@lookup operations will be
312 * impossible in this case, so we fail them with ENOKEY.
313 *
314 * If successful, fscrypt_free_filename() must be called later to clean up.
315 *
316 * Return: 0 on success, -errno on failure
317 */
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700318int fscrypt_setup_filename(struct inode *dir, const struct qstr *iname,
319 int lookup, struct fscrypt_name *fname)
320{
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700321 int ret;
322 int digested;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700323
324 memset(fname, 0, sizeof(struct fscrypt_name));
325 fname->usr_fname = iname;
326
Eric Biggersd750ec72017-10-09 12:15:36 -0700327 if (!IS_ENCRYPTED(dir) || fscrypt_is_dot_dotdot(iname)) {
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700328 fname->disk_name.name = (unsigned char *)iname->name;
329 fname->disk_name.len = iname->len;
330 return 0;
331 }
Eric Biggers2984e522017-02-21 15:07:11 -0800332 ret = fscrypt_get_encryption_info(dir);
Eric Biggersd3679392018-04-30 15:51:41 -0700333 if (ret)
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700334 return ret;
335
336 if (dir->i_crypt_info) {
Eric Biggers549b2062018-01-11 23:30:08 -0500337 if (!fscrypt_fname_encrypted_size(dir, iname->len,
Eric Biggers4ddc3a82018-04-30 15:51:44 -0700338 dir->i_sb->s_cop->max_namelen,
Eric Biggers549b2062018-01-11 23:30:08 -0500339 &fname->crypto_buf.len))
Eric Biggersb0edc2f2018-01-11 23:30:08 -0500340 return -ENAMETOOLONG;
Eric Biggersb0edc2f2018-01-11 23:30:08 -0500341 fname->crypto_buf.name = kmalloc(fname->crypto_buf.len,
342 GFP_NOFS);
343 if (!fname->crypto_buf.name)
344 return -ENOMEM;
345
346 ret = fname_encrypt(dir, iname, fname->crypto_buf.name,
347 fname->crypto_buf.len);
Eric Biggersef1eb3a2016-09-15 17:25:55 -0400348 if (ret)
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700349 goto errout;
350 fname->disk_name.name = fname->crypto_buf.name;
351 fname->disk_name.len = fname->crypto_buf.len;
352 return 0;
353 }
354 if (!lookup)
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700355 return -ENOKEY;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700356
357 /*
358 * We don't have the key and we are doing a lookup; decode the
359 * user-supplied name
360 */
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700361 if (iname->name[0] == '_') {
362 if (iname->len !=
363 1 + BASE64_CHARS(sizeof(struct fscrypt_digested_name)))
364 return -ENOENT;
365 digested = 1;
366 } else {
367 if (iname->len >
368 BASE64_CHARS(FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE))
369 return -ENOENT;
370 digested = 0;
371 }
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700372
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700373 fname->crypto_buf.name =
374 kmalloc(max_t(size_t, FSCRYPT_FNAME_MAX_UNDIGESTED_SIZE,
375 sizeof(struct fscrypt_digested_name)),
376 GFP_KERNEL);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700377 if (fname->crypto_buf.name == NULL)
378 return -ENOMEM;
379
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700380 ret = digest_decode(iname->name + digested, iname->len - digested,
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700381 fname->crypto_buf.name);
382 if (ret < 0) {
383 ret = -ENOENT;
384 goto errout;
385 }
386 fname->crypto_buf.len = ret;
Jaegeuk Kime6b120d2017-07-10 12:55:09 -0700387 if (digested) {
388 const struct fscrypt_digested_name *n =
389 (const void *)fname->crypto_buf.name;
390 fname->hash = n->hash;
391 fname->minor_hash = n->minor_hash;
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700392 } else {
393 fname->disk_name.name = fname->crypto_buf.name;
394 fname->disk_name.len = fname->crypto_buf.len;
395 }
396 return 0;
397
398errout:
Eric Biggersb0edc2f2018-01-11 23:30:08 -0500399 kfree(fname->crypto_buf.name);
Jaegeuk Kim0b81d072015-05-15 16:26:10 -0700400 return ret;
401}
402EXPORT_SYMBOL(fscrypt_setup_filename);