Add tf_fuzz tool
This is fully derived from tf-m repo.
Signed-off-by: Karl Zhang <karl.zhang@arm.com>
Change-Id: I8d35e70eda9081af66d8fa3f3cb4beb1d953060e
diff --git a/tf_fuzz/utility/compute.hpp b/tf_fuzz/utility/compute.hpp
new file mode 100644
index 0000000..c6ece6c
--- /dev/null
+++ b/tf_fuzz/utility/compute.hpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef COMPUTE_HPP
+#define COMPUTE_HPP
+
+#include <cstdlib>
+
+using namespace std;
+
+/* Arguably at least, this LFSR-based hashing code is run more commonly on the
+ target itself -- included in the generated code -- than it is run here.
+ However, it's available here too, such as to parallel-calculate expected hash
+ values. */
+
+class crc32
+{
+public:
+ void seed_lfsr (uint32_t init_value);
+ /* lfsr_1b() performs one shift of the LFSR, factoring in a single bit of info,
+ that single bit must be in the low-order bit of the parameter. */
+ uint32_t lfsr_1b (uint32_t a_bit);
+ // crc() has two overloadings, calculating the CRC for byte or word quantities:
+ uint32_t crc (uint8_t a_byte);
+ uint32_t crc (uint16_t a_halfword);
+ uint32_t crc (uint32_t a_word);
+ crc32 (void);
+private:
+ const uint32_t polynomial = 0xb4bcd35c;
+ uint32_t shift_reg;
+};
+
+#endif /* COMPUTE_HPP */