Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 1 | /* |
Nik Dewally | bacae6c | 2024-07-30 16:58:14 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2019-2024, Arm Limited. All rights reserved. |
Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef CRYPTO_ASSET_HPP |
| 9 | #define CRYPTO_ASSET_HPP |
| 10 | |
| 11 | #include <string> |
| 12 | #include <vector> |
| 13 | #include <cstddef> |
| 14 | #include <cstdint> |
| 15 | |
Nik Dewally | bacae6c | 2024-07-30 16:58:14 +0100 | [diff] [blame^] | 16 | #include "data_blocks.hpp" |
Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 17 | #include "psa_asset.hpp" |
Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 18 | |
Nik Dewally | bacae6c | 2024-07-30 16:58:14 +0100 | [diff] [blame^] | 19 | class key_asset; |
Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 20 | |
| 21 | using namespace std; |
| 22 | |
| 23 | class crypto_asset : public psa_asset |
| 24 | { |
| 25 | public: |
| 26 | // Data members: |
| 27 | key_policy_info policy; |
| 28 | // Methods: |
| 29 | crypto_asset (void); // (constructor) |
| 30 | ~crypto_asset (void); |
| 31 | |
| 32 | protected: |
| 33 | // Data members: |
| 34 | // Methods: |
| 35 | |
| 36 | private: |
| 37 | // Data members: |
| 38 | // Methods: |
| 39 | }; |
| 40 | |
| 41 | class policy_asset : public crypto_asset |
| 42 | { |
| 43 | public: |
| 44 | // Data members: |
| 45 | string policy_usage; // for now just strings; maybe future tap TF-M(?) value list |
| 46 | string key_type; // DES, AES, RAW, vendor, none, etc. |
| 47 | string policy_algorithm; |
| 48 | vector<key_asset*> keys; // keys that use this policy |
| 49 | // Methods: |
| 50 | policy_asset (void); // (constructor) |
| 51 | ~policy_asset (void); |
| 52 | |
| 53 | protected: |
| 54 | // Data members: |
| 55 | // Methods: |
| 56 | |
| 57 | private: |
| 58 | // Data members: |
| 59 | // Methods: |
| 60 | }; |
| 61 | |
| 62 | class key_asset : public crypto_asset |
| 63 | { |
| 64 | public: |
| 65 | // Data members: |
| 66 | vector<policy_asset*>::iterator the_policy_asset; |
| 67 | /* The policy for this key. Note that psa_make_key() lets us create |
| 68 | a key without associating a policy with it. In that case, this will |
| 69 | be null, and the attributes below apply. Later, psa_set_key_policy |
| 70 | lets us associate a policy with a key, at which point this becomes |
| 71 | non-null and the following attributes no longer apply. */ |
| 72 | string key_type; // DES, AES, RAW, vendor, none, etc. |
| 73 | string usage; // for now just strings; maybe future tap TF-M(?) value list |
| 74 | string alg; // these only apply if the string was created without a policy |
| 75 | string lifetime_str; // similarly, the text representation of the key's lifetime |
| 76 | // Methods: |
| 77 | bool set_key_id (int id_n); // checks key-ID value, returns true==success |
| 78 | key_asset (void); // (constructor) |
| 79 | ~key_asset (void); |
| 80 | |
| 81 | protected: |
| 82 | // Data members: |
| 83 | uint64_t key_id; |
| 84 | // Methods: |
| 85 | |
| 86 | private: |
| 87 | // Data members: |
| 88 | // Methods: |
| 89 | }; |
| 90 | |
| 91 | #endif // CRYPTO_ASSET_HPP |