blob: 24b14c0b29d0f201ccd4606e36177d740db0bc38 [file] [log] [blame]
julhal012c18fbf2021-02-01 08:29:28 +00001/*
2 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6#include <platform/interface/trng.h>
7
8/*
9 * A platform trng driver that provides a mock implementation that
10 * always returns a fixed value. Intended for test purposes only.
11 */
12static int mock_poll(void *context, unsigned char *output, size_t nbyte, size_t *len)
13{
14 (void)context;
15 (void)output;
16
17 *len = 0;
18
19 if (nbyte < sizeof(unsigned char) )
20 return 0;
21
22 *len = sizeof(unsigned char);
23
24 return 0;
25}
26
27int platform_trng_create(struct platform_trng_driver *driver,
28 const struct device_region *device_region)
29{
30 static const struct platform_trng_iface iface = { .poll = mock_poll };
31
32 (void)device_region;
33
34 driver->context = NULL;
35 driver->iface = &iface;
36
37 return 0;
38}
39
40void platform_trng_destroy(struct platform_trng_driver *driver)
41{
42 (void)driver;
43}