blob: a9f79f8223233e38dd1a78b2993ea4e0fe1fb853 [file] [log] [blame]
julhal012c18fbf2021-02-01 08:29:28 +00001/*
Jelle Selsf2373042022-01-19 13:35:56 +01002 * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
julhal012c18fbf2021-02-01 08:29:28 +00003 *
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
Jelle Selsf2373042022-01-19 13:35:56 +010027int platform_trng_create(struct platform_trng_driver *driver, int instance)
julhal012c18fbf2021-02-01 08:29:28 +000028{
29 static const struct platform_trng_iface iface = { .poll = mock_poll };
30
Jelle Selsf2373042022-01-19 13:35:56 +010031 (void)instance;
julhal012c18fbf2021-02-01 08:29:28 +000032 driver->context = NULL;
33 driver->iface = &iface;
34
35 return 0;
36}
37
38void platform_trng_destroy(struct platform_trng_driver *driver)
39{
40 (void)driver;
41}