Whamcloud - gitweb
LU-12275 sec: introduce null algo for filename encryption
[fs/lustre-release.git] / libcfs / libcfs / crypto / fname.c
index 08accf8..d3f5832 100644 (file)
@@ -58,6 +58,9 @@ int fname_encrypt(struct inode *inode, const struct qstr *iname,
        memcpy(out, iname->name, iname->len);
        memset(out + iname->len, 0, olen - iname->len);
 
+       if (tfm == NULL)
+               return 0;
+
        /* Initialize the IV */
        llcrypt_generate_iv(&iv, 0, ci);
 
@@ -101,6 +104,13 @@ static int fname_decrypt(struct inode *inode,
        union llcrypt_iv iv;
        int res;
 
+       if (tfm == NULL) {
+               memcpy(oname->name, iname->name, iname->len);
+               oname->name[iname->len] = '\0';
+               oname->len = iname->len;
+               return 0;
+       }
+
        /* Allocate request */
        req = skcipher_request_alloc(tfm, GFP_NOFS);
        if (!req)