For now we'll just go with the sh256.c. That said,
we'll keep the other bits in here. Sooner or later we may
need the other crypto functions. Note these are not compiled
in conditionally.

We should consider removing the conditional compiling
of the unrolled code; we don't have space constraints of firmware.

Change-Id: Ic792cf2b89fa4f01a94c420eb3c620b62c7bf2a9
Signed-off-by: Ronald G. Minnich <rminn...@gmail.com>
---
 kern/include/crypto/2common.h           |  4 +---
 kern/include/crypto/2crc8.h             |  4 +---
 kern/include/crypto/2crypto.h           |  4 +---
 kern/include/crypto/2fw_hash_tags.h     |  4 +---
 kern/include/crypto/2hmac.h             |  3 +--
 kern/include/crypto/2id.h               |  4 +---
 kern/include/crypto/2misc.h             |  4 +---
 kern/include/crypto/2nvstorage.h        |  4 +---
 kern/include/crypto/2nvstorage_fields.h |  4 +---
 kern/include/crypto/2recovery_reasons.h |  4 +---
 kern/include/crypto/2rsa.h              |  4 +---
 kern/include/crypto/2secdata.h          |  4 +---
 kern/include/crypto/2sha.h              |  4 +---
 kern/include/crypto/2struct.h           |  4 +---
 kern/include/crypto/2sysincludes.h      | 35 ++++++++++++++++++++-------------
 kern/include/crypto/2tpm_bootmode.h     |  4 +---
 kern/lib/Kbuild                         |  1 +
 kern/lib/crypto/2sha256.c               |  6 +++---
 18 files changed, 40 insertions(+), 61 deletions(-)

diff --git a/kern/include/crypto/2common.h b/kern/include/crypto/2common.h
index 4622ab1..46c9a36 100644
--- a/kern/include/crypto/2common.h
+++ b/kern/include/crypto/2common.h
@@ -5,8 +5,7 @@
  * Common functions between firmware and kernel verified boot.
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2COMMON_H_
-#define VBOOT_REFERENCE_VBOOT_2COMMON_H_
+#pragma once
 
 #include "2api.h"
 #include "2return_codes.h"
@@ -194,4 +193,3 @@ const struct vb2_id *vb2_hash_id(enum vb2_hash_algorithm 
hash_alg);
 /* Size of work buffer sufficient for vb2_verify_fw_preamble() worst case. */
 #define VB2_VERIFY_FIRMWARE_PREAMBLE_WORKBUF_BYTES 
VB2_VERIFY_DATA_WORKBUF_BYTES
 
-#endif  /* VBOOT_REFERENCE_VBOOT_2COMMON_H_ */
diff --git a/kern/include/crypto/2crc8.h b/kern/include/crypto/2crc8.h
index f01eabd..a846e5a 100644
--- a/kern/include/crypto/2crc8.h
+++ b/kern/include/crypto/2crc8.h
@@ -5,8 +5,7 @@
  * Very simple 8-bit CRC function.
  */
 
-#ifndef VBOOT_REFERENCE_2_CRC8_H_
-#define VBOOT_REFERENCE_2_CRC8_H_
+#pragma once
 
 /**
  * Calculate CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial.
@@ -17,4 +16,3 @@
  */
 uint8_t vb2_crc8(const void *data, uint32_t size);
 
-#endif /* VBOOT_REFERENCE_2_CRC8_H_ */
diff --git a/kern/include/crypto/2crypto.h b/kern/include/crypto/2crypto.h
index c1f225d..461c459 100644
--- a/kern/include/crypto/2crypto.h
+++ b/kern/include/crypto/2crypto.h
@@ -5,8 +5,7 @@
  * Crypto constants for verified boot
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2CRYPTO_H_
-#define VBOOT_REFERENCE_VBOOT_2CRYPTO_H_
+#pragma once
 #include <stdint.h>
 
 /* Verified boot crypto algorithms */
@@ -62,4 +61,3 @@ enum vb2_hash_algorithm {
        VB2_HASH_ALG_COUNT,
 };
 
-#endif /* VBOOT_REFERENCE_VBOOT_2CRYPTO_H_ */
diff --git a/kern/include/crypto/2fw_hash_tags.h 
b/kern/include/crypto/2fw_hash_tags.h
index 0c061f5..d6e366a 100644
--- a/kern/include/crypto/2fw_hash_tags.h
+++ b/kern/include/crypto/2fw_hash_tags.h
@@ -5,8 +5,7 @@
  * Firmware hash tags for verified boot
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2FW_HASH_TAGS_H_
-#define VBOOT_REFERENCE_VBOOT_2FW_HASH_TAGS_H_
+#pragma once
 #include <stdint.h>
 
 /*
@@ -37,4 +36,3 @@ enum vb2_hash_tag {
        VB2_HASH_TAG_CALLER_BASE = 0x40000000
 };
 
-#endif /* VBOOT_REFERENCE_VBOOT_2FW_HASH_TAGS_H_ */
diff --git a/kern/include/crypto/2hmac.h b/kern/include/crypto/2hmac.h
index 1df1939..7209a38 100644
--- a/kern/include/crypto/2hmac.h
+++ b/kern/include/crypto/2hmac.h
@@ -3,8 +3,7 @@
  * found in the LICENSE file.
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2HMAC_H_
-#define VBOOT_REFERENCE_VBOOT_2HMAC_H_
+#pragma once
 
 #include <stdint.h>
 #include "2crypto.h"
diff --git a/kern/include/crypto/2id.h b/kern/include/crypto/2id.h
index 03f6d96..12f5059 100644
--- a/kern/include/crypto/2id.h
+++ b/kern/include/crypto/2id.h
@@ -8,8 +8,7 @@
  * resistant to collisions and easy to compare.
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2ID_H_
-#define VBOOT_REFERENCE_VBOOT_2ID_H_
+#pragma once
 #include <stdint.h>
 
 #define VB2_ID_NUM_BYTES 20
@@ -25,4 +24,3 @@ struct vb2_id {
 #define VB2_ID_NONE_SHA256 {{0x02, 0x56,}}
 #define VB2_ID_NONE_SHA512 {{0x05, 0x12,}}
 
-#endif  /* VBOOT_REFERENCE_VBOOT_2ID_H_ */
diff --git a/kern/include/crypto/2misc.h b/kern/include/crypto/2misc.h
index f562fad..fdc252d 100644
--- a/kern/include/crypto/2misc.h
+++ b/kern/include/crypto/2misc.h
@@ -5,8 +5,7 @@
  * Misc functions which need access to vb2_context but are not public APIs
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2MISC_H_
-#define VBOOT_REFERENCE_VBOOT_2MISC_H_
+#pragma once
 
 #include "2api.h"
 
@@ -163,4 +162,3 @@ int vb2_load_kernel_keyblock(struct vb2_context *ctx);
  */
 int vb2_load_kernel_preamble(struct vb2_context *ctx);
 
-#endif  /* VBOOT_REFERENCE_VBOOT_2MISC_H_ */
diff --git a/kern/include/crypto/2nvstorage.h b/kern/include/crypto/2nvstorage.h
index 66a5fdf..8c436a5 100644
--- a/kern/include/crypto/2nvstorage.h
+++ b/kern/include/crypto/2nvstorage.h
@@ -5,8 +5,7 @@
  * Non-volatile storage routines
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2NVSTORAGE_H_
-#define VBOOT_REFERENCE_VBOOT_2NVSTORAGE_H_
+#pragma once
 
 enum vb2_nv_param {
        /*
@@ -171,4 +170,3 @@ void vb2_nv_set(struct vb2_context *ctx,
                enum vb2_nv_param param,
                uint32_t value);
 
-#endif  /* VBOOT_REFERENCE_VBOOT_2NVSTORAGE_H_ */
diff --git a/kern/include/crypto/2nvstorage_fields.h 
b/kern/include/crypto/2nvstorage_fields.h
index 018bdeb..cff3547 100644
--- a/kern/include/crypto/2nvstorage_fields.h
+++ b/kern/include/crypto/2nvstorage_fields.h
@@ -5,8 +5,7 @@
  * Non-volatile storage bitfields
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_
-#define VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_
+#pragma once
 
 /*
  * Constants for NV storage.  We use this rather than structs and bitfields so
@@ -76,4 +75,3 @@ enum vb2_nv_offset {
 #define VB2_NV_MISC_TRY_RO_SYNC                       0x04
 #define VB2_NV_MISC_BATTERY_CUTOFF             0x08
 
-#endif  /* VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_ */
diff --git a/kern/include/crypto/2recovery_reasons.h 
b/kern/include/crypto/2recovery_reasons.h
index 13685e6..15d4035 100644
--- a/kern/include/crypto/2recovery_reasons.h
+++ b/kern/include/crypto/2recovery_reasons.h
@@ -5,8 +5,7 @@
  * Recovery reasons
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2RECOVERY_REASONS_H_
-#define VBOOT_REFERENCE_VBOOT_2RECOVERY_REASONS_H_
+#pragma once
 
 /* Recovery reason codes */
 enum vb2_nv_recovery {
@@ -224,4 +223,3 @@ enum vb2_nv_recovery {
        VB2_RECOVERY_US_UNSPECIFIED  = 0xff,
 };
 
-#endif  /* VBOOT_REFERENCE_VBOOT_2RECOVERY_REASONS_H_ */
diff --git a/kern/include/crypto/2rsa.h b/kern/include/crypto/2rsa.h
index 7e63a6a..20978f6 100644
--- a/kern/include/crypto/2rsa.h
+++ b/kern/include/crypto/2rsa.h
@@ -3,8 +3,7 @@
  * found in the LICENSE file.
  */
 
-#ifndef VBOOT_REFERENCE_2RSA_H_
-#define VBOOT_REFERENCE_2RSA_H_
+#pragma once
 
 #include "2crypto.h"
 #include "2struct.h"
@@ -77,4 +76,3 @@ int vb2_rsa_verify_digest(const struct vb2_public_key *key,
                          const uint8_t *digest,
                          const struct vb2_workbuf *wb);
 
-#endif  /* VBOOT_REFERENCE_2RSA_H_ */
diff --git a/kern/include/crypto/2secdata.h b/kern/include/crypto/2secdata.h
index d27432e..6609c28 100644
--- a/kern/include/crypto/2secdata.h
+++ b/kern/include/crypto/2secdata.h
@@ -5,8 +5,7 @@
  * Secure non-volatile storage routines
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_SECDATA_H_
-#define VBOOT_REFERENCE_VBOOT_SECDATA_H_
+#pragma once
 
 /*****************************************************************************/
 /* Firmware version space */
@@ -216,4 +215,3 @@ int vb2_secdatak_set(struct vb2_context *ctx,
                     enum vb2_secdatak_param param,
                     uint32_t value);
 
-#endif  /* VBOOT_REFERENCE_VBOOT_2SECDATA_H_ */
diff --git a/kern/include/crypto/2sha.h b/kern/include/crypto/2sha.h
index 38b8a81..26dea0b 100644
--- a/kern/include/crypto/2sha.h
+++ b/kern/include/crypto/2sha.h
@@ -8,8 +8,7 @@
  * SHA library routines below don't interact with the rest of vboot.
  */
 
-#ifndef VBOOT_REFERENCE_2SHA_H_
-#define VBOOT_REFERENCE_2SHA_H_
+#pragma once
 
 #include "2crypto.h"
 
@@ -229,4 +228,3 @@ int vb2_digest_buffer(const uint8_t *buf,
                      uint8_t *digest,
                      uint32_t digest_size);
 
-#endif  /* VBOOT_REFERENCE_2SHA_H_ */
diff --git a/kern/include/crypto/2struct.h b/kern/include/crypto/2struct.h
index da687b0..bc32018 100644
--- a/kern/include/crypto/2struct.h
+++ b/kern/include/crypto/2struct.h
@@ -6,8 +6,7 @@
  * data.
  */
 
-#ifndef VBOOT_REFERENCE_VBOOT_2STRUCT_H_
-#define VBOOT_REFERENCE_VBOOT_2STRUCT_H_
+#pragma once
 #include <stdint.h>
 #include "2crypto.h"
 
@@ -344,4 +343,3 @@ struct vb2_ryu_root_key_hash {
 
 #define EXPECTED_VB2_RYU_ROOT_KEY_HASH_SIZE 48
 
-#endif  /* VBOOT_REFERENCE_VBOOT_2STRUCT_H_ */
diff --git a/kern/include/crypto/2sysincludes.h 
b/kern/include/crypto/2sysincludes.h
index 4c9e66c..34a78d7 100644
--- a/kern/include/crypto/2sysincludes.h
+++ b/kern/include/crypto/2sysincludes.h
@@ -10,18 +10,25 @@
  * platforms which don't have all the system includes.
  */
 
-#ifndef VBOOT_REFERENCE_2_SYSINCLUDES_H_
-#define VBOOT_REFERENCE_2_SYSINCLUDES_H_
+#pragma once
+/* Note that the old include/ros/env.h is merged into this file */
 
-#include <inttypes.h>  /* For PRIu64 */
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined(HAVE_ENDIAN_H) && defined(HAVE_LITTLE_ENDIAN)
-#include <byteswap.h>
-#include <memory.h>
-#endif
-
-#endif  /* VBOOT_REFERENCE_2_SYSINCLUDES_H_ */
+#include <ros/memlayout.h>
+#include <ros/syscall.h>
+#include <ros/sysevent.h>
+#include <ros/procinfo.h>
+#include <error.h>
+#include <ros/procdata.h>
+#include <ros/procinfo.h>
+#include <ros/resource.h>
+#include <trap.h>
+#include <ros/common.h>
+#include <arch/arch.h>
+#include <sys/queue.h>
+#include <atomic.h>
+#include <mm.h>
+#include <vfs.h>
+#include <schedule.h>
+#include <devalarm.h>
+#include <ns.h>
+#include <arch/vmm/vmm.h>
diff --git a/kern/include/crypto/2tpm_bootmode.h 
b/kern/include/crypto/2tpm_bootmode.h
index 63f247d..a598b1d 100644
--- a/kern/include/crypto/2tpm_bootmode.h
+++ b/kern/include/crypto/2tpm_bootmode.h
@@ -5,8 +5,7 @@
  * Functions for updating the TPM state with the status of boot path.
  */
 
-#ifndef VBOOT_REFERENCE_2TPM_BOOTMODE_H_
-#define VBOOT_REFERENCE_2TPM_BOOTMODE_H_
+#pragma once
 
 #include "2api.h"
 
@@ -18,4 +17,3 @@
  */
 const uint8_t *vb2_get_boot_state_digest(struct vb2_context *ctx);
 
-#endif  /* VBOOT_REFERENCE_2TPM_BOOTMODE_H_ */
diff --git a/kern/lib/Kbuild b/kern/lib/Kbuild
index 645b58f..a526703 100644
--- a/kern/lib/Kbuild
+++ b/kern/lib/Kbuild
@@ -2,6 +2,7 @@ obj-y                                           += 
address_range.o
 obj-y                                          += circular_buffer.o
 obj-y                                          += slice.o
 obj-y                                          += sort.o
+obj-y                                          += crypto/
 obj-y                                          += zlib_deflate/
 obj-y                                          += zlib_inflate/
 obj-y                                          += random/
diff --git a/kern/lib/crypto/2sha256.c b/kern/lib/crypto/2sha256.c
index d2cf672..acf9c67 100644
--- a/kern/lib/crypto/2sha256.c
+++ b/kern/lib/crypto/2sha256.c
@@ -35,9 +35,9 @@
  * SUCH DAMAGE.
  */
 
-#include "2sysincludes.h"
-#include "2common.h"
-#include "2sha.h"
+#include <crypto/2sysincludes.h>
+#include <crypto/2common.h>
+#include <crypto/2sha.h>
 
 #define SHFR(x, n)    (x >> n)
 #define ROTR(x, n)   ((x >> n) | (x << ((sizeof(x) << 3) - n)))
-- 
2.8.0.rc3.226.g39d4020

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akaros+unsubscr...@googlegroups.com.
To post to this group, send email to akaros@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to