blob: bcee450c49226616f8c7fa863d116e485582ece7 [file] [log] [blame]
Karl Zhang3de5ab12021-05-31 11:45:48 +08001/*
2 * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
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
16
17/* This project's header files #including other project headers quickly becomes
18 unrealistically complicated. The only solution is for each .cpp to include
19 the headers it needs.
20#include "psa_asset.hpp"
21*/
22
23
24using namespace std;
25
26class crypto_asset : public psa_asset
27{
28public:
29 // Data members:
30 key_policy_info policy;
31 // Methods:
32 crypto_asset (void); // (constructor)
33 ~crypto_asset (void);
34
35protected:
36 // Data members:
37 // Methods:
38
39private:
40 // Data members:
41 // Methods:
42};
43
44class policy_asset : public crypto_asset
45{
46public:
47 // Data members:
48 string policy_usage; // for now just strings; maybe future tap TF-M(?) value list
49 string key_type; // DES, AES, RAW, vendor, none, etc.
50 string policy_algorithm;
51 vector<key_asset*> keys; // keys that use this policy
52 // Methods:
53 policy_asset (void); // (constructor)
54 ~policy_asset (void);
55
56protected:
57 // Data members:
58 // Methods:
59
60private:
61 // Data members:
62 // Methods:
63};
64
65class key_asset : public crypto_asset
66{
67public:
68 // Data members:
69 vector<policy_asset*>::iterator the_policy_asset;
70 /* The policy for this key. Note that psa_make_key() lets us create
71 a key without associating a policy with it. In that case, this will
72 be null, and the attributes below apply. Later, psa_set_key_policy
73 lets us associate a policy with a key, at which point this becomes
74 non-null and the following attributes no longer apply. */
75 string key_type; // DES, AES, RAW, vendor, none, etc.
76 string usage; // for now just strings; maybe future tap TF-M(?) value list
77 string alg; // these only apply if the string was created without a policy
78 string lifetime_str; // similarly, the text representation of the key's lifetime
79 // Methods:
80 bool set_key_id (int id_n); // checks key-ID value, returns true==success
81 key_asset (void); // (constructor)
82 ~key_asset (void);
83
84protected:
85 // Data members:
86 uint64_t key_id;
87 // Methods:
88
89private:
90 // Data members:
91 // Methods:
92};
93
94#endif // CRYPTO_ASSET_HPP