public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/5] tools/env: make env_aes_cbc_crypt re-entrant
Date: Wed, 6 Apr 2016 13:29:07 +0200	[thread overview]
Message-ID: <5704F303.7050304@denx.de> (raw)
In-Reply-To: <1459890822-11382-2-git-send-email-andreas.fenkart@digitalstrom.com>

Hi Andreas,

thanks for fixing this:

On 05/04/2016 23:13, Andreas Fenkart wrote:
> Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
> ---
>  tools/env/fw_env.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
> index 1420ac5..c362a41 100644
> --- a/tools/env/fw_env.c
> +++ b/tools/env/fw_env.c
> @@ -106,7 +106,8 @@ static struct environment environment = {
>  	.flag_scheme = FLAG_NONE,
>  };
>  
> -static int env_aes_cbc_crypt(char *data, const int enc);
> +static int env_aes_cbc_crypt(char *data, const int enc,
> +			     uint8_t key[AES_KEY_LENGTH]);
>  

Formally, is it not simply as pointer ?

static int env_aes_cbc_crypt(char *data, const int enc,
		     uint8_t *key);


>  static int HaveRedundEnv = 0;
>  
> @@ -304,7 +305,8 @@ int fw_env_close(void)
>  {
>  	int ret;
>  	if (common_args.aes_flag) {
> -		ret = env_aes_cbc_crypt(environment.data, 1);
> +		ret = env_aes_cbc_crypt(environment.data, 1,
> +					common_args.aes_key);
>  		if (ret) {
>  			fprintf(stderr,
>  				"Error: can't encrypt env for flash\n");
> @@ -949,7 +951,8 @@ static int flash_flag_obsolete (int dev, int fd, off_t offset)
>  }
>  
>  /* Encrypt or decrypt the environment before writing or reading it. */
> -static int env_aes_cbc_crypt(char *payload, const int enc)
> +static int env_aes_cbc_crypt(char *payload, const int enc,
> +			     uint8_t key[AES_KEY_LENGTH])

Ditto.

>  {
>  	uint8_t *data = (uint8_t *)payload;
>  	const int len = getenvsize();
> @@ -957,7 +960,7 @@ static int env_aes_cbc_crypt(char *payload, const int enc)
>  	uint32_t aes_blocks;
>  
>  	/* First we expand the key. */
> -	aes_expand_key(common_args.aes_key, key_exp);
> +	aes_expand_key(key, key_exp);
>  
>  	/* Calculate the number of AES blocks to encrypt. */
>  	aes_blocks = DIV_ROUND_UP(len, AES_KEY_LENGTH);
> @@ -1186,7 +1189,8 @@ int fw_env_open(void)
>  	crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
>  
>  	if (common_args.aes_flag) {
> -		ret = env_aes_cbc_crypt(environment.data, 0);
> +		ret = env_aes_cbc_crypt(environment.data, 0,
> +					common_args.aes_key);
>  		if (ret)
>  			return ret;
>  	}
> @@ -1243,7 +1247,8 @@ int fw_env_open(void)
>  		crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
>  
>  		if (common_args.aes_flag) {
> -			ret = env_aes_cbc_crypt(redundant->data, 0);
> +			ret = env_aes_cbc_crypt(redundant->data, 0,
> +						common_args.aes_key);
>  			if (ret)
>  				return ret;
>  		}
> 


Regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

  reply	other threads:[~2016-04-06 11:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05 21:13 [U-Boot] [PATCH 0/5] tools/env: pass arguments as parameters not global structure Andreas Fenkart
2016-04-05 21:13 ` [U-Boot] [PATCH 1/5] tools/env: make env_aes_cbc_crypt re-entrant Andreas Fenkart
2016-04-06 11:29   ` Stefano Babic [this message]
2016-04-05 21:13 ` [U-Boot] [PATCH 2/5] tools/env: remove 'extern' from function prototype in fw_env.h Andreas Fenkart
2016-04-05 21:13 ` [U-Boot] [PATCH 3/5] tools/env: fw_printenv pass value_only as argument Andreas Fenkart
2016-04-05 21:13 ` [U-Boot] [PATCH 4/5] tools/env: compute size of usable area only once Andreas Fenkart
2016-04-05 21:13 ` [U-Boot] [PATCH 5/5] tools/env: no global variable sharing between application and library Andreas Fenkart
2016-05-30 17:59   ` [U-Boot] [U-Boot, " Tom Rini
2016-04-06 14:25 ` [U-Boot] [PATCH 0/5] tools/env: pass arguments as parameters not global structure Stefano Babic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5704F303.7050304@denx.de \
    --to=sbabic@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox