mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
crypto: fix crypto_engine_ctx build error
struct crypto_engine_ctx removed in k6.6 hence use
conftest helper based macro to select updated data types
Bug 4346767
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Change-Id: Iaf565c4ef74fdd87ea0020b369bc3d882d32326e
Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3176823
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
(cherry picked from commit cba663d0db)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3196067
This commit is contained in:
committed by
mobile promotions
parent
f73208daa3
commit
f3b12ead83
@@ -4,6 +4,8 @@
|
|||||||
* Crypto driver to handle block cipher algorithms using NVIDIA Security Engine.
|
* Crypto driver to handle block cipher algorithms using NVIDIA Security Engine.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <nvidia/conftest.h>
|
||||||
|
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/dma-mapping.h>
|
#include <linux/dma-mapping.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
@@ -23,7 +25,9 @@
|
|||||||
#include "tegra-se.h"
|
#include "tegra-se.h"
|
||||||
|
|
||||||
struct tegra_aes_ctx {
|
struct tegra_aes_ctx {
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
struct crypto_engine_ctx enginectx;
|
struct crypto_engine_ctx enginectx;
|
||||||
|
#endif
|
||||||
struct tegra_se *se;
|
struct tegra_se *se;
|
||||||
u32 alg;
|
u32 alg;
|
||||||
u32 ivsize;
|
u32 ivsize;
|
||||||
@@ -41,7 +45,9 @@ struct tegra_aes_reqctx {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct tegra_aead_ctx {
|
struct tegra_aead_ctx {
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
struct crypto_engine_ctx enginectx;
|
struct crypto_engine_ctx enginectx;
|
||||||
|
#endif
|
||||||
struct tegra_se *se;
|
struct tegra_se *se;
|
||||||
unsigned int authsize;
|
unsigned int authsize;
|
||||||
u32 alg;
|
u32 alg;
|
||||||
@@ -66,7 +72,9 @@ struct tegra_aead_reqctx {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct tegra_cmac_ctx {
|
struct tegra_cmac_ctx {
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
struct crypto_engine_ctx enginectx;
|
struct crypto_engine_ctx enginectx;
|
||||||
|
#endif
|
||||||
struct tegra_se *se;
|
struct tegra_se *se;
|
||||||
unsigned int alg;
|
unsigned int alg;
|
||||||
u32 key_id;
|
u32 key_id;
|
||||||
@@ -307,7 +315,11 @@ static int tegra_aes_cra_init(struct crypto_skcipher *tfm)
|
|||||||
const char *algname;
|
const char *algname;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher.base);
|
||||||
|
#else
|
||||||
se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher);
|
se_alg = container_of(alg, struct tegra_se_alg, alg.skcipher);
|
||||||
|
#endif
|
||||||
|
|
||||||
crypto_skcipher_set_reqsize(tfm, sizeof(struct tegra_aes_reqctx));
|
crypto_skcipher_set_reqsize(tfm, sizeof(struct tegra_aes_reqctx));
|
||||||
|
|
||||||
@@ -325,9 +337,11 @@ static int tegra_aes_cra_init(struct crypto_skcipher *tfm)
|
|||||||
|
|
||||||
ctx->alg = ret;
|
ctx->alg = ret;
|
||||||
|
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
ctx->enginectx.op.prepare_request = NULL;
|
ctx->enginectx.op.prepare_request = NULL;
|
||||||
ctx->enginectx.op.unprepare_request = NULL;
|
ctx->enginectx.op.unprepare_request = NULL;
|
||||||
ctx->enginectx.op.do_one_request = tegra_aes_do_one_req;
|
ctx->enginectx.op.do_one_request = tegra_aes_do_one_req;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -469,6 +483,9 @@ static int tegra_aes_decrypt(struct skcipher_request *req)
|
|||||||
static struct tegra_se_alg tegra_aes_algs[] = {
|
static struct tegra_se_alg tegra_aes_algs[] = {
|
||||||
{
|
{
|
||||||
.alg.skcipher = {
|
.alg.skcipher = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_aes_cra_init,
|
.init = tegra_aes_cra_init,
|
||||||
.exit = tegra_aes_cra_exit,
|
.exit = tegra_aes_cra_exit,
|
||||||
.setkey = tegra_aes_setkey,
|
.setkey = tegra_aes_setkey,
|
||||||
@@ -487,9 +504,16 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
|||||||
.cra_alignmask = 0xf,
|
.cra_alignmask = 0xf,
|
||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
},
|
},
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_aes_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.skcipher = {
|
.alg.skcipher = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_aes_cra_init,
|
.init = tegra_aes_cra_init,
|
||||||
.exit = tegra_aes_cra_exit,
|
.exit = tegra_aes_cra_exit,
|
||||||
.setkey = tegra_aes_setkey,
|
.setkey = tegra_aes_setkey,
|
||||||
@@ -507,9 +531,16 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
|||||||
.cra_alignmask = 0xf,
|
.cra_alignmask = 0xf,
|
||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
},
|
},
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_aes_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.skcipher = {
|
.alg.skcipher = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_aes_cra_init,
|
.init = tegra_aes_cra_init,
|
||||||
.exit = tegra_aes_cra_exit,
|
.exit = tegra_aes_cra_exit,
|
||||||
.setkey = tegra_aes_setkey,
|
.setkey = tegra_aes_setkey,
|
||||||
@@ -528,9 +559,16 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
|||||||
.cra_alignmask = 0xf,
|
.cra_alignmask = 0xf,
|
||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
},
|
},
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_aes_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.skcipher = {
|
.alg.skcipher = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_aes_cra_init,
|
.init = tegra_aes_cra_init,
|
||||||
.exit = tegra_aes_cra_exit,
|
.exit = tegra_aes_cra_exit,
|
||||||
.setkey = tegra_xts_setkey,
|
.setkey = tegra_xts_setkey,
|
||||||
@@ -548,6 +586,10 @@ static struct tegra_se_alg tegra_aes_algs[] = {
|
|||||||
.cra_alignmask = (__alignof__(u64) - 1),
|
.cra_alignmask = (__alignof__(u64) - 1),
|
||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
},
|
},
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_aes_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1277,7 +1319,11 @@ static int tegra_ccm_cra_init(struct crypto_aead *tfm)
|
|||||||
|
|
||||||
algname = crypto_tfm_alg_name(&tfm->base);
|
algname = crypto_tfm_alg_name(&tfm->base);
|
||||||
|
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
se_alg = container_of(alg, struct tegra_se_alg, alg.aead.base);
|
||||||
|
#else
|
||||||
se_alg = container_of(alg, struct tegra_se_alg, alg.aead);
|
se_alg = container_of(alg, struct tegra_se_alg, alg.aead);
|
||||||
|
#endif
|
||||||
|
|
||||||
crypto_aead_set_reqsize(tfm, sizeof(struct tegra_aead_reqctx));
|
crypto_aead_set_reqsize(tfm, sizeof(struct tegra_aead_reqctx));
|
||||||
|
|
||||||
@@ -1292,9 +1338,11 @@ static int tegra_ccm_cra_init(struct crypto_aead *tfm)
|
|||||||
|
|
||||||
ctx->alg = ret;
|
ctx->alg = ret;
|
||||||
|
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
ctx->enginectx.op.prepare_request = NULL;
|
ctx->enginectx.op.prepare_request = NULL;
|
||||||
ctx->enginectx.op.unprepare_request = NULL;
|
ctx->enginectx.op.unprepare_request = NULL;
|
||||||
ctx->enginectx.op.do_one_request = tegra_ccm_do_one_req;
|
ctx->enginectx.op.do_one_request = tegra_ccm_do_one_req;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1309,7 +1357,11 @@ static int tegra_gcm_cra_init(struct crypto_aead *tfm)
|
|||||||
|
|
||||||
algname = crypto_tfm_alg_name(&tfm->base);
|
algname = crypto_tfm_alg_name(&tfm->base);
|
||||||
|
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
se_alg = container_of(alg, struct tegra_se_alg, alg.aead.base);
|
||||||
|
#else
|
||||||
se_alg = container_of(alg, struct tegra_se_alg, alg.aead);
|
se_alg = container_of(alg, struct tegra_se_alg, alg.aead);
|
||||||
|
#endif
|
||||||
|
|
||||||
crypto_aead_set_reqsize(tfm, sizeof(struct tegra_aead_reqctx));
|
crypto_aead_set_reqsize(tfm, sizeof(struct tegra_aead_reqctx));
|
||||||
|
|
||||||
@@ -1324,10 +1376,11 @@ static int tegra_gcm_cra_init(struct crypto_aead *tfm)
|
|||||||
|
|
||||||
ctx->alg = ret;
|
ctx->alg = ret;
|
||||||
|
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
ctx->enginectx.op.prepare_request = NULL;
|
ctx->enginectx.op.prepare_request = NULL;
|
||||||
ctx->enginectx.op.unprepare_request = NULL;
|
ctx->enginectx.op.unprepare_request = NULL;
|
||||||
ctx->enginectx.op.do_one_request = tegra_gcm_do_one_req;
|
ctx->enginectx.op.do_one_request = tegra_gcm_do_one_req;
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1647,7 +1700,11 @@ static int tegra_cmac_cra_init(struct crypto_tfm *tfm)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
algname = crypto_tfm_alg_name(tfm);
|
algname = crypto_tfm_alg_name(tfm);
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash.base);
|
||||||
|
#else
|
||||||
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash);
|
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash);
|
||||||
|
#endif
|
||||||
|
|
||||||
crypto_ahash_set_reqsize(ahash_tfm, sizeof(struct tegra_cmac_reqctx));
|
crypto_ahash_set_reqsize(ahash_tfm, sizeof(struct tegra_cmac_reqctx));
|
||||||
|
|
||||||
@@ -1662,9 +1719,11 @@ static int tegra_cmac_cra_init(struct crypto_tfm *tfm)
|
|||||||
|
|
||||||
ctx->alg = ret;
|
ctx->alg = ret;
|
||||||
|
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
ctx->enginectx.op.prepare_request = NULL;
|
ctx->enginectx.op.prepare_request = NULL;
|
||||||
ctx->enginectx.op.unprepare_request = NULL;
|
ctx->enginectx.op.unprepare_request = NULL;
|
||||||
ctx->enginectx.op.do_one_request = tegra_cmac_do_one_req;
|
ctx->enginectx.op.do_one_request = tegra_cmac_do_one_req;
|
||||||
|
#endif
|
||||||
|
|
||||||
tegra_cmac_init_fallback(ahash_tfm, ctx, algname);
|
tegra_cmac_init_fallback(ahash_tfm, ctx, algname);
|
||||||
|
|
||||||
@@ -1804,6 +1863,9 @@ static int tegra_cmac_import(struct ahash_request *req, const void *in)
|
|||||||
static struct tegra_se_alg tegra_aead_algs[] = {
|
static struct tegra_se_alg tegra_aead_algs[] = {
|
||||||
{
|
{
|
||||||
.alg.aead = {
|
.alg.aead = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_gcm_cra_init,
|
.init = tegra_gcm_cra_init,
|
||||||
.exit = tegra_aead_cra_exit,
|
.exit = tegra_aead_cra_exit,
|
||||||
.setkey = tegra_aead_setkey,
|
.setkey = tegra_aead_setkey,
|
||||||
@@ -1821,9 +1883,16 @@ static struct tegra_se_alg tegra_aead_algs[] = {
|
|||||||
.cra_alignmask = 0xf,
|
.cra_alignmask = 0xf,
|
||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
},
|
},
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_gcm_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.aead = {
|
.alg.aead = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_ccm_cra_init,
|
.init = tegra_ccm_cra_init,
|
||||||
.exit = tegra_aead_cra_exit,
|
.exit = tegra_aead_cra_exit,
|
||||||
.setkey = tegra_aead_setkey,
|
.setkey = tegra_aead_setkey,
|
||||||
@@ -1842,6 +1911,10 @@ static struct tegra_se_alg tegra_aead_algs[] = {
|
|||||||
.cra_alignmask = 0xf,
|
.cra_alignmask = 0xf,
|
||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
},
|
},
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_ccm_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1849,6 +1922,9 @@ static struct tegra_se_alg tegra_aead_algs[] = {
|
|||||||
static struct tegra_se_alg tegra_cmac_algs[] = {
|
static struct tegra_se_alg tegra_cmac_algs[] = {
|
||||||
{
|
{
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_cmac_init,
|
.init = tegra_cmac_init,
|
||||||
.setkey = tegra_cmac_setkey,
|
.setkey = tegra_cmac_setkey,
|
||||||
.update = tegra_cmac_update,
|
.update = tegra_cmac_update,
|
||||||
@@ -1870,11 +1946,79 @@ static struct tegra_se_alg tegra_cmac_algs[] = {
|
|||||||
.cra_module = THIS_MODULE,
|
.cra_module = THIS_MODULE,
|
||||||
.cra_init = tegra_cmac_cra_init,
|
.cra_init = tegra_cmac_cra_init,
|
||||||
.cra_exit = tegra_cmac_cra_exit,
|
.cra_exit = tegra_cmac_cra_exit,
|
||||||
}
|
},
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_cmac_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
int tegra_init_aes(struct tegra_se *se)
|
||||||
|
{
|
||||||
|
struct aead_engine_alg *aead_alg;
|
||||||
|
struct ahash_engine_alg *ahash_alg;
|
||||||
|
struct skcipher_engine_alg *sk_alg;
|
||||||
|
int i, ret;
|
||||||
|
|
||||||
|
se->manifest = tegra_aes_kac_manifest;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++) {
|
||||||
|
sk_alg = &tegra_aes_algs[i].alg.skcipher;
|
||||||
|
tegra_aes_algs[i].se_dev = se;
|
||||||
|
ret = CRYPTO_REGISTER(skcipher, sk_alg);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(se->dev, "failed to register %s\n",
|
||||||
|
sk_alg->base.base.cra_name);
|
||||||
|
goto err_aes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++) {
|
||||||
|
aead_alg = &tegra_aead_algs[i].alg.aead;
|
||||||
|
tegra_aead_algs[i].se_dev = se;
|
||||||
|
ret = CRYPTO_REGISTER(aead, aead_alg);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(se->dev, "failed to register %s\n",
|
||||||
|
aead_alg->base.base.cra_name);
|
||||||
|
goto err_aead;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++) {
|
||||||
|
ahash_alg = &tegra_cmac_algs[i].alg.ahash;
|
||||||
|
tegra_cmac_algs[i].se_dev = se;
|
||||||
|
ret = CRYPTO_REGISTER(ahash, ahash_alg);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(se->dev, "failed to register %s\n",
|
||||||
|
ahash_alg->base.halg.base.cra_name);
|
||||||
|
goto err_cmac;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_cmac:
|
||||||
|
for (--i; i >= 0; i--)
|
||||||
|
CRYPTO_UNREGISTER(ahash, &tegra_cmac_algs[i].alg.ahash);
|
||||||
|
|
||||||
|
i = ARRAY_SIZE(tegra_aead_algs);
|
||||||
|
err_aead:
|
||||||
|
for (--i; i >= 0; i--)
|
||||||
|
CRYPTO_UNREGISTER(aead, &tegra_aead_algs[i].alg.aead);
|
||||||
|
|
||||||
|
i = ARRAY_SIZE(tegra_aes_algs);
|
||||||
|
err_aes:
|
||||||
|
for (--i; i >= 0; i--)
|
||||||
|
CRYPTO_UNREGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
int tegra_init_aes(struct tegra_se *se)
|
int tegra_init_aes(struct tegra_se *se)
|
||||||
{
|
{
|
||||||
struct aead_alg *aead_alg;
|
struct aead_alg *aead_alg;
|
||||||
@@ -1887,8 +2031,7 @@ int tegra_init_aes(struct tegra_se *se)
|
|||||||
for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++) {
|
for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++) {
|
||||||
sk_alg = &tegra_aes_algs[i].alg.skcipher;
|
sk_alg = &tegra_aes_algs[i].alg.skcipher;
|
||||||
tegra_aes_algs[i].se_dev = se;
|
tegra_aes_algs[i].se_dev = se;
|
||||||
|
ret = CRYPTO_REGISTER(skcipher, sk_alg);
|
||||||
ret = crypto_register_skcipher(sk_alg);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(se->dev, "failed to register %s\n",
|
dev_err(se->dev, "failed to register %s\n",
|
||||||
sk_alg->base.cra_name);
|
sk_alg->base.cra_name);
|
||||||
@@ -1899,8 +2042,7 @@ int tegra_init_aes(struct tegra_se *se)
|
|||||||
for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++) {
|
for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++) {
|
||||||
aead_alg = &tegra_aead_algs[i].alg.aead;
|
aead_alg = &tegra_aead_algs[i].alg.aead;
|
||||||
tegra_aead_algs[i].se_dev = se;
|
tegra_aead_algs[i].se_dev = se;
|
||||||
|
ret = CRYPTO_REGISTER(aead, aead_alg);
|
||||||
ret = crypto_register_aead(aead_alg);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(se->dev, "failed to register %s\n",
|
dev_err(se->dev, "failed to register %s\n",
|
||||||
aead_alg->base.cra_name);
|
aead_alg->base.cra_name);
|
||||||
@@ -1911,8 +2053,7 @@ int tegra_init_aes(struct tegra_se *se)
|
|||||||
for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++) {
|
for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++) {
|
||||||
ahash_alg = &tegra_cmac_algs[i].alg.ahash;
|
ahash_alg = &tegra_cmac_algs[i].alg.ahash;
|
||||||
tegra_cmac_algs[i].se_dev = se;
|
tegra_cmac_algs[i].se_dev = se;
|
||||||
|
ret = CRYPTO_REGISTER(ahash, ahash_alg);
|
||||||
ret = crypto_register_ahash(ahash_alg);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(se->dev, "failed to register %s\n",
|
dev_err(se->dev, "failed to register %s\n",
|
||||||
ahash_alg->halg.base.cra_name);
|
ahash_alg->halg.base.cra_name);
|
||||||
@@ -1923,32 +2064,34 @@ int tegra_init_aes(struct tegra_se *se)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_cmac:
|
err_cmac:
|
||||||
while (i--)
|
for (--i; i >= 0; i--)
|
||||||
crypto_unregister_ahash(&tegra_cmac_algs[i].alg.ahash);
|
CRYPTO_UNREGISTER(ahash, &tegra_cmac_algs[i].alg.ahash);
|
||||||
|
|
||||||
i = ARRAY_SIZE(tegra_aead_algs);
|
i = ARRAY_SIZE(tegra_aead_algs);
|
||||||
err_aead:
|
err_aead:
|
||||||
while (i--)
|
for (--i; i >= 0; i--)
|
||||||
crypto_unregister_aead(&tegra_aead_algs[i].alg.aead);
|
CRYPTO_UNREGISTER(aead, &tegra_aead_algs[i].alg.aead);
|
||||||
|
|
||||||
i = ARRAY_SIZE(tegra_aes_algs);
|
i = ARRAY_SIZE(tegra_aes_algs);
|
||||||
err_aes:
|
err_aes:
|
||||||
while (i--)
|
for (--i; i >= 0; i--)
|
||||||
crypto_unregister_skcipher(&tegra_aes_algs[i].alg.skcipher);
|
CRYPTO_UNREGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tegra_deinit_aes(struct tegra_se *se)
|
void tegra_deinit_aes(struct tegra_se *se)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++)
|
for (i = 0; i < ARRAY_SIZE(tegra_aes_algs); i++)
|
||||||
crypto_unregister_skcipher(&tegra_aes_algs[i].alg.skcipher);
|
CRYPTO_UNREGISTER(skcipher, &tegra_aes_algs[i].alg.skcipher);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++)
|
for (i = 0; i < ARRAY_SIZE(tegra_aead_algs); i++)
|
||||||
crypto_unregister_aead(&tegra_aead_algs[i].alg.aead);
|
CRYPTO_UNREGISTER(aead, &tegra_aead_algs[i].alg.aead);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++)
|
for (i = 0; i < ARRAY_SIZE(tegra_cmac_algs); i++)
|
||||||
crypto_unregister_ahash(&tegra_cmac_algs[i].alg.ahash);
|
CRYPTO_UNREGISTER(ahash, &tegra_cmac_algs[i].alg.ahash);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
* Crypto driver to handle HASH algorithms using NVIDIA Security Engine.
|
* Crypto driver to handle HASH algorithms using NVIDIA Security Engine.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <nvidia/conftest.h>
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/dma-mapping.h>
|
#include <linux/dma-mapping.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
@@ -22,7 +23,9 @@
|
|||||||
#include "tegra-se.h"
|
#include "tegra-se.h"
|
||||||
|
|
||||||
struct tegra_sha_ctx {
|
struct tegra_sha_ctx {
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
struct crypto_engine_ctx enginectx;
|
struct crypto_engine_ctx enginectx;
|
||||||
|
#endif
|
||||||
struct tegra_se *se;
|
struct tegra_se *se;
|
||||||
unsigned int alg;
|
unsigned int alg;
|
||||||
bool fallback;
|
bool fallback;
|
||||||
@@ -466,7 +469,11 @@ static int tegra_sha_cra_init(struct crypto_tfm *tfm)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
algname = crypto_tfm_alg_name(tfm);
|
algname = crypto_tfm_alg_name(tfm);
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash.base);
|
||||||
|
#else
|
||||||
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash);
|
se_alg = container_of(alg, struct tegra_se_alg, alg.ahash);
|
||||||
|
#endif
|
||||||
|
|
||||||
crypto_ahash_set_reqsize(ahash_tfm, sizeof(struct tegra_sha_reqctx));
|
crypto_ahash_set_reqsize(ahash_tfm, sizeof(struct tegra_sha_reqctx));
|
||||||
|
|
||||||
@@ -485,9 +492,11 @@ static int tegra_sha_cra_init(struct crypto_tfm *tfm)
|
|||||||
|
|
||||||
ctx->alg = ret;
|
ctx->alg = ret;
|
||||||
|
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
ctx->enginectx.op.prepare_request = NULL;
|
ctx->enginectx.op.prepare_request = NULL;
|
||||||
ctx->enginectx.op.unprepare_request = NULL;
|
ctx->enginectx.op.unprepare_request = NULL;
|
||||||
ctx->enginectx.op.do_one_request = tegra_sha_do_one_req;
|
ctx->enginectx.op.do_one_request = tegra_sha_do_one_req;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -661,6 +670,9 @@ static int tegra_sha_import(struct ahash_request *req, const void *in)
|
|||||||
static struct tegra_se_alg tegra_hash_algs[] = {
|
static struct tegra_se_alg tegra_hash_algs[] = {
|
||||||
{
|
{
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -682,9 +694,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -706,9 +725,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -730,9 +756,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -754,9 +787,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -778,9 +818,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -802,9 +849,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -826,9 +880,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -850,9 +911,16 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -874,10 +942,17 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg_base = "sha224",
|
.alg_base = "sha224",
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -900,10 +975,17 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg_base = "sha256",
|
.alg_base = "sha256",
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -926,10 +1008,17 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg_base = "sha384",
|
.alg_base = "sha384",
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -952,10 +1041,17 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
.alg_base = "sha512",
|
.alg_base = "sha512",
|
||||||
.alg.ahash = {
|
.alg.ahash = {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
.base = {
|
||||||
|
#endif
|
||||||
.init = tegra_sha_init,
|
.init = tegra_sha_init,
|
||||||
.update = tegra_sha_update,
|
.update = tegra_sha_update,
|
||||||
.final = tegra_sha_final,
|
.final = tegra_sha_final,
|
||||||
@@ -978,6 +1074,10 @@ static struct tegra_se_alg tegra_hash_algs[] = {
|
|||||||
.cra_init = tegra_sha_cra_init,
|
.cra_init = tegra_sha_cra_init,
|
||||||
.cra_exit = tegra_sha_cra_exit,
|
.cra_exit = tegra_sha_cra_exit,
|
||||||
}
|
}
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
},
|
||||||
|
.op.do_one_request = tegra_sha_do_one_req,
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1017,7 +1117,11 @@ static int tegra_hash_kac_manifest(u32 user, u32 alg, u32 keylen)
|
|||||||
|
|
||||||
int tegra_init_hash(struct tegra_se *se)
|
int tegra_init_hash(struct tegra_se *se)
|
||||||
{
|
{
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
struct ahash_engine_alg *alg;
|
||||||
|
#else
|
||||||
struct ahash_alg *alg;
|
struct ahash_alg *alg;
|
||||||
|
#endif
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
se->manifest = tegra_hash_kac_manifest;
|
se->manifest = tegra_hash_kac_manifest;
|
||||||
@@ -1026,10 +1130,15 @@ int tegra_init_hash(struct tegra_se *se)
|
|||||||
tegra_hash_algs[i].se_dev = se;
|
tegra_hash_algs[i].se_dev = se;
|
||||||
alg = &tegra_hash_algs[i].alg.ahash;
|
alg = &tegra_hash_algs[i].alg.ahash;
|
||||||
|
|
||||||
ret = crypto_register_ahash(alg);
|
ret = CRYPTO_REGISTER(ahash, alg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
dev_err(se->dev, "failed to register %s\n",
|
||||||
|
alg->base.halg.base.cra_name);
|
||||||
|
#else
|
||||||
dev_err(se->dev, "failed to register %s\n",
|
dev_err(se->dev, "failed to register %s\n",
|
||||||
alg->halg.base.cra_name);
|
alg->halg.base.cra_name);
|
||||||
|
#endif
|
||||||
goto sha_err;
|
goto sha_err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1037,8 +1146,8 @@ int tegra_init_hash(struct tegra_se *se)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sha_err:
|
sha_err:
|
||||||
while (i--)
|
for (--i; i >= 0; i--)
|
||||||
crypto_unregister_ahash(&tegra_hash_algs[i].alg.ahash);
|
CRYPTO_UNREGISTER(ahash, &tegra_hash_algs[i].alg.ahash);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1048,5 +1157,5 @@ void tegra_deinit_hash(struct tegra_se *se)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(tegra_hash_algs); i++)
|
for (i = 0; i < ARRAY_SIZE(tegra_hash_algs); i++)
|
||||||
crypto_unregister_ahash(&tegra_hash_algs[i].alg.ahash);
|
CRYPTO_UNREGISTER(ahash, &tegra_hash_algs[i].alg.ahash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,6 +348,22 @@
|
|||||||
#define SHA_UPDATE BIT(1)
|
#define SHA_UPDATE BIT(1)
|
||||||
#define SHA_FINAL BIT(2)
|
#define SHA_FINAL BIT(2)
|
||||||
|
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
#define CRYPTO_REGISTER(alg, x) \
|
||||||
|
crypto_engine_register_##alg(x)
|
||||||
|
#else
|
||||||
|
#define CRYPTO_REGISTER(alg, x) \
|
||||||
|
crypto_register_##alg(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
|
#define CRYPTO_UNREGISTER(alg, x) \
|
||||||
|
crypto_engine_unregister_##alg(x)
|
||||||
|
#else
|
||||||
|
#define CRYPTO_UNREGISTER(alg, x) \
|
||||||
|
crypto_unregister_##alg(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Security Engine operation modes */
|
/* Security Engine operation modes */
|
||||||
enum se_aes_alg {
|
enum se_aes_alg {
|
||||||
SE_ALG_CBC, /* Cipher Block Chaining (CBC) mode */
|
SE_ALG_CBC, /* Cipher Block Chaining (CBC) mode */
|
||||||
@@ -385,9 +401,15 @@ struct tegra_se_alg {
|
|||||||
const char *alg_base;
|
const char *alg_base;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
#ifndef NV_CONFTEST_REMOVE_STRUCT_CRYPTO_ENGINE_CTX
|
||||||
struct skcipher_alg skcipher;
|
struct skcipher_alg skcipher;
|
||||||
struct aead_alg aead;
|
struct aead_alg aead;
|
||||||
struct ahash_alg ahash;
|
struct ahash_alg ahash;
|
||||||
|
#else
|
||||||
|
struct skcipher_engine_alg skcipher;
|
||||||
|
struct aead_engine_alg aead;
|
||||||
|
struct ahash_engine_alg ahash;
|
||||||
|
#endif
|
||||||
} alg;
|
} alg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user