public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andreas Fenkart <afenkart@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/7] tools: env: make parse_aes_key stateless
Date: Thu, 26 Nov 2015 11:52:29 +0100	[thread overview]
Message-ID: <1448535154-6350-3-git-send-email-andreas.fenkart@dev.digitalstrom.org> (raw)
In-Reply-To: <1448535154-6350-1-git-send-email-andreas.fenkart@dev.digitalstrom.org>

Signed-off-by: Andreas Fenkart <andreas.fenkart@dev.digitalstrom.org>
---
 tools/env/fw_env.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 22507f6..5b76b74 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -207,7 +207,7 @@ char *fw_getdefenv(char *name)
 	return NULL;
 }
 
-static int parse_aes_key(char *key)
+static int parse_aes_key(char *key, uint8_t *bin_key)
 {
 	char tmp[5] = { '0', 'x', 0, 0, 0 };
 	unsigned long ul;
@@ -229,11 +229,9 @@ static int parse_aes_key(char *key)
 				"## Error: '-a' option requires valid AES key\n");
 			return -1;
 		}
-		aes_key[i] = ul & 0xff;
+		bin_key[i] = ul & 0xff;
 		key += 2;
 	}
-	aes_flag = 1;
-
 	return 0;
 }
 
@@ -266,9 +264,10 @@ int fw_printenv (int argc, char *argv[])
 				"## Error: '-a' option requires AES key\n");
 			return -1;
 		}
-		rc = parse_aes_key(argv[2]);
+		rc = parse_aes_key(argv[2], aes_key);
 		if (rc)
 			return rc;
+		aes_flag = 1;
 		argv += 2;
 		argc -= 2;
 	}
@@ -525,9 +524,10 @@ int fw_setenv(int argc, char *argv[])
 				"## Error: '-a' option requires AES key\n");
 			return -1;
 		}
-		rc = parse_aes_key(argv[2]);
+		rc = parse_aes_key(argv[2], aes_key);
 		if (rc)
 			return rc;
+		aes_flag = 1;
 		argv += 2;
 		argc -= 2;
 	}
-- 
2.6.2

  parent reply	other threads:[~2015-11-26 10:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26 10:52 [U-Boot] [PATCH v2 0/7] tools: env: simplify argument parsing Andreas Fenkart
2015-11-26 10:52 ` [U-Boot] [PATCH v2 1/7] tools: env validate: pass values as 0-based array Andreas Fenkart
2015-11-26 10:52 ` Andreas Fenkart [this message]
2015-11-26 10:52 ` [U-Boot] [PATCH v2 3/7] tools: env: introduce setenv/printenv argument structs Andreas Fenkart
2015-11-26 10:52 ` [U-Boot] [PATCH v2 4/7] tools: env: parse aes key / suppress flag into argument struct Andreas Fenkart
2015-11-26 10:52 ` [U-Boot] [PATCH v2 5/7] tools: env: shift optind arguments and fix argument indices Andreas Fenkart
2015-11-26 10:52 ` [U-Boot] [PATCH v2 6/7] tools: env: factor out parse_common_args Andreas Fenkart
2015-11-26 10:52 ` [U-Boot] [PATCH v2 7/7] tools: env: update usage strings Andreas Fenkart

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=1448535154-6350-3-git-send-email-andreas.fenkart@dev.digitalstrom.org \
    --to=afenkart@gmail.com \
    --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