Add a CRC module to mbedtls and baremetal config
Add a new CRC module along with some tests for it.
The table and the CRC function body is generated using pycrc v0.9.2.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index 9b88597..98df7c5 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -2729,6 +2729,17 @@
#define MBEDTLS_ERROR_C
/**
+ * \def MBEDTLS_CRC_C
+ *
+ * Enable the CRC calculating module
+ *
+ * Module: library/crc.c
+ *
+ * This module enables mbedtls_crc_update.
+ */
+//#define MBEDTLS_CRC_C
+
+/**
* \def MBEDTLS_GCM_C
*
* Enable the Galois/Counter Mode (GCM) for AES.
diff --git a/include/mbedtls/crc.h b/include/mbedtls/crc.h
new file mode 100644
index 0000000..0131666
--- /dev/null
+++ b/include/mbedtls/crc.h
@@ -0,0 +1,47 @@
+/*
+ * CRC-16/ARC implementation, generated using pycrc v0.9.2, https://pycrc.org.
+ *
+ * Used options: --model=crc-16 --algorithm=tbl --generate=h --std=C89 --table-idx-width 4
+ *
+ * Copyright (C) 2006-2020, ARM Limited, All Rights Reserved
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This file is part of mbed TLS (https://tls.mbed.org)
+ */
+
+#ifndef MBEDTLS_CRC_H
+#define MBEDTLS_CRC_H
+
+#include <stdlib.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Update the crc value with new data.
+ *
+ * \param[in] crc The current crc value.
+ * \param[in] data Pointer to a buffer of \a data_len bytes.
+ * \param[in] data_len Number of bytes in the \a data buffer.
+ * \return The updated crc value.
+ */
+uint16_t mbedtls_crc_update( uint16_t crc, const void *data, size_t data_len );
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* MBEDTLS_CRC_H */