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

Commit 64c9295b authored by Horia Geantă's avatar Horia Geantă Committed by Herbert Xu
Browse files

crypto: caam - move append_key_aead() into init_sh_desc_key_aead()



append_key_aead() is used in only one place, thus inline it.

Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 211f41af
Loading
Loading
Loading
Loading
+12 −18
Original line number Original line Diff line number Diff line
@@ -228,12 +228,19 @@ struct caam_ctx {
	unsigned int authsize;
	unsigned int authsize;
};
};


static void append_key_aead(u32 *desc, struct caam_ctx *ctx,
static void init_sh_desc_key_aead(u32 *desc, struct caam_ctx *ctx,
				  int keys_fit_inline, bool is_rfc3686)
				  int keys_fit_inline, bool is_rfc3686)
{
{
	u32 *nonce;
	u32 *key_jump_cmd;
	unsigned int enckeylen = ctx->enckeylen;
	unsigned int enckeylen = ctx->enckeylen;


	/* Note: Context registers are saved. */
	init_sh_desc(desc, HDR_SHARE_SERIAL | HDR_SAVECTX);

	/* Skip if already shared */
	key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
				   JUMP_COND_SHRD);

	/*
	/*
	 * RFC3686 specific:
	 * RFC3686 specific:
	 *	| ctx->key = {AUTH_KEY, ENC_KEY, NONCE}
	 *	| ctx->key = {AUTH_KEY, ENC_KEY, NONCE}
@@ -258,6 +265,8 @@ static void append_key_aead(u32 *desc, struct caam_ctx *ctx,


	/* Load Counter into CONTEXT1 reg */
	/* Load Counter into CONTEXT1 reg */
	if (is_rfc3686) {
	if (is_rfc3686) {
		u32 *nonce;

		nonce = (u32 *)((void *)ctx->key + ctx->split_key_pad_len +
		nonce = (u32 *)((void *)ctx->key + ctx->split_key_pad_len +
			       enckeylen);
			       enckeylen);
		append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE,
		append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE,
@@ -269,21 +278,6 @@ static void append_key_aead(u32 *desc, struct caam_ctx *ctx,
			    (16 << MOVE_OFFSET_SHIFT) |
			    (16 << MOVE_OFFSET_SHIFT) |
			    (CTR_RFC3686_NONCE_SIZE << MOVE_LEN_SHIFT));
			    (CTR_RFC3686_NONCE_SIZE << MOVE_LEN_SHIFT));
	}
	}
}

static void init_sh_desc_key_aead(u32 *desc, struct caam_ctx *ctx,
				  int keys_fit_inline, bool is_rfc3686)
{
	u32 *key_jump_cmd;

	/* Note: Context registers are saved. */
	init_sh_desc(desc, HDR_SHARE_SERIAL | HDR_SAVECTX);

	/* Skip if already shared */
	key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
				   JUMP_COND_SHRD);

	append_key_aead(desc, ctx, keys_fit_inline, is_rfc3686);


	set_jump_tgt_here(desc, key_jump_cmd);
	set_jump_tgt_here(desc, key_jump_cmd);
}
}