1818#include <crypto/skcipher.h>
1919#include "fscrypt_private.h"
2020
21- /**
21+ /*
2222 * struct fscrypt_nokey_name - identifier for directory entry when key is absent
2323 *
2424 * When userspace lists an encrypted directory without access to the key, the
@@ -105,9 +105,12 @@ static inline bool fscrypt_is_dot_dotdot(const struct qstr *str)
105105
106106/**
107107 * fscrypt_fname_encrypt() - encrypt a filename
108- *
109- * The output buffer must be at least as large as the input buffer.
110- * Any extra space is filled with NUL padding before encryption.
108+ * @inode: inode of the parent directory (for regular filenames)
109+ * or of the symlink (for symlink targets)
110+ * @iname: the filename to encrypt
111+ * @out: (output) the encrypted filename
112+ * @olen: size of the encrypted filename. It must be at least @iname->len.
113+ * Any extra space is filled with NUL padding before encryption.
111114 *
112115 * Return: 0 on success, -errno on failure
113116 */
@@ -157,8 +160,11 @@ int fscrypt_fname_encrypt(const struct inode *inode, const struct qstr *iname,
157160
158161/**
159162 * fname_decrypt() - decrypt a filename
160- *
161- * The caller must have allocated sufficient memory for the @oname string.
163+ * @inode: inode of the parent directory (for regular filenames)
164+ * or of the symlink (for symlink targets)
165+ * @iname: the encrypted filename to decrypt
166+ * @oname: (output) the decrypted filename. The caller must have allocated
167+ * enough space for this, e.g. using fscrypt_fname_alloc_buffer().
162168 *
163169 * Return: 0 on success, -errno on failure
164170 */
@@ -206,7 +212,10 @@ static const char lookup_table[65] =
206212#define BASE64_CHARS (nbytes ) DIV_ROUND_UP((nbytes) * 4, 3)
207213
208214/**
209- * base64_encode() -
215+ * base64_encode() - base64-encode some bytes
216+ * @src: the bytes to encode
217+ * @len: number of bytes to encode
218+ * @dst: (output) the base64-encoded string. Not NUL-terminated.
210219 *
211220 * Encodes the input string using characters from the set [A-Za-z0-9+,].
212221 * The encoded string is roughly 4/3 times the size of the input string.
@@ -272,7 +281,12 @@ bool fscrypt_fname_encrypted_size(const struct inode *inode, u32 orig_len,
272281}
273282
274283/**
275- * fscrypt_fname_alloc_buffer - allocate a buffer for presented filenames
284+ * fscrypt_fname_alloc_buffer() - allocate a buffer for presented filenames
285+ * @inode: inode of the parent directory (for regular filenames)
286+ * or of the symlink (for symlink targets)
287+ * @max_encrypted_len: maximum length of encrypted filenames the buffer will be
288+ * used to present
289+ * @crypto_str: (output) buffer to allocate
276290 *
277291 * Allocate a buffer that is large enough to hold any decrypted or encoded
278292 * filename (null-terminated), for the given maximum encrypted filename length.
@@ -297,9 +311,10 @@ int fscrypt_fname_alloc_buffer(const struct inode *inode,
297311EXPORT_SYMBOL (fscrypt_fname_alloc_buffer );
298312
299313/**
300- * fscrypt_fname_free_buffer - free the buffer for presented filenames
314+ * fscrypt_fname_free_buffer() - free a buffer for presented filenames
315+ * @crypto_str: the buffer to free
301316 *
302- * Free the buffer allocated by fscrypt_fname_alloc_buffer().
317+ * Free a buffer that was allocated by fscrypt_fname_alloc_buffer().
303318 */
304319void fscrypt_fname_free_buffer (struct fscrypt_str * crypto_str )
305320{
@@ -311,10 +326,19 @@ void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str)
311326EXPORT_SYMBOL (fscrypt_fname_free_buffer );
312327
313328/**
314- * fscrypt_fname_disk_to_usr() - converts a filename from disk space to user
315- * space
316- *
317- * The caller must have allocated sufficient memory for the @oname string.
329+ * fscrypt_fname_disk_to_usr() - convert an encrypted filename to
330+ * user-presentable form
331+ * @inode: inode of the parent directory (for regular filenames)
332+ * or of the symlink (for symlink targets)
333+ * @hash: first part of the name's dirhash, if applicable. This only needs to
334+ * be provided if the filename is located in an indexed directory whose
335+ * encryption key may be unavailable. Not needed for symlink targets.
336+ * @minor_hash: second part of the name's dirhash, if applicable
337+ * @iname: encrypted filename to convert. May also be "." or "..", which
338+ * aren't actually encrypted.
339+ * @oname: output buffer for the user-presentable filename. The caller must
340+ * have allocated enough space for this, e.g. using
341+ * fscrypt_fname_alloc_buffer().
318342 *
319343 * If the key is available, we'll decrypt the disk name. Otherwise, we'll
320344 * encode it for presentation in fscrypt_nokey_name format.
0 commit comments