[U-Boot] Fix for SHA256 Password Bug

Charles Eidsness charles at ccxtechnologies.com
Tue Sep 5 12:00:35 UTC 2017


Hi All,

The SHA256 password feature doesn't seem to be working. The size argument
that was passed to hash_block was undefined. I'm not sure if this patch is
the best approach, but it does fix it:

--- uboot-2017.01/common/autoboot.c.orig        2017-09-05
07:52:56.635162924 -0400
+++ uboot-2017.01/common/autoboot.c     2017-09-05 07:53:42.295593489 -0400
@@ -31,6 +31,8 @@
 #if defined(CONFIG_AUTOBOOT_KEYED)
 #if defined(CONFIG_AUTOBOOT_STOP_STR_SHA256)

+#include <hash.h>
+
 /*
  * Use a "constant-length" time compare function for this
  * hash compare:
@@ -57,7 +59,6 @@
        const char *algo_name = "sha256";
        u_int presskey_len = 0;
        int abort = 0;
-       int size;
        int ret;

        if (sha_env_str == NULL)
@@ -89,7 +90,7 @@

                        /* Calculate sha256 upon each new char */
                        hash_block(algo_name, (const void *)presskey,
-                                  presskey_len, sha, &size);
+                                  presskey_len, sha, NULL);

                        /* And check if sha matches saved value in env */
                        if (slow_equals(sha, sha_env, SHA256_SUM_LEN))


More information about the U-Boot mailing list