@@ -57,25 +57,6 @@ int main(void)
57
57
58
58
#define PSA_ATTESTATION_PRIVATE_KEY_ID 17
59
59
60
- static const uint8_t private_key_data[] = {
61
- 0x49 , 0xc9 , 0xa8 , 0xc1 , 0x8c , 0x4b , 0x88 , 0x56 ,
62
- 0x38 , 0xc4 , 0x31 , 0xcf , 0x1d , 0xf1 , 0xc9 , 0x94 ,
63
- 0x13 , 0x16 , 0x09 , 0xb5 , 0x80 , 0xd4 , 0xfd , 0x43 ,
64
- 0xa0 , 0xca , 0xb1 , 0x7d , 0xb2 , 0xf1 , 0x3e , 0xee
65
- };
66
-
67
- static const uint8_t public_key_data[] = {
68
- 0x04 , 0x77 , 0x72 , 0x65 , 0x6f , 0x81 , 0x4b , 0x39 ,
69
- 0x92 , 0x79 , 0xd5 , 0xe1 , 0xf1 , 0x78 , 0x1f , 0xac ,
70
- 0x6f , 0x09 , 0x9a , 0x3c , 0x5c , 0xa1 , 0xb0 , 0xe3 ,
71
- 0x53 , 0x51 , 0x83 , 0x4b , 0x08 , 0xb6 , 0x5e , 0x0b ,
72
- 0x57 , 0x25 , 0x90 , 0xcd , 0xaf , 0x8f , 0x76 , 0x93 ,
73
- 0x61 , 0xbc , 0xf3 , 0x4a , 0xcf , 0xc1 , 0x1e , 0x5e ,
74
- 0x07 , 0x4e , 0x84 , 0x26 , 0xbd , 0xde , 0x04 , 0xbe ,
75
- 0x6e , 0x65 , 0x39 , 0x45 , 0x44 , 0x96 , 0x17 , 0xde ,
76
- 0x45
77
- };
78
-
79
60
#define TEST_TOKEN_SIZE (0x200 )
80
61
#define TEST_CHALLENGE_OBJ_SIZE (32u )
81
62
@@ -92,14 +73,14 @@ static psa_status_t check_initial_attestation_get_token()
92
73
{
93
74
psa_status_t status = PSA_SUCCESS;
94
75
size_t exported_length;
95
- uint8_t exported[sizeof (public_key_data )];
76
+ uint8_t exported[PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE ( 256 )];
96
77
enum psa_attest_err_t attest_err = PSA_ATTEST_ERR_SUCCESS;
97
78
uint32_t token_size;
98
79
99
80
status = psa_crypto_init ();
100
81
ASSERT_STATUS (status, PSA_SUCCESS);
101
- status = psa_attestation_inject_key (private_key_data ,
102
- sizeof (private_key_data) ,
82
+ status = psa_attestation_inject_key (NULL ,
83
+ 0 ,
103
84
PSA_KEY_TYPE_ECC_KEYPAIR (PSA_ECC_CURVE_SECP256R1),
104
85
exported,
105
86
sizeof (exported),
@@ -136,40 +117,10 @@ static void attestation_example(void)
136
117
}
137
118
}
138
119
139
- static void fake_set_initial_nvseed (void )
140
- {
141
- /* This function, fake_set_initial_nvseed(), is useless on platforms that
142
- * have already been manufactured correctly. This function demonstrates
143
- * what a factory tool may do in order to manufacture a device that does
144
- * not have its own source of entropy. */
145
-
146
- /* mbedtls_psa_inject_entropy() is always present, but calls to it will
147
- * always fail unless the PSA Secure Processing Element (SPE) is configured
148
- * with both MBEDTLS_ENTROPY_NV_SEED and MBEDTLS_PSA_HAS_ITS_IO by the
149
- * SPE's Mbed TLS configuration system. */
150
- uint8_t seed[MBEDTLS_ENTROPY_MAX_SEED_SIZE];
151
-
152
- /* Calculate a fake seed for injecting. A real factory application would
153
- * inject true entropy for use as the initial NV Seed. */
154
- for (size_t i = 0 ; i < sizeof (seed); ++i) {
155
- seed[i] = i;
156
- }
157
-
158
- int status = mbedtls_psa_inject_entropy (seed, sizeof (seed));
159
- if (status) {
160
- /* The device may already have an NV Seed injected, or another error
161
- * may have happened during injection. */
162
- mbedtls_printf (" warning (%d) - this attempt at entropy injection"
163
- " failed\n " , status);
164
- }
165
- }
166
-
167
120
int main (void )
168
121
{
169
122
const psa_key_id_t key_id = PSA_ATTESTATION_PRIVATE_KEY_ID;
170
123
psa_key_handle_t handle = 0 ;
171
-
172
- fake_set_initial_nvseed ();
173
124
174
125
attestation_example ();
175
126
0 commit comments