All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1 0/4] Add SHA256 encrypted stop string for autobooting
@ 2015-05-07 12:13 Stefan Roese
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values Stefan Roese
                   ` (3 more replies)
  0 siblings, 4 replies; 29+ messages in thread
From: Stefan Roese @ 2015-05-07 12:13 UTC (permalink / raw)
  To: u-boot


The main task for this patch series is to add the new feature to abort
autobooting via a SHA256 encrypted password. For this, some of the old
autobooting related config macros have been moved to Kconfig. This was a bit
more complicated, since Kconfig currently apparently doesn't support using
escape characters '\' as used in printf format strings like "foo %s bar\n".
And this is needed for some of these new Kconfig options. So I needed to
make some changes to the Kconfig sources as well. If nobody complains about
these Kconfig stuff, I'll try to push this into the Linux Kconfig source as
well.

There should be no functional change introduced. Please let me know if you
find any problems.

Thanks,
Stefan


Stefan Roese (4):
  Kconfig: Enable usage of escape char '\' in string values
  autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and
    CONFIG_AUTOBOOT_DELAY_STR2
  autoboot.c: Move config options to Kconfig
  autoboot.c: Add feature to stop autobooting via SHA256 encrypted
    password

 README                                   |  2 -
 common/Kconfig                           | 78 ++++++++++++++++++++++++++
 common/autoboot.c                        | 94 ++++++++++++++++++++++++++------
 configs/CPCI4052_defconfig               |  3 +
 configs/O2DNT2_RAMBOOT_defconfig         |  3 +
 configs/O2DNT2_defconfig                 |  3 +
 configs/PLU405_defconfig                 |  3 +
 configs/PMC405DE_defconfig               |  3 +
 configs/PMC440_defconfig                 |  3 +
 configs/UCP1020_SPIFLASH_defconfig       |  3 +
 configs/UCP1020_defconfig                |  3 +
 configs/a4m072_defconfig                 |  3 +
 configs/atngw100_defconfig               |  4 ++
 configs/atngw100mkii_defconfig           |  4 ++
 configs/atstk1002_defconfig              |  4 ++
 configs/atstk1003_defconfig              |  4 ++
 configs/atstk1004_defconfig              |  4 ++
 configs/atstk1006_defconfig              |  4 ++
 configs/calimain_defconfig               |  2 +
 configs/cpuat91_defconfig                |  4 ++
 configs/cpuat91_ram_defconfig            |  3 +
 configs/digsy_mtc_RAMBOOT_defconfig      |  3 +
 configs/digsy_mtc_defconfig              |  3 +
 configs/digsy_mtc_rev5_RAMBOOT_defconfig |  3 +
 configs/digsy_mtc_rev5_defconfig         |  3 +
 configs/dlvision-10g_defconfig           |  2 +
 configs/draco_defconfig                  |  3 +
 configs/dxr2_defconfig                   |  3 +
 configs/favr-32-ezkit_defconfig          |  4 ++
 configs/gdppc440etx_defconfig            |  2 +
 configs/grasshopper_defconfig            |  4 ++
 configs/hammerhead_defconfig             |  4 ++
 configs/highbank_defconfig               |  3 +
 configs/hrcon_defconfig                  |  2 +
 configs/ids8313_defconfig                |  3 +
 configs/intip_defconfig                  |  2 +
 configs/io64_defconfig                   |  2 +
 configs/io_defconfig                     |  2 +
 configs/iocon_defconfig                  |  2 +
 configs/ip04_defconfig                   |  1 +
 configs/motionpro_defconfig              |  3 +
 configs/nokia_rx51_defconfig             |  1 +
 configs/omap3_mvblx_defconfig            |  2 +
 configs/ph1_ld4_defconfig                |  4 ++
 configs/ph1_pro4_defconfig               |  4 ++
 configs/ph1_sld8_defconfig               |  4 ++
 configs/pm9263_defconfig                 |  1 +
 configs/pxm2_defconfig                   |  3 +
 configs/rut_defconfig                    |  3 +
 configs/spear600_defconfig               |  3 +
 configs/stv0991_defconfig                |  3 +
 configs/x600_defconfig                   |  3 +
 configs/zmx25_defconfig                  |  4 ++
 doc/README.autoboot                      | 10 ----
 include/configs/CPCI4052.h               |  6 --
 include/configs/PLU405.h                 |  9 ---
 include/configs/PMC405DE.h               |  6 --
 include/configs/PMC440.h                 |  6 --
 include/configs/UCP1020.h                | 11 ----
 include/configs/a4m072.h                 |  4 --
 include/configs/atngw100.h               | 10 ----
 include/configs/atngw100mkii.h           | 10 ----
 include/configs/atstk1002.h              | 10 ----
 include/configs/atstk1003.h              | 10 ----
 include/configs/atstk1004.h              | 10 ----
 include/configs/atstk1006.h              | 10 ----
 include/configs/bf537-stamp.h            |  4 --
 include/configs/calimain.h               |  2 -
 include/configs/cpuat91.h                |  6 --
 include/configs/digsy_mtc.h              |  4 --
 include/configs/dlvision-10g.h           |  2 -
 include/configs/favr-32-ezkit.h          | 10 ----
 include/configs/gdppc440etx.h            |  2 -
 include/configs/grasshopper.h            | 10 ----
 include/configs/hammerhead.h             | 10 ----
 include/configs/highbank.h               |  4 +-
 include/configs/hrcon.h                  |  2 -
 include/configs/ids8313.h                |  4 --
 include/configs/intip.h                  |  2 -
 include/configs/io.h                     |  2 -
 include/configs/io64.h                   |  2 -
 include/configs/iocon.h                  |  2 -
 include/configs/ip04.h                   |  1 -
 include/configs/motionpro.h              |  6 --
 include/configs/nokia_rx51.h             |  1 -
 include/configs/o2dnt-common.h           | 12 ----
 include/configs/omap3_mvblx.h            |  2 -
 include/configs/pm9263.h                 |  1 -
 include/configs/siemens-am33x-common.h   |  6 --
 include/configs/spear-common.h           |  4 --
 include/configs/stv0991.h                |  4 --
 include/configs/uniphier.h               |  5 --
 include/configs/x600.h                   |  4 --
 include/configs/zmx25.h                  |  4 --
 scripts/kconfig/confdata.c               | 20 +++----
 scripts/kconfig/symbol.c                 | 43 ---------------
 96 files changed, 315 insertions(+), 301 deletions(-)

-- 
2.4.0

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-07 12:13 [U-Boot] [PATCH v1 0/4] Add SHA256 encrypted stop string for autobooting Stefan Roese
@ 2015-05-07 12:13 ` Stefan Roese
  2015-05-07 12:41   ` Masahiro Yamada
  2015-05-10 14:48   ` Simon Glass
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 2/4] autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2 Stefan Roese
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 29+ messages in thread
From: Stefan Roese @ 2015-05-07 12:13 UTC (permalink / raw)
  To: u-boot

I might have missed something, but I failed to use the escape char '\'
in strings. To pass a printf format string like "foo %d bar\n" via
Kconfig to the code.

Right now its not possible to use the escape character '\' in Kconfig
string values correctly to e.g. set this string value "test output\n".
The '\n' will be converted to 'n'.

The current implementation removes some of the '\' chars from the input
string in conf_set_sym_val(). Examples:

'\'	-> ''
'\\'	-> '\'
'\\\'	-> '\'
'\\\\'	-> '\\'
...

And then doubles the backslash chars in the output string in
sym_escape_string_value(). Example:

'\'	-> ''	-> ''
'\\'	-> '\'	-> '\\'
'\\\'	-> '\'	-> '\\'
'\\\\'	-> '\\'	-> '\\\\'
...

As you see in these examples, its impossible to generate a single '\'
charater in the output string as its needed for something like '\n'.

This patch now changes this behavior to not drop some backslashes in
conf_set_sym_val() and to not add new backslashes in the resulting
output string. Removing the function sym_escape_string_value()
completely as its not needed anymore.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Simon Glass <sjg@chromium.org>
---

 scripts/kconfig/confdata.c | 20 +++++++++-----------
 scripts/kconfig/symbol.c   | 43 -------------------------------------------
 2 files changed, 9 insertions(+), 54 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index f88d90f..4482192 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -155,18 +155,14 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
 	case S_STRING:
 		if (*p++ != '"')
 			break;
-		for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
-			if (*p2 == '"') {
-				*p2 = 0;
-				break;
-			}
-			memmove(p2, p2 + 1, strlen(p2));
-		}
-		if (!p2) {
+		/* Last char has to be a '"' */
+		if (p[strlen(p) - 1] != '"') {
 			if (def != S_DEF_AUTO)
 				conf_warning("invalid string found");
 			return 1;
 		}
+		/* Overwrite '"' with \0 for string termination */
+		p[strlen(p) - 1] = 0;
 		/* fall through */
 	case S_INT:
 	case S_HEX:
@@ -624,6 +620,7 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym,
 			      struct conf_printer *printer, void *printer_arg)
 {
 	const char *str;
+	char *str2;
 
 	switch (sym->type) {
 	case S_OTHER:
@@ -631,9 +628,10 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym,
 		break;
 	case S_STRING:
 		str = sym_get_string_value(sym);
-		str = sym_escape_string_value(str);
-		printer->print_symbol(fp, sym, str, printer_arg);
-		free((void *)str);
+		str2 = xmalloc(strlen(str) + 2);
+		sprintf(str2, "\"%s\"", str);
+		printer->print_symbol(fp, sym, str2, printer_arg);
+		free((void *)str2);
 		break;
 	default:
 		str = sym_get_string_value(sym);
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 7caabdb..ab339eb 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -912,49 +912,6 @@ const char *sym_expand_string_value(const char *in)
 	return res;
 }
 
-const char *sym_escape_string_value(const char *in)
-{
-	const char *p;
-	size_t reslen;
-	char *res;
-	size_t l;
-
-	reslen = strlen(in) + strlen("\"\"") + 1;
-
-	p = in;
-	for (;;) {
-		l = strcspn(p, "\"\\");
-		p += l;
-
-		if (p[0] == '\0')
-			break;
-
-		reslen++;
-		p++;
-	}
-
-	res = xmalloc(reslen);
-	res[0] = '\0';
-
-	strcat(res, "\"");
-
-	p = in;
-	for (;;) {
-		l = strcspn(p, "\"\\");
-		strncat(res, p, l);
-		p += l;
-
-		if (p[0] == '\0')
-			break;
-
-		strcat(res, "\\");
-		strncat(res, p++, 1);
-	}
-
-	strcat(res, "\"");
-	return res;
-}
-
 struct sym_match {
 	struct symbol	*sym;
 	off_t		so, eo;
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 2/4] autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2
  2015-05-07 12:13 [U-Boot] [PATCH v1 0/4] Add SHA256 encrypted stop string for autobooting Stefan Roese
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values Stefan Roese
@ 2015-05-07 12:13 ` Stefan Roese
  2015-05-07 23:47   ` Simon Glass
  2015-05-11 12:38   ` Tom Rini
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig Stefan Roese
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password Stefan Roese
  3 siblings, 2 replies; 29+ messages in thread
From: Stefan Roese @ 2015-05-07 12:13 UTC (permalink / raw)
  To: u-boot

These defines for a 2nd autoboot stop and delay string are nearly unused. Only
sc3 defines CONFIG_AUTOBOOT_DELAY_STR2. And a patch to remove this most likely
unmaintained board is also posted to the list.

By removing these defines the code will become cleaner and moving the remaining
compile options to Kconfig will get easier.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Heiko Schocher <hs@denx.de>
---

 README              |  2 --
 common/autoboot.c   | 14 ++------------
 doc/README.autoboot | 10 ----------
 3 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/README b/README
index 7958921..5956035 100644
--- a/README
+++ b/README
@@ -974,8 +974,6 @@ The following options need to be configured:
 		CONFIG_AUTOBOOT_PROMPT
 		CONFIG_AUTOBOOT_DELAY_STR
 		CONFIG_AUTOBOOT_STOP_STR
-		CONFIG_AUTOBOOT_DELAY_STR2
-		CONFIG_AUTOBOOT_STOP_STR2
 		CONFIG_ZERO_BOOTDELAY_CHECK
 		CONFIG_RESET_TO_RETRY
 
diff --git a/common/autoboot.c b/common/autoboot.c
index c27cc2c..7c92f3e 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -42,9 +42,7 @@ static int abortboot_keyed(int bootdelay)
 	}
 	delaykey[] = {
 		{ .str = getenv("bootdelaykey"),  .retry = 1 },
-		{ .str = getenv("bootdelaykey2"), .retry = 1 },
 		{ .str = getenv("bootstopkey"),   .retry = 0 },
-		{ .str = getenv("bootstopkey2"),  .retry = 0 },
 	};
 
 	char presskey[MAX_DELAY_STOP_STR];
@@ -65,17 +63,9 @@ static int abortboot_keyed(int bootdelay)
 	if (delaykey[0].str == NULL)
 		delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR;
 #  endif
-#  ifdef CONFIG_AUTOBOOT_DELAY_STR2
-	if (delaykey[1].str == NULL)
-		delaykey[1].str = CONFIG_AUTOBOOT_DELAY_STR2;
-#  endif
 #  ifdef CONFIG_AUTOBOOT_STOP_STR
-	if (delaykey[2].str == NULL)
-		delaykey[2].str = CONFIG_AUTOBOOT_STOP_STR;
-#  endif
-#  ifdef CONFIG_AUTOBOOT_STOP_STR2
-	if (delaykey[3].str == NULL)
-		delaykey[3].str = CONFIG_AUTOBOOT_STOP_STR2;
+	if (delaykey[1].str == NULL)
+		delaykey[1].str = CONFIG_AUTOBOOT_STOP_STR;
 #  endif
 
 	for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i++) {
diff --git a/doc/README.autoboot b/doc/README.autoboot
index 14e3660..227e3b5 100644
--- a/doc/README.autoboot
+++ b/doc/README.autoboot
@@ -78,13 +78,9 @@ What they do
   CONFIG_AUTOBOOT_PROMPT
   CONFIG_AUTOBOOT_DELAY_STR
   CONFIG_AUTOBOOT_STOP_STR
-  CONFIG_AUTOBOOT_DELAY_STR2
-  CONFIG_AUTOBOOT_STOP_STR2
 
   "bootdelaykey"  environment variable
   "bootstopkey"	  environment variable
-  "bootdelaykey2" environment variable
-  "bootstopkey2"  environment variable
 
 	These options give more control over stopping autoboot. When
 	they are used a specific character or string is required to
@@ -130,12 +126,6 @@ What they do
 	character of a key string does not appear in the rest of the
 	string.
 
-	Using the CONFIG_AUTOBOOT_DELAY_STR2 #define or the
-	"bootdelaykey2" environment variable and/or the
-	CONFIG_AUTOBOOT_STOP_STR2 #define or the "bootstopkey"
-	environment variable you can specify a second, alternate
-	string (which allows you to have two "password" strings).
-
 	The CONFIG_AUTOBOOT_KEYED_CTRLC #define allows for the boot
 	sequence to be interrupted by ctrl-c, in addition to the
 	"bootdelaykey" and "bootstopkey". Setting this variable
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig
  2015-05-07 12:13 [U-Boot] [PATCH v1 0/4] Add SHA256 encrypted stop string for autobooting Stefan Roese
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values Stefan Roese
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 2/4] autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2 Stefan Roese
@ 2015-05-07 12:13 ` Stefan Roese
  2015-05-07 23:51   ` Simon Glass
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password Stefan Roese
  3 siblings, 1 reply; 29+ messages in thread
From: Stefan Roese @ 2015-05-07 12:13 UTC (permalink / raw)
  To: u-boot

This patch moves the following config options to Kconfig:

CONFIG_AUTOBOOT_KEYED
CONFIG_AUTOBOOT_PROMPT
CONFIG_AUTOBOOT_DELAY_STR
CONFIG_AUTOBOOT_STOP_STR
AUTOBOOT_KEYED_CTRLC

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Simon Glass <sjg@chromium.org>
---

 common/Kconfig                           | 64 ++++++++++++++++++++++++++++++++
 common/autoboot.c                        |  6 ++-
 configs/CPCI4052_defconfig               |  3 ++
 configs/O2DNT2_RAMBOOT_defconfig         |  3 ++
 configs/O2DNT2_defconfig                 |  3 ++
 configs/PLU405_defconfig                 |  3 ++
 configs/PMC405DE_defconfig               |  3 ++
 configs/PMC440_defconfig                 |  3 ++
 configs/UCP1020_SPIFLASH_defconfig       |  3 ++
 configs/UCP1020_defconfig                |  3 ++
 configs/a4m072_defconfig                 |  3 ++
 configs/atngw100_defconfig               |  4 ++
 configs/atngw100mkii_defconfig           |  4 ++
 configs/atstk1002_defconfig              |  4 ++
 configs/atstk1003_defconfig              |  4 ++
 configs/atstk1004_defconfig              |  4 ++
 configs/atstk1006_defconfig              |  4 ++
 configs/calimain_defconfig               |  2 +
 configs/cpuat91_defconfig                |  4 ++
 configs/cpuat91_ram_defconfig            |  3 ++
 configs/digsy_mtc_RAMBOOT_defconfig      |  3 ++
 configs/digsy_mtc_defconfig              |  3 ++
 configs/digsy_mtc_rev5_RAMBOOT_defconfig |  3 ++
 configs/digsy_mtc_rev5_defconfig         |  3 ++
 configs/dlvision-10g_defconfig           |  2 +
 configs/draco_defconfig                  |  3 ++
 configs/dxr2_defconfig                   |  3 ++
 configs/favr-32-ezkit_defconfig          |  4 ++
 configs/gdppc440etx_defconfig            |  2 +
 configs/grasshopper_defconfig            |  4 ++
 configs/hammerhead_defconfig             |  4 ++
 configs/highbank_defconfig               |  3 ++
 configs/hrcon_defconfig                  |  2 +
 configs/ids8313_defconfig                |  3 ++
 configs/intip_defconfig                  |  2 +
 configs/io64_defconfig                   |  2 +
 configs/io_defconfig                     |  2 +
 configs/iocon_defconfig                  |  2 +
 configs/ip04_defconfig                   |  1 +
 configs/motionpro_defconfig              |  3 ++
 configs/nokia_rx51_defconfig             |  1 +
 configs/omap3_mvblx_defconfig            |  2 +
 configs/ph1_ld4_defconfig                |  4 ++
 configs/ph1_pro4_defconfig               |  4 ++
 configs/ph1_sld8_defconfig               |  4 ++
 configs/pm9263_defconfig                 |  1 +
 configs/pxm2_defconfig                   |  3 ++
 configs/rut_defconfig                    |  3 ++
 configs/spear600_defconfig               |  3 ++
 configs/stv0991_defconfig                |  3 ++
 configs/x600_defconfig                   |  3 ++
 configs/zmx25_defconfig                  |  4 ++
 include/configs/CPCI4052.h               |  6 ---
 include/configs/PLU405.h                 |  9 -----
 include/configs/PMC405DE.h               |  6 ---
 include/configs/PMC440.h                 |  6 ---
 include/configs/UCP1020.h                | 11 ------
 include/configs/a4m072.h                 |  4 --
 include/configs/atngw100.h               | 10 -----
 include/configs/atngw100mkii.h           | 10 -----
 include/configs/atstk1002.h              | 10 -----
 include/configs/atstk1003.h              | 10 -----
 include/configs/atstk1004.h              | 10 -----
 include/configs/atstk1006.h              | 10 -----
 include/configs/bf537-stamp.h            |  4 --
 include/configs/calimain.h               |  2 -
 include/configs/cpuat91.h                |  6 ---
 include/configs/digsy_mtc.h              |  4 --
 include/configs/dlvision-10g.h           |  2 -
 include/configs/favr-32-ezkit.h          | 10 -----
 include/configs/gdppc440etx.h            |  2 -
 include/configs/grasshopper.h            | 10 -----
 include/configs/hammerhead.h             | 10 -----
 include/configs/highbank.h               |  4 +-
 include/configs/hrcon.h                  |  2 -
 include/configs/ids8313.h                |  4 --
 include/configs/intip.h                  |  2 -
 include/configs/io.h                     |  2 -
 include/configs/io64.h                   |  2 -
 include/configs/iocon.h                  |  2 -
 include/configs/ip04.h                   |  1 -
 include/configs/motionpro.h              |  6 ---
 include/configs/nokia_rx51.h             |  1 -
 include/configs/o2dnt-common.h           | 12 ------
 include/configs/omap3_mvblx.h            |  2 -
 include/configs/pm9263.h                 |  1 -
 include/configs/siemens-am33x-common.h   |  6 ---
 include/configs/spear-common.h           |  4 --
 include/configs/stv0991.h                |  4 --
 include/configs/uniphier.h               |  5 ---
 include/configs/x600.h                   |  4 --
 include/configs/zmx25.h                  |  4 --
 92 files changed, 219 insertions(+), 220 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 15759f7..ff150f0 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -17,6 +17,70 @@ config SYS_HUSH_PARSER
 	help
 	  Backward compatibility.
 
+menu "Autoboot options"
+
+config AUTOBOOT_KEYED
+	bool "Stop autobooting via specific input key / string"
+	default n
+	help
+	  This option enables stopping (aborting) of the automatic
+	  boot feature only by issuing a specific input key or
+	  string. If not enabled, any input key will abort the
+	  U-Boot automatic booting process and bring the device
+	  to the U-Boot prompt for user input.
+
+config AUTOBOOT_PROMPT
+	string "Autoboot stop prompt"
+	depends on AUTOBOOT_KEYED
+	default "Autoboot in %d seconds\n"
+	help
+	  This string is displayed before the boot delay selected by
+	  CONFIG_BOOTDELAY starts. If it is not defined	there is no
+	  output indicating that autoboot is in progress.
+
+	  Note that this define is used as the (only) argument to a
+	  printf() call, so it may contain '%' format specifications,
+	  provided that it also includes, sepearated by commas exactly
+	  like in a printf statement, the required arguments. It is
+	  the responsibility of the user to select only such arguments
+	  that are valid in the given context.
+
+config AUTOBOOT_DELAY_STR
+	string "Delay autobooting via specific input key / string"
+	depends on AUTOBOOT_KEYED
+	help
+	  This option delays the automatic boot feature by issuing
+	  a specific input key or string. If CONFIG_AUTOBOOT_DELAY_STR
+	  or the environment variable "bootdelaykey" is specified
+	  and this string is received from console input before
+	  autoboot starts booting, U-Boot gives a command prompt. The
+	  U-Boot prompt will time out if CONFIG_BOOT_RETRY_TIME is
+	  used, otherwise it never times out.
+
+config AUTOBOOT_STOP_STR
+	string "Stop autobooting via specific input key / string"
+	depends on AUTOBOOT_KEYED
+	help
+	  This option enables stopping (aborting) of the automatic
+	  boot feature only by issuing a specific input key or
+	  string. If CONFIG_AUTOBOOT_STOP_STR or the environment
+	  variable "bootstopkey" is specified and this string is
+	  received from console input before autoboot starts booting,
+	  U-Boot gives a command prompt. The U-Boot prompt never
+	  times out, even if CONFIG_BOOT_RETRY_TIME is used.
+
+config AUTOBOOT_KEYED_CTRLC
+	bool "Enable Ctrl-C autoboot interruption"
+	depends on AUTOBOOT_KEYED
+	default n
+	help
+	  This option allows for the boot sequence to be interrupted
+	  by ctrl-c, in addition to the "bootdelaykey" and "bootstopkey".
+	  Setting this variable	provides an escape sequence from the
+	  limited "password" strings.
+
+endmenu
+
 comment "Commands"
 
 menu "Info commands"
diff --git a/common/autoboot.c b/common/autoboot.c
index 7c92f3e..f72eb18 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -56,7 +56,11 @@ static int abortboot_keyed(int bootdelay)
 #endif
 
 #  ifdef CONFIG_AUTOBOOT_PROMPT
-	printf(CONFIG_AUTOBOOT_PROMPT);
+	/*
+	 * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
+	 * To print the bootdelay value upon bootup.
+	 */
+	printf(CONFIG_AUTOBOOT_PROMPT, bootdelay);
 #  endif
 
 #  ifdef CONFIG_AUTOBOOT_DELAY_STR
diff --git a/configs/CPCI4052_defconfig b/configs/CPCI4052_defconfig
index 5d30b79..8c7369d 100644
--- a/configs/CPCI4052_defconfig
+++ b/configs/CPCI4052_defconfig
@@ -1,3 +1,6 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_CPCI4052=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/O2DNT2_RAMBOOT_defconfig b/configs/O2DNT2_RAMBOOT_defconfig
index 49e60ab..87d4b74 100644
--- a/configs/O2DNT2_RAMBOOT_defconfig
+++ b/configs/O2DNT2_RAMBOOT_defconfig
@@ -2,3 +2,6 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0x00100000"
 CONFIG_PPC=y
 CONFIG_MPC5xxx=y
 CONFIG_TARGET_O2DNT2=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="++++++++++"
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press password to stop\n"
diff --git a/configs/O2DNT2_defconfig b/configs/O2DNT2_defconfig
index 9df3b88..f729895 100644
--- a/configs/O2DNT2_defconfig
+++ b/configs/O2DNT2_defconfig
@@ -1,3 +1,6 @@
 CONFIG_PPC=y
 CONFIG_MPC5xxx=y
 CONFIG_TARGET_O2DNT2=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="++++++++++"
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press password to stop\n"
diff --git a/configs/PLU405_defconfig b/configs/PLU405_defconfig
index 15477c4..337962f 100644
--- a/configs/PLU405_defconfig
+++ b/configs/PLU405_defconfig
@@ -1,3 +1,6 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_PLU405=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/PMC405DE_defconfig b/configs/PMC405DE_defconfig
index 78c5d39..e26a90f 100644
--- a/configs/PMC405DE_defconfig
+++ b/configs/PMC405DE_defconfig
@@ -1,3 +1,6 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_PMC405DE=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/PMC440_defconfig b/configs/PMC440_defconfig
index 27869ac..7dd69bd 100644
--- a/configs/PMC440_defconfig
+++ b/configs/PMC440_defconfig
@@ -1,3 +1,6 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_PMC440=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/UCP1020_SPIFLASH_defconfig b/configs/UCP1020_SPIFLASH_defconfig
index 2ffb8da..7d045e6 100644
--- a/configs/UCP1020_SPIFLASH_defconfig
+++ b/configs/UCP1020_SPIFLASH_defconfig
@@ -4,3 +4,6 @@ CONFIG_TARGET_UCP1020=y
 CONFIG_TARGET_UCP1020_SPIFLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_UCP1020=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc>\" to stop\n"
+CONFIG_AUTOBOOT_STOP_STR="\x1b"
diff --git a/configs/UCP1020_defconfig b/configs/UCP1020_defconfig
index 61de360..421a2e4 100644
--- a/configs/UCP1020_defconfig
+++ b/configs/UCP1020_defconfig
@@ -3,3 +3,6 @@ CONFIG_MPC85xx=y
 CONFIG_TARGET_UCP1020=y
 CONFIG_SPI_FLASH=y
 CONFIG_UCP1020=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc>\" to stop\n"
+CONFIG_AUTOBOOT_STOP_STR="\x1b"
diff --git a/configs/a4m072_defconfig b/configs/a4m072_defconfig
index ddc8d3f..e01eb44 100644
--- a/configs/a4m072_defconfig
+++ b/configs/a4m072_defconfig
@@ -1,3 +1,6 @@
 CONFIG_PPC=y
 CONFIG_MPC5xxx=y
 CONFIG_TARGET_A4M072=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="asdfg"
+CONFIG_AUTOBOOT_PROMPT="autoboot in %d seconds\n"
diff --git a/configs/atngw100_defconfig b/configs/atngw100_defconfig
index cd79990..c28186e 100644
--- a/configs/atngw100_defconfig
+++ b/configs/atngw100_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_ATNGW100=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/atngw100mkii_defconfig b/configs/atngw100mkii_defconfig
index 88b1de2..05a8f39 100644
--- a/configs/atngw100mkii_defconfig
+++ b/configs/atngw100mkii_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_ATNGW100MKII=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/atstk1002_defconfig b/configs/atstk1002_defconfig
index d6e9a77..5db0ba6 100644
--- a/configs/atstk1002_defconfig
+++ b/configs/atstk1002_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_ATSTK1002=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/atstk1003_defconfig b/configs/atstk1003_defconfig
index b704532..3f97f07 100644
--- a/configs/atstk1003_defconfig
+++ b/configs/atstk1003_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_ATSTK1003=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/atstk1004_defconfig b/configs/atstk1004_defconfig
index 7650254..2016b8c 100644
--- a/configs/atstk1004_defconfig
+++ b/configs/atstk1004_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_ATSTK1004=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/atstk1006_defconfig b/configs/atstk1006_defconfig
index 54beb0b..0bfa84c 100644
--- a/configs/atstk1006_defconfig
+++ b/configs/atstk1006_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_ATSTK1006=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/calimain_defconfig b/configs/calimain_defconfig
index 02d3912..553820f 100644
--- a/configs/calimain_defconfig
+++ b/configs/calimain_defconfig
@@ -1,3 +1,5 @@
 CONFIG_ARM=y
 CONFIG_ARCH_DAVINCI=y
 CONFIG_TARGET_CALIMAIN=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="\x0b"
diff --git a/configs/cpuat91_defconfig b/configs/cpuat91_defconfig
index 5a1ef3a..5c25efa 100644
--- a/configs/cpuat91_defconfig
+++ b/configs/cpuat91_defconfig
@@ -1,3 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_CPUAT91=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/cpuat91_ram_defconfig b/configs/cpuat91_ram_defconfig
index 2759192..b0b94d4 100644
--- a/configs/cpuat91_ram_defconfig
+++ b/configs/cpuat91_ram_defconfig
@@ -2,3 +2,6 @@ CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT"
 CONFIG_ARM=y
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_CPUAT91=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/digsy_mtc_RAMBOOT_defconfig b/configs/digsy_mtc_RAMBOOT_defconfig
index a1e765b..19ba197 100644
--- a/configs/digsy_mtc_RAMBOOT_defconfig
+++ b/configs/digsy_mtc_RAMBOOT_defconfig
@@ -2,3 +2,6 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0x00100000"
 CONFIG_PPC=y
 CONFIG_MPC5xxx=y
 CONFIG_TARGET_DIGSY_MTC=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot\n"
diff --git a/configs/digsy_mtc_defconfig b/configs/digsy_mtc_defconfig
index 666c5c8..cefaa45 100644
--- a/configs/digsy_mtc_defconfig
+++ b/configs/digsy_mtc_defconfig
@@ -1,3 +1,6 @@
 CONFIG_PPC=y
 CONFIG_MPC5xxx=y
 CONFIG_TARGET_DIGSY_MTC=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR=" "
+CONFIG_AUTOBOOT_PROMPT="autoboot in %d seconds\n"
diff --git a/configs/digsy_mtc_rev5_RAMBOOT_defconfig b/configs/digsy_mtc_rev5_RAMBOOT_defconfig
index d356174..818efda 100644
--- a/configs/digsy_mtc_rev5_RAMBOOT_defconfig
+++ b/configs/digsy_mtc_rev5_RAMBOOT_defconfig
@@ -2,3 +2,6 @@ CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0x00100000,DIGSY_REV5"
 CONFIG_PPC=y
 CONFIG_MPC5xxx=y
 CONFIG_TARGET_DIGSY_MTC=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot\n"
diff --git a/configs/digsy_mtc_rev5_defconfig b/configs/digsy_mtc_rev5_defconfig
index f66f86f..cdf021a 100644
--- a/configs/digsy_mtc_rev5_defconfig
+++ b/configs/digsy_mtc_rev5_defconfig
@@ -2,3 +2,6 @@ CONFIG_SYS_EXTRA_OPTIONS="DIGSY_REV5"
 CONFIG_PPC=y
 CONFIG_MPC5xxx=y
 CONFIG_TARGET_DIGSY_MTC=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot\n"
diff --git a/configs/dlvision-10g_defconfig b/configs/dlvision-10g_defconfig
index 1d2a571..2f11eed 100644
--- a/configs/dlvision-10g_defconfig
+++ b/configs/dlvision-10g_defconfig
@@ -1,3 +1,5 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_DLVISION_10G=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/draco_defconfig b/configs/draco_defconfig
index fba7bf1..a09dcf5 100644
--- a/configs/draco_defconfig
+++ b/configs/draco_defconfig
@@ -1,3 +1,6 @@
 CONFIG_SPL=y
 CONFIG_ARM=y
 CONFIG_TARGET_DRACO=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="\x1b\x1b"
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc><Esc>\" to stop\n"
diff --git a/configs/dxr2_defconfig b/configs/dxr2_defconfig
index e0f577f..c5095e9 100644
--- a/configs/dxr2_defconfig
+++ b/configs/dxr2_defconfig
@@ -1,3 +1,6 @@
 CONFIG_SPL=y
 CONFIG_ARM=y
 CONFIG_TARGET_DXR2=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="\x1b\x1b"
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc><Esc>\" to stop\n"
diff --git a/configs/favr-32-ezkit_defconfig b/configs/favr-32-ezkit_defconfig
index 941e028..415a11e 100644
--- a/configs/favr-32-ezkit_defconfig
+++ b/configs/favr-32-ezkit_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_FAVR_32_EZKIT=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/gdppc440etx_defconfig b/configs/gdppc440etx_defconfig
index 1097b9c..2dfebbb 100644
--- a/configs/gdppc440etx_defconfig
+++ b/configs/gdppc440etx_defconfig
@@ -1,3 +1,5 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_GDPPC440ETX=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/grasshopper_defconfig b/configs/grasshopper_defconfig
index 72013e7..287bbd8 100644
--- a/configs/grasshopper_defconfig
+++ b/configs/grasshopper_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_GRASSHOPPER=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
diff --git a/configs/hammerhead_defconfig b/configs/hammerhead_defconfig
index 0d69cc6..deed8e2 100644
--- a/configs/hammerhead_defconfig
+++ b/configs/hammerhead_defconfig
@@ -1,2 +1,6 @@
 CONFIG_AVR32=y
 CONFIG_TARGET_HAMMERHEAD=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds"
diff --git a/configs/highbank_defconfig b/configs/highbank_defconfig
index 88efbdf..d56ae77 100644
--- a/configs/highbank_defconfig
+++ b/configs/highbank_defconfig
@@ -1,2 +1,5 @@
 CONFIG_ARM=y
 CONFIG_ARCH_HIGHBANK=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_KEYED_CTRLC=y
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds...\nPress <s> to stop or <d> to delay\n"
diff --git a/configs/hrcon_defconfig b/configs/hrcon_defconfig
index 69c65ba..b73c41f 100644
--- a/configs/hrcon_defconfig
+++ b/configs/hrcon_defconfig
@@ -1,3 +1,5 @@
 CONFIG_PPC=y
 CONFIG_MPC83xx=y
 CONFIG_TARGET_HRCON=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/ids8313_defconfig b/configs/ids8313_defconfig
index 8479cd4..939361e 100644
--- a/configs/ids8313_defconfig
+++ b/configs/ids8313_defconfig
@@ -4,3 +4,6 @@ CONFIG_MPC83xx=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_TARGET_IDS8313=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_DELAY_STR="ids"
+CONFIG_AUTOBOOT_PROMPT="Enter password - autoboot in %d seconds...\n"
diff --git a/configs/intip_defconfig b/configs/intip_defconfig
index d6af774..a9cfe84 100644
--- a/configs/intip_defconfig
+++ b/configs/intip_defconfig
@@ -2,3 +2,5 @@ CONFIG_SYS_EXTRA_OPTIONS="INTIB"
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_INTIP=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/io64_defconfig b/configs/io64_defconfig
index 1111e54..52829da 100644
--- a/configs/io64_defconfig
+++ b/configs/io64_defconfig
@@ -1,3 +1,5 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_IO64=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/io_defconfig b/configs/io_defconfig
index 959af75..bf76ad3 100644
--- a/configs/io_defconfig
+++ b/configs/io_defconfig
@@ -1,3 +1,5 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_IO=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/iocon_defconfig b/configs/iocon_defconfig
index 6dc8887..bfe718e 100644
--- a/configs/iocon_defconfig
+++ b/configs/iocon_defconfig
@@ -1,3 +1,5 @@
 CONFIG_PPC=y
 CONFIG_4xx=y
 CONFIG_TARGET_IOCON=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/ip04_defconfig b/configs/ip04_defconfig
index ba737ae..d82e2d6 100644
--- a/configs/ip04_defconfig
+++ b/configs/ip04_defconfig
@@ -1,3 +1,4 @@
 CONFIG_BLACKFIN=y
 CONFIG_TARGET_IP04=y
 CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y
+CONFIG_AUTOBOOT_PROMPT="autoboot in %d seconds\n"
diff --git a/configs/motionpro_defconfig b/configs/motionpro_defconfig
index 535cb84..e1bacb4 100644
--- a/configs/motionpro_defconfig
+++ b/configs/motionpro_defconfig
@@ -1,3 +1,6 @@
 CONFIG_PPC=y
 CONFIG_MPC5xxx=y
 CONFIG_TARGET_MOTIONPRO=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="\x1b\x1b"
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc><Esc>\" to stop\n"
diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig
index e03f586..3aff2e6 100644
--- a/configs/nokia_rx51_defconfig
+++ b/configs/nokia_rx51_defconfig
@@ -1,3 +1,4 @@
 CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_NOKIA_RX51=y
+CONFIG_AUTOBOOT_KEYED=y
diff --git a/configs/omap3_mvblx_defconfig b/configs/omap3_mvblx_defconfig
index fb6edc2..33d63de 100644
--- a/configs/omap3_mvblx_defconfig
+++ b/configs/omap3_mvblx_defconfig
@@ -1,3 +1,5 @@
 CONFIG_ARM=y
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_OMAP3_MVBLX=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="S"
diff --git a/configs/ph1_ld4_defconfig b/configs/ph1_ld4_defconfig
index 036e2d1..328e1dc 100644
--- a/configs/ph1_ld4_defconfig
+++ b/configs/ph1_ld4_defconfig
@@ -38,3 +38,7 @@ CONFIG_UNIPHIER_SERIAL=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/ph1_pro4_defconfig b/configs/ph1_pro4_defconfig
index 9a010ee..cc77a0a 100644
--- a/configs/ph1_pro4_defconfig
+++ b/configs/ph1_pro4_defconfig
@@ -38,3 +38,7 @@ CONFIG_UNIPHIER_SERIAL=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_STORAGE=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/ph1_sld8_defconfig b/configs/ph1_sld8_defconfig
index 29fe0e8..1294c93 100644
--- a/configs/ph1_sld8_defconfig
+++ b/configs/ph1_sld8_defconfig
@@ -38,3 +38,7 @@ CONFIG_UNIPHIER_SERIAL=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
+CONFIG_AUTOBOOT_DELAY_STR="d"
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/pm9263_defconfig b/configs/pm9263_defconfig
index 6e88046..db19bc3 100644
--- a/configs/pm9263_defconfig
+++ b/configs/pm9263_defconfig
@@ -2,3 +2,4 @@ CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9263"
 CONFIG_ARM=y
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_PM9263=y
+CONFIG_AUTOBOOT_PROMPT="autoboot in %d seconds\n"
diff --git a/configs/pxm2_defconfig b/configs/pxm2_defconfig
index f9e594f..70c0623 100644
--- a/configs/pxm2_defconfig
+++ b/configs/pxm2_defconfig
@@ -1,3 +1,6 @@
 CONFIG_SPL=y
 CONFIG_ARM=y
 CONFIG_TARGET_PXM2=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="\x1b\x1b"
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc><Esc>\" to stop\n"
diff --git a/configs/rut_defconfig b/configs/rut_defconfig
index b7161ba..0fc8150 100644
--- a/configs/rut_defconfig
+++ b/configs/rut_defconfig
@@ -1,3 +1,6 @@
 CONFIG_SPL=y
 CONFIG_ARM=y
 CONFIG_TARGET_RUT=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR="\x1b\x1b"
+CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"<Esc><Esc>\" to stop\n"
diff --git a/configs/spear600_defconfig b/configs/spear600_defconfig
index dae0d59..7a9ba59 100644
--- a/configs/spear600_defconfig
+++ b/configs/spear600_defconfig
@@ -4,3 +4,6 @@ CONFIG_TARGET_SPEAR600=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_NETDEVICES=y
 CONFIG_NET=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n"
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/stv0991_defconfig b/configs/stv0991_defconfig
index 76ba41b..89308c6 100644
--- a/configs/stv0991_defconfig
+++ b/configs/stv0991_defconfig
@@ -5,3 +5,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_NETDEVICES=y
 CONFIG_NET=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_STOP_STR=" "
+CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n"
diff --git a/configs/x600_defconfig b/configs/x600_defconfig
index 7cd239b..d27fa51 100644
--- a/configs/x600_defconfig
+++ b/configs/x600_defconfig
@@ -4,3 +4,6 @@ CONFIG_TARGET_X600=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_NETDEVICES=y
 CONFIG_NET=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n"
+CONFIG_AUTOBOOT_STOP_STR=" "
diff --git a/configs/zmx25_defconfig b/configs/zmx25_defconfig
index 80a66d0..b0f882d 100644
--- a/configs/zmx25_defconfig
+++ b/configs/zmx25_defconfig
@@ -1,2 +1,6 @@
 CONFIG_ARM=y
 CONFIG_TARGET_ZMX25=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_PROMPT="boot in %d s\n"
+CONFIG_AUTOBOOT_DELAY_STR="delaygs"
+CONFIG_AUTOBOOT_STOP_STR="stopgs"
diff --git a/include/configs/CPCI4052.h b/include/configs/CPCI4052.h
index ceddd7a..c20ecbd 100644
--- a/include/configs/CPCI4052.h
+++ b/include/configs/CPCI4052.h
@@ -141,12 +141,6 @@
 
 #define CONFIG_VERSION_VARIABLE 1	/* include version env variable */
 
-#define CONFIG_AUTOBOOT_KEYED	1
-#define CONFIG_AUTOBOOT_PROMPT	\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#undef CONFIG_AUTOBOOT_DELAY_STR
-#define CONFIG_AUTOBOOT_STOP_STR " "
-
 #define CONFIG_SYS_RX_ETH_BUFFER	16	/* use 16 rx buffer on 405 emac */
 
 /*-----------------------------------------------------------------------
diff --git a/include/configs/PLU405.h b/include/configs/PLU405.h
index a236e11..80f4276 100644
--- a/include/configs/PLU405.h
+++ b/include/configs/PLU405.h
@@ -138,15 +138,6 @@
 #define CONFIG_ZERO_BOOTDELAY_CHECK	/* check for keypress on bootdelay==0 */
 #define CONFIG_BOOTDELAY	3	/* autoboot after 3 seconds	*/
 
-/* Only interrupt boot if space is pressed */
-/* If a long serial cable is connected but */
-/* other end is dead, garbage will be read */
-#define CONFIG_AUTOBOOT_KEYED	1
-#define CONFIG_AUTOBOOT_PROMPT	\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#undef CONFIG_AUTOBOOT_DELAY_STR
-#define CONFIG_AUTOBOOT_STOP_STR " "
-
 #define CONFIG_VERSION_VARIABLE 1	/* include version env variable */
 
 #define CONFIG_SYS_RX_ETH_BUFFER	16	/* use 16 rx buffer on 405 emac */
diff --git a/include/configs/PMC405DE.h b/include/configs/PMC405DE.h
index f7d28e3..a64c82a 100644
--- a/include/configs/PMC405DE.h
+++ b/include/configs/PMC405DE.h
@@ -110,12 +110,6 @@
 #define CONFIG_ZERO_BOOTDELAY_CHECK	/* check for keypress on bootdelay==0 */
 #define CONFIG_VERSION_VARIABLE 1	/* include version env variable */
 
-#define CONFIG_AUTOBOOT_KEYED	1
-#define CONFIG_AUTOBOOT_PROMPT	\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#undef CONFIG_AUTOBOOT_DELAY_STR
-#define CONFIG_AUTOBOOT_STOP_STR " "
-
 /*
  * PCI stuff
  */
diff --git a/include/configs/PMC440.h b/include/configs/PMC440.h
index c29429d..c09f656 100644
--- a/include/configs/PMC440.h
+++ b/include/configs/PMC440.h
@@ -332,12 +332,6 @@
 #define CONFIG_ZERO_BOOTDELAY_CHECK	/* check for keypress on bootdelay==0 */
 #define CONFIG_VERSION_VARIABLE 1	/* include version env variable */
 
-#define CONFIG_AUTOBOOT_KEYED	1
-#define CONFIG_AUTOBOOT_PROMPT	\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#undef CONFIG_AUTOBOOT_DELAY_STR
-#define CONFIG_AUTOBOOT_STOP_STR " "
-
 /*-----------------------------------------------------------------------
  * PCI stuff
  *----------------------------------------------------------------------*/
diff --git a/include/configs/UCP1020.h b/include/configs/UCP1020.h
index 57e0c6c..6593093 100644
--- a/include/configs/UCP1020.h
+++ b/include/configs/UCP1020.h
@@ -628,17 +628,6 @@
 /* default location for tftp and bootm */
 #define CONFIG_LOADADDR		1000000
 
-/*
- * Autobooting
- */
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_STOP_STR	"\x1b"
-#define DEBUG_BOOTKEYS			0
-#undef CONFIG_AUTOBOOT_DELAY_STR
-#undef CONFIG_BOOTARGS
-#define CONFIG_AUTOBOOT_PROMPT	"Autobooting in %d seconds, "	\
-				"press \"<Esc>\" to stop\n", bootdelay
-
 #define CONFIG_BOOTARGS	/* the boot command will set bootargs */
 
 #define CONFIG_BAUDRATE	115200
diff --git a/include/configs/a4m072.h b/include/configs/a4m072.h
index 3c67655..deedfb9 100644
--- a/include/configs/a4m072.h
+++ b/include/configs/a4m072.h
@@ -123,10 +123,6 @@
 
 #define CONFIG_SYS_AUTOLOAD	"n"
 
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		"autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"asdfg"
-
 #undef	CONFIG_BOOTARGS
 #define CONFIG_PREBOOT				"run try_update"
 
diff --git a/include/configs/atngw100.h b/include/configs/atngw100.h
index 540e86a..1202ec2 100644
--- a/include/configs/atngw100.h
+++ b/include/configs/atngw100.h
@@ -59,17 +59,7 @@
 #define CONFIG_BOOTCOMMAND						\
 	"fsload; bootm"
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * After booting the board for the first time, new ethernet addresses
diff --git a/include/configs/atngw100mkii.h b/include/configs/atngw100mkii.h
index eaed7ea..fcaabb4 100644
--- a/include/configs/atngw100mkii.h
+++ b/include/configs/atngw100mkii.h
@@ -82,17 +82,7 @@
 #define CONFIG_BOOTCOMMAND						\
 	"fsload 0x10400000 /uImage; bootm"
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * After booting the board for the first time, new ethernet addresses
diff --git a/include/configs/atstk1002.h b/include/configs/atstk1002.h
index a9c064a..64b5519 100644
--- a/include/configs/atstk1002.h
+++ b/include/configs/atstk1002.h
@@ -79,17 +79,7 @@
 #define CONFIG_BOOTCOMMAND						\
 	"fsload; bootm $(fileaddr)"
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * After booting the board for the first time, new ethernet addresses
diff --git a/include/configs/atstk1003.h b/include/configs/atstk1003.h
index 63704b1..786713f 100644
--- a/include/configs/atstk1003.h
+++ b/include/configs/atstk1003.h
@@ -79,17 +79,7 @@
 #define CONFIG_BOOTCOMMAND						\
 	"mmc rescan; ext2load mmc 0:1 0x10400000 /boot/uImage; bootm"
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * Command line configuration.
diff --git a/include/configs/atstk1004.h b/include/configs/atstk1004.h
index 331a60d..0b2a9ff 100644
--- a/include/configs/atstk1004.h
+++ b/include/configs/atstk1004.h
@@ -79,17 +79,7 @@
 #define CONFIG_BOOTCOMMAND						\
 	"mmc rescan; ext2load mmc 0:1 0x10200000 /boot/uImage; bootm"
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * Command line configuration.
diff --git a/include/configs/atstk1006.h b/include/configs/atstk1006.h
index 25090a6..cbf17db 100644
--- a/include/configs/atstk1006.h
+++ b/include/configs/atstk1006.h
@@ -80,17 +80,7 @@
 #define CONFIG_BOOTCOMMAND						\
 	"fsload; bootm $(fileaddr)"
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * After booting the board for the first time, new ethernet addresses
diff --git a/include/configs/bf537-stamp.h b/include/configs/bf537-stamp.h
index 7b5a5a7..b3e13c1 100644
--- a/include/configs/bf537-stamp.h
+++ b/include/configs/bf537-stamp.h
@@ -272,10 +272,6 @@
 /* These are for board tests */
 #if 0
 #define CONFIG_BOOTCOMMAND       "bootldr 0x203f0100"
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT \
-	"autoboot in %d seconds: press space to stop\n", bootdelay
-#define CONFIG_AUTOBOOT_STOP_STR " "
 #endif
 
 
diff --git a/include/configs/calimain.h b/include/configs/calimain.h
index 44c947f..0eeaf8b 100644
--- a/include/configs/calimain.h
+++ b/include/configs/calimain.h
@@ -221,8 +221,6 @@
 #define CONFIG_BOOTDELAY          0
 #define CONFIG_ZERO_BOOTDELAY_CHECK   /* check for keypress on bootdelay==0 */
 #define CONFIG_BOOT_RETRY_TIME    60  /* continue boot after 60 s inactivity */
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_DELAY_STR "\x0d" /* press ENTER to interrupt BOOT */
 #define CONFIG_RESET_TO_RETRY
 
 /*
diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
index 8c7d97a..77d3ab8 100644
--- a/include/configs/cpuat91.h
+++ b/include/configs/cpuat91.h
@@ -195,12 +195,6 @@
 #define CONFIG_DEVICE_NULLDEV
 #define CONFIG_SILENT_CONSOLE
 
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		\
-	"Press SPACE to abort autoboot\n"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-
 #define CONFIG_VERSION_VARIABLE
 
 #define MTDIDS_DEFAULT			"nor0=physmap-flash.0"
diff --git a/include/configs/digsy_mtc.h b/include/configs/digsy_mtc.h
index 76ec168..06da3c3 100644
--- a/include/configs/digsy_mtc.h
+++ b/include/configs/digsy_mtc.h
@@ -396,10 +396,6 @@
 #define CONFIG_CMDLINE_EDITING	1
 #define CONFIG_SYS_HUSH_PARSER
 
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT "autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	" "
-
 #define CONFIG_LOOPW		1
 #define CONFIG_MX_CYCLIC	1
 #define CONFIG_ZERO_BOOTDELAY_CHECK
diff --git a/include/configs/dlvision-10g.h b/include/configs/dlvision-10g.h
index d9bd564..0f67595 100644
--- a/include/configs/dlvision-10g.h
+++ b/include/configs/dlvision-10g.h
@@ -29,8 +29,6 @@
 #define CONFIG_SYS_CLK_FREQ	33333333 /* external frequency to pll   */
 
 #undef CONFIG_ZERO_BOOTDELAY_CHECK     /* ignore keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED          /* use key strings to stop autoboot */
-#define CONFIG_AUTOBOOT_STOP_STR " "
 
 /*
  * Configure PLL
diff --git a/include/configs/favr-32-ezkit.h b/include/configs/favr-32-ezkit.h
index 75bff4c..04f4124 100644
--- a/include/configs/favr-32-ezkit.h
+++ b/include/configs/favr-32-ezkit.h
@@ -80,17 +80,7 @@
 #define CONFIG_BOOTCOMMAND						\
 	"fsload; bootm $(fileaddr)"
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * After booting the board for the first time, new ethernet addresses
diff --git a/include/configs/gdppc440etx.h b/include/configs/gdppc440etx.h
index 12fd75d..bfaba42 100644
--- a/include/configs/gdppc440etx.h
+++ b/include/configs/gdppc440etx.h
@@ -35,8 +35,6 @@
 #define CONFIG_SYS_GENERIC_BOARD
 
 #undef CONFIG_ZERO_BOOTDELAY_CHECK     /* ignore keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED          /* use key strings to stop autoboot */
-#define CONFIG_AUTOBOOT_STOP_STR " "
 
 /*
  * Base addresses -- Note these are effective addresses where the
diff --git a/include/configs/grasshopper.h b/include/configs/grasshopper.h
index 54eb977..99d2389 100644
--- a/include/configs/grasshopper.h
+++ b/include/configs/grasshopper.h
@@ -75,17 +75,7 @@
 
 #define CONFIG_BAUDRATE			115200
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT		"Press SPACE to abort autoboot in %d" \
-					" seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * After booting the board for the first time, new ethernet addresses
diff --git a/include/configs/hammerhead.h b/include/configs/hammerhead.h
index 0bc42f1..274f2a8 100644
--- a/include/configs/hammerhead.h
+++ b/include/configs/hammerhead.h
@@ -60,17 +60,7 @@
 #define CONFIG_BOOTCOMMAND						\
 	"fsload; bootm"
 
-/*
- * Only interrupt autoboot if <space> is pressed. Otherwise, garbage
- * data on the serial line may interrupt the boot sequence.
- */
 #define CONFIG_BOOTDELAY		1
-#define CONFIG_AUTOBOOT
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT				\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"d"
-#define CONFIG_AUTOBOOT_STOP_STR	" "
 
 /*
  * After booting the board for the first time, new ethernet address
diff --git a/include/configs/highbank.h b/include/configs/highbank.h
index da1c837..08dcdf8 100644
--- a/include/configs/highbank.h
+++ b/include/configs/highbank.h
@@ -63,9 +63,7 @@
 
 #define CONFIG_BOOT_RETRY_TIME		-1
 #define CONFIG_RESET_TO_RETRY
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT "Autobooting in %d seconds...\nPress <s> to stop or <d> to delay\n", bootdelay
-#define CONFIG_AUTOBOOT_KEYED_CTRLC
+
 /*
  * Miscellaneous configurable options
  */
diff --git a/include/configs/hrcon.h b/include/configs/hrcon.h
index e7df9ad..608e7d0 100644
--- a/include/configs/hrcon.h
+++ b/include/configs/hrcon.h
@@ -491,8 +491,6 @@ int fpga_gpio_get(unsigned int bus, int pin);
 #define CONFIG_SYS_HZ		1000	/* decrementer freq: 1ms ticks */
 
 #undef CONFIG_ZERO_BOOTDELAY_CHECK	/* ignore keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED		/* use key strings to stop autoboot */
-#define CONFIG_AUTOBOOT_STOP_STR " "
 
 #define CONFIG_SYS_CBSIZE	1024 /* Console I/O Buffer Size */
 
diff --git a/include/configs/ids8313.h b/include/configs/ids8313.h
index c1ca56c..7730f63 100644
--- a/include/configs/ids8313.h
+++ b/include/configs/ids8313.h
@@ -25,10 +25,6 @@
 
 #define CONFIG_MISC_INIT_R
 
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT	\
-	"\nEnter password - autoboot in %d seconds...\n", CONFIG_BOOTDELAY
-#define CONFIG_AUTOBOOT_DELAY_STR	"ids"
 #define CONFIG_BOOT_RETRY_TIME		900
 #define CONFIG_BOOT_RETRY_MIN		30
 #define CONFIG_BOOTDELAY		1
diff --git a/include/configs/intip.h b/include/configs/intip.h
index 928eb5b..18d3140 100644
--- a/include/configs/intip.h
+++ b/include/configs/intip.h
@@ -51,8 +51,6 @@
 #define CFG_ALT_MEMTEST
 
 #undef CONFIG_ZERO_BOOTDELAY_CHECK     /* ignore keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED          /* use key strings to stop autoboot */
-#define CONFIG_AUTOBOOT_STOP_STR " "
 
 /*
  * Base addresses -- Note these are effective addresses where the
diff --git a/include/configs/io.h b/include/configs/io.h
index d4ae0ad..8101933 100644
--- a/include/configs/io.h
+++ b/include/configs/io.h
@@ -35,8 +35,6 @@
 #define PLLMR1_DEFAULT PLLMR1_266_133_66
 
 #undef CONFIG_ZERO_BOOTDELAY_CHECK	/* ignore keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED		/* use key strings to stop autoboot */
-#define CONFIG_AUTOBOOT_STOP_STR " "
 
 /* new uImage format support */
 #define CONFIG_FIT
diff --git a/include/configs/io64.h b/include/configs/io64.h
index 2a9ff37..94ccb6b 100644
--- a/include/configs/io64.h
+++ b/include/configs/io64.h
@@ -46,8 +46,6 @@
 #define CONFIG_SYS_GENERIC_BOARD
 
 #undef CONFIG_ZERO_BOOTDELAY_CHECK	/* ignore keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED		/* use key strings to stop autoboot */
-#define CONFIG_AUTOBOOT_STOP_STR " "
 
 /* new uImage format support */
 #define CONFIG_FIT
diff --git a/include/configs/iocon.h b/include/configs/iocon.h
index 38d473d..9d9dabf 100644
--- a/include/configs/iocon.h
+++ b/include/configs/iocon.h
@@ -34,8 +34,6 @@
 #define PLLMR1_DEFAULT PLLMR1_266_133_66
 
 #undef CONFIG_ZERO_BOOTDELAY_CHECK	/* ignore keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED		/* use key strings to stop autoboot */
-#define CONFIG_AUTOBOOT_STOP_STR " "
 
 /* new uImage format support */
 #define CONFIG_FIT
diff --git a/include/configs/ip04.h b/include/configs/ip04.h
index 2ee215f..8081a05 100644
--- a/include/configs/ip04.h
+++ b/include/configs/ip04.h
@@ -138,7 +138,6 @@
 /* Enable this if bootretry required; currently it's disabled */
 #define CONFIG_BOOT_RETRY_TIME	-1
 #define CONFIG_BOOTCOMMAND	"run nandboot"
-#define CONFIG_AUTOBOOT_PROMPT	"autoboot in %d seconds\n"
 
 
 /*
diff --git a/include/configs/motionpro.h b/include/configs/motionpro.h
index e8b0593..8d29d95 100644
--- a/include/configs/motionpro.h
+++ b/include/configs/motionpro.h
@@ -73,13 +73,7 @@
  * Autobooting
  */
 #define CONFIG_BOOTDELAY	2	/* autoboot after 2 seconds */
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_STOP_STR	"\x1b\x1b"
-#define DEBUG_BOOTKEYS		0
-#undef CONFIG_AUTOBOOT_DELAY_STR
 #undef CONFIG_BOOTARGS
-#define CONFIG_AUTOBOOT_PROMPT	"Autobooting in %d seconds, "		\
-				"press \"<Esc><Esc>\" to stop\n", bootdelay
 
 #define CONFIG_CMDLINE_EDITING		1	/* add command line history	*/
 #define	CONFIG_SYS_HUSH_PARSER		1	/* use "hush" command parser	*/
diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h
index 152a6e5..58b6f6f 100644
--- a/include/configs/nokia_rx51.h
+++ b/include/configs/nokia_rx51.h
@@ -397,7 +397,6 @@ int rx51_kp_getc(struct stdio_dev *sdev);
 	"echo"
 
 #define CONFIG_BOOTDELAY 30
-#define CONFIG_AUTOBOOT_KEYED
 #define CONFIG_MENU
 #define CONFIG_MENU_SHOW
 
diff --git a/include/configs/o2dnt-common.h b/include/configs/o2dnt-common.h
index 18388d1..3248429 100644
--- a/include/configs/o2dnt-common.h
+++ b/include/configs/o2dnt-common.h
@@ -98,18 +98,6 @@
 #error "CONFIG_SYS_TEXT_BASE value is invalid"
 #endif
 
-/*
- * Autobooting
- * Be selective on what keys can delay or stop the autoboot process
- * To stop use: "++++++++++"
- */
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT	"Autobooting in %d seconds, " \
-				"press password to stop\n", bootdelay
-#define CONFIG_AUTOBOOT_STOP_STR	"++++++++++"
-#undef CONFIG_AUTOBOOT_DELAY_STR
-#define DEBUG_BOOTKEYS		0
-
 #define CONFIG_BOOTDELAY	5	/* autoboot after 5 seconds */
 
 #define CONFIG_PREBOOT	"run master"
diff --git a/include/configs/omap3_mvblx.h b/include/configs/omap3_mvblx.h
index b61297f..41908a9 100644
--- a/include/configs/omap3_mvblx.h
+++ b/include/configs/omap3_mvblx.h
@@ -145,8 +145,6 @@
 #undef CONFIG_ENV_OVERWRITE	/* disallow overwriting serial# and ethaddr */
 #define CONFIG_BOOTDELAY		0
 #define CONFIG_ZERO_BOOTDELAY_CHECK
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_STOP_STR "S"
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"silent=true\0" \
diff --git a/include/configs/pm9263.h b/include/configs/pm9263.h
index f6aebf4..9bdbf53 100644
--- a/include/configs/pm9263.h
+++ b/include/configs/pm9263.h
@@ -339,7 +339,6 @@
 
 #define CONFIG_BOOTCOMMAND		"run flashboot"
 #define CONFIG_ROOTPATH			"/ronetix/rootfs"
-#define CONFIG_AUTOBOOT_PROMPT		"autoboot in %d seconds\n", bootdelay
 
 #define CONFIG_CON_ROT			"fbcon=rotate:3 "
 #define CONFIG_BOOTARGS			"root=/dev/mtdblock4 rootfstype=jffs2 "\
diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h
index c7affd6..50efdc8 100644
--- a/include/configs/siemens-am33x-common.h
+++ b/include/configs/siemens-am33x-common.h
@@ -478,12 +478,6 @@
 /* Watchdog */
 #define CONFIG_HW_WATCHDOG
 
-/* Stop autoboot with ESC ESC key detected */
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_STOP_STR	"\x1b\x1b"
-#define CONFIG_AUTOBOOT_PROMPT	"Autobooting in %d seconds, "		\
-				"press \"<Esc><Esc>\" to stop\n", bootdelay
-
 /* Reboot after 60 sec if bootcmd fails */
 #define CONFIG_RESET_TO_RETRY
 #define CONFIG_BOOT_RETRY_TIME 60
diff --git a/include/configs/spear-common.h b/include/configs/spear-common.h
index 409cf54..ac308d5 100644
--- a/include/configs/spear-common.h
+++ b/include/configs/spear-common.h
@@ -202,10 +202,6 @@
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_MISC_INIT_R
 #define CONFIG_ZERO_BOOTDELAY_CHECK
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_STOP_STR		" "
-#define CONFIG_AUTOBOOT_PROMPT			\
-		"Hit SPACE in %d seconds to stop autoboot.\n", bootdelay
 
 #define CONFIG_SYS_MEMTEST_START		0x00800000
 #define CONFIG_SYS_MEMTEST_END			0x04000000
diff --git a/include/configs/stv0991.h b/include/configs/stv0991.h
index ab1e61c..89fce9b 100644
--- a/include/configs/stv0991.h
+++ b/include/configs/stv0991.h
@@ -75,9 +75,5 @@
 
 #define CONFIG_BOOTDELAY                       3
 #define CONFIG_BOOTCOMMAND                     "go 0x40040000"
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_STOP_STR               " "
-#define CONFIG_AUTOBOOT_PROMPT                 \
-	"Hit SPACE in %d seconds to stop autoboot.\n", bootdelay
 
 #endif /* __CONFIG_H */
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
index d4688c5..75eba7d 100644
--- a/include/configs/uniphier.h
+++ b/include/configs/uniphier.h
@@ -200,11 +200,6 @@
 
 #define CONFIG_BOOTDELAY			3
 #define CONFIG_ZERO_BOOTDELAY_CHECK	/* check for keypress on bootdelay==0 */
-#define CONFIG_AUTOBOOT_KEYED			1
-#define CONFIG_AUTOBOOT_PROMPT	\
-	"Press SPACE to abort autoboot in %d seconds\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR		"d"
-#define CONFIG_AUTOBOOT_STOP_STR		" "
 
 /*
  * Network Configuration
diff --git a/include/configs/x600.h b/include/configs/x600.h
index 27a66a5..2b608bf 100644
--- a/include/configs/x600.h
+++ b/include/configs/x600.h
@@ -153,10 +153,6 @@
 #define CONFIG_LOOPW			/* enable loopw command         */
 #define CONFIG_MX_CYCLIC		/* enable mdc/mwc commands      */
 #define CONFIG_ZERO_BOOTDELAY_CHECK
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_STOP_STR		" "
-#define CONFIG_AUTOBOOT_PROMPT			\
-		"Hit SPACE in %d seconds to stop autoboot.\n", bootdelay
 
 #define CONFIG_SYS_MEMTEST_START		0x00800000
 #define CONFIG_SYS_MEMTEST_END			0x04000000
diff --git a/include/configs/zmx25.h b/include/configs/zmx25.h
index 342fa2c..23e1026 100644
--- a/include/configs/zmx25.h
+++ b/include/configs/zmx25.h
@@ -151,10 +151,6 @@
 #define CONFIG_PREBOOT  ""
 
 #define CONFIG_BOOTDELAY	5
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT "boot in %d s\n", bootdelay
-#define CONFIG_AUTOBOOT_DELAY_STR	"delaygs"
-#define CONFIG_AUTOBOOT_STOP_STR	"stopgs"
 
 /*
  * Size of malloc() pool
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password
  2015-05-07 12:13 [U-Boot] [PATCH v1 0/4] Add SHA256 encrypted stop string for autobooting Stefan Roese
                   ` (2 preceding siblings ...)
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig Stefan Roese
@ 2015-05-07 12:13 ` Stefan Roese
  2015-05-07 20:56   ` Magnus Lilja
  2015-05-08  7:52   ` [U-Boot] [PATCH v2 " Stefan Roese
  3 siblings, 2 replies; 29+ messages in thread
From: Stefan Roese @ 2015-05-07 12:13 UTC (permalink / raw)
  To: u-boot

This patch adds the feature to only stop the autobooting, and therefor
boot into the U-Boot prompt, when the input string / password matches
a values that is encypted via a SHA256 hash and saved in the environment.

This feature is enabled by defined these config options:
     CONFIG_AUTOBOOT_KEYED
     CONFIG_AUTOBOOT_STOP_STR_SHA256

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>

---

 common/Kconfig    |  20 ++++++++--
 common/autoboot.c | 112 +++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 107 insertions(+), 25 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index ff150f0..5d06558 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -45,9 +45,14 @@ config AUTOBOOT_PROMPT
 	  the responsibility of the user to select only such arguments
 	  that are valid in the given context.
 
+config AUTOBOOT_ENCRYPTION
+	bool "Enable encryption in autoboot stopping"
+	depends on AUTOBOOT_KEYED
+	default n
+
 config AUTOBOOT_DELAY_STR
 	string "Delay autobooting via specific input key / string"
-	depends on AUTOBOOT_KEYED
+	depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
 	help
 	  This option delays the automatic boot feature by issuing
 	  a specific input key or string. If CONFIG_AUTOBOOT_DELAY_STR
@@ -59,7 +64,7 @@ config AUTOBOOT_DELAY_STR
 
 config AUTOBOOT_STOP_STR
 	string "Stop autobooting via specific input key / string"
-	depends on AUTOBOOT_KEYED
+	depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
 	help
 	  This option enables stopping (aborting) of the automatic
 	  boot feature only by issuing a specific input key or
@@ -71,7 +76,7 @@ config AUTOBOOT_STOP_STR
 
 config AUTOBOOT_KEYED_CTRLC
 	bool "Enable Ctrl-C autoboot interruption"
-	depends on AUTOBOOT_KEYED
+	depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
 	default n
 	help
 	  This option allows for the boot sequence to be interrupted
@@ -79,6 +84,15 @@ config AUTOBOOT_KEYED_CTRLC
 	  Setting this variable	provides an escape sequence from the
 	  limited "password" strings.
 
+config AUTOBOOT_STOP_STR_SHA256
+	bool "Stop autobooting via SHA256 encrypted password"
+	depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION
+	help
+	  This option adds the feature to only stop the autobooting,
+	  and therefore boot into the U-Boot prompt, when the input
+	  string / password matches a values that is encypted via
+	  a SHA256 hash and saved in the environment.
+
 endmenu
 
 comment "Commands"
diff --git a/common/autoboot.c b/common/autoboot.c
index f72eb18..0fca6af 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -12,6 +12,7 @@
 #include <fdtdec.h>
 #include <menu.h>
 #include <post.h>
+#include <u-boot/sha256.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -26,15 +27,58 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Stored value of bootdelay, used by autoboot_command() */
 static int stored_bootdelay;
 
-/***************************************************************************
- * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
- * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
- */
-# if defined(CONFIG_AUTOBOOT_KEYED)
-static int abortboot_keyed(int bootdelay)
+#if defined(CONFIG_AUTOBOOT_KEYED)
+#if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256)
+static int passwd_abort(uint64_t etime)
+{
+	const char *sha_env_str = getenv("bootstopkeysha256");
+	u8 sha_env[SHA256_SUM_LEN];
+	u8 sha[SHA256_SUM_LEN];
+	char presskey[MAX_DELAY_STOP_STR];
+	u_int presskey_len = 0;
+	int i;
+	int abort = 0;
+
+	if (sha_env_str == NULL)
+		sha_env_str = CONFIG_AUTOBOOT_STOP_STR_SHA256;
+
+	/*
+	 * Generate the binary value from the environment hash value
+	 * so that we can compare this value with the computed hash
+	 * from the user input
+	 */
+	for (i = 0; i < SHA256_SUM_LEN; i++) {
+		char chr[3];
+
+		strncpy(chr, &sha_env_str[i * 2], 2);
+		sha_env[i] = simple_strtoul(chr, NULL, 16);
+	}
+
+	/*
+	 * We don't know how long the stop-string is, so we need to
+	 * generate the sha256 hash upon each input character and
+	 * compare the value with the one saved in the environment
+	 */
+	do {
+		if (tstc()) {
+			presskey[presskey_len++] = getc();
+
+			/* Calculate sha256 upon each new char */
+			sha256_csum_wd((unsigned char *)presskey, presskey_len,
+				       sha, CHUNKSZ_SHA256);
+
+			/* And check if sha matches saved value in env */
+			if (memcmp(sha, sha_env, SHA256_SUM_LEN) == 0)
+				abort = 1;
+		}
+	} while (!abort && get_ticks() <= etime);
+
+	return abort;
+}
+#else
+static int passwd_abort(uint64_t etime)
 {
 	int abort = 0;
-	uint64_t etime = endtick(bootdelay);
 	struct {
 		char *str;
 		u_int len;
@@ -42,7 +86,9 @@ static int abortboot_keyed(int bootdelay)
 	}
 	delaykey[] = {
 		{ .str = getenv("bootdelaykey"),  .retry = 1 },
+		{ .str = getenv("bootdelaykey2"), .retry = 1 },
 		{ .str = getenv("bootstopkey"),   .retry = 0 },
+		{ .str = getenv("bootstopkey2"),  .retry = 0 },
 	};
 
 	char presskey[MAX_DELAY_STOP_STR];
@@ -50,26 +96,21 @@ static int abortboot_keyed(int bootdelay)
 	u_int presskey_max = 0;
 	u_int i;
 
-#ifndef CONFIG_ZERO_BOOTDELAY_CHECK
-	if (bootdelay == 0)
-		return 0;
-#endif
-
-#  ifdef CONFIG_AUTOBOOT_PROMPT
-	/*
-	 * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
-	 * To print the bootdelay value upon bootup.
-	 */
-	printf(CONFIG_AUTOBOOT_PROMPT, bootdelay);
-#  endif
-
 #  ifdef CONFIG_AUTOBOOT_DELAY_STR
 	if (delaykey[0].str == NULL)
 		delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR;
 #  endif
-#  ifdef CONFIG_AUTOBOOT_STOP_STR
+#  ifdef CONFIG_AUTOBOOT_DELAY_STR2
 	if (delaykey[1].str == NULL)
-		delaykey[1].str = CONFIG_AUTOBOOT_STOP_STR;
+		delaykey[1].str = CONFIG_AUTOBOOT_DELAY_STR2;
+#  endif
+#  ifdef CONFIG_AUTOBOOT_STOP_STR
+	if (delaykey[2].str == NULL)
+		delaykey[2].str = CONFIG_AUTOBOOT_STOP_STR;
+#  endif
+#  ifdef CONFIG_AUTOBOOT_STOP_STR2
+	if (delaykey[3].str == NULL)
+		delaykey[3].str = CONFIG_AUTOBOOT_STOP_STR2;
 #  endif
 
 	for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i++) {
@@ -119,6 +160,33 @@ static int abortboot_keyed(int bootdelay)
 		}
 	} while (!abort && get_ticks() <= etime);
 
+	return abort;
+}
+#endif
+
+/***************************************************************************
+ * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
+ * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
+ */
+static int abortboot_keyed(int bootdelay)
+{
+	int abort;
+	uint64_t etime = endtick(bootdelay);
+
+#ifndef CONFIG_ZERO_BOOTDELAY_CHECK
+	if (bootdelay == 0)
+		return 0;
+#endif
+
+#  ifdef CONFIG_AUTOBOOT_PROMPT
+	/*
+	 * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
+	 * To print the bootdelay value upon bootup.
+	 */
+	printf(CONFIG_AUTOBOOT_PROMPT, bootdelay);
+#  endif
+
+	abort = passwd_abort(etime);
 	if (!abort)
 		debug_bootkeys("key timeout\n");
 
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values Stefan Roese
@ 2015-05-07 12:41   ` Masahiro Yamada
  2015-05-07 12:46     ` Stefan Roese
  2015-05-10 14:48   ` Simon Glass
  1 sibling, 1 reply; 29+ messages in thread
From: Masahiro Yamada @ 2015-05-07 12:41 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

2015-05-07 21:13 GMT+09:00 Stefan Roese <sr@denx.de>:
> I might have missed something, but I failed to use the escape char '\'
> in strings. To pass a printf format string like "foo %d bar\n" via
> Kconfig to the code.
>
> Right now its not possible to use the escape character '\' in Kconfig
> string values correctly to e.g. set this string value "test output\n".
> The '\n' will be converted to 'n'.
>
> The current implementation removes some of the '\' chars from the input
> string in conf_set_sym_val(). Examples:
>
> '\'     -> ''
> '\\'    -> '\'
> '\\\'   -> '\'
> '\\\\'  -> '\\'
> ...
>
> And then doubles the backslash chars in the output string in
> sym_escape_string_value(). Example:
>
> '\'     -> ''   -> ''
> '\\'    -> '\'  -> '\\'
> '\\\'   -> '\'  -> '\\'
> '\\\\'  -> '\\' -> '\\\\'
> ...
>
> As you see in these examples, its impossible to generate a single '\'
> charater in the output string as its needed for something like '\n'.
>
> This patch now changes this behavior to not drop some backslashes in
> conf_set_sym_val() and to not add new backslashes in the resulting
> output string. Removing the function sym_escape_string_value()
> completely as its not needed anymore.


Interesting.
I did not know this behavior of strings in Kconfig.

I want to see the reaction from linux-kconfig ML.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-07 12:41   ` Masahiro Yamada
@ 2015-05-07 12:46     ` Stefan Roese
  2015-05-07 12:53       ` Masahiro Yamada
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Roese @ 2015-05-07 12:46 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 07.05.2015 14:41, Masahiro Yamada wrote:
> 2015-05-07 21:13 GMT+09:00 Stefan Roese <sr@denx.de>:
>> I might have missed something, but I failed to use the escape char '\'
>> in strings. To pass a printf format string like "foo %d bar\n" via
>> Kconfig to the code.
>>
>> Right now its not possible to use the escape character '\' in Kconfig
>> string values correctly to e.g. set this string value "test output\n".
>> The '\n' will be converted to 'n'.
>>
>> The current implementation removes some of the '\' chars from the input
>> string in conf_set_sym_val(). Examples:
>>
>> '\'     -> ''
>> '\\'    -> '\'
>> '\\\'   -> '\'
>> '\\\\'  -> '\\'
>> ...
>>
>> And then doubles the backslash chars in the output string in
>> sym_escape_string_value(). Example:
>>
>> '\'     -> ''   -> ''
>> '\\'    -> '\'  -> '\\'
>> '\\\'   -> '\'  -> '\\'
>> '\\\\'  -> '\\' -> '\\\\'
>> ...
>>
>> As you see in these examples, its impossible to generate a single '\'
>> charater in the output string as its needed for something like '\n'.
>>
>> This patch now changes this behavior to not drop some backslashes in
>> conf_set_sym_val() and to not add new backslashes in the resulting
>> output string. Removing the function sym_escape_string_value()
>> completely as its not needed anymore.
>
>
> Interesting.
> I did not know this behavior of strings in Kconfig.

Then I'm not the only one. ;)

> I want to see the reaction from linux-kconfig ML.

Okay. It makes sense then to send this patch to this list right away. A 
quick search didn't reveal any results though. Where is this list hosted?

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-07 12:46     ` Stefan Roese
@ 2015-05-07 12:53       ` Masahiro Yamada
  0 siblings, 0 replies; 29+ messages in thread
From: Masahiro Yamada @ 2015-05-07 12:53 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

2015-05-07 21:46 GMT+09:00 Stefan Roese <sr@denx.de>:
> Hi Masahiro,
>
>
> On 07.05.2015 14:41, Masahiro Yamada wrote:
>>
>> 2015-05-07 21:13 GMT+09:00 Stefan Roese <sr@denx.de>:
>>>
>>> I might have missed something, but I failed to use the escape char '\'
>>> in strings. To pass a printf format string like "foo %d bar\n" via
>>> Kconfig to the code.
>>>
>>> Right now its not possible to use the escape character '\' in Kconfig
>>> string values correctly to e.g. set this string value "test output\n".
>>> The '\n' will be converted to 'n'.
>>>
>>> The current implementation removes some of the '\' chars from the input
>>> string in conf_set_sym_val(). Examples:
>>>
>>> '\'     -> ''
>>> '\\'    -> '\'
>>> '\\\'   -> '\'
>>> '\\\\'  -> '\\'
>>> ...
>>>
>>> And then doubles the backslash chars in the output string in
>>> sym_escape_string_value(). Example:
>>>
>>> '\'     -> ''   -> ''
>>> '\\'    -> '\'  -> '\\'
>>> '\\\'   -> '\'  -> '\\'
>>> '\\\\'  -> '\\' -> '\\\\'
>>> ...
>>>
>>> As you see in these examples, its impossible to generate a single '\'
>>> charater in the output string as its needed for something like '\n'.
>>>
>>> This patch now changes this behavior to not drop some backslashes in
>>> conf_set_sym_val() and to not add new backslashes in the resulting
>>> output string. Removing the function sym_escape_string_value()
>>> completely as its not needed anymore.
>>
>>
>>
>> Interesting.
>> I did not know this behavior of strings in Kconfig.
>
>
> Then I'm not the only one. ;)
>
>> I want to see the reaction from linux-kconfig ML.
>
>
> Okay. It makes sense then to send this patch to this list right away. A
> quick search didn't reveal any results though. Where is this list hosted?


Sorry, there is no decicated ML for Kconfig.

Kconfig patches should go to linux-kbuild ML
(linux-kbuild at vger.kernel.org).

If you want to subscribe to the list, please visit
http://vger.kernel.org/vger-lists.html#linux-kbuild


Yann E. MORIN is not active these days, so I think Michal Marek is the
maintainer.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password Stefan Roese
@ 2015-05-07 20:56   ` Magnus Lilja
  2015-05-08  7:52   ` [U-Boot] [PATCH v2 " Stefan Roese
  1 sibling, 0 replies; 29+ messages in thread
From: Magnus Lilja @ 2015-05-07 20:56 UTC (permalink / raw)
  To: u-boot

Hi Stefan

On 7 May 2015 at 14:13, Stefan Roese <sr@denx.de> wrote:
> This patch adds the feature to only stop the autobooting, and therefor
> boot into the U-Boot prompt, when the input string / password matches
> a values that is encypted via a SHA256 hash and saved in the environment.
>
> This feature is enabled by defined these config options:
>      CONFIG_AUTOBOOT_KEYED
>      CONFIG_AUTOBOOT_STOP_STR_SHA256
>
> +       /*
> +        * Generate the binary value from the environment hash value
> +        * so that we can compare this value with the computed hash
> +        * from the user input
> +        */
> +       for (i = 0; i < SHA256_SUM_LEN; i++) {
> +               char chr[3];
> +
> +               strncpy(chr, &sha_env_str[i * 2], 2);
> +               sha_env[i] = simple_strtoul(chr, NULL, 16);
> +       }
> +
> +       /*
> +        * We don't know how long the stop-string is, so we need to
> +        * generate the sha256 hash upon each input character and
> +        * compare the value with the one saved in the environment
> +        */
> +       do {
> +               if (tstc()) {
> +                       presskey[presskey_len++] = getc();
> +
> +                       /* Calculate sha256 upon each new char */
> +                       sha256_csum_wd((unsigned char *)presskey, presskey_len,
> +                                      sha, CHUNKSZ_SHA256);
> +
> +                       /* And check if sha matches saved value in env */
> +                       if (memcmp(sha, sha_env, SHA256_SUM_LEN) == 0)
> +                               abort = 1;
> +               }
> +       } while (!abort && get_ticks() <= etime);

I don't know what the security requirements are for this feature, i.e.
what strength the mechanism should have but:

1. Simply hashing the password is not recommended, a long salt
(generated by a good random number generator) should be pre-pended to
the passphrase before hashing. See [1]

2. Using memcmp() is not recommended for the above comparison. See [1]
(SlowEqual example).


3. I haven't looked closely@the code above but it looks to me that
there is no check that the stop-string entered by the user/attacker
fits the presskey buffer. I.e. a buffer overflow attack might be
possible.


[1] https://crackstation.net/hashing-security.htm

Regards, Magnus

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 2/4] autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 2/4] autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2 Stefan Roese
@ 2015-05-07 23:47   ` Simon Glass
  2015-05-11 12:38   ` Tom Rini
  1 sibling, 0 replies; 29+ messages in thread
From: Simon Glass @ 2015-05-07 23:47 UTC (permalink / raw)
  To: u-boot

On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>
> These defines for a 2nd autoboot stop and delay string are nearly unused. Only
> sc3 defines CONFIG_AUTOBOOT_DELAY_STR2. And a patch to remove this most likely
> unmaintained board is also posted to the list.
>
> By removing these defines the code will become cleaner and moving the remaining
> compile options to Kconfig will get easier.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>
>  README              |  2 --
>  common/autoboot.c   | 14 ++------------
>  doc/README.autoboot | 10 ----------
>  3 files changed, 2 insertions(+), 24 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig Stefan Roese
@ 2015-05-07 23:51   ` Simon Glass
  2015-05-08  3:30     ` Masahiro Yamada
  2015-05-08  5:55     ` Stefan Roese
  0 siblings, 2 replies; 29+ messages in thread
From: Simon Glass @ 2015-05-07 23:51 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
> This patch moves the following config options to Kconfig:
>
> CONFIG_AUTOBOOT_KEYED
> CONFIG_AUTOBOOT_PROMPT
> CONFIG_AUTOBOOT_DELAY_STR
> CONFIG_AUTOBOOT_STOP_STR
> AUTOBOOT_KEYED_CTRLC
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>
>  common/Kconfig                           | 64 ++++++++++++++++++++++++++++++++
>  common/autoboot.c                        |  6 ++-
>  configs/CPCI4052_defconfig               |  3 ++
>  configs/O2DNT2_RAMBOOT_defconfig         |  3 ++
>  configs/O2DNT2_defconfig                 |  3 ++
>  configs/PLU405_defconfig                 |  3 ++
>  configs/PMC405DE_defconfig               |  3 ++
>  configs/PMC440_defconfig                 |  3 ++
>  configs/UCP1020_SPIFLASH_defconfig       |  3 ++
>  configs/UCP1020_defconfig                |  3 ++
>  configs/a4m072_defconfig                 |  3 ++
>  configs/atngw100_defconfig               |  4 ++
>  configs/atngw100mkii_defconfig           |  4 ++
>  configs/atstk1002_defconfig              |  4 ++
>  configs/atstk1003_defconfig              |  4 ++
>  configs/atstk1004_defconfig              |  4 ++
>  configs/atstk1006_defconfig              |  4 ++
>  configs/calimain_defconfig               |  2 +
>  configs/cpuat91_defconfig                |  4 ++
>  configs/cpuat91_ram_defconfig            |  3 ++
>  configs/digsy_mtc_RAMBOOT_defconfig      |  3 ++
>  configs/digsy_mtc_defconfig              |  3 ++
>  configs/digsy_mtc_rev5_RAMBOOT_defconfig |  3 ++
>  configs/digsy_mtc_rev5_defconfig         |  3 ++
>  configs/dlvision-10g_defconfig           |  2 +
>  configs/draco_defconfig                  |  3 ++
>  configs/dxr2_defconfig                   |  3 ++
>  configs/favr-32-ezkit_defconfig          |  4 ++
>  configs/gdppc440etx_defconfig            |  2 +
>  configs/grasshopper_defconfig            |  4 ++
>  configs/hammerhead_defconfig             |  4 ++
>  configs/highbank_defconfig               |  3 ++
>  configs/hrcon_defconfig                  |  2 +
>  configs/ids8313_defconfig                |  3 ++
>  configs/intip_defconfig                  |  2 +
>  configs/io64_defconfig                   |  2 +
>  configs/io_defconfig                     |  2 +
>  configs/iocon_defconfig                  |  2 +
>  configs/ip04_defconfig                   |  1 +
>  configs/motionpro_defconfig              |  3 ++
>  configs/nokia_rx51_defconfig             |  1 +
>  configs/omap3_mvblx_defconfig            |  2 +
>  configs/ph1_ld4_defconfig                |  4 ++
>  configs/ph1_pro4_defconfig               |  4 ++
>  configs/ph1_sld8_defconfig               |  4 ++
>  configs/pm9263_defconfig                 |  1 +
>  configs/pxm2_defconfig                   |  3 ++
>  configs/rut_defconfig                    |  3 ++
>  configs/spear600_defconfig               |  3 ++
>  configs/stv0991_defconfig                |  3 ++
>  configs/x600_defconfig                   |  3 ++
>  configs/zmx25_defconfig                  |  4 ++
>  include/configs/CPCI4052.h               |  6 ---
>  include/configs/PLU405.h                 |  9 -----
>  include/configs/PMC405DE.h               |  6 ---
>  include/configs/PMC440.h                 |  6 ---
>  include/configs/UCP1020.h                | 11 ------
>  include/configs/a4m072.h                 |  4 --
>  include/configs/atngw100.h               | 10 -----
>  include/configs/atngw100mkii.h           | 10 -----
>  include/configs/atstk1002.h              | 10 -----
>  include/configs/atstk1003.h              | 10 -----
>  include/configs/atstk1004.h              | 10 -----
>  include/configs/atstk1006.h              | 10 -----
>  include/configs/bf537-stamp.h            |  4 --
>  include/configs/calimain.h               |  2 -
>  include/configs/cpuat91.h                |  6 ---
>  include/configs/digsy_mtc.h              |  4 --
>  include/configs/dlvision-10g.h           |  2 -
>  include/configs/favr-32-ezkit.h          | 10 -----
>  include/configs/gdppc440etx.h            |  2 -
>  include/configs/grasshopper.h            | 10 -----
>  include/configs/hammerhead.h             | 10 -----
>  include/configs/highbank.h               |  4 +-
>  include/configs/hrcon.h                  |  2 -
>  include/configs/ids8313.h                |  4 --
>  include/configs/intip.h                  |  2 -
>  include/configs/io.h                     |  2 -
>  include/configs/io64.h                   |  2 -
>  include/configs/iocon.h                  |  2 -
>  include/configs/ip04.h                   |  1 -
>  include/configs/motionpro.h              |  6 ---
>  include/configs/nokia_rx51.h             |  1 -
>  include/configs/o2dnt-common.h           | 12 ------
>  include/configs/omap3_mvblx.h            |  2 -
>  include/configs/pm9263.h                 |  1 -
>  include/configs/siemens-am33x-common.h   |  6 ---
>  include/configs/spear-common.h           |  4 --
>  include/configs/stv0991.h                |  4 --
>  include/configs/uniphier.h               |  5 ---
>  include/configs/x600.h                   |  4 --
>  include/configs/zmx25.h                  |  4 --
>  92 files changed, 219 insertions(+), 220 deletions(-)
>
> diff --git a/common/Kconfig b/common/Kconfig
> index 15759f7..ff150f0 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -17,6 +17,70 @@ config SYS_HUSH_PARSER
>         help
>           Backward compatibility.
>
> +menu "Autoboot options"
> +
> +config AUTOBOOT_KEYED
> +       bool "Stop autobooting via specific input key / string"
> +       default n
> +       help
> +         This option enables stopping (aborting) of the automatic
> +         boot feature only by issuing a specific input key or
> +         string. If not enabled, any input key will abort the
> +         U-Boot automatic booting process and bring the device
> +         to the U-Boot prompt for user input.
> +
> +config AUTOBOOT_PROMPT
> +       string "Autoboot stop prompt"
> +       depends on AUTOBOOT_KEYED
> +       default "Autoboot in %d seconds\n"

Doesn't this mean that the autoboot message will always be printed? I
wonder if we need a separate 'AUTOBOOT' to enable the feature?

[snip]

Regards,
Simon

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig
  2015-05-07 23:51   ` Simon Glass
@ 2015-05-08  3:30     ` Masahiro Yamada
  2015-05-08  6:00       ` Stefan Roese
  2015-05-08  5:55     ` Stefan Roese
  1 sibling, 1 reply; 29+ messages in thread
From: Masahiro Yamada @ 2015-05-08  3:30 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

2015-05-08 8:51 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Stefan,
>
> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>> This patch moves the following config options to Kconfig:
>>
>> CONFIG_AUTOBOOT_KEYED
>> CONFIG_AUTOBOOT_PROMPT
>> CONFIG_AUTOBOOT_DELAY_STR
>> CONFIG_AUTOBOOT_STOP_STR
>> AUTOBOOT_KEYED_CTRLC
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Cc: Simon Glass <sjg@chromium.org>


Thanks for working on a task requiring much effort.


I am just wondering if we need not move the prompt messages verbatim to Kconfig.

I know CONFIG_AUTOBOOT_PROMPT provides us the best flexibility,
but the messages are most likely "autoboot in %d seconds" or "Press ...".

Can we put the message directly into common/autoboot.c like this?

 #ifdef CONFIG_SHOW_AUTOBOOT_PROMPT
        printf("Autoboot in %d seconds\n", CONFIG_BOOTDELAY);
        printf("Press %c to abort in %d seconds\n", CONFIG_AUTOBOOT_STOP_STR);
 #endif


I think I am missing some things here:
  - Those boards that require a password do not want to show it
  - We need to convert " " to user-visible "<SPACE>" if
CONFIG_AUTOBOOT_STOP_STP == " "


Any ideas?


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig
  2015-05-07 23:51   ` Simon Glass
  2015-05-08  3:30     ` Masahiro Yamada
@ 2015-05-08  5:55     ` Stefan Roese
  2015-05-10 14:49       ` Simon Glass
  1 sibling, 1 reply; 29+ messages in thread
From: Stefan Roese @ 2015-05-08  5:55 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 08.05.2015 01:51, Simon Glass wrote:
> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>> This patch moves the following config options to Kconfig:
>>
>> CONFIG_AUTOBOOT_KEYED
>> CONFIG_AUTOBOOT_PROMPT
>> CONFIG_AUTOBOOT_DELAY_STR
>> CONFIG_AUTOBOOT_STOP_STR
>> AUTOBOOT_KEYED_CTRLC
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>>

<snip>

>> diff --git a/common/Kconfig b/common/Kconfig
>> index 15759f7..ff150f0 100644
>> --- a/common/Kconfig
>> +++ b/common/Kconfig
>> @@ -17,6 +17,70 @@ config SYS_HUSH_PARSER
>>          help
>>            Backward compatibility.
>>
>> +menu "Autoboot options"
>> +
>> +config AUTOBOOT_KEYED
>> +       bool "Stop autobooting via specific input key / string"
>> +       default n
>> +       help
>> +         This option enables stopping (aborting) of the automatic
>> +         boot feature only by issuing a specific input key or
>> +         string. If not enabled, any input key will abort the
>> +         U-Boot automatic booting process and bring the device
>> +         to the U-Boot prompt for user input.
>> +
>> +config AUTOBOOT_PROMPT
>> +       string "Autoboot stop prompt"
>> +       depends on AUTOBOOT_KEYED
>> +       default "Autoboot in %d seconds\n"
>
> Doesn't this mean that the autoboot message will always be printed? I
> wonder if we need a separate 'AUTOBOOT' to enable the feature?

AUTOBOOT_PROMPT is enabled now via AUTOBOOT_KEYED. Most boards don't 
enable this option, so nothing is changed for those boards.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig
  2015-05-08  3:30     ` Masahiro Yamada
@ 2015-05-08  6:00       ` Stefan Roese
  0 siblings, 0 replies; 29+ messages in thread
From: Stefan Roese @ 2015-05-08  6:00 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 08.05.2015 05:30, Masahiro Yamada wrote:
> 2015-05-08 8:51 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> Hi Stefan,
>>
>> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>>> This patch moves the following config options to Kconfig:
>>>
>>> CONFIG_AUTOBOOT_KEYED
>>> CONFIG_AUTOBOOT_PROMPT
>>> CONFIG_AUTOBOOT_DELAY_STR
>>> CONFIG_AUTOBOOT_STOP_STR
>>> AUTOBOOT_KEYED_CTRLC
>>>
>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> Cc: Simon Glass <sjg@chromium.org>
>
>
> Thanks for working on a task requiring much effort.

Yes. I really admire you for all your hard work on this. Now that I've 
done a tiny bit here as well. ;)

> I am just wondering if we need not move the prompt messages verbatim to Kconfig.
>
> I know CONFIG_AUTOBOOT_PROMPT provides us the best flexibility,
> but the messages are most likely "autoboot in %d seconds" or "Press ...".
>
> Can we put the message directly into common/autoboot.c like this?
>
>   #ifdef CONFIG_SHOW_AUTOBOOT_PROMPT
>          printf("Autoboot in %d seconds\n", CONFIG_BOOTDELAY);
>          printf("Press %c to abort in %d seconds\n", CONFIG_AUTOBOOT_STOP_STR);
>   #endif
>
>
> I think I am missing some things here:
>    - Those boards that require a password do not want to show it
>    - We need to convert " " to user-visible "<SPACE>" if
> CONFIG_AUTOBOOT_STOP_STP == " "
>
>
> Any ideas?

Unfortunately not all boards print such a message. There is quite a 
range of alternatives, I'm afraid. Some boards use 
CONFIG_AUTOBOOT_STOP_STR, some CONFIG_AUTOBOOT_DELAY_STR. Some print 
this string / char, some don't. So we can't really convert them all into 
such a generic implementation. Without breaking backward (user) 
compatibility. At least I don't see such a way.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v2 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password Stefan Roese
  2015-05-07 20:56   ` Magnus Lilja
@ 2015-05-08  7:52   ` Stefan Roese
  2015-05-10 14:49     ` Simon Glass
                       ` (2 more replies)
  1 sibling, 3 replies; 29+ messages in thread
From: Stefan Roese @ 2015-05-08  7:52 UTC (permalink / raw)
  To: u-boot

This patch adds the feature to only stop the autobooting, and therefor
boot into the U-Boot prompt, when the input string / password matches
a values that is encypted via a SHA256 hash and saved in the environment.

This feature is enabled by defined these config options:
     CONFIG_AUTOBOOT_KEYED
     CONFIG_AUTOBOOT_STOP_STR_SHA256

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Magnus Lilja <lilja.magnus@gmail.com>
---
v2:
- AUTOBOOT_STOP_STR_SHA256 is a string and not bool
- Add input key length check as suggested by Magnus
- Add "constant-length" time compare function as suggested
  by Magnus

 common/Kconfig    |  20 +++++++--
 common/autoboot.c | 132 +++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 128 insertions(+), 24 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index ff150f0..71c5c10 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -45,9 +45,14 @@ config AUTOBOOT_PROMPT
 	  the responsibility of the user to select only such arguments
 	  that are valid in the given context.
 
+config AUTOBOOT_ENCRYPTION
+	bool "Enable encryption in autoboot stopping"
+	depends on AUTOBOOT_KEYED
+	default n
+
 config AUTOBOOT_DELAY_STR
 	string "Delay autobooting via specific input key / string"
-	depends on AUTOBOOT_KEYED
+	depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
 	help
 	  This option delays the automatic boot feature by issuing
 	  a specific input key or string. If CONFIG_AUTOBOOT_DELAY_STR
@@ -59,7 +64,7 @@ config AUTOBOOT_DELAY_STR
 
 config AUTOBOOT_STOP_STR
 	string "Stop autobooting via specific input key / string"
-	depends on AUTOBOOT_KEYED
+	depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
 	help
 	  This option enables stopping (aborting) of the automatic
 	  boot feature only by issuing a specific input key or
@@ -71,7 +76,7 @@ config AUTOBOOT_STOP_STR
 
 config AUTOBOOT_KEYED_CTRLC
 	bool "Enable Ctrl-C autoboot interruption"
-	depends on AUTOBOOT_KEYED
+	depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
 	default n
 	help
 	  This option allows for the boot sequence to be interrupted
@@ -79,6 +84,15 @@ config AUTOBOOT_KEYED_CTRLC
 	  Setting this variable	provides an escape sequence from the
 	  limited "password" strings.
 
+config AUTOBOOT_STOP_STR_SHA256
+	string "Stop autobooting via SHA256 encrypted password"
+	depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION
+	help
+	  This option adds the feature to only stop the autobooting,
+	  and therefore boot into the U-Boot prompt, when the input
+	  string / password matches a values that is encypted via
+	  a SHA256 hash and saved in the environment.
+
 endmenu
 
 comment "Commands"
diff --git a/common/autoboot.c b/common/autoboot.c
index f72eb18..dde3d04 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -12,6 +12,7 @@
 #include <fdtdec.h>
 #include <menu.h>
 #include <post.h>
+#include <u-boot/sha256.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -26,15 +27,80 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Stored value of bootdelay, used by autoboot_command() */
 static int stored_bootdelay;
 
-/***************************************************************************
- * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
- * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
+#if defined(CONFIG_AUTOBOOT_KEYED)
+#if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256)
+
+/*
+ * Use a "constant-length" time compare function for this
+ * hash compare:
+ *
+ * https://crackstation.net/hashing-security.htm
  */
-# if defined(CONFIG_AUTOBOOT_KEYED)
-static int abortboot_keyed(int bootdelay)
+static int slow_equals(u8 *a, u8 *b, int len)
+{
+	int diff = 0;
+	int i;
+
+	for (i = 0; i < len; i++)
+		diff |= a[i] ^ b[i];
+
+	return diff == 0;
+}
+
+static int passwd_abort(uint64_t etime)
+{
+	const char *sha_env_str = getenv("bootstopkeysha256");
+	u8 sha_env[SHA256_SUM_LEN];
+	u8 sha[SHA256_SUM_LEN];
+	char presskey[MAX_DELAY_STOP_STR];
+	u_int presskey_len = 0;
+	int i;
+	int abort = 0;
+
+	if (sha_env_str == NULL)
+		sha_env_str = CONFIG_AUTOBOOT_STOP_STR_SHA256;
+
+	/*
+	 * Generate the binary value from the environment hash value
+	 * so that we can compare this value with the computed hash
+	 * from the user input
+	 */
+	for (i = 0; i < SHA256_SUM_LEN; i++) {
+		char chr[3];
+
+		strncpy(chr, &sha_env_str[i * 2], 2);
+		sha_env[i] = simple_strtoul(chr, NULL, 16);
+	}
+
+	/*
+	 * We don't know how long the stop-string is, so we need to
+	 * generate the sha256 hash upon each input character and
+	 * compare the value with the one saved in the environment
+	 */
+	do {
+		if (tstc()) {
+			/* Check for input string overflow */
+			if (presskey_len >= MAX_DELAY_STOP_STR)
+				return 0;
+
+			presskey[presskey_len++] = getc();
+
+			/* Calculate sha256 upon each new char */
+			sha256_csum_wd((unsigned char *)presskey, presskey_len,
+				       sha, CHUNKSZ_SHA256);
+
+			/* And check if sha matches saved value in env */
+			if (slow_equals(sha, sha_env, SHA256_SUM_LEN))
+				abort = 1;
+		}
+	} while (!abort && get_ticks() <= etime);
+
+	return abort;
+}
+#else
+static int passwd_abort(uint64_t etime)
 {
 	int abort = 0;
-	uint64_t etime = endtick(bootdelay);
 	struct {
 		char *str;
 		u_int len;
@@ -42,7 +108,9 @@ static int abortboot_keyed(int bootdelay)
 	}
 	delaykey[] = {
 		{ .str = getenv("bootdelaykey"),  .retry = 1 },
+		{ .str = getenv("bootdelaykey2"), .retry = 1 },
 		{ .str = getenv("bootstopkey"),   .retry = 0 },
+		{ .str = getenv("bootstopkey2"),  .retry = 0 },
 	};
 
 	char presskey[MAX_DELAY_STOP_STR];
@@ -50,26 +118,21 @@ static int abortboot_keyed(int bootdelay)
 	u_int presskey_max = 0;
 	u_int i;
 
-#ifndef CONFIG_ZERO_BOOTDELAY_CHECK
-	if (bootdelay == 0)
-		return 0;
-#endif
-
-#  ifdef CONFIG_AUTOBOOT_PROMPT
-	/*
-	 * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
-	 * To print the bootdelay value upon bootup.
-	 */
-	printf(CONFIG_AUTOBOOT_PROMPT, bootdelay);
-#  endif
-
 #  ifdef CONFIG_AUTOBOOT_DELAY_STR
 	if (delaykey[0].str == NULL)
 		delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR;
 #  endif
-#  ifdef CONFIG_AUTOBOOT_STOP_STR
+#  ifdef CONFIG_AUTOBOOT_DELAY_STR2
 	if (delaykey[1].str == NULL)
-		delaykey[1].str = CONFIG_AUTOBOOT_STOP_STR;
+		delaykey[1].str = CONFIG_AUTOBOOT_DELAY_STR2;
+#  endif
+#  ifdef CONFIG_AUTOBOOT_STOP_STR
+	if (delaykey[2].str == NULL)
+		delaykey[2].str = CONFIG_AUTOBOOT_STOP_STR;
+#  endif
+#  ifdef CONFIG_AUTOBOOT_STOP_STR2
+	if (delaykey[3].str == NULL)
+		delaykey[3].str = CONFIG_AUTOBOOT_STOP_STR2;
 #  endif
 
 	for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i++) {
@@ -119,6 +182,33 @@ static int abortboot_keyed(int bootdelay)
 		}
 	} while (!abort && get_ticks() <= etime);
 
+	return abort;
+}
+#endif
+
+/***************************************************************************
+ * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
+ * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
+ */
+static int abortboot_keyed(int bootdelay)
+{
+	int abort;
+	uint64_t etime = endtick(bootdelay);
+
+#ifndef CONFIG_ZERO_BOOTDELAY_CHECK
+	if (bootdelay == 0)
+		return 0;
+#endif
+
+#  ifdef CONFIG_AUTOBOOT_PROMPT
+	/*
+	 * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
+	 * To print the bootdelay value upon bootup.
+	 */
+	printf(CONFIG_AUTOBOOT_PROMPT, bootdelay);
+#  endif
+
+	abort = passwd_abort(etime);
 	if (!abort)
 		debug_bootkeys("key timeout\n");
 
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values Stefan Roese
  2015-05-07 12:41   ` Masahiro Yamada
@ 2015-05-10 14:48   ` Simon Glass
  2015-05-11  7:58     ` Stefan Roese
  1 sibling, 1 reply; 29+ messages in thread
From: Simon Glass @ 2015-05-10 14:48 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
> I might have missed something, but I failed to use the escape char '\'
> in strings. To pass a printf format string like "foo %d bar\n" via
> Kconfig to the code.
>
> Right now its not possible to use the escape character '\' in Kconfig
> string values correctly to e.g. set this string value "test output\n".
> The '\n' will be converted to 'n'.
>
> The current implementation removes some of the '\' chars from the input
> string in conf_set_sym_val(). Examples:
>
> '\'     -> ''
> '\\'    -> '\'
> '\\\'   -> '\'
> '\\\\'  -> '\\'
> ...
>
> And then doubles the backslash chars in the output string in
> sym_escape_string_value(). Example:
>
> '\'     -> ''   -> ''
> '\\'    -> '\'  -> '\\'
> '\\\'   -> '\'  -> '\\'
> '\\\\'  -> '\\' -> '\\\\'
> ...
>
> As you see in these examples, its impossible to generate a single '\'
> charater in the output string as its needed for something like '\n'.
>
> This patch now changes this behavior to not drop some backslashes in
> conf_set_sym_val() and to not add new backslashes in the resulting
> output string. Removing the function sym_escape_string_value()
> completely as its not needed anymore.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>
>  scripts/kconfig/confdata.c | 20 +++++++++-----------
>  scripts/kconfig/symbol.c   | 43 -------------------------------------------
>  2 files changed, 9 insertions(+), 54 deletions(-)

This looks right to me. But I do see one problem - the default string
for CONFIG_AUTOBOOT_PROMPT appears as:

"Autoboot in %d secondsn"

so something is still removing the \ in the Kconfig default;

[snip]

Regards,
Simon

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig
  2015-05-08  5:55     ` Stefan Roese
@ 2015-05-10 14:49       ` Simon Glass
  0 siblings, 0 replies; 29+ messages in thread
From: Simon Glass @ 2015-05-10 14:49 UTC (permalink / raw)
  To: u-boot

On 7 May 2015 at 23:55, Stefan Roese <sr@denx.de> wrote:
> Hi Simon,
>
> On 08.05.2015 01:51, Simon Glass wrote:
>>
>> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>>>
>>> This patch moves the following config options to Kconfig:
>>>
>>> CONFIG_AUTOBOOT_KEYED
>>> CONFIG_AUTOBOOT_PROMPT
>>> CONFIG_AUTOBOOT_DELAY_STR
>>> CONFIG_AUTOBOOT_STOP_STR
>>> AUTOBOOT_KEYED_CTRLC
>>>
>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> Cc: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>
> <snip>
>
>
>>> diff --git a/common/Kconfig b/common/Kconfig
>>> index 15759f7..ff150f0 100644
>>> --- a/common/Kconfig
>>> +++ b/common/Kconfig
>>> @@ -17,6 +17,70 @@ config SYS_HUSH_PARSER
>>>          help
>>>            Backward compatibility.
>>>
>>> +menu "Autoboot options"
>>> +
>>> +config AUTOBOOT_KEYED
>>> +       bool "Stop autobooting via specific input key / string"
>>> +       default n
>>> +       help
>>> +         This option enables stopping (aborting) of the automatic
>>> +         boot feature only by issuing a specific input key or
>>> +         string. If not enabled, any input key will abort the
>>> +         U-Boot automatic booting process and bring the device
>>> +         to the U-Boot prompt for user input.
>>> +
>>> +config AUTOBOOT_PROMPT
>>> +       string "Autoboot stop prompt"
>>> +       depends on AUTOBOOT_KEYED
>>> +       default "Autoboot in %d seconds\n"
>>
>>
>> Doesn't this mean that the autoboot message will always be printed? I
>> wonder if we need a separate 'AUTOBOOT' to enable the feature?
>
>
> AUTOBOOT_PROMPT is enabled now via AUTOBOOT_KEYED. Most boards don't enable
> this option, so nothing is changed for those boards.

Thanks.

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v2 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password
  2015-05-08  7:52   ` [U-Boot] [PATCH v2 " Stefan Roese
@ 2015-05-10 14:49     ` Simon Glass
  2015-05-11  7:16     ` Andreas Bießmann
  2015-05-15  7:44     ` Magnus Lilja
  2 siblings, 0 replies; 29+ messages in thread
From: Simon Glass @ 2015-05-10 14:49 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 8 May 2015 at 01:52, Stefan Roese <sr@denx.de> wrote:
> This patch adds the feature to only stop the autobooting, and therefor
> boot into the U-Boot prompt, when the input string / password matches
> a values that is encypted via a SHA256 hash and saved in the environment.
>
> This feature is enabled by defined these config options:
>      CONFIG_AUTOBOOT_KEYED
>      CONFIG_AUTOBOOT_STOP_STR_SHA256
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Magnus Lilja <lilja.magnus@gmail.com>
> ---
> v2:
> - AUTOBOOT_STOP_STR_SHA256 is a string and not bool
> - Add input key length check as suggested by Magnus
> - Add "constant-length" time compare function as suggested
>   by Magnus
>
>  common/Kconfig    |  20 +++++++--
>  common/autoboot.c | 132 +++++++++++++++++++++++++++++++++++++++++++++---------
>  2 files changed, 128 insertions(+), 24 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

A few optional ideas below.

>
> diff --git a/common/Kconfig b/common/Kconfig
> index ff150f0..71c5c10 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -45,9 +45,14 @@ config AUTOBOOT_PROMPT
>           the responsibility of the user to select only such arguments
>           that are valid in the given context.
>
> +config AUTOBOOT_ENCRYPTION
> +       bool "Enable encryption in autoboot stopping"
> +       depends on AUTOBOOT_KEYED
> +       default n
> +
>  config AUTOBOOT_DELAY_STR
>         string "Delay autobooting via specific input key / string"
> -       depends on AUTOBOOT_KEYED
> +       depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
>         help
>           This option delays the automatic boot feature by issuing
>           a specific input key or string. If CONFIG_AUTOBOOT_DELAY_STR
> @@ -59,7 +64,7 @@ config AUTOBOOT_DELAY_STR
>
>  config AUTOBOOT_STOP_STR
>         string "Stop autobooting via specific input key / string"
> -       depends on AUTOBOOT_KEYED
> +       depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
>         help
>           This option enables stopping (aborting) of the automatic
>           boot feature only by issuing a specific input key or
> @@ -71,7 +76,7 @@ config AUTOBOOT_STOP_STR
>
>  config AUTOBOOT_KEYED_CTRLC
>         bool "Enable Ctrl-C autoboot interruption"
> -       depends on AUTOBOOT_KEYED
> +       depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION
>         default n
>         help
>           This option allows for the boot sequence to be interrupted
> @@ -79,6 +84,15 @@ config AUTOBOOT_KEYED_CTRLC
>           Setting this variable provides an escape sequence from the
>           limited "password" strings.
>
> +config AUTOBOOT_STOP_STR_SHA256
> +       string "Stop autobooting via SHA256 encrypted password"
> +       depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION
> +       help
> +         This option adds the feature to only stop the autobooting,
> +         and therefore boot into the U-Boot prompt, when the input
> +         string / password matches a values that is encypted via
> +         a SHA256 hash and saved in the environment.
> +
>  endmenu
>
>  comment "Commands"
> diff --git a/common/autoboot.c b/common/autoboot.c
> index f72eb18..dde3d04 100644
> --- a/common/autoboot.c
> +++ b/common/autoboot.c
> @@ -12,6 +12,7 @@
>  #include <fdtdec.h>
>  #include <menu.h>
>  #include <post.h>
> +#include <u-boot/sha256.h>
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -26,15 +27,80 @@ DECLARE_GLOBAL_DATA_PTR;
>  /* Stored value of bootdelay, used by autoboot_command() */
>  static int stored_bootdelay;
>
> -/***************************************************************************
> - * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
> - * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
> +#if defined(CONFIG_AUTOBOOT_KEYED)
> +#if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256)
> +
> +/*
> + * Use a "constant-length" time compare function for this
> + * hash compare:
> + *
> + * https://crackstation.net/hashing-security.htm
>   */
> -# if defined(CONFIG_AUTOBOOT_KEYED)
> -static int abortboot_keyed(int bootdelay)
> +static int slow_equals(u8 *a, u8 *b, int len)
> +{
> +       int diff = 0;
> +       int i;
> +
> +       for (i = 0; i < len; i++)
> +               diff |= a[i] ^ b[i];
> +
> +       return diff == 0;
> +}
> +
> +static int passwd_abort(uint64_t etime)
> +{
> +       const char *sha_env_str = getenv("bootstopkeysha256");
> +       u8 sha_env[SHA256_SUM_LEN];
> +       u8 sha[SHA256_SUM_LEN];
> +       char presskey[MAX_DELAY_STOP_STR];
> +       u_int presskey_len = 0;
> +       int i;
> +       int abort = 0;
> +
> +       if (sha_env_str == NULL)
> +               sha_env_str = CONFIG_AUTOBOOT_STOP_STR_SHA256;
> +
> +       /*
> +        * Generate the binary value from the environment hash value
> +        * so that we can compare this value with the computed hash
> +        * from the user input
> +        */
> +       for (i = 0; i < SHA256_SUM_LEN; i++) {
> +               char chr[3];
> +
> +               strncpy(chr, &sha_env_str[i * 2], 2);
> +               sha_env[i] = simple_strtoul(chr, NULL, 16);
> +       }
> +

There is similar code in parse_verify_sum() in hash.c. Not sure if it
is worth putting it in a function, like:

hash_parse_string(const char *algo_name, cost char *str, u8 *result)

It could support other algorithms for autoboot in the future if that
became useful.

> +       /*
> +        * We don't know how long the stop-string is, so we need to
> +        * generate the sha256 hash upon each input character and
> +        * compare the value with the one saved in the environment
> +        */
> +       do {
> +               if (tstc()) {
> +                       /* Check for input string overflow */
> +                       if (presskey_len >= MAX_DELAY_STOP_STR)
> +                               return 0;
> +
> +                       presskey[presskey_len++] = getc();
> +
> +                       /* Calculate sha256 upon each new char */
> +                       sha256_csum_wd((unsigned char *)presskey, presskey_len,
> +                                      sha, CHUNKSZ_SHA256);

Could use hash_block()

> +
> +                       /* And check if sha matches saved value in env */
> +                       if (slow_equals(sha, sha_env, SHA256_SUM_LEN))
> +                               abort = 1;
> +               }
> +       } while (!abort && get_ticks() <= etime);
> +
> +       return abort;
> +}
> +#else
> +static int passwd_abort(uint64_t etime)
>  {
>         int abort = 0;
> -       uint64_t etime = endtick(bootdelay);
>         struct {
>                 char *str;
>                 u_int len;
> @@ -42,7 +108,9 @@ static int abortboot_keyed(int bootdelay)
>         }
>         delaykey[] = {
>                 { .str = getenv("bootdelaykey"),  .retry = 1 },
> +               { .str = getenv("bootdelaykey2"), .retry = 1 },
>                 { .str = getenv("bootstopkey"),   .retry = 0 },
> +               { .str = getenv("bootstopkey2"),  .retry = 0 },
>         };
>
>         char presskey[MAX_DELAY_STOP_STR];
> @@ -50,26 +118,21 @@ static int abortboot_keyed(int bootdelay)
>         u_int presskey_max = 0;
>         u_int i;
>
> -#ifndef CONFIG_ZERO_BOOTDELAY_CHECK
> -       if (bootdelay == 0)
> -               return 0;
> -#endif
> -
> -#  ifdef CONFIG_AUTOBOOT_PROMPT
> -       /*
> -        * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
> -        * To print the bootdelay value upon bootup.
> -        */
> -       printf(CONFIG_AUTOBOOT_PROMPT, bootdelay);
> -#  endif
> -
>  #  ifdef CONFIG_AUTOBOOT_DELAY_STR
>         if (delaykey[0].str == NULL)
>                 delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR;
>  #  endif
> -#  ifdef CONFIG_AUTOBOOT_STOP_STR
> +#  ifdef CONFIG_AUTOBOOT_DELAY_STR2
>         if (delaykey[1].str == NULL)
> -               delaykey[1].str = CONFIG_AUTOBOOT_STOP_STR;
> +               delaykey[1].str = CONFIG_AUTOBOOT_DELAY_STR2;
> +#  endif
> +#  ifdef CONFIG_AUTOBOOT_STOP_STR
> +       if (delaykey[2].str == NULL)
> +               delaykey[2].str = CONFIG_AUTOBOOT_STOP_STR;
> +#  endif
> +#  ifdef CONFIG_AUTOBOOT_STOP_STR2
> +       if (delaykey[3].str == NULL)
> +               delaykey[3].str = CONFIG_AUTOBOOT_STOP_STR2;
>  #  endif
>
>         for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i++) {
> @@ -119,6 +182,33 @@ static int abortboot_keyed(int bootdelay)
>                 }
>         } while (!abort && get_ticks() <= etime);
>
> +       return abort;
> +}
> +#endif
> +
> +/***************************************************************************
> + * Watch for 'delay' seconds for autoboot stop or autoboot delay string.
> + * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
> + */
> +static int abortboot_keyed(int bootdelay)
> +{
> +       int abort;
> +       uint64_t etime = endtick(bootdelay);
> +
> +#ifndef CONFIG_ZERO_BOOTDELAY_CHECK
> +       if (bootdelay == 0)
> +               return 0;
> +#endif
> +
> +#  ifdef CONFIG_AUTOBOOT_PROMPT
> +       /*
> +        * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
> +        * To print the bootdelay value upon bootup.
> +        */
> +       printf(CONFIG_AUTOBOOT_PROMPT, bootdelay);
> +#  endif
> +
> +       abort = passwd_abort(etime);
>         if (!abort)
>                 debug_bootkeys("key timeout\n");
>
> --
> 2.4.0
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v2 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password
  2015-05-08  7:52   ` [U-Boot] [PATCH v2 " Stefan Roese
  2015-05-10 14:49     ` Simon Glass
@ 2015-05-11  7:16     ` Andreas Bießmann
  2015-05-11  7:44       ` Stefan Roese
  2015-05-15  7:44     ` Magnus Lilja
  2 siblings, 1 reply; 29+ messages in thread
From: Andreas Bießmann @ 2015-05-11  7:16 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 05/08/2015 09:52 AM, Stefan Roese wrote:
> This patch adds the feature to only stop the autobooting, and therefor
> boot into the U-Boot prompt, when the input string / password matches
> a values that is encypted via a SHA256 hash and saved in the environment.
> 
> This feature is enabled by defined these config options:
>      CONFIG_AUTOBOOT_KEYED
>      CONFIG_AUTOBOOT_STOP_STR_SHA256
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Magnus Lilja <lilja.magnus@gmail.com>
> ---
> v2:
> - AUTOBOOT_STOP_STR_SHA256 is a string and not bool
> - Add input key length check as suggested by Magnus
> - Add "constant-length" time compare function as suggested
>   by Magnus
> 
>  common/Kconfig    |  20 +++++++--
>  common/autoboot.c | 132 +++++++++++++++++++++++++++++++++++++++++++++---------
>  2 files changed, 128 insertions(+), 24 deletions(-)

[snip]

> @@ -42,7 +108,9 @@ static int abortboot_keyed(int bootdelay)
>  	}
>  	delaykey[] = {
>  		{ .str = getenv("bootdelaykey"),  .retry = 1 },
> +		{ .str = getenv("bootdelaykey2"), .retry = 1 },
>  		{ .str = getenv("bootstopkey"),   .retry = 0 },
> +		{ .str = getenv("bootstopkey2"),  .retry = 0 },
>  	};
>  
>  	char presskey[MAX_DELAY_STOP_STR];
> @@ -50,26 +118,21 @@ static int abortboot_keyed(int bootdelay)
>  	u_int presskey_max = 0;
>  	u_int i;
>  
> -#ifndef CONFIG_ZERO_BOOTDELAY_CHECK
> -	if (bootdelay == 0)
> -		return 0;
> -#endif
> -
> -#  ifdef CONFIG_AUTOBOOT_PROMPT
> -	/*
> -	 * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
> -	 * To print the bootdelay value upon bootup.
> -	 */
> -	printf(CONFIG_AUTOBOOT_PROMPT, bootdelay);
> -#  endif
> -
>  #  ifdef CONFIG_AUTOBOOT_DELAY_STR
>  	if (delaykey[0].str == NULL)
>  		delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR;
>  #  endif
> -#  ifdef CONFIG_AUTOBOOT_STOP_STR
> +#  ifdef CONFIG_AUTOBOOT_DELAY_STR2
>  	if (delaykey[1].str == NULL)
> -		delaykey[1].str = CONFIG_AUTOBOOT_STOP_STR;
> +		delaykey[1].str = CONFIG_AUTOBOOT_DELAY_STR2;
> +#  endif
> +#  ifdef CONFIG_AUTOBOOT_STOP_STR
> +	if (delaykey[2].str == NULL)
> +		delaykey[2].str = CONFIG_AUTOBOOT_STOP_STR;
> +#  endif
> +#  ifdef CONFIG_AUTOBOOT_STOP_STR2
> +	if (delaykey[3].str == NULL)
> +		delaykey[3].str = CONFIG_AUTOBOOT_STOP_STR2;
>  #  endif
>  
>  	for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i++) {

isn't this part removed before in 2/4 'autoboot.c: Remove
CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2'?

Andreas

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v2 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password
  2015-05-11  7:16     ` Andreas Bießmann
@ 2015-05-11  7:44       ` Stefan Roese
  0 siblings, 0 replies; 29+ messages in thread
From: Stefan Roese @ 2015-05-11  7:44 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On 11.05.2015 09:16, Andreas Bie?mann wrote:
>>   #  ifdef CONFIG_AUTOBOOT_DELAY_STR
>>   	if (delaykey[0].str == NULL)
>>   		delaykey[0].str = CONFIG_AUTOBOOT_DELAY_STR;
>>   #  endif
>> -#  ifdef CONFIG_AUTOBOOT_STOP_STR
>> +#  ifdef CONFIG_AUTOBOOT_DELAY_STR2
>>   	if (delaykey[1].str == NULL)
>> -		delaykey[1].str = CONFIG_AUTOBOOT_STOP_STR;
>> +		delaykey[1].str = CONFIG_AUTOBOOT_DELAY_STR2;
>> +#  endif
>> +#  ifdef CONFIG_AUTOBOOT_STOP_STR
>> +	if (delaykey[2].str == NULL)
>> +		delaykey[2].str = CONFIG_AUTOBOOT_STOP_STR;
>> +#  endif
>> +#  ifdef CONFIG_AUTOBOOT_STOP_STR2
>> +	if (delaykey[3].str == NULL)
>> +		delaykey[3].str = CONFIG_AUTOBOOT_STOP_STR2;
>>   #  endif
>>
>>   	for (i = 0; i < sizeof(delaykey) / sizeof(delaykey[0]); i++) {
>
> isn't this part removed before in 2/4 'autoboot.c: Remove
> CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2'?

Right. I messed up while rebasing. v3 will follow hopefully today.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-10 14:48   ` Simon Glass
@ 2015-05-11  7:58     ` Stefan Roese
  2015-05-11 13:27       ` Stefan Roese
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Roese @ 2015-05-11  7:58 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 10.05.2015 16:48, Simon Glass wrote:
> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>> I might have missed something, but I failed to use the escape char '\'
>> in strings. To pass a printf format string like "foo %d bar\n" via
>> Kconfig to the code.
>>
>> Right now its not possible to use the escape character '\' in Kconfig
>> string values correctly to e.g. set this string value "test output\n".
>> The '\n' will be converted to 'n'.
>>
>> The current implementation removes some of the '\' chars from the input
>> string in conf_set_sym_val(). Examples:
>>
>> '\'     -> ''
>> '\\'    -> '\'
>> '\\\'   -> '\'
>> '\\\\'  -> '\\'
>> ...
>>
>> And then doubles the backslash chars in the output string in
>> sym_escape_string_value(). Example:
>>
>> '\'     -> ''   -> ''
>> '\\'    -> '\'  -> '\\'
>> '\\\'   -> '\'  -> '\\'
>> '\\\\'  -> '\\' -> '\\\\'
>> ...
>>
>> As you see in these examples, its impossible to generate a single '\'
>> charater in the output string as its needed for something like '\n'.
>>
>> This patch now changes this behavior to not drop some backslashes in
>> conf_set_sym_val() and to not add new backslashes in the resulting
>> output string. Removing the function sym_escape_string_value()
>> completely as its not needed anymore.
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>>
>>   scripts/kconfig/confdata.c | 20 +++++++++-----------
>>   scripts/kconfig/symbol.c   | 43 -------------------------------------------
>>   2 files changed, 9 insertions(+), 54 deletions(-)
>
> This looks right to me. But I do see one problem - the default string
> for CONFIG_AUTOBOOT_PROMPT appears as:
>
> "Autoboot in %d secondsn"
>
> so something is still removing the \ in the Kconfig default;

Right. Thanks for spotting. I'll fix this in v3.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 2/4] autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2
  2015-05-07 12:13 ` [U-Boot] [PATCH v1 2/4] autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2 Stefan Roese
  2015-05-07 23:47   ` Simon Glass
@ 2015-05-11 12:38   ` Tom Rini
  1 sibling, 0 replies; 29+ messages in thread
From: Tom Rini @ 2015-05-11 12:38 UTC (permalink / raw)
  To: u-boot

On Thu, May 07, 2015 at 02:13:30PM +0200, Stefan Roese wrote:

> These defines for a 2nd autoboot stop and delay string are nearly unused. Only
> sc3 defines CONFIG_AUTOBOOT_DELAY_STR2. And a patch to remove this most likely
> unmaintained board is also posted to the list.
> 
> By removing these defines the code will become cleaner and moving the remaining
> compile options to Kconfig will get easier.
> 
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Heiko Schocher <hs@denx.de>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150511/d3ac43d9/attachment.sig>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-11  7:58     ` Stefan Roese
@ 2015-05-11 13:27       ` Stefan Roese
  2015-05-11 22:41         ` Simon Glass
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Roese @ 2015-05-11 13:27 UTC (permalink / raw)
  To: u-boot

Hi Simon, Hi Masahiro,

On 11.05.2015 09:58, Stefan Roese wrote:
> On 10.05.2015 16:48, Simon Glass wrote:
>> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>>> I might have missed something, but I failed to use the escape char '\'
>>> in strings. To pass a printf format string like "foo %d bar\n" via
>>> Kconfig to the code.
>>>
>>> Right now its not possible to use the escape character '\' in Kconfig
>>> string values correctly to e.g. set this string value "test output\n".
>>> The '\n' will be converted to 'n'.
>>>
>>> The current implementation removes some of the '\' chars from the input
>>> string in conf_set_sym_val(). Examples:
>>>
>>> '\'     -> ''
>>> '\\'    -> '\'
>>> '\\\'   -> '\'
>>> '\\\\'  -> '\\'
>>> ...
>>>
>>> And then doubles the backslash chars in the output string in
>>> sym_escape_string_value(). Example:
>>>
>>> '\'     -> ''   -> ''
>>> '\\'    -> '\'  -> '\\'
>>> '\\\'   -> '\'  -> '\\'
>>> '\\\\'  -> '\\' -> '\\\\'
>>> ...
>>>
>>> As you see in these examples, its impossible to generate a single '\'
>>> charater in the output string as its needed for something like '\n'.
>>>
>>> This patch now changes this behavior to not drop some backslashes in
>>> conf_set_sym_val() and to not add new backslashes in the resulting
>>> output string. Removing the function sym_escape_string_value()
>>> completely as its not needed anymore.
>>>
>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>> Cc: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>>   scripts/kconfig/confdata.c | 20 +++++++++-----------
>>>   scripts/kconfig/symbol.c   | 43
>>> -------------------------------------------
>>>   2 files changed, 9 insertions(+), 54 deletions(-)
>>
>> This looks right to me. But I do see one problem - the default string
>> for CONFIG_AUTOBOOT_PROMPT appears as:
>>
>> "Autoboot in %d secondsn"
>>
>> so something is still removing the \ in the Kconfig default;
>
> Right. Thanks for spotting. I'll fix this in v3.

I could easily change the default string in the Kconfig file to 
"Autoboot in %d seconds\\n". This works. But its a different syntax 
regarding using the escape character backslash compared to editing the 
.config file or editing the string in "make menuconfig etc...". So I 
hesitate to "fix" it this way.

Unfortunately fixing this issue in the code is not that easy. At least 
not for me. As the default values of the "string values" are set in the 
conf_parse() function (in scripts/kconfig/zconf.y). And I really have 
absolutely no experience with yacc / bison. Perhaps one of you guys has 
a quick fix to make this default value of strings compatible again so 
that this additional '\' is not needed in the Kconfig file?

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-11 13:27       ` Stefan Roese
@ 2015-05-11 22:41         ` Simon Glass
  2015-05-13  1:34           ` Masahiro Yamada
  0 siblings, 1 reply; 29+ messages in thread
From: Simon Glass @ 2015-05-11 22:41 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 11 May 2015 at 07:27, Stefan Roese <mail@roese.nl> wrote:
> Hi Simon, Hi Masahiro,
>
>
> On 11.05.2015 09:58, Stefan Roese wrote:
>>
>> On 10.05.2015 16:48, Simon Glass wrote:
>>>
>>> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>>>>
>>>> I might have missed something, but I failed to use the escape char '\'
>>>> in strings. To pass a printf format string like "foo %d bar\n" via
>>>> Kconfig to the code.
>>>>
>>>> Right now its not possible to use the escape character '\' in Kconfig
>>>> string values correctly to e.g. set this string value "test output\n".
>>>> The '\n' will be converted to 'n'.
>>>>
>>>> The current implementation removes some of the '\' chars from the input
>>>> string in conf_set_sym_val(). Examples:
>>>>
>>>> '\'     -> ''
>>>> '\\'    -> '\'
>>>> '\\\'   -> '\'
>>>> '\\\\'  -> '\\'
>>>> ...
>>>>
>>>> And then doubles the backslash chars in the output string in
>>>> sym_escape_string_value(). Example:
>>>>
>>>> '\'     -> ''   -> ''
>>>> '\\'    -> '\'  -> '\\'
>>>> '\\\'   -> '\'  -> '\\'
>>>> '\\\\'  -> '\\' -> '\\\\'
>>>> ...
>>>>
>>>> As you see in these examples, its impossible to generate a single '\'
>>>> charater in the output string as its needed for something like '\n'.
>>>>
>>>> This patch now changes this behavior to not drop some backslashes in
>>>> conf_set_sym_val() and to not add new backslashes in the resulting
>>>> output string. Removing the function sym_escape_string_value()
>>>> completely as its not needed anymore.
>>>>
>>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>> Cc: Simon Glass <sjg@chromium.org>
>>>> ---
>>>>
>>>>   scripts/kconfig/confdata.c | 20 +++++++++-----------
>>>>   scripts/kconfig/symbol.c   | 43
>>>> -------------------------------------------
>>>>   2 files changed, 9 insertions(+), 54 deletions(-)
>>>
>>>
>>> This looks right to me. But I do see one problem - the default string
>>> for CONFIG_AUTOBOOT_PROMPT appears as:
>>>
>>> "Autoboot in %d secondsn"
>>>
>>> so something is still removing the \ in the Kconfig default;
>>
>>
>> Right. Thanks for spotting. I'll fix this in v3.
>
>
> I could easily change the default string in the Kconfig file to "Autoboot in
> %d seconds\\n". This works. But its a different syntax regarding using the
> escape character backslash compared to editing the .config file or editing
> the string in "make menuconfig etc...". So I hesitate to "fix" it this way.
>
> Unfortunately fixing this issue in the code is not that easy. At least not
> for me. As the default values of the "string values" are set in the
> conf_parse() function (in scripts/kconfig/zconf.y). And I really have
> absolutely no experience with yacc / bison. Perhaps one of you guys has a
> quick fix to make this default value of strings compatible again so that
> this additional '\' is not needed in the Kconfig file?

Well I am familiar with those tools but I think Masahiro probably
knows a lot more here.

Regards,
Simon

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-11 22:41         ` Simon Glass
@ 2015-05-13  1:34           ` Masahiro Yamada
  2015-05-15  7:13             ` Stefan Roese
  0 siblings, 1 reply; 29+ messages in thread
From: Masahiro Yamada @ 2015-05-13  1:34 UTC (permalink / raw)
  To: u-boot

Hi, Simon, Stefan,


2015-05-12 7:41 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi Stefan,
>
> On 11 May 2015 at 07:27, Stefan Roese <mail@roese.nl> wrote:
>> Hi Simon, Hi Masahiro,
>>
>>
>> On 11.05.2015 09:58, Stefan Roese wrote:
>>>
>>> On 10.05.2015 16:48, Simon Glass wrote:
>>>>
>>>> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>>>>>
>>>>> I might have missed something, but I failed to use the escape char '\'
>>>>> in strings. To pass a printf format string like "foo %d bar\n" via
>>>>> Kconfig to the code.
>>>>>
>>>>> Right now its not possible to use the escape character '\' in Kconfig
>>>>> string values correctly to e.g. set this string value "test output\n".
>>>>> The '\n' will be converted to 'n'.
>>>>>
>>>>> The current implementation removes some of the '\' chars from the input
>>>>> string in conf_set_sym_val(). Examples:
>>>>>
>>>>> '\'     -> ''
>>>>> '\\'    -> '\'
>>>>> '\\\'   -> '\'
>>>>> '\\\\'  -> '\\'
>>>>> ...
>>>>>
>>>>> And then doubles the backslash chars in the output string in
>>>>> sym_escape_string_value(). Example:
>>>>>
>>>>> '\'     -> ''   -> ''
>>>>> '\\'    -> '\'  -> '\\'
>>>>> '\\\'   -> '\'  -> '\\'
>>>>> '\\\\'  -> '\\' -> '\\\\'
>>>>> ...
>>>>>
>>>>> As you see in these examples, its impossible to generate a single '\'
>>>>> charater in the output string as its needed for something like '\n'.
>>>>>
>>>>> This patch now changes this behavior to not drop some backslashes in
>>>>> conf_set_sym_val() and to not add new backslashes in the resulting
>>>>> output string. Removing the function sym_escape_string_value()
>>>>> completely as its not needed anymore.
>>>>>
>>>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>>> Cc: Simon Glass <sjg@chromium.org>
>>>>> ---
>>>>>
>>>>>   scripts/kconfig/confdata.c | 20 +++++++++-----------
>>>>>   scripts/kconfig/symbol.c   | 43
>>>>> -------------------------------------------
>>>>>   2 files changed, 9 insertions(+), 54 deletions(-)
>>>>
>>>>
>>>> This looks right to me. But I do see one problem - the default string
>>>> for CONFIG_AUTOBOOT_PROMPT appears as:
>>>>
>>>> "Autoboot in %d secondsn"
>>>>
>>>> so something is still removing the \ in the Kconfig default;
>>>
>>>
>>> Right. Thanks for spotting. I'll fix this in v3.
>>
>>
>> I could easily change the default string in the Kconfig file to "Autoboot in
>> %d seconds\\n". This works. But its a different syntax regarding using the
>> escape character backslash compared to editing the .config file or editing
>> the string in "make menuconfig etc...". So I hesitate to "fix" it this way.
>>
>> Unfortunately fixing this issue in the code is not that easy. At least not
>> for me. As the default values of the "string values" are set in the
>> conf_parse() function (in scripts/kconfig/zconf.y). And I really have
>> absolutely no experience with yacc / bison. Perhaps one of you guys has a
>> quick fix to make this default value of strings compatible again so that
>> this additional '\' is not needed in the Kconfig file?
>
> Well I am familiar with those tools but I think Masahiro probably
> knows a lot more here.


I am not so familiar with Bison, and I am getting a bit busy these days.
So, I cannot find time to take a close look.  Sorry.

If Simon (or someone else) could follow it up, that'd be nice.

BTW, if you have already figured out that conf_parse() is the cause of
the problem,
you do not have to invoke Bison.

Bison does not touch the C part.
conf_parse() is just copied verbatim from zconf.y to zconf.tab.c_shipped.

You can modify conf_parse() exactly in the same way in both of them.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-13  1:34           ` Masahiro Yamada
@ 2015-05-15  7:13             ` Stefan Roese
  2015-05-15  7:49               ` Masahiro Yamada
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Roese @ 2015-05-15  7:13 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 13.05.2015 03:34, Masahiro Yamada wrote:
> Hi, Simon, Stefan,
>
>
> 2015-05-12 7:41 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> Hi Stefan,
>>
>> On 11 May 2015 at 07:27, Stefan Roese <mail@roese.nl> wrote:
>>> Hi Simon, Hi Masahiro,
>>>
>>>
>>> On 11.05.2015 09:58, Stefan Roese wrote:
>>>>
>>>> On 10.05.2015 16:48, Simon Glass wrote:
>>>>>
>>>>> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>>>>>>
>>>>>> I might have missed something, but I failed to use the escape char '\'
>>>>>> in strings. To pass a printf format string like "foo %d bar\n" via
>>>>>> Kconfig to the code.
>>>>>>
>>>>>> Right now its not possible to use the escape character '\' in Kconfig
>>>>>> string values correctly to e.g. set this string value "test output\n".
>>>>>> The '\n' will be converted to 'n'.
>>>>>>
>>>>>> The current implementation removes some of the '\' chars from the input
>>>>>> string in conf_set_sym_val(). Examples:
>>>>>>
>>>>>> '\'     -> ''
>>>>>> '\\'    -> '\'
>>>>>> '\\\'   -> '\'
>>>>>> '\\\\'  -> '\\'
>>>>>> ...
>>>>>>
>>>>>> And then doubles the backslash chars in the output string in
>>>>>> sym_escape_string_value(). Example:
>>>>>>
>>>>>> '\'     -> ''   -> ''
>>>>>> '\\'    -> '\'  -> '\\'
>>>>>> '\\\'   -> '\'  -> '\\'
>>>>>> '\\\\'  -> '\\' -> '\\\\'
>>>>>> ...
>>>>>>
>>>>>> As you see in these examples, its impossible to generate a single '\'
>>>>>> charater in the output string as its needed for something like '\n'.
>>>>>>
>>>>>> This patch now changes this behavior to not drop some backslashes in
>>>>>> conf_set_sym_val() and to not add new backslashes in the resulting
>>>>>> output string. Removing the function sym_escape_string_value()
>>>>>> completely as its not needed anymore.
>>>>>>
>>>>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>>>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>>>> Cc: Simon Glass <sjg@chromium.org>
>>>>>> ---
>>>>>>
>>>>>>    scripts/kconfig/confdata.c | 20 +++++++++-----------
>>>>>>    scripts/kconfig/symbol.c   | 43
>>>>>> -------------------------------------------
>>>>>>    2 files changed, 9 insertions(+), 54 deletions(-)
>>>>>
>>>>>
>>>>> This looks right to me. But I do see one problem - the default string
>>>>> for CONFIG_AUTOBOOT_PROMPT appears as:
>>>>>
>>>>> "Autoboot in %d secondsn"
>>>>>
>>>>> so something is still removing the \ in the Kconfig default;
>>>>
>>>>
>>>> Right. Thanks for spotting. I'll fix this in v3.
>>>
>>>
>>> I could easily change the default string in the Kconfig file to "Autoboot in
>>> %d seconds\\n". This works. But its a different syntax regarding using the
>>> escape character backslash compared to editing the .config file or editing
>>> the string in "make menuconfig etc...". So I hesitate to "fix" it this way.
>>>
>>> Unfortunately fixing this issue in the code is not that easy. At least not
>>> for me. As the default values of the "string values" are set in the
>>> conf_parse() function (in scripts/kconfig/zconf.y). And I really have
>>> absolutely no experience with yacc / bison. Perhaps one of you guys has a
>>> quick fix to make this default value of strings compatible again so that
>>> this additional '\' is not needed in the Kconfig file?
>>
>> Well I am familiar with those tools but I think Masahiro probably
>> knows a lot more here.
>
>
> I am not so familiar with Bison, and I am getting a bit busy these days.
> So, I cannot find time to take a close look.  Sorry.
>
> If Simon (or someone else) could follow it up, that'd be nice.
>
> BTW, if you have already figured out that conf_parse() is the cause of
> the problem,
> you do not have to invoke Bison.
>
> Bison does not touch the C part.
> conf_parse() is just copied verbatim from zconf.y to zconf.tab.c_shipped.
>
> You can modify conf_parse() exactly in the same way in both of them.

Thanks. Did it and found that zconfparse() is responsible for this 
default value configuration / parsing. I must be missing something, but 
I fail to see where this function is really implemented:

$ git grep zconfparse
scripts/kconfig/lkc.h:int zconfparse(void);
scripts/kconfig/zconf.tab.c_shipped:#define yyparse         zconfparse
scripts/kconfig/zconf.tab.c_shipped:    zconfparse();
scripts/kconfig/zconf.y:        zconfparse();

I'm inclined to just add this additional backslash to the default value 
in Kconfig.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v2 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password
  2015-05-08  7:52   ` [U-Boot] [PATCH v2 " Stefan Roese
  2015-05-10 14:49     ` Simon Glass
  2015-05-11  7:16     ` Andreas Bießmann
@ 2015-05-15  7:44     ` Magnus Lilja
  2015-05-15  8:44       ` Stefan Roese
  2 siblings, 1 reply; 29+ messages in thread
From: Magnus Lilja @ 2015-05-15  7:44 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 8 May 2015 at 09:52, Stefan Roese <sr@denx.de> wrote:
> This patch adds the feature to only stop the autobooting, and therefor
> boot into the U-Boot prompt, when the input string / password matches
> a values that is encypted via a SHA256 hash and saved in the environment.
>
> This feature is enabled by defined these config options:
>      CONFIG_AUTOBOOT_KEYED
>      CONFIG_AUTOBOOT_STOP_STR_SHA256
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Magnus Lilja <lilja.magnus@gmail.com>
> ---
> v2:
> - AUTOBOOT_STOP_STR_SHA256 is a string and not bool
> - Add input key length check as suggested by Magnus
> - Add "constant-length" time compare function as suggested
>   by Magnus

May I ask why you don't go all the way and use the salt mechanism
instead of just hashing the password?

Regards; Magnus

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values
  2015-05-15  7:13             ` Stefan Roese
@ 2015-05-15  7:49               ` Masahiro Yamada
  0 siblings, 0 replies; 29+ messages in thread
From: Masahiro Yamada @ 2015-05-15  7:49 UTC (permalink / raw)
  To: u-boot

Hi Stefan,




2015-05-15 16:13 GMT+09:00 Stefan Roese <sr@denx.de>:
> Hi Masahiro,
>
>
> On 13.05.2015 03:34, Masahiro Yamada wrote:
>>
>> Hi, Simon, Stefan,
>>
>>
>> 2015-05-12 7:41 GMT+09:00 Simon Glass <sjg@chromium.org>:
>>>
>>> Hi Stefan,
>>>
>>> On 11 May 2015 at 07:27, Stefan Roese <mail@roese.nl> wrote:
>>>>
>>>> Hi Simon, Hi Masahiro,
>>>>
>>>>
>>>> On 11.05.2015 09:58, Stefan Roese wrote:
>>>>>
>>>>>
>>>>> On 10.05.2015 16:48, Simon Glass wrote:
>>>>>>
>>>>>>
>>>>>> On 7 May 2015 at 06:13, Stefan Roese <sr@denx.de> wrote:
>>>>>>>
>>>>>>>
>>>>>>> I might have missed something, but I failed to use the escape char
>>>>>>> '\'
>>>>>>> in strings. To pass a printf format string like "foo %d bar\n" via
>>>>>>> Kconfig to the code.
>>>>>>>
>>>>>>> Right now its not possible to use the escape character '\' in Kconfig
>>>>>>> string values correctly to e.g. set this string value "test
>>>>>>> output\n".
>>>>>>> The '\n' will be converted to 'n'.
>>>>>>>
>>>>>>> The current implementation removes some of the '\' chars from the
>>>>>>> input
>>>>>>> string in conf_set_sym_val(). Examples:
>>>>>>>
>>>>>>> '\'     -> ''
>>>>>>> '\\'    -> '\'
>>>>>>> '\\\'   -> '\'
>>>>>>> '\\\\'  -> '\\'
>>>>>>> ...
>>>>>>>
>>>>>>> And then doubles the backslash chars in the output string in
>>>>>>> sym_escape_string_value(). Example:
>>>>>>>
>>>>>>> '\'     -> ''   -> ''
>>>>>>> '\\'    -> '\'  -> '\\'
>>>>>>> '\\\'   -> '\'  -> '\\'
>>>>>>> '\\\\'  -> '\\' -> '\\\\'
>>>>>>> ...
>>>>>>>
>>>>>>> As you see in these examples, its impossible to generate a single '\'
>>>>>>> charater in the output string as its needed for something like '\n'.
>>>>>>>
>>>>>>> This patch now changes this behavior to not drop some backslashes in
>>>>>>> conf_set_sym_val() and to not add new backslashes in the resulting
>>>>>>> output string. Removing the function sym_escape_string_value()
>>>>>>> completely as its not needed anymore.
>>>>>>>
>>>>>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>>>>>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>>>>>>> Cc: Simon Glass <sjg@chromium.org>
>>>>>>> ---
>>>>>>>
>>>>>>>    scripts/kconfig/confdata.c | 20 +++++++++-----------
>>>>>>>    scripts/kconfig/symbol.c   | 43
>>>>>>> -------------------------------------------
>>>>>>>    2 files changed, 9 insertions(+), 54 deletions(-)
>>>>>>
>>>>>>
>>>>>>
>>>>>> This looks right to me. But I do see one problem - the default string
>>>>>> for CONFIG_AUTOBOOT_PROMPT appears as:
>>>>>>
>>>>>> "Autoboot in %d secondsn"
>>>>>>
>>>>>> so something is still removing the \ in the Kconfig default;
>>>>>
>>>>>
>>>>>
>>>>> Right. Thanks for spotting. I'll fix this in v3.
>>>>
>>>>
>>>>
>>>> I could easily change the default string in the Kconfig file to
>>>> "Autoboot in
>>>> %d seconds\\n". This works. But its a different syntax regarding using
>>>> the
>>>> escape character backslash compared to editing the .config file or
>>>> editing
>>>> the string in "make menuconfig etc...". So I hesitate to "fix" it this
>>>> way.
>>>>
>>>> Unfortunately fixing this issue in the code is not that easy. At least
>>>> not
>>>> for me. As the default values of the "string values" are set in the
>>>> conf_parse() function (in scripts/kconfig/zconf.y). And I really have
>>>> absolutely no experience with yacc / bison. Perhaps one of you guys has
>>>> a
>>>> quick fix to make this default value of strings compatible again so that
>>>> this additional '\' is not needed in the Kconfig file?
>>>
>>>
>>> Well I am familiar with those tools but I think Masahiro probably
>>> knows a lot more here.
>>
>>
>>
>> I am not so familiar with Bison, and I am getting a bit busy these days.
>> So, I cannot find time to take a close look.  Sorry.
>>
>> If Simon (or someone else) could follow it up, that'd be nice.
>>
>> BTW, if you have already figured out that conf_parse() is the cause of
>> the problem,
>> you do not have to invoke Bison.
>>
>> Bison does not touch the C part.
>> conf_parse() is just copied verbatim from zconf.y to zconf.tab.c_shipped.
>>
>> You can modify conf_parse() exactly in the same way in both of them.
>
>
> Thanks. Did it and found that zconfparse() is responsible for this default
> value configuration / parsing. I must be missing something, but I fail to
> see where this function is really implemented:
>
> $ git grep zconfparse
> scripts/kconfig/lkc.h:int zconfparse(void);
> scripts/kconfig/zconf.tab.c_shipped:#define yyparse         zconfparse
> scripts/kconfig/zconf.tab.c_shipped:    zconfparse();
> scripts/kconfig/zconf.y:        zconfparse();





Bison converts zconf.y into zconf.tab.c_shipped

You will notice the following part.

/* Substitute the variable and function names.  */
#define yyparse         zconfparse
#define yylex           zconflex



I think zconfparse was taken from the basename of zconf.y


And then, you will also notice the following part:



/*----------.
| yyparse.  |
`----------*/

#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
int
yyparse (void *YYPARSE_PARAM)
#else
int
yyparse (YYPARSE_PARAM)
    void *YYPARSE_PARAM;
#endif
#else /* ! YYPARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \
     || defined __cplusplus || defined _MSC_VER)
int
yyparse (void)
#else
int
yyparse ()

#endif
#endif
{
    int yystate;
    /* Number of tokens to shift before error messages enabled.  */




"yyparse" is replaced with "zconfparse" by the prepreocessor,
so this is the implementation of zconfparse(),
and it is the parser generated by Bison.

I think it is almost impossible to read the generated parser directly.
Instead, you should read zconf.y, but you need to understand Bison
grammer for that...





-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [U-Boot] [PATCH v2 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password
  2015-05-15  7:44     ` Magnus Lilja
@ 2015-05-15  8:44       ` Stefan Roese
  0 siblings, 0 replies; 29+ messages in thread
From: Stefan Roese @ 2015-05-15  8:44 UTC (permalink / raw)
  To: u-boot

Hi Magnus,

On 15.05.2015 09:44, Magnus Lilja wrote:
> On 8 May 2015 at 09:52, Stefan Roese <sr@denx.de> wrote:
>> This patch adds the feature to only stop the autobooting, and therefor
>> boot into the U-Boot prompt, when the input string / password matches
>> a values that is encypted via a SHA256 hash and saved in the environment.
>>
>> This feature is enabled by defined these config options:
>>       CONFIG_AUTOBOOT_KEYED
>>       CONFIG_AUTOBOOT_STOP_STR_SHA256
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: Magnus Lilja <lilja.magnus@gmail.com>
>> ---
>> v2:
>> - AUTOBOOT_STOP_STR_SHA256 is a string and not bool
>> - Add input key length check as suggested by Magnus
>> - Add "constant-length" time compare function as suggested
>>    by Magnus
>
> May I ask why you don't go all the way and use the salt mechanism
> instead of just hashing the password?

Because its a customer requirement to implement it in this "simple" way. 
Even though cracking will be easier than by using this salt mechanism. 
If someone needs this stronger encryption support at some time, I 
suggest to add it as an additional feature / option then.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2015-05-15  8:44 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-07 12:13 [U-Boot] [PATCH v1 0/4] Add SHA256 encrypted stop string for autobooting Stefan Roese
2015-05-07 12:13 ` [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values Stefan Roese
2015-05-07 12:41   ` Masahiro Yamada
2015-05-07 12:46     ` Stefan Roese
2015-05-07 12:53       ` Masahiro Yamada
2015-05-10 14:48   ` Simon Glass
2015-05-11  7:58     ` Stefan Roese
2015-05-11 13:27       ` Stefan Roese
2015-05-11 22:41         ` Simon Glass
2015-05-13  1:34           ` Masahiro Yamada
2015-05-15  7:13             ` Stefan Roese
2015-05-15  7:49               ` Masahiro Yamada
2015-05-07 12:13 ` [U-Boot] [PATCH v1 2/4] autoboot.c: Remove CONFIG_AUTOBOOT_STOP_STR2 and CONFIG_AUTOBOOT_DELAY_STR2 Stefan Roese
2015-05-07 23:47   ` Simon Glass
2015-05-11 12:38   ` Tom Rini
2015-05-07 12:13 ` [U-Boot] [PATCH v1 3/4] autoboot.c: Move config options to Kconfig Stefan Roese
2015-05-07 23:51   ` Simon Glass
2015-05-08  3:30     ` Masahiro Yamada
2015-05-08  6:00       ` Stefan Roese
2015-05-08  5:55     ` Stefan Roese
2015-05-10 14:49       ` Simon Glass
2015-05-07 12:13 ` [U-Boot] [PATCH v1 4/4] autoboot.c: Add feature to stop autobooting via SHA256 encrypted password Stefan Roese
2015-05-07 20:56   ` Magnus Lilja
2015-05-08  7:52   ` [U-Boot] [PATCH v2 " Stefan Roese
2015-05-10 14:49     ` Simon Glass
2015-05-11  7:16     ` Andreas Bießmann
2015-05-11  7:44       ` Stefan Roese
2015-05-15  7:44     ` Magnus Lilja
2015-05-15  8:44       ` Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.