X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Flibcfs%2Fcrypto%2Fcrypto.c;h=e06a160cc31cf2c19066e71775bf9cffb0b5024b;hb=056eb9dcc0d5f80451c400342d54037f6de24bd9;hp=3d18715a06c3d2ed8544e2c3eb6ca0f8f2a9dc8a;hpb=8d828762d18ffaa2945bde56039127d0e75aceb3;p=fs%2Flustre-release.git diff --git a/libcfs/libcfs/crypto/crypto.c b/libcfs/libcfs/crypto/crypto.c index 3d18715..e06a160 100644 --- a/libcfs/libcfs/crypto/crypto.c +++ b/libcfs/libcfs/crypto/crypto.c @@ -51,6 +51,12 @@ module_param(num_prealloc_crypto_ctxs, uint, 0444); MODULE_PARM_DESC(num_prealloc_crypto_ctxs, "Number of crypto contexts to preallocate"); +static char *client_encryption_engine = "aes-ni"; +module_param(client_encryption_engine, charp, 0444); +MODULE_PARM_DESC(client_encryption_engine, "Client encryption engine"); + +enum llcrypt_crypto_engine_type llcrypt_crypto_engine = LLCRYPT_ENGINE_AES_NI; + static mempool_t *llcrypt_bounce_page_pool = NULL; static LIST_HEAD(llcrypt_free_ctxs); @@ -494,6 +500,21 @@ void llcrypt_msg(const struct inode *inode, int mask, va_end(args); } +static inline int set_llcrypt_crypto_engine_type(void) +{ + if (strcmp(client_encryption_engine, "system-default") == 0) + llcrypt_crypto_engine = LLCRYPT_ENGINE_SYSTEM_DEFAULT; + else if (strcmp(client_encryption_engine, "aes-ni") == 0) + llcrypt_crypto_engine = LLCRYPT_ENGINE_AES_NI; + else + llcrypt_crypto_engine = LLCRYPT_ENGINE_INVALID; + + if (llcrypt_crypto_engine == LLCRYPT_ENGINE_INVALID) + return -EINVAL; + + return 0; +} + /** * llcrypt_init() - Set up for fs encryption. */ @@ -523,6 +544,13 @@ int __init llcrypt_init(void) if (!llcrypt_info_cachep) goto fail_free_ctx; + err = set_llcrypt_crypto_engine_type(); + if (err) { + CERROR("libcfs: bad crypto engine provided via 'client_encryption_engine': rc = %d\n", + err); + goto fail_free_info; + } + err = llcrypt_init_keyring(); if (err) goto fail_free_info;