[U-Boot] [PATCH v2 2/7] tools: env: make parse_aes_key stateless

Andreas Fenkart afenkart at gmail.com
Thu Nov 26 11:52:29 CET 2015


Signed-off-by: Andreas Fenkart <andreas.fenkart at 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



More information about the U-Boot mailing list