blob: a7fb0587d944a3938f2a2aa91c14839c937ea08a [file] [log] [blame]
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +01001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8/**
9 * \file psa_sst_asset_macros.h
10 *
11 * \brief Platform security architecture (PSA) asset macros definitions for
12 * secure storage partition
13 */
14#ifndef __PSA_SST_ASSET_MACROS_H__
15#define __PSA_SST_ASSET_MACROS_H__
16
17#include "psa_sst_asset_defs.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/*!
24 * \def PSA_SST_ASSET_IS_ASSET_CAT(psa_sst_def_cat_type, type)
25 *
26 * \brief Macro to check if the asset category type (type) is equal to the
27 * PSA SST asset defined category types (psa_sst_def_cat_type).
28 *
29 * \param[in] psa_sst_def_cat_type PSA SST asset defined category type
30 * \param[in] type Asset type
31 *
32 * \return Returns 1 if the asset type is equal to the PSA SST asset defined
33 * type. Otherwise, it returns 0.
34 */
35#define PSA_SST_ASSET_IS_ASSET_CAT(psa_sst_def_cat_type, type) \
36 (((type & PSA_SST_ASSET_CAT_VENDOR_DEFINED) != 0) && \
37 ((type & PSA_SST_ASSET_CAT_TYPE_MASK) == psa_sst_def_cat_type))
38
39/*!
40 * \def PSA_SST_ASSET_IS_ASSET_TYPE(psa_sst_def_type, type)
41 *
42 * \brief Macro to check if the asset type (type) is equal to the
43 * PSA SST asset defined type (psa_sst_def_type).
44 *
45 * \param[in] psa_sst_def_type PSA SST asset defined type
46 * \param[in] type Asset type
47 *
48 * \return Returns 1 if the asset type is equal to the PSA SST asset defined
49 * type. Otherwise, it returns 0.
50 */
51#define PSA_SST_ASSET_IS_ASSET_TYPE(psa_sst_def_type, type) \
52 (((type & PSA_SST_ASSET_CAT_VENDOR_DEFINED) != 0) && \
53 (type == psa_sst_def_type))
54
55/*!
56 * \def PSA_SST_ASSET_IS_VENDOR_DEFINED(type)
57 *
58 * \brief Macro to check if the asset type is vendor defined.
59 *
60 * \param[in] type Asset type
61 *
62 * \return Returns 1 if the asset type is equal to PSA_SST_ASSET_VENDOR_DEFINED.
63 * Otherwise, it returns 0.
64 */
65#define PSA_SST_ASSET_IS_VENDOR_DEFINED(type) \
66 ((type & PSA_SST_ASSET_VENDOR_DEFINED) != 0)
67
68/*!
69 * \def PSA_SST_ASSET_IS_KEY_TYPE(type)
70 *
71 * \brief Macro to check if the asset type is a key.
72 *
73 * \param[in] type Asset type
74 *
75 * \return Returns 1 if it is a key. Otherwise, it returns 0.
76 */
77#define PSA_SST_ASSET_IS_KEY_TYPE(type) \
78 ((type & PSA_SST_ASSET_KEY_MASK) != 0)
79
80/*!
81 * \def PSA_SST_ASSET_IS_ASYMMETRIC_KEY_TYPE(type)
82 *
83 * \brief Macro to check if the asset type is a symmetric key.
84 *
85 * \param[in] type Asset type
86 *
87 * \return Returns 1 if it is an asymmetric key. Otherwise, it returns 0.
88 */
89#define PSA_SST_ASSET_IS_ASYMMETRIC_KEY_TYPE(type) \
90 ((type & PSA_SST_ASSET_KEY_ASYMMETRIC_MASK) != 0)
91
92/*!
93 * \def PSA_SST_ASSET_HAS_ATTR(psa_sst_def_asset_attr, attrs)
94 *
95 * \brief Macro to check if the asset attributes (attrs) have a specific PSA
96 * SST asset defined bit attribute (psa_sst_def_asset_attr).
97 *
98 * \param[in] psa_sst_def_type PSA SST asset defined bit attribute
99 * \param[in] attrs Asset attributes
100 *
101 * \return Returns 1 if the asset has the PSA SST asset defined
102 * attribute. Otherwise, it returns 0.
103 */
104#define PSA_SST_ASSET_HAS_ATTR(psa_sst_def_asset_attr, attrs) \
105 (((attrs & psa_sst_def_asset_attr) != 0) && \
106 ((attrs & PSA_SST_ASSET_ATTR_VENDOR_DEFINED) == 0))
107
108/*!
109 * \def PSA_SST_ASSET_HAS_ATTR_VENDOR_DEFINED(attrs)
110 *
111 * \brief Macro to check if the asset attributes are vendor defined.
112 *
113 * \param[in] attrs Asset attributes
114 *
115 * \return Returns 1 if the asset type is equal to PSA_SST_ASSET_VENDOR_DEFINED.
116 * Otherwise, it returns 0.
117 */
118#define PSA_SST_ASSET_HAS_ATTR_VENDOR_DEFINED(attrs) \
119 ((attrs & PSA_SST_ASSET_ATTR_VENDOR_DEFINED) != 0)
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* __PSA_SST_ASSET_MACROS_H__ */