Karl Zhang | 3de5ab1 | 2021-05-31 11:45:48 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019-2020, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef PSA_ASSET_HPP |
| 9 | #define PSA_ASSET_HPP |
| 10 | |
| 11 | #include <string> |
| 12 | #include <vector> |
| 13 | #include <cstdint> |
| 14 | |
| 15 | /* This project's header files #including other project headers quickly becomes |
| 16 | unrealistically complicated. The only solution is for each .cpp to include |
| 17 | the headers it needs. */ |
| 18 | |
| 19 | using namespace std; |
| 20 | |
| 21 | class psa_asset |
| 22 | { |
| 23 | public: |
| 24 | /* Data members -- not all PSA assets have all of these, but they need to be |
| 25 | accessible polymorphically via a psa_asset iterator: */ |
| 26 | set_data_info set_data; |
| 27 | /* For a PSA-asset tracker, this is really more about an asset's |
| 28 | on-going, real-time asset data value than about *setting* its data |
| 29 | value. On a template_line or a psa_call, it's about setting its |
| 30 | value at one particular time. */ |
| 31 | expect_info exp_data; |
| 32 | /* For now at least, this is here only for its n_exp_vars member, to |
| 33 | keep track of how many expected-data variables in the test. */ |
| 34 | asset_name_id_info asset_info; // everything about the asset(s) for this line |
| 35 | key_policy_info policy; // (specific to crypto, but have to put this here) |
| 36 | vector<int> template_ref; |
| 37 | // list of template line #s that reference this asset |
| 38 | vector<psa_call> call_ref; // list of PSA calls that reference this asset |
| 39 | string handle_str; // the text name of the key's "handle" |
| 40 | bool asset_name_specified; |
| 41 | /* true if the template specified the asset_name, as opposed to us |
| 42 | having inferred it. */ |
| 43 | // Methods: |
| 44 | void set_name (string set_val); |
| 45 | string get_name (void); |
| 46 | virtual bool simulate (void); |
| 47 | /* simulate() tells this asset to react to its current state information. |
| 48 | Initially, this won't really do much, but will allow assets to react |
| 49 | to each other, if that is relevant. It returns true if anything |
| 50 | in the state of the asset changed, in which case all assets' simulate() |
| 51 | methods will be invoked again to react again. That will repeat until |
| 52 | all assets read a quiescent state. */ |
| 53 | psa_asset(); // (constructor) |
| 54 | ~psa_asset(); |
| 55 | |
| 56 | protected: |
| 57 | // Data members: |
| 58 | // These are initially copied over from the call (or possibly template line): |
| 59 | string data; // String describing current data value. |
| 60 | string asset_name; // human-meaningful name |
| 61 | static long unique_id_counter; // counts off unique IDs for assets |
| 62 | // Methods: |
| 63 | |
| 64 | private: |
| 65 | // Data members: |
| 66 | // Methods: |
| 67 | }; |
| 68 | |
| 69 | #endif // PSA_ASSET_HPP |