mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins

Dependents:   IGLOO_board

Fork of mbed-dev by mbed official

Committer:
ua1arn
Date:
Mon Jul 30 12:31:10 2018 +0000
Revision:
188:3f10722804f9
Parent:
182:a56a73fd2a6f
before add multi-configuration USB descriptors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anna Bridge 180:96ed750bd169 1 /* mbed Microcontroller Library
Anna Bridge 180:96ed750bd169 2 * Copyright (c) 2015-2016 Nuvoton
Anna Bridge 180:96ed750bd169 3 *
Anna Bridge 180:96ed750bd169 4 * Licensed under the Apache License, Version 2.0 (the "License");
Anna Bridge 180:96ed750bd169 5 * you may not use this file except in compliance with the License.
Anna Bridge 180:96ed750bd169 6 * You may obtain a copy of the License at
Anna Bridge 180:96ed750bd169 7 *
Anna Bridge 180:96ed750bd169 8 * http://www.apache.org/licenses/LICENSE-2.0
Anna Bridge 180:96ed750bd169 9 *
Anna Bridge 180:96ed750bd169 10 * Unless required by applicable law or agreed to in writing, software
Anna Bridge 180:96ed750bd169 11 * distributed under the License is distributed on an "AS IS" BASIS,
Anna Bridge 180:96ed750bd169 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Anna Bridge 180:96ed750bd169 13 * See the License for the specific language governing permissions and
Anna Bridge 180:96ed750bd169 14 * limitations under the License.
Anna Bridge 180:96ed750bd169 15 */
Anna Bridge 180:96ed750bd169 16
Anna Bridge 180:96ed750bd169 17 #ifndef MBED_CRYPTO_MISC_H
Anna Bridge 180:96ed750bd169 18 #define MBED_CRYPTO_MISC_H
Anna Bridge 180:96ed750bd169 19
Anna Bridge 180:96ed750bd169 20 #include <stdbool.h>
Anna Bridge 180:96ed750bd169 21
Anna Bridge 180:96ed750bd169 22 #ifdef __cplusplus
Anna Bridge 180:96ed750bd169 23 extern "C" {
Anna Bridge 180:96ed750bd169 24 #endif
Anna Bridge 180:96ed750bd169 25
Anna Bridge 180:96ed750bd169 26 /* Init/Uninit crypto module */
Anna Bridge 180:96ed750bd169 27 void crypto_init(void);
Anna Bridge 180:96ed750bd169 28 void crypto_uninit(void);
Anna Bridge 180:96ed750bd169 29
Anna Bridge 180:96ed750bd169 30 /* Clear buffer to zero
Anna Bridge 180:96ed750bd169 31 * Implementation that should never be optimized out by the compiler */
Anna Bridge 180:96ed750bd169 32 void crypto_zeroize(void *v, size_t n);
AnnaBridge 182:a56a73fd2a6f 33 void crypto_zeroize32(uint32_t *v, size_t n);
Anna Bridge 180:96ed750bd169 34
Anna Bridge 180:96ed750bd169 35 /* Acquire/release ownership of AES H/W */
Anna Bridge 180:96ed750bd169 36 /* NOTE: If "acquire" succeeds, "release" must be done to pair it. */
Anna Bridge 180:96ed750bd169 37 bool crypto_aes_acquire(void);
Anna Bridge 180:96ed750bd169 38 void crypto_aes_release(void);
Anna Bridge 180:96ed750bd169 39
Anna Bridge 180:96ed750bd169 40 /* Acquire/release ownership of DES H/W */
Anna Bridge 180:96ed750bd169 41 /* NOTE: If "acquire" succeeds, "release" must be done to pair it. */
Anna Bridge 180:96ed750bd169 42 bool crypto_des_acquire(void);
Anna Bridge 180:96ed750bd169 43 void crypto_des_release(void);
Anna Bridge 180:96ed750bd169 44
Anna Bridge 180:96ed750bd169 45 /* Acquire/release ownership of SHA H/W */
Anna Bridge 180:96ed750bd169 46 /* NOTE: If "acquire" succeeds, "release" must be done to pair it. */
Anna Bridge 180:96ed750bd169 47 bool crypto_sha_acquire(void);
Anna Bridge 180:96ed750bd169 48 void crypto_sha_release(void);
Anna Bridge 180:96ed750bd169 49
AnnaBridge 182:a56a73fd2a6f 50 /* Acquire/release ownership of ECC H/W */
AnnaBridge 182:a56a73fd2a6f 51 /* NOTE: If "acquire" succeeds, "release" must be done to pair it. */
AnnaBridge 182:a56a73fd2a6f 52 bool crypto_ecc_acquire(void);
AnnaBridge 182:a56a73fd2a6f 53 void crypto_ecc_release(void);
AnnaBridge 182:a56a73fd2a6f 54
Anna Bridge 180:96ed750bd169 55 /* Flow control between crypto/xxx start and crypto/xxx ISR
Anna Bridge 180:96ed750bd169 56 *
Anna Bridge 180:96ed750bd169 57 * crypto_xxx_prestart/crypto_xxx_wait encapsulate control flow between crypto/xxx start and crypto/xxx ISR.
Anna Bridge 180:96ed750bd169 58 *
Anna Bridge 180:96ed750bd169 59 * crypto_xxx_prestart will also address synchronization issue with memory barrier instruction.
Anna Bridge 180:96ed750bd169 60 *
Anna Bridge 180:96ed750bd169 61 * On finish, return of crypto_xxx_wait indicates success or not:
Anna Bridge 180:96ed750bd169 62 * true if successful
Anna Bridge 180:96ed750bd169 63 * false if failed
Anna Bridge 180:96ed750bd169 64 *
Anna Bridge 180:96ed750bd169 65 * Example: Start AES H/W and wait for its finish
Anna Bridge 180:96ed750bd169 66 * crypto_aes_prestart();
Anna Bridge 180:96ed750bd169 67 * AES_Start();
Anna Bridge 180:96ed750bd169 68 * crypto_aes_wait();
Anna Bridge 180:96ed750bd169 69 */
Anna Bridge 180:96ed750bd169 70 void crypto_prng_prestart(void);
Anna Bridge 180:96ed750bd169 71 bool crypto_prng_wait(void);
Anna Bridge 180:96ed750bd169 72 void crypto_aes_prestart(void);
Anna Bridge 180:96ed750bd169 73 bool crypto_aes_wait(void);
Anna Bridge 180:96ed750bd169 74 void crypto_des_prestart(void);
Anna Bridge 180:96ed750bd169 75 bool crypto_des_wait(void);
AnnaBridge 182:a56a73fd2a6f 76 void crypto_ecc_prestart(void);
AnnaBridge 182:a56a73fd2a6f 77 bool crypto_ecc_wait(void);
Anna Bridge 180:96ed750bd169 78
Anna Bridge 180:96ed750bd169 79
Anna Bridge 180:96ed750bd169 80 /* Check if buffer can be used for crypto DMA. It has the following requirements:
Anna Bridge 180:96ed750bd169 81 * (1) Word-aligned buffer base address
Anna Bridge 180:96ed750bd169 82 * (2) Crypto submodule (AES, DES, SHA, etc.) dependent buffer size alignment. Must be 2 power.
Anna Bridge 180:96ed750bd169 83 * (3) Located in 0x20000000-0x2FFFFFFF region
Anna Bridge 180:96ed750bd169 84 */
Anna Bridge 180:96ed750bd169 85 bool crypto_dma_buff_compat(const void *buff, size_t buff_size, size_t size_aligned_to);
Anna Bridge 180:96ed750bd169 86
Anna Bridge 180:96ed750bd169 87 /* Check if input/output buffers are overlapped */
Anna Bridge 180:96ed750bd169 88 bool crypto_dma_buffs_overlap(const void *in_buff, size_t in_buff_size, const void *out_buff, size_t out_buff_size);
Anna Bridge 180:96ed750bd169 89
Anna Bridge 180:96ed750bd169 90 #ifdef __cplusplus
Anna Bridge 180:96ed750bd169 91 }
Anna Bridge 180:96ed750bd169 92 #endif
Anna Bridge 180:96ed750bd169 93
Anna Bridge 180:96ed750bd169 94 #endif