18
18
#include <crypto/skcipher.h>
19
19
#include "fscrypt_private.h"
20
20
21
- /**
21
+ /*
22
22
* struct fscrypt_nokey_name - identifier for directory entry when key is absent
23
23
*
24
24
* When userspace lists an encrypted directory without access to the key, the
@@ -100,9 +100,12 @@ static inline bool fscrypt_is_dot_dotdot(const struct qstr *str)
100
100
101
101
/**
102
102
* fscrypt_fname_encrypt() - encrypt a filename
103
- *
104
- * The output buffer must be at least as large as the input buffer.
105
- * Any extra space is filled with NUL padding before encryption.
103
+ * @inode: inode of the parent directory (for regular filenames)
104
+ * or of the symlink (for symlink targets)
105
+ * @iname: the filename to encrypt
106
+ * @out: (output) the encrypted filename
107
+ * @olen: size of the encrypted filename. It must be at least @iname->len.
108
+ * Any extra space is filled with NUL padding before encryption.
106
109
*
107
110
* Return: 0 on success, -errno on failure
108
111
*/
@@ -152,8 +155,11 @@ int fscrypt_fname_encrypt(const struct inode *inode, const struct qstr *iname,
152
155
153
156
/**
154
157
* fname_decrypt() - decrypt a filename
155
- *
156
- * The caller must have allocated sufficient memory for the @oname string.
158
+ * @inode: inode of the parent directory (for regular filenames)
159
+ * or of the symlink (for symlink targets)
160
+ * @iname: the encrypted filename to decrypt
161
+ * @oname: (output) the decrypted filename. The caller must have allocated
162
+ * enough space for this, e.g. using fscrypt_fname_alloc_buffer().
157
163
*
158
164
* Return: 0 on success, -errno on failure
159
165
*/
@@ -201,7 +207,10 @@ static const char lookup_table[65] =
201
207
#define BASE64_CHARS (nbytes ) DIV_ROUND_UP((nbytes) * 4, 3)
202
208
203
209
/**
204
- * base64_encode() -
210
+ * base64_encode() - base64-encode some bytes
211
+ * @src: the bytes to encode
212
+ * @len: number of bytes to encode
213
+ * @dst: (output) the base64-encoded string. Not NUL-terminated.
205
214
*
206
215
* Encodes the input string using characters from the set [A-Za-z0-9+,].
207
216
* The encoded string is roughly 4/3 times the size of the input string.
@@ -267,7 +276,12 @@ bool fscrypt_fname_encrypted_size(const struct inode *inode, u32 orig_len,
267
276
}
268
277
269
278
/**
270
- * fscrypt_fname_alloc_buffer - allocate a buffer for presented filenames
279
+ * fscrypt_fname_alloc_buffer() - allocate a buffer for presented filenames
280
+ * @inode: inode of the parent directory (for regular filenames)
281
+ * or of the symlink (for symlink targets)
282
+ * @max_encrypted_len: maximum length of encrypted filenames the buffer will be
283
+ * used to present
284
+ * @crypto_str: (output) buffer to allocate
271
285
*
272
286
* Allocate a buffer that is large enough to hold any decrypted or encoded
273
287
* filename (null-terminated), for the given maximum encrypted filename length.
@@ -292,9 +306,10 @@ int fscrypt_fname_alloc_buffer(const struct inode *inode,
292
306
EXPORT_SYMBOL (fscrypt_fname_alloc_buffer );
293
307
294
308
/**
295
- * fscrypt_fname_free_buffer - free the buffer for presented filenames
309
+ * fscrypt_fname_free_buffer() - free a buffer for presented filenames
310
+ * @crypto_str: the buffer to free
296
311
*
297
- * Free the buffer allocated by fscrypt_fname_alloc_buffer().
312
+ * Free a buffer that was allocated by fscrypt_fname_alloc_buffer().
298
313
*/
299
314
void fscrypt_fname_free_buffer (struct fscrypt_str * crypto_str )
300
315
{
@@ -306,10 +321,19 @@ void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
306
321
EXPORT_SYMBOL (fscrypt_fname_free_buffer );
307
322
308
323
/**
309
- * fscrypt_fname_disk_to_usr() - converts a filename from disk space to user
310
- * space
311
- *
312
- * The caller must have allocated sufficient memory for the @oname string.
324
+ * fscrypt_fname_disk_to_usr() - convert an encrypted filename to
325
+ * user-presentable form
326
+ * @inode: inode of the parent directory (for regular filenames)
327
+ * or of the symlink (for symlink targets)
328
+ * @hash: first part of the name's dirhash, if applicable. This only needs to
329
+ * be provided if the filename is located in an indexed directory whose
330
+ * encryption key may be unavailable. Not needed for symlink targets.
331
+ * @minor_hash: second part of the name's dirhash, if applicable
332
+ * @iname: encrypted filename to convert. May also be "." or "..", which
333
+ * aren't actually encrypted.
334
+ * @oname: output buffer for the user-presentable filename. The caller must
335
+ * have allocated enough space for this, e.g. using
336
+ * fscrypt_fname_alloc_buffer().
313
337
*
314
338
* If the key is available, we'll decrypt the disk name. Otherwise, we'll
315
339
* encode it for presentation in fscrypt_nokey_name format.
0 commit comments