Added support for the WNC M14A2A Cellular LTE Data Module.

Dependencies:   WNC14A2AInterface

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SPIRIT_Aes.h Source File

SPIRIT_Aes.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003  * @file    SPIRIT_Aes.h
00004   * @author  VMA division - AMS
00005   * @version 3.2.2
00006   * @date    08-July-2015
00007  * @brief   Configuration and management of SPIRIT AES Engine.
00008   *
00009  * @details
00010  *
00011  * In order to encrypt data, the user must manage the AES_END IRQ.
00012  * The data have to be splitted in blocks of 16 bytes and written
00013  * into the <i>AES DATA IN registers</i>. Then, after the key is written
00014  * into the <i>AES KEY registers</i>, a command of <i>Execute encryption</i>
00015  * has to be sent.
00016  *
00017  * <b>Example:</b>
00018  * @code
00019  *
00020  *  SpiritAesWriteDataIn(data_buff , N_BYTES);
00021  *  SpiritAesExecuteEncryption();
00022  *
00023  *  while(!aes_end_flag);       // the flag is set by the ISR routine which manages the AES_END irq
00024  *  aes_end_flag=RESET;
00025  *
00026  *  SpiritAesReadDataOut(enc_data_buff , N_BYTES);
00027  *
00028  * @endcode
00029  *
00030  * In order to decrypt data, the user must manage the AES_END IRQ and have a decryption key.
00031  * There are two operative modes to make the data decryption:
00032  * <ul>
00033  * <li> Derive the decryption key from the encryption key and decrypt data directly
00034  * using the <i>SpiritAesDeriveDecKeyExecuteDec()</i> function
00035  *
00036  * <b>Example:</b>
00037  * @code
00038  *
00039  *  SpiritAesWriteDataIn(enc_data_buff , N_BYTES);
00040  *  SpiritAesDeriveDecKeyExecuteDec();
00041  *
00042  *  while(!aes_end_flag);       // the flag is set by the ISR routine which manages the AES_END irq
00043  *  aes_end_flag=RESET;
00044  *
00045  *  SpiritAesReadDataOut(data_buff , N_BYTES);
00046  *
00047  * @endcode
00048  * </li>
00049  *
00050  * <li> Derive the decryption key from the encryption key using the <i>SpiritAesDeriveDecKeyFromEnc()</i>
00051  * function, store it into the <i>AES KEY registers</i> and then decrypt data using the
00052  * <i>SpiritAesExecuteDecryption()</i> function
00053  *
00054  * <b>Example:</b>
00055  * @code
00056  *
00057  *  SpiritAesWriteDataIn(key_enc , 16);
00058  *  SpiritAesDeriveDecKeyFromEnc();
00059  *
00060  *  while(!aes_end_flag);       // the flag is set by the ISR routine which manages the AES_END irq
00061  *  aes_end_flag=RESET;
00062  *
00063  *  SpiritAesReadDataOut(key_dec , 16);
00064  *
00065  *  SpiritAesWriteKey(key_dec);
00066  *  SpiritAesWriteDataIn(enc_data_buff , 16);
00067  *  SpiritAesExecuteDecryption();
00068  *
00069  *  while(!aes_end_flag);       // the flag is set by the ISR routine which manages the AES_END irq
00070  *  aes_end_flag=RESET;
00071  *
00072  *  SpiritAesReadDataOut(data_buff , N_BYTES);
00073  *
00074  * @endcode
00075  * </li>
00076  * </ul>
00077  *
00078   * @attention
00079   *
00080   * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
00081   *
00082   * Redistribution and use in source and binary forms, with or without modification,
00083   * are permitted provided that the following conditions are met:
00084   *   1. Redistributions of source code must retain the above copyright notice,
00085   *      this list of conditions and the following disclaimer.
00086   *   2. Redistributions in binary form must reproduce the above copyright notice,
00087   *      this list of conditions and the following disclaimer in the documentation
00088   *      and/or other materials provided with the distribution.
00089   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00090   *      may be used to endorse or promote products derived from this software
00091   *      without specific prior written permission.
00092   *
00093   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00094   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00095   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00096   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00097   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00098   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00099   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00100   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00101   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00102   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00103  *
00104   ******************************************************************************
00105  */
00106 
00107 /* Define to prevent recursive inclusion -------------------------------------*/
00108 #ifndef __SPIRIT_AES_H
00109 #define __SPIRIT_AES_H
00110 
00111 
00112 /* Includes ------------------------------------------------------------------*/
00113 
00114 #include "SPIRIT_Regs.h"
00115 #include "SPIRIT_Types.h"
00116 
00117 
00118 #ifdef __cplusplus
00119  extern "C" {
00120 #endif
00121 
00122 
00123 /**
00124  * @addtogroup SPIRIT_Libraries
00125  * @{
00126  */
00127 
00128 
00129 /**
00130  * @defgroup SPIRIT_Aes AES
00131  * @brief Configuration and management of SPIRIT AES Engine.
00132  * @details See the file <i>@ref SPIRIT_Aes.h</i> for more details.
00133  * @{
00134  */
00135 
00136 /**
00137  * @defgroup Aes_Exported_Types AES Exported Types
00138  * @{
00139  */
00140 
00141 /**
00142  * @}
00143  */
00144 
00145 
00146 /**
00147  * @defgroup Aes_Exported_Constants     AES Exported Constants
00148  * @{
00149  */
00150 
00151 
00152 /**
00153  * @}
00154  */
00155 
00156 
00157 /**
00158  * @defgroup Aes_Exported_Macros        AES Exported Macros
00159  * @{
00160  */
00161 
00162 
00163 /**
00164  * @}
00165  */
00166 
00167 
00168 /**
00169  * @defgroup Aes_Exported_Functions     AES Exported Functions
00170  * @{
00171  */
00172 
00173 void SpiritAesMode(SpiritFunctionalState xNewState);
00174 void SpiritAesWriteDataIn(uint8_t* pcBufferDataIn, uint8_t cDataLength);
00175 void SpiritAesReadDataOut(uint8_t* pcBufferDataOut, uint8_t cDataLength);
00176 void SpiritAesWriteKey(uint8_t* pcKey);
00177 void SpiritAesReadKey(uint8_t* pcKey);
00178 void SpiritAesDeriveDecKeyFromEnc(void);
00179 void SpiritAesExecuteEncryption(void);
00180 void SpiritAesExecuteDecryption(void);
00181 void SpiritAesDeriveDecKeyExecuteDec(void);
00182 
00183 /**
00184  * @}
00185  */
00186 
00187 /**
00188  * @}
00189  */
00190 
00191 
00192 /**
00193  * @}
00194  */
00195 
00196 
00197 
00198 
00199 #ifdef __cplusplus
00200 }
00201 #endif
00202 
00203 #endif
00204 
00205 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/