Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_hal_aes.h Source File

arm_hal_aes.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2014-2017, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /**
00019  * \file arm_hal_aes.h
00020  * \brief AES Platform API
00021  */
00022 
00023 #ifndef ARM_HAL_AES_H_
00024 #define ARM_HAL_AES_H_
00025 
00026 /* The network library requires a simple AES implementation for its
00027  * IEEE 802.15.4 security. The expectation is that 802.15.4 devices will have
00028  * some hardware acceleration, which should be made available through this API.
00029  *
00030  * If no hardware acceleration is available, the API can be easily hooked up to
00031  * an external software library such as mbed TLS.
00032  *
00033  * To simplify porting, the API is used single-threaded, so that no special care
00034  * is needed to maintain global context or state in the hardware accelerator.
00035  */
00036 
00037 #include "ns_types.h"
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 /**
00044  * \brief Set the AES key
00045  *
00046  * This function sets the 128-bit AES key that will be used for future
00047  * calls to arm_aes_encrypt(). The key must be copied by the function.
00048  *
00049  * \param key pointer to 128-bit AES key
00050  */
00051 void arm_aes_start(const uint8_t key[__static 16]);
00052 
00053 /**
00054  * \brief This function performs dst=E[preset key,src] (Simple ECB block).
00055  *
00056  * This function performs a single-block AES encryption, using the preset key.
00057  * It is called between arm_aes_start() and arm_aes_finish().
00058  * Note that src and dst pointers may be equal.
00059  *
00060  * \param src pointer to 128-bit plaintext in
00061  * \param dst pointer for 128-bit ciphertext out
00062  */
00063 extern void arm_aes_encrypt(
00064     const uint8_t src[__static 16],
00065     uint8_t dst[__static 16]);
00066 
00067 /**
00068  * \brief Finish AES operations
00069  *
00070  * This function is called to terminate a series of AES operations.
00071  * It may be a no-op, or it may disable AES hardware. Use of the preset key is
00072  * no longer valid after this call.
00073  */
00074 void arm_aes_finish(void);
00075 
00076 #ifdef __cplusplus
00077 }
00078 #endif
00079 #endif /* ARM_HAL_AES_H_ */