summaryrefslogtreecommitdiff
path: root/include/sha256.h
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-25 13:40:42 -0700
committerGerrit <chrome-bot@google.com>2012-10-25 17:03:44 -0700
commit00b344ddbb570a5dae9b27f8441202dcecba9a4a (patch)
treeeee0a8d12ca3b062c7d60b12ddd84cbc06559528 /include/sha256.h
parentf48f9a6228c32c3435eaa113ed34268503c69a4f (diff)
downloadchrome-ec-00b344ddbb570a5dae9b27f8441202dcecba9a4a.tar.gz
Clean up vboot hash support
This copies the parts of sha256.c that we need from vboot_reference, and removes the explicit dependency on vboot_reference. That dependency was a good idea when we were doing full verified boot in the EC, but is now overkill and makes it harder for others to reuse the EC code. This also lets us call EC functions directly instead of needing vboot_stub.cc; that reduces code size by ~100 bytes. BUG=chrome-os-partner:15579 BRANCH=none TEST=vboot_hash ro, then compare with result of sha256sum build/link/ec.RO.flat Change-Id: I0f236174291df3e7f3c75e960fe9ab32af305a61 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36589 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'include/sha256.h')
-rw-r--r--include/sha256.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/sha256.h b/include/sha256.h
new file mode 100644
index 0000000000..714d87351c
--- /dev/null
+++ b/include/sha256.h
@@ -0,0 +1,29 @@
+/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* SHA-256 functions */
+
+#ifndef _CROS_EC_SHA256_H
+#define _CROS_EC_SHA256_H
+
+#include "common.h"
+
+#define SHA256_DIGEST_SIZE 32
+#define SHA256_BLOCK_SIZE 64
+
+/* SHA256 context */
+struct sha256_ctx {
+ uint32_t h[8];
+ uint32_t tot_len;
+ uint32_t len;
+ uint8_t block[2 * SHA256_BLOCK_SIZE];
+ uint8_t buf[SHA256_DIGEST_SIZE]; /* Used to store the final digest. */
+};
+
+void SHA256_init(struct sha256_ctx *ctx);
+void SHA256_update(struct sha256_ctx *ctx, const uint8_t *data, uint32_t len);
+uint8_t *SHA256_final(struct sha256_ctx *ctx);
+
+#endif /* _CROS_EC_SHA256_H */