《STM32自学笔记》随书资料 高清电子版.rar

  • Z6_208430
  • 6.4MB
  • rar
  • 0
  • VIP专享
  • 0
  • 2022-06-05 04:59
/** ****************************************************************************** * @file AES/AES_Modes/Src/main.c * @author MCD Application Team * @version V1.1.0 * @date 18-June-2014 * @brief This example provides a short description of how to use the CRYPTO * peripheral to encrypt and decrypt data using AES in chaining modes * (ECB, CBC, CTR) and key size 128 Algorithm. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32L0xx_HAL_Examples * @{ */ /** @addtogroup AES_Modes * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* CRYP handler declaration */ CRYP_HandleTypeDef CrypHandle; /* Initialization vector */ uint8_t aInitVector[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}; /* Key size 128 bytes */ __ALIGN_BEGIN uint8_t aAES128Key[16] __ALIGN_END = {0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6, 0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c}; /* Plaintext */ uint8_t aPlaintext[AES_TEXT_SIZE] = {0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96, 0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a, 0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c, 0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51, 0x30,0xc8,0x1c,0x46,0xa3,0x5c,0xe4,0x11, 0xe5,0xfb,0xc1,0x19,0x1a,0x0a,0x52,0xef, 0xf6,0x9f,0x24,0x45,0xdf,0x4f,0x9b,0x17, 0xad,0x2b,0x41,0x7b,0xe6,0x6c,0x37,0x10}; /* Cyphertext */ uint8_t aCyphertext[AES_TEXT_SIZE] = {0x76,0x49,0xab,0xac,0x81,0x19,0xb2,0x46, 0xce,0xe9,0x8e,0x9b,0x12,0xe9,0x19,0x7d, 0x50,0x86,0xcb,0x9b,0x50,0x72,0x19,0xee, 0x95,0xdb,0x11,0x3a,0x91,0x76,0x78,0xb2, 0x73,0xbe,0xd6,0xb8,0xe3,0xc1,0x74,0x3b, 0x71,0x16,0xe6,0x9e,0x22,0x22,0x95,0x16, 0x3f,0xf1,0xca,0xa1,0x68,0x1f,0xac,0x09, 0x12,0x0e,0xca,0x30,0x75,0x86,0xe1,0xa7}; #ifdef AES_ECB /* Expected text: Encrypted Data with AES 128 Mode ECB */ uint8_t aEncryptedTextECB[AES_TEXT_SIZE] = {0x3A, 0xD7, 0x7B, 0xB4, 0x0D, 0x7A, 0x36, 0x60, 0xA8, 0x9E, 0xCA, 0xF3, 0x24, 0x66, 0xEF, 0x97, 0xF5, 0xD3, 0xD5, 0x85, 0x03, 0xB9, 0x69, 0x9D, 0xE7, 0x85, 0x89, 0x5A, 0x96, 0xFD, 0xBA, 0xAF, 0x43, 0xB1, 0xCD, 0x7F, 0x59, 0x8E, 0xCE, 0x23, 0x88, 0x1B, 0x00, 0xE3, 0xED, 0x03, 0x06, 0x88, 0x7B, 0x0C, 0x78, 0x5E, 0x27, 0xE8, 0xAD, 0x3F, 0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5D, 0xD4}; /* Expected text: Decrypted Data with AES 128 Mode ECB */ uint8_t aDecryptedTextECB[AES_TEXT_SIZE] = {0x6B, 0xC0, 0xBC, 0xE1, 0x2A, 0x45, 0x99, 0x91, 0xE1, 0x34, 0x74, 0x1A, 0x7F, 0x9E, 0x19, 0x25, 0xD8, 0x64, 0x21, 0xFB, 0x9F, 0x1A, 0x1E, 0xDA, 0x50, 0x5E, 0xE1, 0x37, 0x57, 0x46, 0x97, 0x2C, 0x60, 0x4E, 0xD7, 0xDD, 0xF3, 0x2E, 0xFD, 0xFF, 0x70, 0x20, 0xD0, 0x23, 0x8B, 0x7C, 0x2A, 0x5D, 0x85, 0x21, 0xF2, 0xFD, 0x3C, 0x8E, 0xEF, 0x2C, 0xDC, 0x3D, 0xA7, 0xE5, 0xC4, 0x4E, 0xA2, 0x06}; #endif /* AES_ECB */ #ifdef AES_CBC /* Expected text: Encrypted Data with AES 128 Mode CBC */ uint8_t aDecryptedTextCBC[AES_TEXT_SIZE] = {0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A, 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51, 0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF, 0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17, 0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10}; #endif /* AES_CBC */ #ifdef AES_CTR /* Expected text: Encrypted Data with AES 128 Mode CTR */ uint8_t aEncryptedTextCTR[AES_TEXT_SIZE] = {0x3B, 0x3F, 0xD9, 0x2E, 0xB7, 0x2D, 0xAD, 0x20, 0x33, 0x34, 0x49, 0xF8, 0xE8, 0x3C, 0xFB, 0x4A, 0x01, 0x0C, 0x04, 0x19, 0x99, 0xE0, 0x3F, 0x36,
    • STM32 程序
    • STM32
      STM32 该存储库用于容纳我的学习项目,以便使用STM32开发板进行嵌入式系统编程。
    • stm32f103
    • STM32
    • stm32 sim 7600
      stm32 ota sim 7600 stm32 ota sim 7600stm32 ota sim 7600stm32 ota sim 7600stm32 ota sim 7600stm32 ota sim 7600stm32 ota sim 7600stm32 ota sim 7600stm32 ota sim 7600stm32 ota sim 7600stm32 ota sim 7600...
    • STM32 SPWM
    • stm32 pack
      keil5 中使用的 STM32包 其中包括 STM32F0 STM32F1 STM32F3 STM32L0 STM32L1
    • stm32cubemx
      stm32cubemx st的代码生成器,安装后可以进行图形化的代码生成,项目生成!
    • STM32CubeMX
    • STM32 JoyStickMouse
      今天终于把 STM32 的例程 JoyStickMouse 跑起来了,上传一份备忘。 注意要根据 stm32f10x_conf.h 中的注释去掉一些没用到的文件