BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Committer:
gustavatmel
Date:
Tue May 01 15:47:08 2018 +0000
Revision:
1:9c5af431a1f1
sdf

Who changed what in which revision?

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