Attest: Rename useful_buf to q_useful_buf
Set proper namespace to indicate that q_usful_buf
is originated from QCBOR library and to prevent
namespace collison.
Change-Id: I00a10ccc052dd4d4757f1c451d6534385e58ef00
Signed-off-by: Laurence Lundblade <lgl@securitytheory.com>
Co-authored-by: Tamas Ban <tamas.ban@arm.com>
diff --git a/lib/ext/qcbor/inc/UsefulBuf.h b/lib/ext/qcbor/inc/UsefulBuf.h
index 86a7da7..0aaa9b6 100644
--- a/lib/ext/qcbor/inc/UsefulBuf.h
+++ b/lib/ext/qcbor/inc/UsefulBuf.h
@@ -150,7 +150,7 @@
Eeyore's balloon fits beautifully, "it goes in and out like anything".
*/
-typedef struct useful_buf_c {
+typedef struct q_useful_buf_c {
const void *ptr;
size_t len;
} UsefulBufC;
@@ -161,7 +161,7 @@
that is to be filled in. The len is the amount of memory,
not the length of the valid data in the buffer.
*/
-typedef struct useful_buf {
+typedef struct q_useful_buf {
void *ptr;
size_t len;
} UsefulBuf;
diff --git a/lib/ext/qcbor/inc/q_useful_buf.h b/lib/ext/qcbor/inc/q_useful_buf.h
new file mode 100644
index 0000000..d7e38d4
--- /dev/null
+++ b/lib/ext/qcbor/inc/q_useful_buf.h
@@ -0,0 +1,151 @@
+/*
+ * q_useful_buf.h
+ *
+ * Copyright 2019, Laurence Lundblade
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * See BSD-3-Clause license in README.mdE.
+ */
+
+
+#ifndef __Q_USEFUL_BUF_H__
+#define __Q_USEFUL_BUF_H__
+
+#include "UsefulBuf.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * \file q_useful_buf.h
+ *
+ * \brief This is a TF-M coding style version of UsefulBuf.
+ * See UsefulBuf for documentation of these functions.
+ */
+
+
+#define NULL_Q_USEFUL_BUF_C NULLUsefulBufC
+
+#define NULL_Q_USEFUL_BUF NULLUsefulBuf
+
+
+static inline int q_useful_buf_c_is_null(struct q_useful_buf_c in)
+{
+ return UsefulBuf_IsNULLC(in);
+}
+
+
+static inline int q_useful_buf_is_null(struct q_useful_buf in)
+{
+ return UsefulBuf_IsNULL(in);
+}
+
+
+static inline int q_useful_buf_c_is_empty(struct q_useful_buf_c in)
+{
+ return UsefulBuf_IsEmptyC(in);
+}
+
+static inline int q_useful_buf_is_empty(struct q_useful_buf in)
+{
+ return UsefulBuf_IsEmpty(in);
+}
+
+
+static inline int q_useful_buf_is_null_or_empty(struct q_useful_buf in)
+{
+ return UsefulBuf_IsNULLOrEmpty(in);
+}
+
+
+static inline int q_useful_buf_c_is_null_or_empty(struct q_useful_buf_c in)
+{
+ return UsefulBuf_IsNULLOrEmptyC(in);
+}
+
+
+static inline struct q_useful_buf q_useful_buf_unconst(struct q_useful_buf_c in)
+{
+ return UsefulBuf_Unconst(in);
+}
+
+#define Q_USEFUL_BUF_FROM_SZ_LITERAL UsefulBuf_FROM_SZ_LITERAL
+
+#define Q_USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL UsefulBuf_FROM_BYTE_ARRAY_LITERAL
+
+#define Q_USEFUL_BUF_MAKE_STACK_UB UsefulBuf_MAKE_STACK_UB
+
+#define Q_USEFUL_BUF_FROM_BYTE_ARRAY UsefulBuf_FROM_BYTE_ARRAY
+
+
+static inline struct q_useful_buf_c q_useful_buf_from_sz(const char *string)
+{
+ return UsefulBuf_FromSZ(string);
+}
+
+static inline struct q_useful_buf_c
+useful_buf_copy_offset(struct q_useful_buf dest,
+ size_t offset,
+ struct q_useful_buf_c src)
+{
+ return UsefulBuf_CopyOffset(dest, offset, src);
+}
+
+
+
+static inline struct q_useful_buf_c q_useful_buf_copy(struct q_useful_buf dest,
+ struct q_useful_buf_c src)
+{
+ return UsefulBuf_Copy(dest, src);
+}
+
+
+static inline struct q_useful_buf_c q_useful_buf_set(struct q_useful_buf dest,
+ uint8_t value)
+{
+ return UsefulBuf_Set(dest, value);
+}
+
+
+static inline struct q_useful_buf_c q_useful_buf_copy_ptr(struct q_useful_buf dest,
+ const void *ptr,
+ size_t len)
+{
+ return UsefulBuf_CopyPtr(dest, ptr, len);
+}
+
+
+static inline struct q_useful_buf_c q_useful_buf_head(struct q_useful_buf_c buf,
+ size_t amount)
+{
+ return UsefulBuf_Head(buf, amount);
+}
+
+static inline struct q_useful_buf_c q_useful_buf_tail(struct q_useful_buf_c buf,
+ size_t amount)
+{
+ return UsefulBuf_Tail(buf, amount);
+}
+
+static inline int q_useful_buf_compare(const struct q_useful_buf_c buf1,
+ const struct q_useful_buf_c buf2)
+{
+ return UsefulBuf_Compare(buf1, buf2);
+}
+
+static inline size_t
+useful_buf_find_bytes(const struct q_useful_buf_c bytes_to_search,
+ const struct q_useful_buf_c bytes_to_find)
+{
+ return UsefulBuf_FindBytes(bytes_to_search, bytes_to_find);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __Q_USEFUL_BUF_H__ */
diff --git a/lib/ext/qcbor/inc/useful_buf.h b/lib/ext/qcbor/inc/useful_buf.h
deleted file mode 100644
index dcb88b8..0000000
--- a/lib/ext/qcbor/inc/useful_buf.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * useful_buf.h
- *
- * Copyright 2019, Laurence Lundblade
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * See BSD-3-Clause license in README.mdE.
- */
-
-
-#ifndef __USEFUL_BUF_H__
-#define __USEFUL_BUF_H__
-
-#include "UsefulBuf.h"
-
-
-/**
- * \file useful_buf.h
- *
- * \brief This is a TF-M coding style version of UsefulBuf.
- * See UsefulBuf for documentation of these functions.
- */
-
-
-#define NULL_USEFUL_BUF_C NULLUsefulBufC
-
-#define NULL_USEFUL_BUF NULLUsefulBuf
-
-
-static inline int useful_buf_c_is_null(struct useful_buf_c in)
-{
- return UsefulBuf_IsNULLC(in);
-}
-
-
-static inline int useful_buf_is_null(struct useful_buf in)
-{
- return UsefulBuf_IsNULL(in);
-}
-
-
-static inline int useful_buf_c_is_empty(struct useful_buf_c in)
-{
- return UsefulBuf_IsEmptyC(in);
-}
-
-static inline int useful_buf_is_empty(struct useful_buf in)
-{
- return UsefulBuf_IsEmpty(in);
-}
-
-
-static inline int useful_buf_is_null_or_empty(struct useful_buf in)
-{
- return UsefulBuf_IsNULLOrEmpty(in);
-}
-
-
-static inline int useful_buf_c_is_null_or_empty(struct useful_buf_c in)
-{
- return UsefulBuf_IsNULLOrEmptyC(in);
-}
-
-
-static inline struct useful_buf useful_buf_unconst(struct useful_buf_c in)
-{
- return UsefulBuf_Unconst(in);
-}
-
-#define USEFUL_BUF_FROM_SZ_LITERAL UsefulBuf_FROM_SZ_LITERAL
-
-#define USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL UsefulBuf_FROM_BYTE_ARRAY_LITERAL
-
-#define USEFUL_BUF_MAKE_STACK_UB UsefulBuf_MAKE_STACK_UB
-
-#define USEFUL_BUF_FROM_BYTE_ARRAY UsefulBuf_FROM_BYTE_ARRAY
-
-
-static inline struct useful_buf_c useful_buf_from_sz(const char *string)
-{
- return UsefulBuf_FromSZ(string);
-}
-
-static inline struct
-useful_buf_c useful_buf_copy_offset(struct useful_buf dest,
- size_t offset,
- struct useful_buf_c src)
-{
- return UsefulBuf_CopyOffset(dest, offset, src);
-}
-
-
-
-static inline struct useful_buf_c useful_buf_copy(struct useful_buf dest,
- struct useful_buf_c src)
-{
- return UsefulBuf_Copy(dest, src);
-}
-
-
-static inline struct useful_buf_c useful_buf_set(struct useful_buf dest,
- uint8_t value)
-{
- return UsefulBuf_Set(dest, value);
-}
-
-
-static inline struct useful_buf_c useful_buf_copy_ptr(struct useful_buf dest,
- const void *ptr,
- size_t len)
-{
- return UsefulBuf_CopyPtr(dest, ptr, len);
-}
-
-
-static inline struct useful_buf_c useful_buf_head(struct useful_buf_c buf,
- size_t amount)
-{
- return UsefulBuf_Head(buf, amount);
-}
-
-static inline struct useful_buf_c useful_buf_tail(struct useful_buf_c buf,
- size_t amount)
-{
- return UsefulBuf_Tail(buf, amount);
-}
-
-static inline int useful_buf_compare(const struct useful_buf_c buf1,
- const struct useful_buf_c buf2)
-{
- return UsefulBuf_Compare(buf1, buf2);
-}
-
-static inline size_t
-useful_buf_find_bytes(const struct useful_buf_c bytes_to_search,
- const struct useful_buf_c bytes_to_find)
-{
- return UsefulBuf_FindBytes(bytes_to_search, bytes_to_find);
-}
-
-
-#endif /* __USEFUL_BUF_H__ */
diff --git a/lib/t_cose/inc/t_cose_common.h b/lib/t_cose/inc/t_cose_common.h
index d509a4b..1459702 100644
--- a/lib/t_cose/inc/t_cose_common.h
+++ b/lib/t_cose/inc/t_cose_common.h
@@ -12,6 +12,9 @@
#ifndef __T_COSE_COMMON_H__
#define __T_COSE_COMMON_H__
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
* \file t_cose_common.h
@@ -143,6 +146,9 @@
T_COSE_ERR_SHORT_CIRCUIT_SIG
};
+#ifdef __cplusplus
+}
+#endif
#endif /* __T_COSE_COMMON_H__ */
diff --git a/lib/t_cose/inc/t_cose_sign1_sign.h b/lib/t_cose/inc/t_cose_sign1_sign.h
index 35b26e5..dbe8896 100644
--- a/lib/t_cose/inc/t_cose_sign1_sign.h
+++ b/lib/t_cose/inc/t_cose_sign1_sign.h
@@ -16,6 +16,10 @@
#include "qcbor.h"
#include "t_cose_common.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \file t_cose_sign1_sign.h
@@ -59,13 +63,13 @@
*/
struct t_cose_sign1_ctx {
/* Private data structure */
- uint8_t buffer_for_protected_headers[
- T_COSE_SIGN1_MAX_PROT_HEADER];
- struct useful_buf_c protected_headers;
- int32_t cose_algorithm_id;
- int32_t key_select;
- bool short_circuit_sign;
- QCBOREncodeContext *cbor_encode_ctx;
+ uint8_t buffer_for_protected_headers[
+ T_COSE_SIGN1_MAX_PROT_HEADER];
+ struct q_useful_buf_c protected_headers;
+ int32_t cose_algorithm_id;
+ int32_t key_select;
+ bool short_circuit_sign;
+ QCBOREncodeContext *cbor_encode_ctx;
};
@@ -175,7 +179,11 @@
* cbor_encode_ctx by calling \c QCBOREncode_Finish()
*/
enum t_cose_err_t t_cose_sign1_finish(struct t_cose_sign1_ctx *me,
- struct useful_buf_c payload);
+ struct q_useful_buf_c payload);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __T_COSE_SIGN1_H__ */
diff --git a/lib/t_cose/src/t_cose_crypto.h b/lib/t_cose/src/t_cose_crypto.h
index b77af32..d66f983 100644
--- a/lib/t_cose/src/t_cose_crypto.h
+++ b/lib/t_cose/src/t_cose_crypto.h
@@ -13,10 +13,13 @@
#define __T_COSE_CRYPTO_H__
#include "t_cose_common.h"
-#include "useful_buf.h"
+#include "q_useful_buf.h"
#include <stdint.h>
#include "t_cose_defines.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
* \file t_cose_crypto.h
@@ -27,8 +30,8 @@
* This is small wrapper around the cryptographic functions to:
* - Map COSE algorithm IDs to TF-M algorithm IDs
* - Map crypto errors to \ref t_cose_err_t errors
- * - Have inputs and outputs be \c struct \c useful_buf_c and
- * \c struct \c useful_buf
+ * - Have inputs and outputs be \c struct \c q_useful_buf_c and
+ * \c struct \c q_useful_buf
* - Handle key selection
*
* The idea is that implementations can be made of these functions
@@ -45,14 +48,14 @@
* the IANA registry.
*
* Binary data is returned to the caller using a \c struct \c
- * useful_buf to pass the buffer to receive the data and its length in
- * and a \c useful_buf_c to return the pointer and length of the
+ * q_useful_buf to pass the buffer to receive the data and its length in
+ * and a \c q_useful_buf_c to return the pointer and length of the
* returned data. The point of this is coding hygiene. The buffer
* passed in is not const as it is to be modified. The \c
- * useful_buf_c returned is const.
+ * q_useful_buf_c returned is const.
*
- * The pointer in the \c useful_buf_c will always point to the buffer
- * passed in via the \c useful_buf so the lifetime of the data is
+ * The pointer in the \c q_useful_buf_c will always point to the buffer
+ * passed in via the \c q_useful_buf so the lifetime of the data is
* under control of the caller.
*
* This is not intended as any sort of general cryptographic API. It
@@ -137,7 +140,7 @@
* The key selection depends on the platform / OS.
*
* See the note in the Detailed Description (the \\file comment block)
- * for details on how \c useful_buf and \c useful_buf_c are used to
+ * for details on how \c q_useful_buf and \c q_useful_buf_c are used to
* return the signature.
*
* To find out the size of the signature buffer needed, call this with
@@ -148,9 +151,9 @@
enum t_cose_err_t
t_cose_crypto_pub_key_sign(int32_t cose_alg_id,
int32_t key_select,
- struct useful_buf_c hash_to_sign,
- struct useful_buf signature_buffer,
- struct useful_buf_c *signature);
+ struct q_useful_buf_c hash_to_sign,
+ struct q_useful_buf signature_buffer,
+ struct q_useful_buf_c *signature);
/**
@@ -166,7 +169,7 @@
* locally (\c \#define) if the needed one
* hasn't been registered.
* \param[in] key_select Verification key selection.
- * \param[in] key_id A key id or \c NULL_USEFUL_BUF_C.
+ * \param[in] key_id A key id or \c NULL_Q_USEFUL_BUF_C.
* \param[in] hash_to_verify The data or hash that is to be verified.
* \param[in] signature The signature.
*
@@ -174,7 +177,7 @@
* hash_to_verify passed in.
*
* The public key used to verify the signature is selected by the \c
- * key_id if it is not \c NULL_USEFUL_BUF_C or the \c key_select if it
+ * key_id if it is not \c NULL_Q_USEFUL_BUF_C or the \c key_select if it
* is.
*
* The key selected must be, or include, a public key of the correct
@@ -206,9 +209,9 @@
enum t_cose_err_t
t_cose_crypto_pub_key_verify(int32_t cose_alg_id,
int32_t key_select,
- struct useful_buf_c key_id,
- struct useful_buf_c hash_to_verify,
- struct useful_buf_c signature);
+ struct q_useful_buf_c key_id,
+ struct q_useful_buf_c hash_to_verify,
+ struct q_useful_buf_c signature);
/**
@@ -228,9 +231,9 @@
*
* \param[in] key_select Used to look up the public
* key to return when \c kid is
- * \c NULL_USEFUL_BUF_C.
+ * \c NULL_Q_USEFUL_BUF_C.
* \param[in] kid A key ID to look up against. May be
- * \c NULL_USEFUL_BUF_C. This is typically
+ * \c NULL_Q_USEFUL_BUF_C. This is typically
* the kid from the COSE unprotected header.
* \param[out] cose_curve_id The curve ID of the key returned as
* defined by [COSE (RFC 8152)]
@@ -265,17 +268,17 @@
* coordinate for the NIST P-256 curve.
*
* See the note in the Detailed Description (the \\file comment block)
- * for details on how \c useful_buf and \c useful_buf_c are used to
+ * for details on how \c q_useful_buf and \c q_useful_buf_c are used to
* return the X and Y coordinates.
*/
enum t_cose_err_t
t_cose_crypto_get_ec_pub_key(int32_t key_select,
- struct useful_buf_c kid,
+ struct q_useful_buf_c kid,
int32_t *cose_curve_id,
- struct useful_buf buf_to_hold_x_coord,
- struct useful_buf buf_to_hold_y_coord,
- struct useful_buf_c *x_coord,
- struct useful_buf_c *y_coord);
+ struct q_useful_buf buf_to_hold_x_coord,
+ struct q_useful_buf buf_to_hold_y_coord,
+ struct q_useful_buf_c *x_coord,
+ struct q_useful_buf_c *y_coord);
/*
@@ -361,7 +364,7 @@
* not do anything.
*/
void t_cose_crypto_hash_update(struct t_cose_crypto_hash *hash_ctx,
- struct useful_buf_c data_to_hash);
+ struct q_useful_buf_c data_to_hash);
/**
@@ -386,13 +389,13 @@
* returned here.
*
* See the note in the Detailed Description (the \\file comment block)
- * for details on how \c useful_buf and \c useful_buf_c are used to
+ * for details on how \c q_useful_buf and \c q_useful_buf_c are used to
* return the hash.
*/
enum t_cose_err_t
t_cose_crypto_hash_finish(struct t_cose_crypto_hash *hash_ctx,
- struct useful_buf buffer_to_hold_result,
- struct useful_buf_c *hash_result);
+ struct q_useful_buf buffer_to_hold_result,
+ struct q_useful_buf_c *hash_result);
@@ -410,4 +413,8 @@
}
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __T_COSE_CRYPTO_H__ */
diff --git a/lib/t_cose/src/t_cose_psa_crypto.c b/lib/t_cose/src/t_cose_psa_crypto.c
index 89c8fa3..56a3b8e 100644
--- a/lib/t_cose/src/t_cose_psa_crypto.c
+++ b/lib/t_cose/src/t_cose_psa_crypto.c
@@ -31,9 +31,9 @@
enum t_cose_err_t
t_cose_crypto_pub_key_sign(int32_t cose_alg_id,
int32_t key_select,
- struct useful_buf_c hash_to_sign,
- struct useful_buf signature_buffer,
- struct useful_buf_c *signature)
+ struct q_useful_buf_c hash_to_sign,
+ struct q_useful_buf signature_buffer,
+ struct q_useful_buf_c *signature)
{
enum t_cose_err_t cose_ret = T_COSE_SUCCESS;
enum psa_attest_err_t attest_ret;
@@ -84,12 +84,12 @@
enum t_cose_err_t
t_cose_crypto_get_ec_pub_key(int32_t key_select,
- struct useful_buf_c kid,
+ struct q_useful_buf_c kid,
int32_t *cose_curve_id,
- struct useful_buf buf_to_hold_x_coord,
- struct useful_buf buf_to_hold_y_coord,
- struct useful_buf_c *x_coord,
- struct useful_buf_c *y_coord)
+ struct q_useful_buf buf_to_hold_x_coord,
+ struct q_useful_buf buf_to_hold_y_coord,
+ struct q_useful_buf_c *x_coord,
+ struct q_useful_buf_c *y_coord)
{
enum tfm_plat_err_t plat_res;
enum ecc_curve_t cose_curve;
@@ -232,7 +232,7 @@
}
void t_cose_crypto_hash_update(struct t_cose_crypto_hash *hash_ctx,
- struct useful_buf_c data_to_hash)
+ struct q_useful_buf_c data_to_hash)
{
struct t_cose_psa_crypto_hash *psa_hash_ctx;
@@ -259,8 +259,8 @@
enum t_cose_err_t
t_cose_crypto_hash_finish(struct t_cose_crypto_hash *hash_ctx,
- struct useful_buf buffer_to_hold_result,
- struct useful_buf_c *hash_result)
+ struct q_useful_buf buffer_to_hold_result,
+ struct q_useful_buf_c *hash_result)
{
enum t_cose_err_t cose_ret = T_COSE_SUCCESS;
psa_status_t psa_ret;
diff --git a/lib/t_cose/src/t_cose_sign1_sign.c b/lib/t_cose/src/t_cose_sign1_sign.c
index 8f55bc0..47ee795 100644
--- a/lib/t_cose/src/t_cose_sign1_sign.c
+++ b/lib/t_cose/src/t_cose_sign1_sign.c
@@ -46,9 +46,9 @@
*/
static inline enum t_cose_err_t
short_circuit_sign(int32_t cose_alg_id,
- struct useful_buf_c hash_to_sign,
- struct useful_buf signature_buffer,
- struct useful_buf_c *signature)
+ struct q_useful_buf_c hash_to_sign,
+ struct q_useful_buf signature_buffer,
+ struct q_useful_buf_c *signature)
{
/* approximate stack use on 32-bit machine: local use: 16
*/
@@ -119,28 +119,28 @@
*/
static enum t_cose_err_t
t_cose_encode_cose_key(int32_t key_select,
- struct useful_buf buffer_for_cose_key,
- struct useful_buf_c *cose_key)
+ struct q_useful_buf buffer_for_cose_key,
+ struct q_useful_buf_c *cose_key)
{
/* approximate stack use on 32-bit machine:
* local use: 328
* with calls: 370
*/
- enum t_cose_err_t return_value;
- QCBORError qcbor_result;
- QCBOREncodeContext cbor_encode_ctx;
- USEFUL_BUF_MAKE_STACK_UB( buffer_for_x_coord,
- T_COSE_CRYPTO_EC_P256_COORD_SIZE);
- USEFUL_BUF_MAKE_STACK_UB( buffer_for_y_coord,
- T_COSE_CRYPTO_EC_P256_COORD_SIZE);
- struct useful_buf_c x_coord;
- struct useful_buf_c y_coord;
- int32_t cose_curve_id;
- struct useful_buf_c encoded_key_id;
+ enum t_cose_err_t return_value;
+ QCBORError qcbor_result;
+ QCBOREncodeContext cbor_encode_ctx;
+ Q_USEFUL_BUF_MAKE_STACK_UB( buffer_for_x_coord,
+ T_COSE_CRYPTO_EC_P256_COORD_SIZE);
+ Q_USEFUL_BUF_MAKE_STACK_UB( buffer_for_y_coord,
+ T_COSE_CRYPTO_EC_P256_COORD_SIZE);
+ struct q_useful_buf_c x_coord;
+ struct q_useful_buf_c y_coord;
+ int32_t cose_curve_id;
+ struct q_useful_buf_c encoded_key_id;
/* Get the public key x and y */
return_value = t_cose_crypto_get_ec_pub_key(key_select,
- NULL_USEFUL_BUF_C,
+ NULL_Q_USEFUL_BUF_C,
&cose_curve_id,
buffer_for_x_coord,
buffer_for_y_coord,
@@ -199,9 +199,9 @@
* Having this as a separate function helps keep stack usage down and
* is convenient.
*/
-static enum t_cose_err_t quick_sha256(struct useful_buf_c bytes_to_hash,
- struct useful_buf buffer_for_hash,
- struct useful_buf_c *hash)
+static enum t_cose_err_t quick_sha256(struct q_useful_buf_c bytes_to_hash,
+ struct q_useful_buf buffer_for_hash,
+ struct q_useful_buf_c *hash)
{
/* approximate stack use on 32-bit machine:
local use: 132
@@ -241,18 +241,18 @@
* created here.
*/
static inline enum t_cose_err_t get_keyid(int32_t key_select,
- struct useful_buf buffer_for_key_id,
- struct useful_buf_c *key_id)
+ struct q_useful_buf buffer_for_key_id,
+ struct q_useful_buf_c *key_id)
{
/* approximate stack use on 32-bit machine:
* local use: 100
* with calls inlined: 560
* with calls not inlined: 428
*/
- enum t_cose_err_t return_value;
- USEFUL_BUF_MAKE_STACK_UB( buffer_for_cose_key,
- MAX_ENCODED_COSE_KEY_SIZE);
- struct useful_buf_c cose_key;
+ enum t_cose_err_t return_value;
+ Q_USEFUL_BUF_MAKE_STACK_UB( buffer_for_cose_key,
+ MAX_ENCODED_COSE_KEY_SIZE);
+ struct q_useful_buf_c cose_key;
/* Doing the COSE encoding and the hashing in separate functions
* called from here reduces the stack usage in this function by a
@@ -285,28 +285,28 @@
* headers is put.
*
* \return The pointer and length of the protected headers is
- * returned, or \c NULL_USEFUL_BUF_C if this fails.
+ * returned, or \c NULL_Q_USEFUL_BUF_C if this fails.
*
* The protected headers are returned in fully encoded CBOR format as
* they are added to the \c COSE_Sign1 as a binary string. This is
* different from the unprotected headers which are not handled this
* way.
*
- * This returns \c NULL_USEFUL_BUF_C if buffer_for_header was too
+ * This returns \c NULL_Q_USEFUL_BUF_C if buffer_for_header was too
* small. See also definition of \ref T_COSE_SIGN1_MAX_PROT_HEADER
*/
-static inline struct useful_buf_c
+static inline struct q_useful_buf_c
make_protected_header(int32_t cose_alg_id,
- struct useful_buf buffer_for_header)
+ struct q_useful_buf buffer_for_header)
{
/* approximate stack use on 32-bit machine:
* local use: 170
* with calls: 210
*/
- struct useful_buf_c protected_headers;
- QCBORError qcbor_result;
- QCBOREncodeContext cbor_encode_ctx;
- struct useful_buf_c return_value;
+ struct q_useful_buf_c protected_headers;
+ QCBORError qcbor_result;
+ QCBOREncodeContext cbor_encode_ctx;
+ struct q_useful_buf_c return_value;
QCBOREncode_Init(&cbor_encode_ctx, buffer_for_header);
QCBOREncode_OpenMap(&cbor_encode_ctx);
@@ -319,7 +319,7 @@
if(qcbor_result == QCBOR_SUCCESS) {
return_value = protected_headers;
} else {
- return_value = NULL_USEFUL_BUF_C;
+ return_value = NULL_Q_USEFUL_BUF_C;
}
return return_value;
@@ -338,7 +338,7 @@
* The unprotected headers added by this are just the key ID
*/
static inline void add_unprotected_headers(QCBOREncodeContext *cbor_encode_ctx,
- struct useful_buf_c kid)
+ struct q_useful_buf_c kid)
{
QCBOREncode_OpenMap(cbor_encode_ctx);
QCBOREncode_AddBytesToMapN(cbor_encode_ctx, COSE_HEADER_PARAM_KID, kid);
@@ -361,11 +361,11 @@
* with calls not inlined: 500
*/
- int32_t hash_alg;
- enum t_cose_err_t return_value;
- USEFUL_BUF_MAKE_STACK_UB( buffer_for_kid, T_COSE_CRYPTO_SHA256_SIZE);
- struct useful_buf_c kid;
- struct useful_buf buffer_for_protected_header;
+ int32_t hash_alg;
+ enum t_cose_err_t return_value;
+ Q_USEFUL_BUF_MAKE_STACK_UB( buffer_for_kid, T_COSE_CRYPTO_SHA256_SIZE);
+ struct q_useful_buf_c kid;
+ struct q_useful_buf buffer_for_protected_header;
/* Check the cose_alg_id now by getting the hash alg as an early
error check even though it is not used until later. */
@@ -398,10 +398,10 @@
/* The protected headers, which are added as a wrapped bstr */
buffer_for_protected_header =
- USEFUL_BUF_FROM_BYTE_ARRAY(me->buffer_for_protected_headers);
+ Q_USEFUL_BUF_FROM_BYTE_ARRAY(me->buffer_for_protected_headers);
me->protected_headers = make_protected_header(cose_alg_id,
buffer_for_protected_header);
- if(useful_buf_c_is_null(me->protected_headers)) {
+ if(q_useful_buf_c_is_null(me->protected_headers)) {
/* The sizing of storage for protected headers is
off (should never happen in tested, released code) */
return_value = T_COSE_SUCCESS;
@@ -427,24 +427,24 @@
* Public function. See t_cose_sign1_sign.h
*/
enum t_cose_err_t t_cose_sign1_finish(struct t_cose_sign1_ctx *me,
- struct useful_buf_c signed_payload)
+ struct q_useful_buf_c signed_payload)
{
/* approximate stack use on 32-bit machine:
* local use: 116
* with calls inline: 500
* with calls not inlined; 450
*/
- enum t_cose_err_t return_value;
+ enum t_cose_err_t return_value;
/* pointer and length of the completed tbs hash */
- struct useful_buf_c tbs_hash;
+ struct q_useful_buf_c tbs_hash;
/* Pointer and length of the completed signature */
- struct useful_buf_c signature;
+ struct q_useful_buf_c signature;
/* Buffer for the actual signature */
- USEFUL_BUF_MAKE_STACK_UB( buffer_for_signature,
- T_COSE_MAX_EC_SIG_SIZE);
+ Q_USEFUL_BUF_MAKE_STACK_UB( buffer_for_signature,
+ T_COSE_MAX_EC_SIG_SIZE);
/* Buffer for the tbs hash. Only big enough for SHA256 */
- USEFUL_BUF_MAKE_STACK_UB( buffer_for_tbs_hash,
- T_COSE_CRYPTO_SHA256_SIZE);
+ Q_USEFUL_BUF_MAKE_STACK_UB( buffer_for_tbs_hash,
+ T_COSE_CRYPTO_SHA256_SIZE);
/* Create the hash of the to-be-signed bytes. Inputs to the hash
* are the protected headers, the payload that getting signed, the
diff --git a/lib/t_cose/src/t_cose_util.c b/lib/t_cose/src/t_cose_util.c
index ba4910e..4228c2b 100644
--- a/lib/t_cose/src/t_cose_util.c
+++ b/lib/t_cose/src/t_cose_util.c
@@ -76,10 +76,10 @@
* Public function. See t_cose_util.h
*/
enum t_cose_err_t create_tbs_hash(int32_t cose_alg_id,
- struct useful_buf buffer_for_hash,
- struct useful_buf_c *hash,
- struct useful_buf_c protected_headers,
- struct useful_buf_c payload)
+ struct q_useful_buf buffer_for_hash,
+ struct q_useful_buf_c *hash,
+ struct q_useful_buf_c protected_headers,
+ struct q_useful_buf_c payload)
{
/* approximate stack use on 32-bit machine:
* local use: 320
@@ -88,7 +88,7 @@
enum t_cose_err_t return_value;
QCBOREncodeContext cbor_encode_ctx;
UsefulBuf_MAKE_STACK_UB( buffer_for_TBS_first_part, T_COSE_SIZE_OF_TBS);
- struct useful_buf_c tbs_first_part;
+ struct q_useful_buf_c tbs_first_part;
QCBORError qcbor_result;
struct t_cose_crypto_hash hash_ctx;
int32_t hash_alg_id;
@@ -103,14 +103,14 @@
QCBOREncode_AddBytes(&cbor_encode_ctx,
protected_headers);
/* sign_protected */
- QCBOREncode_AddBytes(&cbor_encode_ctx, NULL_USEFUL_BUF_C);
+ QCBOREncode_AddBytes(&cbor_encode_ctx, NULL_Q_USEFUL_BUF_C);
/* external_aad */
- QCBOREncode_AddBytes(&cbor_encode_ctx, NULL_USEFUL_BUF_C);
+ QCBOREncode_AddBytes(&cbor_encode_ctx, NULL_Q_USEFUL_BUF_C);
/* fake payload */
- QCBOREncode_AddBytes(&cbor_encode_ctx, NULL_USEFUL_BUF_C);
+ QCBOREncode_AddBytes(&cbor_encode_ctx, NULL_Q_USEFUL_BUF_C);
QCBOREncode_CloseArray(&cbor_encode_ctx);
- /* get the result and convert it to struct useful_buf_c representation */
+ /* get the result and convert it to struct q_useful_buf_c representation */
qcbor_result = QCBOREncode_Finish(&cbor_encode_ctx, &tbs_first_part);
if(qcbor_result) {
/* Mainly means that the protected_headers were too big
@@ -137,8 +137,8 @@
* buffer for the whole cose sign1.
*/
t_cose_crypto_hash_update(&hash_ctx,
- useful_buf_head(tbs_first_part,
- tbs_first_part.len - 2));
+ q_useful_buf_head(tbs_first_part,
+ tbs_first_part.len - 2));
/* Hash the payload */
t_cose_crypto_hash_update(&hash_ctx, payload);
@@ -157,8 +157,8 @@
* Public function. See t_cose_util.h
*/
enum t_cose_err_t
-get_short_circuit_kid(struct useful_buf buffer_for_kid,
- struct useful_buf_c *kid)
+get_short_circuit_kid(struct q_useful_buf buffer_for_kid,
+ struct q_useful_buf_c *kid)
{
/* This is a random hard coded key ID that is used to indicate
* short-circuit signing. It is OK to hard code this as the
@@ -179,11 +179,11 @@
return T_COSE_ERR_BAD_SHORT_CIRCUIT_KID;
}
- *kid = useful_buf_copy(buffer_for_kid,
- USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(
- defined_short_circuit_kid));
+ *kid = q_useful_buf_copy(buffer_for_kid,
+ Q_USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(
+ defined_short_circuit_kid));
- return useful_buf_c_is_null(*kid) ?
+ return q_useful_buf_c_is_null(*kid) ?
T_COSE_ERR_KEY_BUFFER_SIZE :
T_COSE_SUCCESS;
}
diff --git a/lib/t_cose/src/t_cose_util.h b/lib/t_cose/src/t_cose_util.h
index 7b39dc3..5539862 100644
--- a/lib/t_cose/src/t_cose_util.h
+++ b/lib/t_cose/src/t_cose_util.h
@@ -13,9 +13,13 @@
#define __T_COSE_UTIL_H__
#include <stdint.h>
-#include "useful_buf.h"
+#include "q_useful_buf.h"
#include "t_cose_common.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \file t_cose_util.h
*
@@ -79,10 +83,10 @@
* "TBS" bytes.
*/
enum t_cose_err_t create_tbs_hash(int32_t cose_alg_id,
- struct useful_buf buffer_for_hash,
- struct useful_buf_c *hash,
- struct useful_buf_c protected_headers,
- struct useful_buf_c payload);
+ struct q_useful_buf buffer_for_hash,
+ struct q_useful_buf_c *hash,
+ struct q_useful_buf_c protected_headers,
+ struct q_useful_buf_c payload);
/**
@@ -120,7 +124,11 @@
*
*/
enum t_cose_err_t
-get_short_circuit_kid(struct useful_buf buffer_for_kid,
- struct useful_buf_c *kid);
+get_short_circuit_kid(struct q_useful_buf buffer_for_kid,
+ struct q_useful_buf_c *kid);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* __T_COSE_UTIL_H__ */
diff --git a/secure_fw/services/initial_attestation/attest_token.c b/secure_fw/services/initial_attestation/attest_token.c
index 8cf5f74..077a57b 100644
--- a/secure_fw/services/initial_attestation/attest_token.c
+++ b/secure_fw/services/initial_attestation/attest_token.c
@@ -81,7 +81,7 @@
uint32_t opt_flags,
int32_t key_select,
int32_t cose_alg_id,
- const struct useful_buf *out_buf)
+ const struct q_useful_buf *out_buf)
{
/* approximate stack usage on 32-bit machine: 4 bytes */
enum t_cose_err_t cose_return_value;
@@ -146,7 +146,7 @@
*/
void attest_token_add_bstr(struct attest_token_ctx *me,
int32_t label,
- const struct useful_buf_c *bstr)
+ const struct q_useful_buf_c *bstr)
{
QCBOREncode_AddBytesToMapN(&(me->cbor_enc_ctx),
label,
@@ -159,7 +159,7 @@
*/
void attest_token_add_tstr(struct attest_token_ctx *me,
int32_t label,
- const struct useful_buf_c *tstr)
+ const struct q_useful_buf_c *tstr)
{
QCBOREncode_AddTextToMapN(&(me->cbor_enc_ctx), label, *tstr);
}
@@ -170,7 +170,7 @@
*/
void attest_token_add_encoded(struct attest_token_ctx *me,
int32_t label,
- const struct useful_buf_c *encoded)
+ const struct q_useful_buf_c *encoded)
{
QCBOREncode_AddEncodedToMapN(&(me->cbor_enc_ctx), label, *encoded);
}
@@ -181,14 +181,14 @@
*/
enum attest_token_err_t
attest_token_finish(struct attest_token_ctx *me,
- struct useful_buf_c *completed_token)
+ struct q_useful_buf_c *completed_token)
{
/* approximate stack usage on 32-bit machine: 4 + 4 + 8 + 8 = 24 */
enum attest_token_err_t return_value = ATTEST_TOKEN_ERR_SUCCESS;
/* The payload with all the claims that is signed */
- struct useful_buf_c token_payload_ub;
+ struct q_useful_buf_c token_payload_ub;
/* The completed and signed encoded cose_sign1 */
- struct useful_buf_c completed_token_ub;
+ struct q_useful_buf_c completed_token_ub;
QCBORError qcbor_result;
enum t_cose_err_t cose_return_value;
diff --git a/secure_fw/services/initial_attestation/attest_token.h b/secure_fw/services/initial_attestation/attest_token.h
index 903c42b..eac7c6e 100644
--- a/secure_fw/services/initial_attestation/attest_token.h
+++ b/secure_fw/services/initial_attestation/attest_token.h
@@ -15,6 +15,10 @@
#include "qcbor.h"
#include "t_cose_sign1_sign.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \file attest_token.h
@@ -24,7 +28,7 @@
* The context and functions here are the way to create an attestation
* token. The steps are roughly:
*
- * -# Creation and initialize an attest_token_ctx indicating the
+ * -# Create and initialize an attest_token_ctx indicating the
* options, key and such using attest_token_start().
*
* -# Use various add methods to fill in the payload with claims. The
@@ -75,7 +79,9 @@
/** Tampering detected in cryptographic function. */
ATTEST_TOKEN_ERR_TAMPERING_DETECTED,
/** Verification key is not found or of wrong type. */
- ATTEST_TOKEN_ERR_VERIFICATION_KEY
+ ATTEST_TOKEN_ERR_VERIFICATION_KEY,
+ /** */
+ ATTEST_TOKEN_ERR_NO_VALID_TOKEN
};
@@ -153,7 +159,7 @@
uint32_t opt_flags,
int32_t key_select,
int32_t cose_alg_id,
- const struct useful_buf *out_buffer);
+ const struct q_useful_buf *out_buffer);
@@ -193,7 +199,7 @@
*/
void attest_token_add_bstr(struct attest_token_ctx *me,
int32_t label,
- const struct useful_buf_c *value);
+ const struct q_useful_buf_c *value);
/**
* \brief Add a text string claim
@@ -204,7 +210,7 @@
*/
void attest_token_add_tstr(struct attest_token_ctx *me,
int32_t label,
- const struct useful_buf_c *value);
+ const struct q_useful_buf_c *value);
/**
* \brief Add some already-encoded CBOR to payload
@@ -219,7 +225,7 @@
*/
void attest_token_add_encoded(struct attest_token_ctx *me,
int32_t label,
- const struct useful_buf_c *encoded);
+ const struct q_useful_buf_c *encoded);
/**
@@ -236,6 +242,10 @@
*/
enum attest_token_err_t
attest_token_finish(struct attest_token_ctx *me,
- struct useful_buf_c *completed_token);
+ struct q_useful_buf_c *completed_token);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* __ATTEST_TOKEN_H__ */
diff --git a/secure_fw/services/initial_attestation/attestation_core.c b/secure_fw/services/initial_attestation/attestation_core.c
index 245c1cf..5a67330 100644
--- a/secure_fw/services/initial_attestation/attestation_core.c
+++ b/secure_fw/services/initial_attestation/attestation_core.c
@@ -237,7 +237,7 @@
static enum psa_attest_err_t
attest_add_sw_component_claim(struct attest_token_ctx *token_ctx,
uint8_t tlv_id,
- const struct useful_buf_c *claim_value)
+ const struct q_useful_buf_c *claim_value)
{
int32_t res;
uint32_t value;
@@ -308,7 +308,7 @@
uint8_t tlv_id;
uint8_t *tlv_ptr = tlv_address;
int32_t found = 1;
- struct useful_buf_c claim_value;
+ struct q_useful_buf_c claim_value;
enum psa_attest_err_t res;
QCBOREncodeContext *cbor_encode_ctx;
@@ -376,7 +376,7 @@
uint8_t *tlv_ptr = tlv_address;
int32_t found = 1;
uint32_t measurement_claim_cnt = 0;
- struct useful_buf_c claim_value;
+ struct q_useful_buf_c claim_value;
QCBOREncodeContext *cbor_encode_ctx;
/* Create local copy to avoid unaligned access */
@@ -500,7 +500,7 @@
__attribute__ ((aligned(4)))
uint8_t boot_seed[BOOT_SEED_SIZE];
enum tfm_plat_err_t res;
- struct useful_buf_c claim_value = {0};
+ struct q_useful_buf_c claim_value = {0};
uint16_t tlv_len;
uint8_t *tlv_ptr = NULL;
int32_t found = 0;
@@ -552,7 +552,7 @@
uint8_t instance_id[INSTANCE_ID_MAX_SIZE];
enum tfm_plat_err_t res_plat;
uint32_t size = sizeof(instance_id);
- struct useful_buf_c claim_value;
+ struct q_useful_buf_c claim_value;
res_plat = tfm_plat_get_instance_id(&size, instance_id);
if (res_plat != TFM_PLAT_ERR_SUCCESS) {
@@ -586,7 +586,7 @@
uint8_t implementation_id[IMPLEMENTATION_ID_MAX_SIZE];
enum tfm_plat_err_t res_plat;
uint32_t size = sizeof(implementation_id);
- struct useful_buf_c claim_value;
+ struct q_useful_buf_c claim_value;
res_plat = tfm_plat_get_implementation_id(&size, implementation_id);
if (res_plat != TFM_PLAT_ERR_SUCCESS) {
@@ -620,7 +620,7 @@
uint8_t hw_version[HW_VERSION_MAX_SIZE];
enum tfm_plat_err_t res_plat;
uint32_t size = sizeof(hw_version);
- struct useful_buf_c claim_value = {0};
+ struct q_useful_buf_c claim_value = {0};
uint16_t tlv_len;
uint8_t *tlv_ptr = NULL;
int32_t found = 0;
@@ -691,7 +691,7 @@
enum tfm_security_lifecycle_t security_lifecycle;
uint32_t slc_value;
int32_t res;
- struct useful_buf_c claim_value = {0};
+ struct q_useful_buf_c claim_value = {0};
uint16_t tlv_len;
uint8_t *tlv_ptr = NULL;
int32_t found = 0;
@@ -738,7 +738,7 @@
*/
static enum psa_attest_err_t
attest_add_challenge_claim(struct attest_token_ctx *token_ctx,
- const struct useful_buf_c *challenge)
+ const struct q_useful_buf_c *challenge)
{
attest_token_add_bstr(token_ctx, EAT_CBOR_ARM_LABEL_CHALLENGE, challenge);
@@ -756,7 +756,7 @@
static enum psa_attest_err_t
attest_add_verification_service(struct attest_token_ctx *token_ctx)
{
- struct useful_buf_c service;
+ struct q_useful_buf_c service;
uint32_t size;
service.ptr = tfm_attest_hal_get_verification_service(&size);
@@ -781,7 +781,7 @@
static enum psa_attest_err_t
attest_add_profile_definition(struct attest_token_ctx *token_ctx)
{
- struct useful_buf_c profile;
+ struct q_useful_buf_c profile;
uint32_t size;
profile.ptr = tfm_attest_hal_get_profile_definition(&size);
@@ -833,9 +833,9 @@
* \return Returns error code as specified in \ref psa_attest_err_t
*/
static enum psa_attest_err_t
-attest_create_token(struct useful_buf_c *challenge,
- struct useful_buf *token,
- struct useful_buf_c *completed_token)
+attest_create_token(struct q_useful_buf_c *challenge,
+ struct q_useful_buf *token,
+ struct q_useful_buf_c *completed_token)
{
enum psa_attest_err_t attest_err = PSA_ATTEST_ERR_SUCCESS;
enum attest_token_err_t token_err;
@@ -959,9 +959,9 @@
psa_outvec *out_vec, uint32_t num_outvec)
{
enum psa_attest_err_t attest_err = PSA_ATTEST_ERR_SUCCESS;
- struct useful_buf_c challenge;
- struct useful_buf token;
- struct useful_buf_c completed_token;
+ struct q_useful_buf_c challenge;
+ struct q_useful_buf token;
+ struct q_useful_buf_c completed_token;
challenge.ptr = in_vec[0].base;
challenge.len = in_vec[0].len;
@@ -1007,9 +1007,9 @@
enum psa_attest_err_t attest_err = PSA_ATTEST_ERR_SUCCESS;
uint32_t challenge_size = *(uint32_t *)in_vec[0].base;
uint32_t *token_buf_size = (uint32_t *)out_vec[0].base;
- struct useful_buf_c challenge;
- struct useful_buf token;
- struct useful_buf_c completed_token;
+ struct q_useful_buf_c challenge;
+ struct q_useful_buf token;
+ struct q_useful_buf_c completed_token;
/* Only the size of the challenge is needed */
challenge.ptr = NULL;
diff --git a/test/suites/attestation/token_test.c b/test/suites/attestation/token_test.c
index 4da727b..ea84322 100644
--- a/test/suites/attestation/token_test.c
+++ b/test/suites/attestation/token_test.c
@@ -9,7 +9,7 @@
*/
#include "token_test.h"
-#include "useful_buf.h"
+#include "q_useful_buf.h"
#include "psa_initial_attestation_api.h"
#include "attest_token.h"
@@ -34,18 +34,18 @@
*
*/
int token_main_alt(uint32_t option_flags,
- struct useful_buf_c nonce,
- struct useful_buf buffer,
- struct useful_buf_c *completed_token)
+ struct q_useful_buf_c nonce,
+ struct q_useful_buf buffer,
+ struct q_useful_buf_c *completed_token)
{
uint32_t completed_token_len;
/* 68 = 64 + 4, the max expected nonce and 4 for the options */
- USEFUL_BUF_MAKE_STACK_UB(nonce2_storage, 68);
- struct useful_buf_c nonce2;
+ Q_USEFUL_BUF_MAKE_STACK_UB(nonce2_storage, 68);
+ struct q_useful_buf_c nonce2;
int return_value;
- nonce2 = useful_buf_copy(nonce2_storage, nonce);
+ nonce2 = q_useful_buf_copy(nonce2_storage, nonce);
/* Now for the hack... */
memcpy((uint8_t *)nonce2.ptr + nonce2.len, (uint8_t *) &option_flags, 4);
nonce2.len += 4;
@@ -56,7 +56,7 @@
buffer.ptr,
&completed_token_len);
- *completed_token = (struct useful_buf_c) {buffer.ptr, completed_token_len};
+ *completed_token = (struct q_useful_buf_c) {buffer.ptr, completed_token_len};
return return_value;
}
@@ -130,15 +130,15 @@
int minimal_test()
{
int return_value = 0;
- USEFUL_BUF_MAKE_STACK_UB(token_storage,
+ Q_USEFUL_BUF_MAKE_STACK_UB(token_storage,
sizeof(expected_minimal_token_bytes));
- struct useful_buf_c completed_token;
- struct useful_buf_c expected_token;
+ struct q_useful_buf_c completed_token;
+ struct q_useful_buf_c expected_token;
return_value =
token_main_alt(TOKEN_OPT_SHORT_CIRCUIT_SIGN |
TOKEN_OPT_OMIT_CLAIMS,
- USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(nonce_bytes),
+ Q_USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(nonce_bytes),
token_storage,
&completed_token);
if(return_value) {
@@ -146,9 +146,9 @@
}
expected_token =
- USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(expected_minimal_token_bytes);
+ Q_USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(expected_minimal_token_bytes);
- if(useful_buf_compare(completed_token,expected_token)) {
+ if(q_useful_buf_compare(completed_token,expected_token)) {
return_value = -3;
}
@@ -164,14 +164,14 @@
{
int return_value;
uint32_t length;
- struct useful_buf_c expected_token;
- struct useful_buf_c nonce;
+ struct q_useful_buf_c expected_token;
+ struct q_useful_buf_c nonce;
return_value = 0;
- nonce = USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(nonce_bytes);
+ nonce = Q_USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(nonce_bytes);
expected_token =
- USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(expected_minimal_token_bytes);
+ Q_USEFUL_BUF_FROM_BYTE_ARRAY_LITERAL(expected_minimal_token_bytes);
return_value = psa_initial_attest_get_token_size((uint32_t)nonce.len,
diff --git a/test/suites/attestation/token_test.h b/test/suites/attestation/token_test.h
index 00d8521..12e7c1b 100644
--- a/test/suites/attestation/token_test.h
+++ b/test/suites/attestation/token_test.h
@@ -11,6 +11,10 @@
#ifndef __TOKEN_TEST_H__
#define __TOKEN_TEST_H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \file token_test.h
*
@@ -33,4 +37,9 @@
*/
int minimal_get_size_test(void);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __TOKEN_TEST_H__ */