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

Commit 83c570e1 authored by Zhen Kong's avatar Zhen Kong
Browse files

crypto: msm: Fix key length setting



Hardcoding key length to a constant value results in overwriting
command element information in the command descriptor beyond what
is allocate for the key information in the command element list.
This results in corruption of the command list in the case where
command descriptors are used for configuring crypto registers and
needlessly writing to key registers that are not relevant to the
operation (when writing to registers directly), and thus leads to
crypto operation failures. Fix is to use the key length based on
what is requested by the client.

Change-Id: Ibd625dc7a438fac84b13588700bf472004e246d5
Signed-off-by: default avatarZhen Kong <zkong@codeaurora.org>
parent 4ae4d503
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
/* Qualcomm Crypto Engine driver.
 *
 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -279,7 +279,7 @@ static int _ce_setup_hash(struct qce_device *pce_dev,
	struct sps_command_element *pce = NULL;
	bool use_hw_key = false;
	bool use_pipe_key = false;
	uint32_t authk_size_in_word = SHA_HMAC_KEY_SIZE/sizeof(uint32_t);
	uint32_t authk_size_in_word = sreq->authklen/sizeof(uint32_t);
	uint32_t auth_cfg;

	if ((sreq->alg == QCE_HASH_SHA1_HMAC) ||
@@ -1049,8 +1049,7 @@ static int _ce_setup_hash_direct(struct qce_device *pce_dev,
	int i;
	uint32_t mackey32[SHA_HMAC_KEY_SIZE/sizeof(uint32_t)] = {
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	uint32_t authk_size_in_word =
			SHA_HMAC_KEY_SIZE/sizeof(uint32_t);
	uint32_t authk_size_in_word = sreq->authklen/sizeof(uint32_t);
	bool sha1 = false;
	uint32_t auth_cfg = 0;