aboutsummaryrefslogtreecommitdiff
path: root/tools/tf_fuzz/assets/crypto_asset.cpp
blob: 7918a794a26a1a19896160ab42424635a17677b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

#include "class_forwards.hpp"

#include "boilerplate.hpp"
#include "randomization.hpp"
#include "gibberish.hpp"
#include "compute.hpp"
#include "data_blocks.hpp"
#include "psa_asset.hpp"
#include "find_or_create_asset.hpp"
#include "template_line.hpp"
#include "tf_fuzz.hpp"
#include "crypto_asset.hpp"
#include "psa_call.hpp"



/**********************************************************************************
   Methods of class crypto_asset follow:
**********************************************************************************/

crypto_asset::crypto_asset (void)  // (default constructor)
{
    return;  // just to have something to pin a breakpoint onto
}


crypto_asset::~crypto_asset (void)  // (destructor)
{
    return;  // just to have something to pin a breakpoint onto
}

/**********************************************************************************
   End of methods of class crypto_asset.
**********************************************************************************/


/**********************************************************************************
   Methods of class policy_asset follow:
**********************************************************************************/

policy_asset::policy_asset (void)  // (default constructor)
{
    // Randomize key-policy usage and algorithm:
    policy_usage = rand_key_usage();
    policy_algorithm = rand_key_algorithm();
    // keys:  Should automatically come up as empby.
}


policy_asset::~policy_asset (void)  // (destructor)
{
    return;  // just to have something to pin a breakpoint onto
}

/**********************************************************************************
   End of methods of class policy_asset.
**********************************************************************************/


/**********************************************************************************
   Methods of class key_asset follow:
**********************************************************************************/

bool key_asset::set_key_id (int id_n)
{
    key_id = id_n;
    return true;
}


key_asset::key_asset (void)
{
    // Note:  Similar random initialization for asset and template
    // Randomize handle:
    // TODO:  Key handles appear to be a lot more complex a question than the below
    gibberish *gib = new gibberish;
    char buffer[256];
    char *end;
    int buf_len = 5ULL + (uint64_t) (rand() % 10);
    end = gib->word (false, buffer, buffer + buf_len);
    *end = '\0';
    buffer[buf_len] = '\0';
    handle_str = buffer;
    // Randomize key type:
    key_type = rand_key_type();
    // Randomize lifetime:
    lifetime_str = ((rand() % 2) == 1)?
                       "PSA_KEY_LIFETIME_VOLATILE" : "PSA_KEY_LIFETIME_PERSISTENT";
}


key_asset::~key_asset (void)
{
    return;  // just to have something to pin a breakpoint onto
}

/**********************************************************************************
   End of methods of class key_asset.
**********************************************************************************/