Skip to content

Commit 7eb8807

Browse files
authored
Merge pull request #11589 from jamesbeyond/fm_psa
Enable PSA tests for fastmodel
2 parents eeb033f + bdff628 commit 7eb8807

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

targets/TARGET_ARM_FM/TARGET_FVP_MPS2/objects.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ struct flash_s {
7878
uint8_t not_used;
7979
};
8080

81+
struct trng_s {
82+
uint8_t not_used;
83+
};
84+
8185
#include "gpio_object.h"
8286

8387
#ifdef __cplusplus
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2017-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing software
12+
* distributed under the License is distributed on an "AS IS" BASIS
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "trng_api.h"
19+
#include "device.h"
20+
#include <stdlib.h>
21+
22+
/** NOTE: FastModel are software models not contain any TRNG peripheral
23+
* So C library srand() and rand() are used to simulate TRNG device
24+
*/
25+
26+
void trng_init(trng_t *obj)
27+
{
28+
srand(0);
29+
(void)obj;
30+
}
31+
32+
33+
void trng_free(trng_t *obj)
34+
{
35+
(void)obj;
36+
}
37+
38+
/** Get random data from TRNG peripheral
39+
*
40+
* @param obj The TRNG object
41+
* @param output The pointer to an output array
42+
* @param length The size of output data, to avoid buffer overwrite
43+
* @param output_length The length of generated data
44+
* @return 0 success, -1 fail
45+
*/
46+
int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length)
47+
{
48+
(void)obj;
49+
50+
for (int i = 0; i < length; ++i) {
51+
output[i] = rand() % 256;
52+
}
53+
*output_length = length;
54+
55+
return 0;
56+
}

targets/targets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8609,7 +8609,7 @@
86098609
"ARM_FM": {
86108610
"inherits": ["Target"],
86118611
"public": false,
8612-
"extra_labels": ["ARM_FM"]
8612+
"extra_labels": ["ARM_FM","PSA"]
86138613
},
86148614
"FVP_MPS2": {
86158615
"inherits": ["ARM_FM"],
@@ -8633,6 +8633,7 @@
86338633
"SPI",
86348634
"SPISLAVE",
86358635
"TSC",
8636+
"TRNG",
86368637
"USTICKER"
86378638
],
86388639
"release_versions": ["5"],

0 commit comments

Comments
 (0)