u32 max_len, u32 *encrypted_len_ret)
{
const struct llcrypt_info *ci = llcrypt_info(inode);
+ struct crypto_skcipher *tfm = ci->ci_ctfm;
int padding = 4 << (llcrypt_policy_flags(&ci->ci_policy) &
LLCRYPT_POLICY_FLAGS_PAD_MASK);
u32 encrypted_len;
if (orig_len > max_len)
return false;
- encrypted_len = max(orig_len, (u32)LL_CRYPTO_BLOCK_SIZE);
- encrypted_len = round_up(encrypted_len, padding);
- *encrypted_len_ret = min(encrypted_len, max_len);
+ if (tfm == NULL) {
+ *encrypted_len_ret = orig_len;
+ } else {
+ encrypted_len = max(orig_len, (u32)LL_CRYPTO_BLOCK_SIZE);
+ encrypted_len = round_up(encrypted_len, padding);
+ *encrypted_len_ret = min(encrypted_len, max_len);
+ }
return true;
}
return 0;
}
- if (iname->len < LL_CRYPTO_BLOCK_SIZE)
- return -EUCLEAN;
+ if (llcrypt_has_encryption_key(inode)) {
+ struct llcrypt_info *ci = llcrypt_info(inode);
+ struct crypto_skcipher *tfm = ci->ci_ctfm;
+
+ if (tfm && iname->len < LL_CRYPTO_BLOCK_SIZE)
+ return -EUCLEAN;
- if (llcrypt_has_encryption_key(inode))
return fname_decrypt(inode, iname, oname);
+ }
+
+ if (unlikely(!llcrypt_policy_has_filename_enc(inode))) {
+ memcpy(oname->name, iname->name, iname->len);
+ oname->name[iname->len] = '\0';
+ oname->len = iname->len;
+ return 0;
+ }
if (iname->len <= LLCRYPT_FNAME_MAX_UNDIGESTED_SIZE) {
oname->len = base64_encode(iname->name, iname->len,
}
if (!lookup)
return -ENOKEY;
+
+ if (unlikely(!llcrypt_policy_has_filename_enc(dir))) {
+ fname->disk_name.name = (unsigned char *)iname->name;
+ fname->disk_name.len = iname->len;
+ return 0;
+ }
+
fname->is_ciphertext_name = true;
/*