Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-dev/hal/trng_api.h@60:8399756e1ba1, 2021-01-22 (annotated)
- Committer:
- MartinGurtner
- Date:
- Fri Jan 22 13:10:37 2021 +0000
- Revision:
- 60:8399756e1ba1
.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MartinGurtner | 60:8399756e1ba1 | 1 | |
| MartinGurtner | 60:8399756e1ba1 | 2 | /** \addtogroup hal */ |
| MartinGurtner | 60:8399756e1ba1 | 3 | /** @{*/ |
| MartinGurtner | 60:8399756e1ba1 | 4 | /* mbed Microcontroller Library |
| MartinGurtner | 60:8399756e1ba1 | 5 | * Copyright (c) 2016 ARM Limited |
| MartinGurtner | 60:8399756e1ba1 | 6 | * |
| MartinGurtner | 60:8399756e1ba1 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| MartinGurtner | 60:8399756e1ba1 | 8 | * you may not use this file except in compliance with the License. |
| MartinGurtner | 60:8399756e1ba1 | 9 | * You may obtain a copy of the License at |
| MartinGurtner | 60:8399756e1ba1 | 10 | * |
| MartinGurtner | 60:8399756e1ba1 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| MartinGurtner | 60:8399756e1ba1 | 12 | * |
| MartinGurtner | 60:8399756e1ba1 | 13 | * Unless required by applicable law or agreed to in writing, software |
| MartinGurtner | 60:8399756e1ba1 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| MartinGurtner | 60:8399756e1ba1 | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| MartinGurtner | 60:8399756e1ba1 | 16 | * See the License for the specific language governing permissions and |
| MartinGurtner | 60:8399756e1ba1 | 17 | * limitations under the License. |
| MartinGurtner | 60:8399756e1ba1 | 18 | */ |
| MartinGurtner | 60:8399756e1ba1 | 19 | #ifndef MBED_TRNG_API_H |
| MartinGurtner | 60:8399756e1ba1 | 20 | #define MBED_TRNG_API_H |
| MartinGurtner | 60:8399756e1ba1 | 21 | |
| MartinGurtner | 60:8399756e1ba1 | 22 | #include <stddef.h> |
| MartinGurtner | 60:8399756e1ba1 | 23 | #include "device.h" |
| MartinGurtner | 60:8399756e1ba1 | 24 | |
| MartinGurtner | 60:8399756e1ba1 | 25 | #if DEVICE_TRNG |
| MartinGurtner | 60:8399756e1ba1 | 26 | |
| MartinGurtner | 60:8399756e1ba1 | 27 | /** TRNG HAL structure. trng_s is declared in the target's HAL |
| MartinGurtner | 60:8399756e1ba1 | 28 | */ |
| MartinGurtner | 60:8399756e1ba1 | 29 | typedef struct trng_s trng_t; |
| MartinGurtner | 60:8399756e1ba1 | 30 | |
| MartinGurtner | 60:8399756e1ba1 | 31 | #ifdef __cplusplus |
| MartinGurtner | 60:8399756e1ba1 | 32 | extern "C" { |
| MartinGurtner | 60:8399756e1ba1 | 33 | #endif |
| MartinGurtner | 60:8399756e1ba1 | 34 | |
| MartinGurtner | 60:8399756e1ba1 | 35 | /** |
| MartinGurtner | 60:8399756e1ba1 | 36 | * \defgroup hal_trng TRNG hal functions |
| MartinGurtner | 60:8399756e1ba1 | 37 | * @{ |
| MartinGurtner | 60:8399756e1ba1 | 38 | */ |
| MartinGurtner | 60:8399756e1ba1 | 39 | |
| MartinGurtner | 60:8399756e1ba1 | 40 | /** Initialize the TRNG peripheral |
| MartinGurtner | 60:8399756e1ba1 | 41 | * |
| MartinGurtner | 60:8399756e1ba1 | 42 | * @param obj The TRNG object |
| MartinGurtner | 60:8399756e1ba1 | 43 | */ |
| MartinGurtner | 60:8399756e1ba1 | 44 | void trng_init(trng_t *obj); |
| MartinGurtner | 60:8399756e1ba1 | 45 | |
| MartinGurtner | 60:8399756e1ba1 | 46 | /** Deinitialize the TRNG peripheral |
| MartinGurtner | 60:8399756e1ba1 | 47 | * |
| MartinGurtner | 60:8399756e1ba1 | 48 | * @param obj The TRNG object |
| MartinGurtner | 60:8399756e1ba1 | 49 | */ |
| MartinGurtner | 60:8399756e1ba1 | 50 | void trng_free(trng_t *obj); |
| MartinGurtner | 60:8399756e1ba1 | 51 | |
| MartinGurtner | 60:8399756e1ba1 | 52 | /** Get random data from TRNG peripheral |
| MartinGurtner | 60:8399756e1ba1 | 53 | * |
| MartinGurtner | 60:8399756e1ba1 | 54 | * @param obj The TRNG object |
| MartinGurtner | 60:8399756e1ba1 | 55 | * @param output The pointer to an output array |
| MartinGurtner | 60:8399756e1ba1 | 56 | * @param length The size of output data, to avoid buffer overwrite |
| MartinGurtner | 60:8399756e1ba1 | 57 | * @param output_length The length of generated data |
| MartinGurtner | 60:8399756e1ba1 | 58 | * @return 0 success, -1 fail |
| MartinGurtner | 60:8399756e1ba1 | 59 | */ |
| MartinGurtner | 60:8399756e1ba1 | 60 | int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length); |
| MartinGurtner | 60:8399756e1ba1 | 61 | |
| MartinGurtner | 60:8399756e1ba1 | 62 | /**@}*/ |
| MartinGurtner | 60:8399756e1ba1 | 63 | |
| MartinGurtner | 60:8399756e1ba1 | 64 | #ifdef __cplusplus |
| MartinGurtner | 60:8399756e1ba1 | 65 | } |
| MartinGurtner | 60:8399756e1ba1 | 66 | #endif |
| MartinGurtner | 60:8399756e1ba1 | 67 | |
| MartinGurtner | 60:8399756e1ba1 | 68 | #endif |
| MartinGurtner | 60:8399756e1ba1 | 69 | |
| MartinGurtner | 60:8399756e1ba1 | 70 | #endif |
| MartinGurtner | 60:8399756e1ba1 | 71 | |
| MartinGurtner | 60:8399756e1ba1 | 72 | /** @}*/ |