Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d30cb2fa authored by Russell King's avatar Russell King Committed by Herbert Xu
Browse files

crypto: marvell/cesa - ensure template operation is initialised



Ensure that the template operation is fully initialised, otherwise we
end up loading data from the kernel stack into the engines, which can
upset the hash results.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 51954a96
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -866,7 +866,7 @@ static int mv_cesa_ahash_import(struct ahash_request *req, const void *hash,


static int mv_cesa_md5_init(struct ahash_request *req)
static int mv_cesa_md5_init(struct ahash_request *req)
{
{
	struct mv_cesa_op_ctx tmpl;
	struct mv_cesa_op_ctx tmpl = { };


	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_MD5);
	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_MD5);


@@ -929,7 +929,7 @@ struct ahash_alg mv_md5_alg = {


static int mv_cesa_sha1_init(struct ahash_request *req)
static int mv_cesa_sha1_init(struct ahash_request *req)
{
{
	struct mv_cesa_op_ctx tmpl;
	struct mv_cesa_op_ctx tmpl = { };


	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA1);
	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA1);


@@ -992,7 +992,7 @@ struct ahash_alg mv_sha1_alg = {


static int mv_cesa_sha256_init(struct ahash_request *req)
static int mv_cesa_sha256_init(struct ahash_request *req)
{
{
	struct mv_cesa_op_ctx tmpl;
	struct mv_cesa_op_ctx tmpl = { };


	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA256);
	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA256);


@@ -1222,7 +1222,7 @@ static int mv_cesa_ahmac_cra_init(struct crypto_tfm *tfm)
static int mv_cesa_ahmac_md5_init(struct ahash_request *req)
static int mv_cesa_ahmac_md5_init(struct ahash_request *req)
{
{
	struct mv_cesa_hmac_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
	struct mv_cesa_hmac_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
	struct mv_cesa_op_ctx tmpl;
	struct mv_cesa_op_ctx tmpl = { };


	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_MD5);
	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_MD5);
	memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));
	memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));
@@ -1292,7 +1292,7 @@ struct ahash_alg mv_ahmac_md5_alg = {
static int mv_cesa_ahmac_sha1_init(struct ahash_request *req)
static int mv_cesa_ahmac_sha1_init(struct ahash_request *req)
{
{
	struct mv_cesa_hmac_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
	struct mv_cesa_hmac_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
	struct mv_cesa_op_ctx tmpl;
	struct mv_cesa_op_ctx tmpl = { };


	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_SHA1);
	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_SHA1);
	memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));
	memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));
@@ -1382,7 +1382,7 @@ static int mv_cesa_ahmac_sha256_setkey(struct crypto_ahash *tfm, const u8 *key,
static int mv_cesa_ahmac_sha256_init(struct ahash_request *req)
static int mv_cesa_ahmac_sha256_init(struct ahash_request *req)
{
{
	struct mv_cesa_hmac_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
	struct mv_cesa_hmac_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
	struct mv_cesa_op_ctx tmpl;
	struct mv_cesa_op_ctx tmpl = { };


	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_SHA256);
	mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_SHA256);
	memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));
	memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));