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