The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_KL82Z/TOOLCHAIN_IAR/fsl_ltc.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 145:64910690c574 | 1 | /* |
AnnaBridge | 145:64910690c574 | 2 | * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. |
AnnaBridge | 145:64910690c574 | 3 | * All rights reserved. |
AnnaBridge | 145:64910690c574 | 4 | * |
AnnaBridge | 145:64910690c574 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 145:64910690c574 | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 145:64910690c574 | 7 | * |
AnnaBridge | 145:64910690c574 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 145:64910690c574 | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 145:64910690c574 | 10 | * |
AnnaBridge | 145:64910690c574 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 145:64910690c574 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 145:64910690c574 | 13 | * other materials provided with the distribution. |
AnnaBridge | 145:64910690c574 | 14 | * |
AnnaBridge | 145:64910690c574 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 145:64910690c574 | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 145:64910690c574 | 17 | * software without specific prior written permission. |
AnnaBridge | 145:64910690c574 | 18 | * |
AnnaBridge | 145:64910690c574 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 145:64910690c574 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 145:64910690c574 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 145:64910690c574 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 145:64910690c574 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 145:64910690c574 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 145:64910690c574 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 145:64910690c574 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 145:64910690c574 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 145:64910690c574 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 145:64910690c574 | 29 | */ |
AnnaBridge | 145:64910690c574 | 30 | #ifndef _FSL_LTC_H_ |
AnnaBridge | 145:64910690c574 | 31 | #define _FSL_LTC_H_ |
AnnaBridge | 145:64910690c574 | 32 | |
AnnaBridge | 145:64910690c574 | 33 | #include "fsl_common.h" |
AnnaBridge | 145:64910690c574 | 34 | |
AnnaBridge | 145:64910690c574 | 35 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 36 | * Definitions |
AnnaBridge | 145:64910690c574 | 37 | *******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 38 | |
AnnaBridge | 145:64910690c574 | 39 | /*! |
AnnaBridge | 145:64910690c574 | 40 | * @addtogroup ltc |
AnnaBridge | 145:64910690c574 | 41 | * @{ |
AnnaBridge | 145:64910690c574 | 42 | */ |
AnnaBridge | 145:64910690c574 | 43 | /*! @name Driver version */ |
AnnaBridge | 145:64910690c574 | 44 | /*@{*/ |
AnnaBridge | 145:64910690c574 | 45 | /*! @brief LTC driver version. Version 2.0.1. |
AnnaBridge | 145:64910690c574 | 46 | * |
AnnaBridge | 145:64910690c574 | 47 | * Current version: 2.0.1 |
AnnaBridge | 145:64910690c574 | 48 | * |
AnnaBridge | 145:64910690c574 | 49 | * Change log: |
AnnaBridge | 145:64910690c574 | 50 | * - Version 2.0.1 |
AnnaBridge | 145:64910690c574 | 51 | * - fixed warning during g++ compilation |
AnnaBridge | 145:64910690c574 | 52 | */ |
AnnaBridge | 145:64910690c574 | 53 | #define FSL_LTC_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
AnnaBridge | 145:64910690c574 | 54 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 55 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 56 | |
AnnaBridge | 145:64910690c574 | 57 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 58 | * AES Definitions |
AnnaBridge | 145:64910690c574 | 59 | *******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 60 | /*! |
AnnaBridge | 145:64910690c574 | 61 | * @addtogroup ltc_driver_aes |
AnnaBridge | 145:64910690c574 | 62 | * @{ |
AnnaBridge | 145:64910690c574 | 63 | */ |
AnnaBridge | 145:64910690c574 | 64 | /*! AES block size in bytes */ |
AnnaBridge | 145:64910690c574 | 65 | #define LTC_AES_BLOCK_SIZE 16 |
AnnaBridge | 145:64910690c574 | 66 | /*! AES Input Vector size in bytes */ |
AnnaBridge | 145:64910690c574 | 67 | #define LTC_AES_IV_SIZE 16 |
AnnaBridge | 145:64910690c574 | 68 | |
AnnaBridge | 145:64910690c574 | 69 | /*! @brief Type of AES key for ECB and CBC decrypt operations. */ |
AnnaBridge | 145:64910690c574 | 70 | typedef enum _ltc_aes_key_t |
AnnaBridge | 145:64910690c574 | 71 | { |
AnnaBridge | 145:64910690c574 | 72 | kLTC_EncryptKey = 0U, /*!< Input key is an encrypt key */ |
AnnaBridge | 145:64910690c574 | 73 | kLTC_DecryptKey = 1U, /*!< Input key is a decrypt key */ |
AnnaBridge | 145:64910690c574 | 74 | } ltc_aes_key_t; |
AnnaBridge | 145:64910690c574 | 75 | |
AnnaBridge | 145:64910690c574 | 76 | /*! |
AnnaBridge | 145:64910690c574 | 77 | *@} |
AnnaBridge | 145:64910690c574 | 78 | */ |
AnnaBridge | 145:64910690c574 | 79 | |
AnnaBridge | 145:64910690c574 | 80 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 81 | * DES Definitions |
AnnaBridge | 145:64910690c574 | 82 | *******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 83 | /*! |
AnnaBridge | 145:64910690c574 | 84 | * @addtogroup ltc_driver_des |
AnnaBridge | 145:64910690c574 | 85 | * @{ |
AnnaBridge | 145:64910690c574 | 86 | */ |
AnnaBridge | 145:64910690c574 | 87 | |
AnnaBridge | 145:64910690c574 | 88 | /*! @brief LTC DES key size - 64 bits. */ |
AnnaBridge | 145:64910690c574 | 89 | #define LTC_DES_KEY_SIZE 8 |
AnnaBridge | 145:64910690c574 | 90 | |
AnnaBridge | 145:64910690c574 | 91 | /*! @brief LTC DES IV size - 8 bytes */ |
AnnaBridge | 145:64910690c574 | 92 | #define LTC_DES_IV_SIZE 8 |
AnnaBridge | 145:64910690c574 | 93 | |
AnnaBridge | 145:64910690c574 | 94 | /*! |
AnnaBridge | 145:64910690c574 | 95 | *@} |
AnnaBridge | 145:64910690c574 | 96 | */ |
AnnaBridge | 145:64910690c574 | 97 | |
AnnaBridge | 145:64910690c574 | 98 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 99 | * HASH Definitions |
AnnaBridge | 145:64910690c574 | 100 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 101 | /*! |
AnnaBridge | 145:64910690c574 | 102 | * @addtogroup ltc_driver_hash |
AnnaBridge | 145:64910690c574 | 103 | * @{ |
AnnaBridge | 145:64910690c574 | 104 | */ |
AnnaBridge | 145:64910690c574 | 105 | /*! Supported cryptographic block cipher functions for HASH creation */ |
AnnaBridge | 145:64910690c574 | 106 | typedef enum _ltc_hash_algo_t |
AnnaBridge | 145:64910690c574 | 107 | { |
AnnaBridge | 145:64910690c574 | 108 | kLTC_XcbcMac = 0, /*!< XCBC-MAC (AES engine) */ |
AnnaBridge | 145:64910690c574 | 109 | kLTC_Cmac, /*!< CMAC (AES engine) */ |
AnnaBridge | 145:64910690c574 | 110 | #if defined(FSL_FEATURE_LTC_HAS_SHA) && FSL_FEATURE_LTC_HAS_SHA |
AnnaBridge | 145:64910690c574 | 111 | kLTC_Sha1, /*!< SHA_1 (MDHA engine) */ |
AnnaBridge | 145:64910690c574 | 112 | kLTC_Sha224, /*!< SHA_224 (MDHA engine) */ |
AnnaBridge | 145:64910690c574 | 113 | kLTC_Sha256, /*!< SHA_256 (MDHA engine) */ |
AnnaBridge | 145:64910690c574 | 114 | #endif /* FSL_FEATURE_LTC_HAS_SHA */ |
AnnaBridge | 145:64910690c574 | 115 | } ltc_hash_algo_t; |
AnnaBridge | 145:64910690c574 | 116 | |
AnnaBridge | 145:64910690c574 | 117 | /*! @brief LTC HASH Context size. */ |
AnnaBridge | 145:64910690c574 | 118 | #if defined(FSL_FEATURE_LTC_HAS_SHA) && FSL_FEATURE_LTC_HAS_SHA |
AnnaBridge | 145:64910690c574 | 119 | #define LTC_HASH_CTX_SIZE 41 |
AnnaBridge | 145:64910690c574 | 120 | #else |
AnnaBridge | 145:64910690c574 | 121 | #define LTC_HASH_CTX_SIZE 29 |
AnnaBridge | 145:64910690c574 | 122 | #endif /* FSL_FEATURE_LTC_HAS_SHA */ |
AnnaBridge | 145:64910690c574 | 123 | |
AnnaBridge | 145:64910690c574 | 124 | /*! @brief Storage type used to save hash context. */ |
AnnaBridge | 145:64910690c574 | 125 | typedef uint32_t ltc_hash_ctx_t[LTC_HASH_CTX_SIZE]; |
AnnaBridge | 145:64910690c574 | 126 | |
AnnaBridge | 145:64910690c574 | 127 | /*! |
AnnaBridge | 145:64910690c574 | 128 | *@} |
AnnaBridge | 145:64910690c574 | 129 | */ |
AnnaBridge | 145:64910690c574 | 130 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 131 | * PKHA Definitions |
AnnaBridge | 145:64910690c574 | 132 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 133 | /*! |
AnnaBridge | 145:64910690c574 | 134 | * @addtogroup ltc_driver_pkha |
AnnaBridge | 145:64910690c574 | 135 | * @{ |
AnnaBridge | 145:64910690c574 | 136 | */ |
AnnaBridge | 145:64910690c574 | 137 | /*! PKHA ECC point structure */ |
AnnaBridge | 145:64910690c574 | 138 | typedef struct _ltc_pkha_ecc_point_t |
AnnaBridge | 145:64910690c574 | 139 | { |
AnnaBridge | 145:64910690c574 | 140 | uint8_t *X; /*!< X coordinate (affine) */ |
AnnaBridge | 145:64910690c574 | 141 | uint8_t *Y; /*!< Y coordinate (affine) */ |
AnnaBridge | 145:64910690c574 | 142 | } ltc_pkha_ecc_point_t; |
AnnaBridge | 145:64910690c574 | 143 | |
AnnaBridge | 145:64910690c574 | 144 | /*! @brief Use of timing equalized version of a PKHA function. */ |
AnnaBridge | 145:64910690c574 | 145 | typedef enum _ltc_pkha_timing_t |
AnnaBridge | 145:64910690c574 | 146 | { |
AnnaBridge | 145:64910690c574 | 147 | kLTC_PKHA_NoTimingEqualized = 0U, /*!< Normal version of a PKHA operation */ |
AnnaBridge | 145:64910690c574 | 148 | kLTC_PKHA_TimingEqualized = 1U /*!< Timing-equalized version of a PKHA operation */ |
AnnaBridge | 145:64910690c574 | 149 | } ltc_pkha_timing_t; |
AnnaBridge | 145:64910690c574 | 150 | |
AnnaBridge | 145:64910690c574 | 151 | /*! @brief Integer vs binary polynomial arithmetic selection. */ |
AnnaBridge | 145:64910690c574 | 152 | typedef enum _ltc_pkha_f2m_t |
AnnaBridge | 145:64910690c574 | 153 | { |
AnnaBridge | 145:64910690c574 | 154 | kLTC_PKHA_IntegerArith = 0U, /*!< Use integer arithmetic */ |
AnnaBridge | 145:64910690c574 | 155 | kLTC_PKHA_F2mArith = 1U /*!< Use binary polynomial arithmetic */ |
AnnaBridge | 145:64910690c574 | 156 | } ltc_pkha_f2m_t; |
AnnaBridge | 145:64910690c574 | 157 | |
AnnaBridge | 145:64910690c574 | 158 | /*! @brief Montgomery or normal PKHA input format. */ |
AnnaBridge | 145:64910690c574 | 159 | typedef enum _ltc_pkha_montgomery_form_t |
AnnaBridge | 145:64910690c574 | 160 | { |
AnnaBridge | 145:64910690c574 | 161 | kLTC_PKHA_NormalValue = 0U, /*!< PKHA number is normal integer */ |
AnnaBridge | 145:64910690c574 | 162 | kLTC_PKHA_MontgomeryFormat = 1U /*!< PKHA number is in montgomery format */ |
AnnaBridge | 145:64910690c574 | 163 | } ltc_pkha_montgomery_form_t; |
AnnaBridge | 145:64910690c574 | 164 | |
AnnaBridge | 145:64910690c574 | 165 | /*! |
AnnaBridge | 145:64910690c574 | 166 | *@} |
AnnaBridge | 145:64910690c574 | 167 | */ |
AnnaBridge | 145:64910690c574 | 168 | |
AnnaBridge | 145:64910690c574 | 169 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 170 | * API |
AnnaBridge | 145:64910690c574 | 171 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 172 | |
AnnaBridge | 145:64910690c574 | 173 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 174 | extern "C" { |
AnnaBridge | 145:64910690c574 | 175 | #endif |
AnnaBridge | 145:64910690c574 | 176 | |
AnnaBridge | 145:64910690c574 | 177 | /*! |
AnnaBridge | 145:64910690c574 | 178 | * @addtogroup ltc |
AnnaBridge | 145:64910690c574 | 179 | * @{ |
AnnaBridge | 145:64910690c574 | 180 | */ |
AnnaBridge | 145:64910690c574 | 181 | |
AnnaBridge | 145:64910690c574 | 182 | /*! |
AnnaBridge | 145:64910690c574 | 183 | * @brief Initializes the LTC driver. |
AnnaBridge | 145:64910690c574 | 184 | * This function initializes the LTC driver. |
AnnaBridge | 145:64910690c574 | 185 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 186 | */ |
AnnaBridge | 145:64910690c574 | 187 | void LTC_Init(LTC_Type *base); |
AnnaBridge | 145:64910690c574 | 188 | |
AnnaBridge | 145:64910690c574 | 189 | /*! |
AnnaBridge | 145:64910690c574 | 190 | * @brief Deinitializes the LTC driver. |
AnnaBridge | 145:64910690c574 | 191 | * This function deinitializes the LTC driver. |
AnnaBridge | 145:64910690c574 | 192 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 193 | */ |
AnnaBridge | 145:64910690c574 | 194 | void LTC_Deinit(LTC_Type *base); |
AnnaBridge | 145:64910690c574 | 195 | |
AnnaBridge | 145:64910690c574 | 196 | #if defined(FSL_FEATURE_LTC_HAS_DPAMS) && FSL_FEATURE_LTC_HAS_DPAMS |
AnnaBridge | 145:64910690c574 | 197 | /*! |
AnnaBridge | 145:64910690c574 | 198 | * @brief Sets the DPA Mask Seed register. |
AnnaBridge | 145:64910690c574 | 199 | * |
AnnaBridge | 145:64910690c574 | 200 | * The DPA Mask Seed register reseeds the mask that provides resistance against DPA (differential power analysis) |
AnnaBridge | 145:64910690c574 | 201 | * attacks on AES or DES keys. |
AnnaBridge | 145:64910690c574 | 202 | * |
AnnaBridge | 145:64910690c574 | 203 | * Differential Power Analysis Mask (DPA) resistance uses a randomly changing mask that introduces |
AnnaBridge | 145:64910690c574 | 204 | * "noise" into the power consumed by the AES or DES. This reduces the signal-to-noise ratio that differential |
AnnaBridge | 145:64910690c574 | 205 | * power analysis attacks use to "guess" bits of the key. This randomly changing mask should be |
AnnaBridge | 145:64910690c574 | 206 | * seeded at POR, and continues to provide DPA resistance from that point on. However, to provide even more |
AnnaBridge | 145:64910690c574 | 207 | * DPA protection it is recommended that the DPA mask be reseeded after every 50,000 blocks have |
AnnaBridge | 145:64910690c574 | 208 | * been processed. At that time, software can opt to write a new seed (preferably obtained from an RNG) |
AnnaBridge | 145:64910690c574 | 209 | * into the DPA Mask Seed register (DPAMS), or software can opt to provide the new seed earlier or |
AnnaBridge | 145:64910690c574 | 210 | * later, or not at all. DPA resistance continues even if the DPA mask is never reseeded. |
AnnaBridge | 145:64910690c574 | 211 | * |
AnnaBridge | 145:64910690c574 | 212 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 213 | * @param mask The DPA mask seed. |
AnnaBridge | 145:64910690c574 | 214 | */ |
AnnaBridge | 145:64910690c574 | 215 | void LTC_SetDpaMaskSeed(LTC_Type *base, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 216 | #endif /* FSL_FEATURE_LTC_HAS_DPAMS */ |
AnnaBridge | 145:64910690c574 | 217 | |
AnnaBridge | 145:64910690c574 | 218 | /*! |
AnnaBridge | 145:64910690c574 | 219 | *@} |
AnnaBridge | 145:64910690c574 | 220 | */ |
AnnaBridge | 145:64910690c574 | 221 | |
AnnaBridge | 145:64910690c574 | 222 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 223 | * AES API |
AnnaBridge | 145:64910690c574 | 224 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 225 | |
AnnaBridge | 145:64910690c574 | 226 | /*! |
AnnaBridge | 145:64910690c574 | 227 | * @addtogroup ltc_driver_aes |
AnnaBridge | 145:64910690c574 | 228 | * @{ |
AnnaBridge | 145:64910690c574 | 229 | */ |
AnnaBridge | 145:64910690c574 | 230 | |
AnnaBridge | 145:64910690c574 | 231 | /*! |
AnnaBridge | 145:64910690c574 | 232 | * @brief Transforms an AES encrypt key (forward AES) into the decrypt key (inverse AES). |
AnnaBridge | 145:64910690c574 | 233 | * |
AnnaBridge | 145:64910690c574 | 234 | * Transforms the AES encrypt key (forward AES) into the decrypt key (inverse AES). |
AnnaBridge | 145:64910690c574 | 235 | * The key derived by this function can be used as a direct load decrypt key |
AnnaBridge | 145:64910690c574 | 236 | * for AES ECB and CBC decryption operations (keyType argument). |
AnnaBridge | 145:64910690c574 | 237 | * |
AnnaBridge | 145:64910690c574 | 238 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 239 | * @param encryptKey Input key for decrypt key transformation |
AnnaBridge | 145:64910690c574 | 240 | * @param[out] decryptKey Output key, the decrypt form of the AES key. |
AnnaBridge | 145:64910690c574 | 241 | * @param keySize Size of the input key and output key in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 242 | * @return Status from key generation operation |
AnnaBridge | 145:64910690c574 | 243 | */ |
AnnaBridge | 145:64910690c574 | 244 | status_t LTC_AES_GenerateDecryptKey(LTC_Type *base, const uint8_t *encryptKey, uint8_t *decryptKey, uint32_t keySize); |
AnnaBridge | 145:64910690c574 | 245 | |
AnnaBridge | 145:64910690c574 | 246 | /*! |
AnnaBridge | 145:64910690c574 | 247 | * @brief Encrypts AES using the ECB block mode. |
AnnaBridge | 145:64910690c574 | 248 | * |
AnnaBridge | 145:64910690c574 | 249 | * Encrypts AES using the ECB block mode. |
AnnaBridge | 145:64910690c574 | 250 | * |
AnnaBridge | 145:64910690c574 | 251 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 252 | * @param plaintext Input plain text to encrypt |
AnnaBridge | 145:64910690c574 | 253 | * @param[out] ciphertext Output cipher text |
AnnaBridge | 145:64910690c574 | 254 | * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. |
AnnaBridge | 145:64910690c574 | 255 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 256 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 257 | * @return Status from encrypt operation |
AnnaBridge | 145:64910690c574 | 258 | */ |
AnnaBridge | 145:64910690c574 | 259 | status_t LTC_AES_EncryptEcb( |
AnnaBridge | 145:64910690c574 | 260 | LTC_Type *base, const uint8_t *plaintext, uint8_t *ciphertext, uint32_t size, const uint8_t *key, uint32_t keySize); |
AnnaBridge | 145:64910690c574 | 261 | |
AnnaBridge | 145:64910690c574 | 262 | /*! |
AnnaBridge | 145:64910690c574 | 263 | * @brief Decrypts AES using ECB block mode. |
AnnaBridge | 145:64910690c574 | 264 | * |
AnnaBridge | 145:64910690c574 | 265 | * Decrypts AES using ECB block mode. |
AnnaBridge | 145:64910690c574 | 266 | * |
AnnaBridge | 145:64910690c574 | 267 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 268 | * @param ciphertext Input cipher text to decrypt |
AnnaBridge | 145:64910690c574 | 269 | * @param[out] plaintext Output plain text |
AnnaBridge | 145:64910690c574 | 270 | * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. |
AnnaBridge | 145:64910690c574 | 271 | * @param key Input key. |
AnnaBridge | 145:64910690c574 | 272 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 273 | * @param keyType Input type of the key (allows to directly load decrypt key for AES ECB decrypt operation.) |
AnnaBridge | 145:64910690c574 | 274 | * @return Status from decrypt operation |
AnnaBridge | 145:64910690c574 | 275 | */ |
AnnaBridge | 145:64910690c574 | 276 | status_t LTC_AES_DecryptEcb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 277 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 278 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 279 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 280 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 281 | uint32_t keySize, |
AnnaBridge | 145:64910690c574 | 282 | ltc_aes_key_t keyType); |
AnnaBridge | 145:64910690c574 | 283 | |
AnnaBridge | 145:64910690c574 | 284 | /*! |
AnnaBridge | 145:64910690c574 | 285 | * @brief Encrypts AES using CBC block mode. |
AnnaBridge | 145:64910690c574 | 286 | * |
AnnaBridge | 145:64910690c574 | 287 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 288 | * @param plaintext Input plain text to encrypt |
AnnaBridge | 145:64910690c574 | 289 | * @param[out] ciphertext Output cipher text |
AnnaBridge | 145:64910690c574 | 290 | * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. |
AnnaBridge | 145:64910690c574 | 291 | * @param iv Input initial vector to combine with the first input block. |
AnnaBridge | 145:64910690c574 | 292 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 293 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 294 | * @return Status from encrypt operation |
AnnaBridge | 145:64910690c574 | 295 | */ |
AnnaBridge | 145:64910690c574 | 296 | status_t LTC_AES_EncryptCbc(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 297 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 298 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 299 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 300 | const uint8_t iv[LTC_AES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 301 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 302 | uint32_t keySize); |
AnnaBridge | 145:64910690c574 | 303 | |
AnnaBridge | 145:64910690c574 | 304 | /*! |
AnnaBridge | 145:64910690c574 | 305 | * @brief Decrypts AES using CBC block mode. |
AnnaBridge | 145:64910690c574 | 306 | * |
AnnaBridge | 145:64910690c574 | 307 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 308 | * @param ciphertext Input cipher text to decrypt |
AnnaBridge | 145:64910690c574 | 309 | * @param[out] plaintext Output plain text |
AnnaBridge | 145:64910690c574 | 310 | * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. |
AnnaBridge | 145:64910690c574 | 311 | * @param iv Input initial vector to combine with the first input block. |
AnnaBridge | 145:64910690c574 | 312 | * @param key Input key to use for decryption |
AnnaBridge | 145:64910690c574 | 313 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 314 | * @param keyType Input type of the key (allows to directly load decrypt key for AES CBC decrypt operation.) |
AnnaBridge | 145:64910690c574 | 315 | * @return Status from decrypt operation |
AnnaBridge | 145:64910690c574 | 316 | */ |
AnnaBridge | 145:64910690c574 | 317 | status_t LTC_AES_DecryptCbc(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 318 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 319 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 320 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 321 | const uint8_t iv[LTC_AES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 322 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 323 | uint32_t keySize, |
AnnaBridge | 145:64910690c574 | 324 | ltc_aes_key_t keyType); |
AnnaBridge | 145:64910690c574 | 325 | |
AnnaBridge | 145:64910690c574 | 326 | /*! |
AnnaBridge | 145:64910690c574 | 327 | * @brief Encrypts or decrypts AES using CTR block mode. |
AnnaBridge | 145:64910690c574 | 328 | * |
AnnaBridge | 145:64910690c574 | 329 | * Encrypts or decrypts AES using CTR block mode. |
AnnaBridge | 145:64910690c574 | 330 | * AES CTR mode uses only forward AES cipher and same algorithm for encryption and decryption. |
AnnaBridge | 145:64910690c574 | 331 | * The only difference between encryption and decryption is that, for encryption, the input argument |
AnnaBridge | 145:64910690c574 | 332 | * is plain text and the output argument is cipher text. For decryption, the input argument is cipher text |
AnnaBridge | 145:64910690c574 | 333 | * and the output argument is plain text. |
AnnaBridge | 145:64910690c574 | 334 | * |
AnnaBridge | 145:64910690c574 | 335 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 336 | * @param input Input data for CTR block mode |
AnnaBridge | 145:64910690c574 | 337 | * @param[out] output Output data for CTR block mode |
AnnaBridge | 145:64910690c574 | 338 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 339 | * @param[in,out] counter Input counter (updates on return) |
AnnaBridge | 145:64910690c574 | 340 | * @param key Input key to use for forward AES cipher |
AnnaBridge | 145:64910690c574 | 341 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 342 | * @param[out] counterlast Output cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are |
AnnaBridge | 145:64910690c574 | 343 | * not used. |
AnnaBridge | 145:64910690c574 | 344 | * @param[out] szLeft Output number of bytes in left unused in counterlast block. NULL can be passed if chained calls |
AnnaBridge | 145:64910690c574 | 345 | * are not used. |
AnnaBridge | 145:64910690c574 | 346 | * @return Status from encrypt operation |
AnnaBridge | 145:64910690c574 | 347 | */ |
AnnaBridge | 145:64910690c574 | 348 | status_t LTC_AES_CryptCtr(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 349 | const uint8_t *input, |
AnnaBridge | 145:64910690c574 | 350 | uint8_t *output, |
AnnaBridge | 145:64910690c574 | 351 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 352 | uint8_t counter[LTC_AES_BLOCK_SIZE], |
AnnaBridge | 145:64910690c574 | 353 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 354 | uint32_t keySize, |
AnnaBridge | 145:64910690c574 | 355 | uint8_t counterlast[LTC_AES_BLOCK_SIZE], |
AnnaBridge | 145:64910690c574 | 356 | uint32_t *szLeft); |
AnnaBridge | 145:64910690c574 | 357 | |
AnnaBridge | 145:64910690c574 | 358 | /*! AES CTR decrypt is mapped to the AES CTR generic operation */ |
AnnaBridge | 145:64910690c574 | 359 | #define LTC_AES_DecryptCtr(base, input, output, size, counter, key, keySize, counterlast, szLeft) \ |
AnnaBridge | 145:64910690c574 | 360 | LTC_AES_CryptCtr(base, input, output, size, counter, key, keySize, counterlast, szLeft) |
AnnaBridge | 145:64910690c574 | 361 | |
AnnaBridge | 145:64910690c574 | 362 | /*! AES CTR encrypt is mapped to the AES CTR generic operation */ |
AnnaBridge | 145:64910690c574 | 363 | #define LTC_AES_EncryptCtr(base, input, output, size, counter, key, keySize, counterlast, szLeft) \ |
AnnaBridge | 145:64910690c574 | 364 | LTC_AES_CryptCtr(base, input, output, size, counter, key, keySize, counterlast, szLeft) |
AnnaBridge | 145:64910690c574 | 365 | |
AnnaBridge | 145:64910690c574 | 366 | #if defined(FSL_FEATURE_LTC_HAS_GCM) && FSL_FEATURE_LTC_HAS_GCM |
AnnaBridge | 145:64910690c574 | 367 | /*! |
AnnaBridge | 145:64910690c574 | 368 | * @brief Encrypts AES and tags using GCM block mode. |
AnnaBridge | 145:64910690c574 | 369 | * |
AnnaBridge | 145:64910690c574 | 370 | * Encrypts AES and optionally tags using GCM block mode. If plaintext is NULL, only the GHASH is calculated and output |
AnnaBridge | 145:64910690c574 | 371 | * in the 'tag' field. |
AnnaBridge | 145:64910690c574 | 372 | * |
AnnaBridge | 145:64910690c574 | 373 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 374 | * @param plaintext Input plain text to encrypt |
AnnaBridge | 145:64910690c574 | 375 | * @param[out] ciphertext Output cipher text. |
AnnaBridge | 145:64910690c574 | 376 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 377 | * @param iv Input initial vector |
AnnaBridge | 145:64910690c574 | 378 | * @param ivSize Size of the IV |
AnnaBridge | 145:64910690c574 | 379 | * @param aad Input additional authentication data |
AnnaBridge | 145:64910690c574 | 380 | * @param aadSize Input size in bytes of AAD |
AnnaBridge | 145:64910690c574 | 381 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 382 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 383 | * @param[out] tag Output hash tag. Set to NULL to skip tag processing. |
AnnaBridge | 145:64910690c574 | 384 | * @param tagSize Input size of the tag to generate, in bytes. Must be 4,8,12,13,14,15 or 16. |
AnnaBridge | 145:64910690c574 | 385 | * @return Status from encrypt operation |
AnnaBridge | 145:64910690c574 | 386 | */ |
AnnaBridge | 145:64910690c574 | 387 | status_t LTC_AES_EncryptTagGcm(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 388 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 389 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 390 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 391 | const uint8_t *iv, |
AnnaBridge | 145:64910690c574 | 392 | uint32_t ivSize, |
AnnaBridge | 145:64910690c574 | 393 | const uint8_t *aad, |
AnnaBridge | 145:64910690c574 | 394 | uint32_t aadSize, |
AnnaBridge | 145:64910690c574 | 395 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 396 | uint32_t keySize, |
AnnaBridge | 145:64910690c574 | 397 | uint8_t *tag, |
AnnaBridge | 145:64910690c574 | 398 | uint32_t tagSize); |
AnnaBridge | 145:64910690c574 | 399 | |
AnnaBridge | 145:64910690c574 | 400 | /*! |
AnnaBridge | 145:64910690c574 | 401 | * @brief Decrypts AES and authenticates using GCM block mode. |
AnnaBridge | 145:64910690c574 | 402 | * |
AnnaBridge | 145:64910690c574 | 403 | * Decrypts AES and optionally authenticates using GCM block mode. If ciphertext is NULL, only the GHASH is calculated |
AnnaBridge | 145:64910690c574 | 404 | * and compared with the received GHASH in 'tag' field. |
AnnaBridge | 145:64910690c574 | 405 | * |
AnnaBridge | 145:64910690c574 | 406 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 407 | * @param ciphertext Input cipher text to decrypt |
AnnaBridge | 145:64910690c574 | 408 | * @param[out] plaintext Output plain text. |
AnnaBridge | 145:64910690c574 | 409 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 410 | * @param iv Input initial vector |
AnnaBridge | 145:64910690c574 | 411 | * @param ivSize Size of the IV |
AnnaBridge | 145:64910690c574 | 412 | * @param aad Input additional authentication data |
AnnaBridge | 145:64910690c574 | 413 | * @param aadSize Input size in bytes of AAD |
AnnaBridge | 145:64910690c574 | 414 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 415 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 416 | * @param tag Input hash tag to compare. Set to NULL to skip tag processing. |
AnnaBridge | 145:64910690c574 | 417 | * @param tagSize Input size of the tag, in bytes. Must be 4, 8, 12, 13, 14, 15, or 16. |
AnnaBridge | 145:64910690c574 | 418 | * @return Status from decrypt operation |
AnnaBridge | 145:64910690c574 | 419 | */ |
AnnaBridge | 145:64910690c574 | 420 | status_t LTC_AES_DecryptTagGcm(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 421 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 422 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 423 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 424 | const uint8_t *iv, |
AnnaBridge | 145:64910690c574 | 425 | uint32_t ivSize, |
AnnaBridge | 145:64910690c574 | 426 | const uint8_t *aad, |
AnnaBridge | 145:64910690c574 | 427 | uint32_t aadSize, |
AnnaBridge | 145:64910690c574 | 428 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 429 | uint32_t keySize, |
AnnaBridge | 145:64910690c574 | 430 | const uint8_t *tag, |
AnnaBridge | 145:64910690c574 | 431 | uint32_t tagSize); |
AnnaBridge | 145:64910690c574 | 432 | #endif /* FSL_FEATURE_LTC_HAS_GCM */ |
AnnaBridge | 145:64910690c574 | 433 | |
AnnaBridge | 145:64910690c574 | 434 | /*! |
AnnaBridge | 145:64910690c574 | 435 | * @brief Encrypts AES and tags using CCM block mode. |
AnnaBridge | 145:64910690c574 | 436 | * |
AnnaBridge | 145:64910690c574 | 437 | * Encrypts AES and optionally tags using CCM block mode. |
AnnaBridge | 145:64910690c574 | 438 | * |
AnnaBridge | 145:64910690c574 | 439 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 440 | * @param plaintext Input plain text to encrypt |
AnnaBridge | 145:64910690c574 | 441 | * @param[out] ciphertext Output cipher text. |
AnnaBridge | 145:64910690c574 | 442 | * @param size Size of input and output data in bytes. Zero means authentication only. |
AnnaBridge | 145:64910690c574 | 443 | * @param iv Nonce |
AnnaBridge | 145:64910690c574 | 444 | * @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13. |
AnnaBridge | 145:64910690c574 | 445 | * @param aad Input additional authentication data. Can be NULL if aadSize is zero. |
AnnaBridge | 145:64910690c574 | 446 | * @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication skipped). |
AnnaBridge | 145:64910690c574 | 447 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 448 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 449 | * @param[out] tag Generated output tag. Set to NULL to skip tag processing. |
AnnaBridge | 145:64910690c574 | 450 | * @param tagSize Input size of the tag to generate, in bytes. Must be 4, 6, 8, 10, 12, 14, or 16. |
AnnaBridge | 145:64910690c574 | 451 | * @return Status from encrypt operation |
AnnaBridge | 145:64910690c574 | 452 | */ |
AnnaBridge | 145:64910690c574 | 453 | status_t LTC_AES_EncryptTagCcm(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 454 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 455 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 456 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 457 | const uint8_t *iv, |
AnnaBridge | 145:64910690c574 | 458 | uint32_t ivSize, |
AnnaBridge | 145:64910690c574 | 459 | const uint8_t *aad, |
AnnaBridge | 145:64910690c574 | 460 | uint32_t aadSize, |
AnnaBridge | 145:64910690c574 | 461 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 462 | uint32_t keySize, |
AnnaBridge | 145:64910690c574 | 463 | uint8_t *tag, |
AnnaBridge | 145:64910690c574 | 464 | uint32_t tagSize); |
AnnaBridge | 145:64910690c574 | 465 | |
AnnaBridge | 145:64910690c574 | 466 | /*! |
AnnaBridge | 145:64910690c574 | 467 | * @brief Decrypts AES and authenticates using CCM block mode. |
AnnaBridge | 145:64910690c574 | 468 | * |
AnnaBridge | 145:64910690c574 | 469 | * Decrypts AES and optionally authenticates using CCM block mode. |
AnnaBridge | 145:64910690c574 | 470 | * |
AnnaBridge | 145:64910690c574 | 471 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 472 | * @param ciphertext Input cipher text to decrypt |
AnnaBridge | 145:64910690c574 | 473 | * @param[out] plaintext Output plain text. |
AnnaBridge | 145:64910690c574 | 474 | * @param size Size of input and output data in bytes. Zero means authentication only. |
AnnaBridge | 145:64910690c574 | 475 | * @param iv Nonce |
AnnaBridge | 145:64910690c574 | 476 | * @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13. |
AnnaBridge | 145:64910690c574 | 477 | * @param aad Input additional authentication data. Can be NULL if aadSize is zero. |
AnnaBridge | 145:64910690c574 | 478 | * @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication skipped). |
AnnaBridge | 145:64910690c574 | 479 | * @param key Input key to use for decryption |
AnnaBridge | 145:64910690c574 | 480 | * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. |
AnnaBridge | 145:64910690c574 | 481 | * @param tag Received tag. Set to NULL to skip tag processing. |
AnnaBridge | 145:64910690c574 | 482 | * @param tagSize Input size of the received tag to compare with the computed tag, in bytes. Must be 4, 6, 8, 10, 12, |
AnnaBridge | 145:64910690c574 | 483 | * 14, or 16. |
AnnaBridge | 145:64910690c574 | 484 | * @return Status from decrypt operation |
AnnaBridge | 145:64910690c574 | 485 | */ |
AnnaBridge | 145:64910690c574 | 486 | status_t LTC_AES_DecryptTagCcm(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 487 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 488 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 489 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 490 | const uint8_t *iv, |
AnnaBridge | 145:64910690c574 | 491 | uint32_t ivSize, |
AnnaBridge | 145:64910690c574 | 492 | const uint8_t *aad, |
AnnaBridge | 145:64910690c574 | 493 | uint32_t aadSize, |
AnnaBridge | 145:64910690c574 | 494 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 495 | uint32_t keySize, |
AnnaBridge | 145:64910690c574 | 496 | const uint8_t *tag, |
AnnaBridge | 145:64910690c574 | 497 | uint32_t tagSize); |
AnnaBridge | 145:64910690c574 | 498 | |
AnnaBridge | 145:64910690c574 | 499 | /*! |
AnnaBridge | 145:64910690c574 | 500 | *@} |
AnnaBridge | 145:64910690c574 | 501 | */ |
AnnaBridge | 145:64910690c574 | 502 | |
AnnaBridge | 145:64910690c574 | 503 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 504 | * DES API |
AnnaBridge | 145:64910690c574 | 505 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 506 | /*! |
AnnaBridge | 145:64910690c574 | 507 | * @addtogroup ltc_driver_des |
AnnaBridge | 145:64910690c574 | 508 | * @{ |
AnnaBridge | 145:64910690c574 | 509 | */ |
AnnaBridge | 145:64910690c574 | 510 | /*! |
AnnaBridge | 145:64910690c574 | 511 | * @brief Encrypts DES using ECB block mode. |
AnnaBridge | 145:64910690c574 | 512 | * |
AnnaBridge | 145:64910690c574 | 513 | * Encrypts DES using ECB block mode. |
AnnaBridge | 145:64910690c574 | 514 | * |
AnnaBridge | 145:64910690c574 | 515 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 516 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 517 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 518 | * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. |
AnnaBridge | 145:64910690c574 | 519 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 520 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 521 | */ |
AnnaBridge | 145:64910690c574 | 522 | status_t LTC_DES_EncryptEcb( |
AnnaBridge | 145:64910690c574 | 523 | LTC_Type *base, const uint8_t *plaintext, uint8_t *ciphertext, uint32_t size, const uint8_t key[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 524 | |
AnnaBridge | 145:64910690c574 | 525 | /*! |
AnnaBridge | 145:64910690c574 | 526 | * @brief Decrypts DES using ECB block mode. |
AnnaBridge | 145:64910690c574 | 527 | * |
AnnaBridge | 145:64910690c574 | 528 | * Decrypts DES using ECB block mode. |
AnnaBridge | 145:64910690c574 | 529 | * |
AnnaBridge | 145:64910690c574 | 530 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 531 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 532 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 533 | * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. |
AnnaBridge | 145:64910690c574 | 534 | * @param key Input key to use for decryption |
AnnaBridge | 145:64910690c574 | 535 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 536 | */ |
AnnaBridge | 145:64910690c574 | 537 | status_t LTC_DES_DecryptEcb( |
AnnaBridge | 145:64910690c574 | 538 | LTC_Type *base, const uint8_t *ciphertext, uint8_t *plaintext, uint32_t size, const uint8_t key[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 539 | |
AnnaBridge | 145:64910690c574 | 540 | /*! |
AnnaBridge | 145:64910690c574 | 541 | * @brief Encrypts DES using CBC block mode. |
AnnaBridge | 145:64910690c574 | 542 | * |
AnnaBridge | 145:64910690c574 | 543 | * Encrypts DES using CBC block mode. |
AnnaBridge | 145:64910690c574 | 544 | * |
AnnaBridge | 145:64910690c574 | 545 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 546 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 547 | * @param[out] ciphertext Ouput ciphertext |
AnnaBridge | 145:64910690c574 | 548 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 549 | * @param iv Input initial vector to combine with the first plaintext block. |
AnnaBridge | 145:64910690c574 | 550 | * The iv does not need to be secret, but it must be unpredictable. |
AnnaBridge | 145:64910690c574 | 551 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 552 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 553 | */ |
AnnaBridge | 145:64910690c574 | 554 | status_t LTC_DES_EncryptCbc(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 555 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 556 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 557 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 558 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 559 | const uint8_t key[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 560 | |
AnnaBridge | 145:64910690c574 | 561 | /*! |
AnnaBridge | 145:64910690c574 | 562 | * @brief Decrypts DES using CBC block mode. |
AnnaBridge | 145:64910690c574 | 563 | * |
AnnaBridge | 145:64910690c574 | 564 | * Decrypts DES using CBC block mode. |
AnnaBridge | 145:64910690c574 | 565 | * |
AnnaBridge | 145:64910690c574 | 566 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 567 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 568 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 569 | * @param size Size of input data in bytes |
AnnaBridge | 145:64910690c574 | 570 | * @param iv Input initial vector to combine with the first plaintext block. |
AnnaBridge | 145:64910690c574 | 571 | * The iv does not need to be secret, but it must be unpredictable. |
AnnaBridge | 145:64910690c574 | 572 | * @param key Input key to use for decryption |
AnnaBridge | 145:64910690c574 | 573 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 574 | */ |
AnnaBridge | 145:64910690c574 | 575 | status_t LTC_DES_DecryptCbc(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 576 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 577 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 578 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 579 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 580 | const uint8_t key[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 581 | |
AnnaBridge | 145:64910690c574 | 582 | /*! |
AnnaBridge | 145:64910690c574 | 583 | * @brief Encrypts DES using CFB block mode. |
AnnaBridge | 145:64910690c574 | 584 | * |
AnnaBridge | 145:64910690c574 | 585 | * Encrypts DES using CFB block mode. |
AnnaBridge | 145:64910690c574 | 586 | * |
AnnaBridge | 145:64910690c574 | 587 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 588 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 589 | * @param size Size of input data in bytes |
AnnaBridge | 145:64910690c574 | 590 | * @param iv Input initial block. |
AnnaBridge | 145:64910690c574 | 591 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 592 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 593 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 594 | */ |
AnnaBridge | 145:64910690c574 | 595 | status_t LTC_DES_EncryptCfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 596 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 597 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 598 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 599 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 600 | const uint8_t key[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 601 | |
AnnaBridge | 145:64910690c574 | 602 | /*! |
AnnaBridge | 145:64910690c574 | 603 | * @brief Decrypts DES using CFB block mode. |
AnnaBridge | 145:64910690c574 | 604 | * |
AnnaBridge | 145:64910690c574 | 605 | * Decrypts DES using CFB block mode. |
AnnaBridge | 145:64910690c574 | 606 | * |
AnnaBridge | 145:64910690c574 | 607 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 608 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 609 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 610 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 611 | * @param iv Input initial block. |
AnnaBridge | 145:64910690c574 | 612 | * @param key Input key to use for decryption |
AnnaBridge | 145:64910690c574 | 613 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 614 | */ |
AnnaBridge | 145:64910690c574 | 615 | status_t LTC_DES_DecryptCfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 616 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 617 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 618 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 619 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 620 | const uint8_t key[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 621 | |
AnnaBridge | 145:64910690c574 | 622 | /*! |
AnnaBridge | 145:64910690c574 | 623 | * @brief Encrypts DES using OFB block mode. |
AnnaBridge | 145:64910690c574 | 624 | * |
AnnaBridge | 145:64910690c574 | 625 | * Encrypts DES using OFB block mode. |
AnnaBridge | 145:64910690c574 | 626 | * |
AnnaBridge | 145:64910690c574 | 627 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 628 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 629 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 630 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 631 | * @param iv Input unique input vector. The OFB mode requires that the IV be unique |
AnnaBridge | 145:64910690c574 | 632 | * for each execution of the mode under the given key. |
AnnaBridge | 145:64910690c574 | 633 | * @param key Input key to use for encryption |
AnnaBridge | 145:64910690c574 | 634 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 635 | */ |
AnnaBridge | 145:64910690c574 | 636 | status_t LTC_DES_EncryptOfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 637 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 638 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 639 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 640 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 641 | const uint8_t key[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 642 | |
AnnaBridge | 145:64910690c574 | 643 | /*! |
AnnaBridge | 145:64910690c574 | 644 | * @brief Decrypts DES using OFB block mode. |
AnnaBridge | 145:64910690c574 | 645 | * |
AnnaBridge | 145:64910690c574 | 646 | * Decrypts DES using OFB block mode. |
AnnaBridge | 145:64910690c574 | 647 | * |
AnnaBridge | 145:64910690c574 | 648 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 649 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 650 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 651 | * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. |
AnnaBridge | 145:64910690c574 | 652 | * @param iv Input unique input vector. The OFB mode requires that the IV be unique |
AnnaBridge | 145:64910690c574 | 653 | * for each execution of the mode under the given key. |
AnnaBridge | 145:64910690c574 | 654 | * @param key Input key to use for decryption |
AnnaBridge | 145:64910690c574 | 655 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 656 | */ |
AnnaBridge | 145:64910690c574 | 657 | status_t LTC_DES_DecryptOfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 658 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 659 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 660 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 661 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 662 | const uint8_t key[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 663 | |
AnnaBridge | 145:64910690c574 | 664 | /*! |
AnnaBridge | 145:64910690c574 | 665 | * @brief Encrypts triple DES using ECB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 666 | * |
AnnaBridge | 145:64910690c574 | 667 | * Encrypts triple DES using ECB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 668 | * |
AnnaBridge | 145:64910690c574 | 669 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 670 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 671 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 672 | * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. |
AnnaBridge | 145:64910690c574 | 673 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 674 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 675 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 676 | */ |
AnnaBridge | 145:64910690c574 | 677 | status_t LTC_DES2_EncryptEcb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 678 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 679 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 680 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 681 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 682 | const uint8_t key2[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 683 | |
AnnaBridge | 145:64910690c574 | 684 | /*! |
AnnaBridge | 145:64910690c574 | 685 | * @brief Decrypts triple DES using ECB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 686 | * |
AnnaBridge | 145:64910690c574 | 687 | * Decrypts triple DES using ECB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 688 | * |
AnnaBridge | 145:64910690c574 | 689 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 690 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 691 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 692 | * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. |
AnnaBridge | 145:64910690c574 | 693 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 694 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 695 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 696 | */ |
AnnaBridge | 145:64910690c574 | 697 | status_t LTC_DES2_DecryptEcb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 698 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 699 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 700 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 701 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 702 | const uint8_t key2[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 703 | |
AnnaBridge | 145:64910690c574 | 704 | /*! |
AnnaBridge | 145:64910690c574 | 705 | * @brief Encrypts triple DES using CBC block mode with two keys. |
AnnaBridge | 145:64910690c574 | 706 | * |
AnnaBridge | 145:64910690c574 | 707 | * Encrypts triple DES using CBC block mode with two keys. |
AnnaBridge | 145:64910690c574 | 708 | * |
AnnaBridge | 145:64910690c574 | 709 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 710 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 711 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 712 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 713 | * @param iv Input initial vector to combine with the first plaintext block. |
AnnaBridge | 145:64910690c574 | 714 | * The iv does not need to be secret, but it must be unpredictable. |
AnnaBridge | 145:64910690c574 | 715 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 716 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 717 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 718 | */ |
AnnaBridge | 145:64910690c574 | 719 | status_t LTC_DES2_EncryptCbc(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 720 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 721 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 722 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 723 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 724 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 725 | const uint8_t key2[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 726 | |
AnnaBridge | 145:64910690c574 | 727 | /*! |
AnnaBridge | 145:64910690c574 | 728 | * @brief Decrypts triple DES using CBC block mode with two keys. |
AnnaBridge | 145:64910690c574 | 729 | * |
AnnaBridge | 145:64910690c574 | 730 | * Decrypts triple DES using CBC block mode with two keys. |
AnnaBridge | 145:64910690c574 | 731 | * |
AnnaBridge | 145:64910690c574 | 732 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 733 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 734 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 735 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 736 | * @param iv Input initial vector to combine with the first plaintext block. |
AnnaBridge | 145:64910690c574 | 737 | * The iv does not need to be secret, but it must be unpredictable. |
AnnaBridge | 145:64910690c574 | 738 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 739 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 740 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 741 | */ |
AnnaBridge | 145:64910690c574 | 742 | status_t LTC_DES2_DecryptCbc(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 743 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 744 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 745 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 746 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 747 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 748 | const uint8_t key2[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 749 | |
AnnaBridge | 145:64910690c574 | 750 | /*! |
AnnaBridge | 145:64910690c574 | 751 | * @brief Encrypts triple DES using CFB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 752 | * |
AnnaBridge | 145:64910690c574 | 753 | * Encrypts triple DES using CFB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 754 | * |
AnnaBridge | 145:64910690c574 | 755 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 756 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 757 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 758 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 759 | * @param iv Input initial block. |
AnnaBridge | 145:64910690c574 | 760 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 761 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 762 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 763 | */ |
AnnaBridge | 145:64910690c574 | 764 | status_t LTC_DES2_EncryptCfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 765 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 766 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 767 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 768 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 769 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 770 | const uint8_t key2[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 771 | |
AnnaBridge | 145:64910690c574 | 772 | /*! |
AnnaBridge | 145:64910690c574 | 773 | * @brief Decrypts triple DES using CFB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 774 | * |
AnnaBridge | 145:64910690c574 | 775 | * Decrypts triple DES using CFB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 776 | * |
AnnaBridge | 145:64910690c574 | 777 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 778 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 779 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 780 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 781 | * @param iv Input initial block. |
AnnaBridge | 145:64910690c574 | 782 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 783 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 784 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 785 | */ |
AnnaBridge | 145:64910690c574 | 786 | status_t LTC_DES2_DecryptCfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 787 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 788 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 789 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 790 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 791 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 792 | const uint8_t key2[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 793 | |
AnnaBridge | 145:64910690c574 | 794 | /*! |
AnnaBridge | 145:64910690c574 | 795 | * @brief Encrypts triple DES using OFB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 796 | * |
AnnaBridge | 145:64910690c574 | 797 | * Encrypts triple DES using OFB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 798 | * |
AnnaBridge | 145:64910690c574 | 799 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 800 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 801 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 802 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 803 | * @param iv Input unique input vector. The OFB mode requires that the IV be unique |
AnnaBridge | 145:64910690c574 | 804 | * for each execution of the mode under the given key. |
AnnaBridge | 145:64910690c574 | 805 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 806 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 807 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 808 | */ |
AnnaBridge | 145:64910690c574 | 809 | status_t LTC_DES2_EncryptOfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 810 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 811 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 812 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 813 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 814 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 815 | const uint8_t key2[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 816 | |
AnnaBridge | 145:64910690c574 | 817 | /*! |
AnnaBridge | 145:64910690c574 | 818 | * @brief Decrypts triple DES using OFB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 819 | * |
AnnaBridge | 145:64910690c574 | 820 | * Decrypts triple DES using OFB block mode with two keys. |
AnnaBridge | 145:64910690c574 | 821 | * |
AnnaBridge | 145:64910690c574 | 822 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 823 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 824 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 825 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 826 | * @param iv Input unique input vector. The OFB mode requires that the IV be unique |
AnnaBridge | 145:64910690c574 | 827 | * for each execution of the mode under the given key. |
AnnaBridge | 145:64910690c574 | 828 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 829 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 830 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 831 | */ |
AnnaBridge | 145:64910690c574 | 832 | status_t LTC_DES2_DecryptOfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 833 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 834 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 835 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 836 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 837 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 838 | const uint8_t key2[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 839 | |
AnnaBridge | 145:64910690c574 | 840 | /*! |
AnnaBridge | 145:64910690c574 | 841 | * @brief Encrypts triple DES using ECB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 842 | * |
AnnaBridge | 145:64910690c574 | 843 | * Encrypts triple DES using ECB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 844 | * |
AnnaBridge | 145:64910690c574 | 845 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 846 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 847 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 848 | * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. |
AnnaBridge | 145:64910690c574 | 849 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 850 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 851 | * @param key3 Third input key for key bundle |
AnnaBridge | 145:64910690c574 | 852 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 853 | */ |
AnnaBridge | 145:64910690c574 | 854 | status_t LTC_DES3_EncryptEcb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 855 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 856 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 857 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 858 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 859 | const uint8_t key2[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 860 | const uint8_t key3[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 861 | |
AnnaBridge | 145:64910690c574 | 862 | /*! |
AnnaBridge | 145:64910690c574 | 863 | * @brief Decrypts triple DES using ECB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 864 | * |
AnnaBridge | 145:64910690c574 | 865 | * Decrypts triple DES using ECB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 866 | * |
AnnaBridge | 145:64910690c574 | 867 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 868 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 869 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 870 | * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. |
AnnaBridge | 145:64910690c574 | 871 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 872 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 873 | * @param key3 Third input key for key bundle |
AnnaBridge | 145:64910690c574 | 874 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 875 | */ |
AnnaBridge | 145:64910690c574 | 876 | status_t LTC_DES3_DecryptEcb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 877 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 878 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 879 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 880 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 881 | const uint8_t key2[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 882 | const uint8_t key3[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 883 | |
AnnaBridge | 145:64910690c574 | 884 | /*! |
AnnaBridge | 145:64910690c574 | 885 | * @brief Encrypts triple DES using CBC block mode with three keys. |
AnnaBridge | 145:64910690c574 | 886 | * |
AnnaBridge | 145:64910690c574 | 887 | * Encrypts triple DES using CBC block mode with three keys. |
AnnaBridge | 145:64910690c574 | 888 | * |
AnnaBridge | 145:64910690c574 | 889 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 890 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 891 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 892 | * @param size Size of input data in bytes |
AnnaBridge | 145:64910690c574 | 893 | * @param iv Input initial vector to combine with the first plaintext block. |
AnnaBridge | 145:64910690c574 | 894 | * The iv does not need to be secret, but it must be unpredictable. |
AnnaBridge | 145:64910690c574 | 895 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 896 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 897 | * @param key3 Third input key for key bundle |
AnnaBridge | 145:64910690c574 | 898 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 899 | */ |
AnnaBridge | 145:64910690c574 | 900 | status_t LTC_DES3_EncryptCbc(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 901 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 902 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 903 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 904 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 905 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 906 | const uint8_t key2[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 907 | const uint8_t key3[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 908 | |
AnnaBridge | 145:64910690c574 | 909 | /*! |
AnnaBridge | 145:64910690c574 | 910 | * @brief Decrypts triple DES using CBC block mode with three keys. |
AnnaBridge | 145:64910690c574 | 911 | * |
AnnaBridge | 145:64910690c574 | 912 | * Decrypts triple DES using CBC block mode with three keys. |
AnnaBridge | 145:64910690c574 | 913 | * |
AnnaBridge | 145:64910690c574 | 914 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 915 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 916 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 917 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 918 | * @param iv Input initial vector to combine with the first plaintext block. |
AnnaBridge | 145:64910690c574 | 919 | * The iv does not need to be secret, but it must be unpredictable. |
AnnaBridge | 145:64910690c574 | 920 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 921 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 922 | * @param key3 Third input key for key bundle |
AnnaBridge | 145:64910690c574 | 923 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 924 | */ |
AnnaBridge | 145:64910690c574 | 925 | status_t LTC_DES3_DecryptCbc(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 926 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 927 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 928 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 929 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 930 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 931 | const uint8_t key2[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 932 | const uint8_t key3[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 933 | |
AnnaBridge | 145:64910690c574 | 934 | /*! |
AnnaBridge | 145:64910690c574 | 935 | * @brief Encrypts triple DES using CFB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 936 | * |
AnnaBridge | 145:64910690c574 | 937 | * Encrypts triple DES using CFB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 938 | * |
AnnaBridge | 145:64910690c574 | 939 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 940 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 941 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 942 | * @param size Size of input and ouput data in bytes |
AnnaBridge | 145:64910690c574 | 943 | * @param iv Input initial block. |
AnnaBridge | 145:64910690c574 | 944 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 945 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 946 | * @param key3 Third input key for key bundle |
AnnaBridge | 145:64910690c574 | 947 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 948 | */ |
AnnaBridge | 145:64910690c574 | 949 | status_t LTC_DES3_EncryptCfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 950 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 951 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 952 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 953 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 954 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 955 | const uint8_t key2[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 956 | const uint8_t key3[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 957 | |
AnnaBridge | 145:64910690c574 | 958 | /*! |
AnnaBridge | 145:64910690c574 | 959 | * @brief Decrypts triple DES using CFB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 960 | * |
AnnaBridge | 145:64910690c574 | 961 | * Decrypts triple DES using CFB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 962 | * |
AnnaBridge | 145:64910690c574 | 963 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 964 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 965 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 966 | * @param size Size of input data in bytes |
AnnaBridge | 145:64910690c574 | 967 | * @param iv Input initial block. |
AnnaBridge | 145:64910690c574 | 968 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 969 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 970 | * @param key3 Third input key for key bundle |
AnnaBridge | 145:64910690c574 | 971 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 972 | */ |
AnnaBridge | 145:64910690c574 | 973 | status_t LTC_DES3_DecryptCfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 974 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 975 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 976 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 977 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 978 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 979 | const uint8_t key2[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 980 | const uint8_t key3[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 981 | |
AnnaBridge | 145:64910690c574 | 982 | /*! |
AnnaBridge | 145:64910690c574 | 983 | * @brief Encrypts triple DES using OFB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 984 | * |
AnnaBridge | 145:64910690c574 | 985 | * Encrypts triple DES using OFB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 986 | * |
AnnaBridge | 145:64910690c574 | 987 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 988 | * @param plaintext Input plaintext to encrypt |
AnnaBridge | 145:64910690c574 | 989 | * @param[out] ciphertext Output ciphertext |
AnnaBridge | 145:64910690c574 | 990 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 991 | * @param iv Input unique input vector. The OFB mode requires that the IV be unique |
AnnaBridge | 145:64910690c574 | 992 | * for each execution of the mode under the given key. |
AnnaBridge | 145:64910690c574 | 993 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 994 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 995 | * @param key3 Third input key for key bundle |
AnnaBridge | 145:64910690c574 | 996 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 997 | */ |
AnnaBridge | 145:64910690c574 | 998 | status_t LTC_DES3_EncryptOfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 999 | const uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 1000 | uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 1001 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 1002 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 1003 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 1004 | const uint8_t key2[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 1005 | const uint8_t key3[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 1006 | |
AnnaBridge | 145:64910690c574 | 1007 | /*! |
AnnaBridge | 145:64910690c574 | 1008 | * @brief Decrypts triple DES using OFB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 1009 | * |
AnnaBridge | 145:64910690c574 | 1010 | * Decrypts triple DES using OFB block mode with three keys. |
AnnaBridge | 145:64910690c574 | 1011 | * |
AnnaBridge | 145:64910690c574 | 1012 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1013 | * @param ciphertext Input ciphertext to decrypt |
AnnaBridge | 145:64910690c574 | 1014 | * @param[out] plaintext Output plaintext |
AnnaBridge | 145:64910690c574 | 1015 | * @param size Size of input and output data in bytes |
AnnaBridge | 145:64910690c574 | 1016 | * @param iv Input unique input vector. The OFB mode requires that the IV be unique |
AnnaBridge | 145:64910690c574 | 1017 | * for each execution of the mode under the given key. |
AnnaBridge | 145:64910690c574 | 1018 | * @param key1 First input key for key bundle |
AnnaBridge | 145:64910690c574 | 1019 | * @param key2 Second input key for key bundle |
AnnaBridge | 145:64910690c574 | 1020 | * @param key3 Third input key for key bundle |
AnnaBridge | 145:64910690c574 | 1021 | * @return Status from encrypt/decrypt operation |
AnnaBridge | 145:64910690c574 | 1022 | */ |
AnnaBridge | 145:64910690c574 | 1023 | status_t LTC_DES3_DecryptOfb(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1024 | const uint8_t *ciphertext, |
AnnaBridge | 145:64910690c574 | 1025 | uint8_t *plaintext, |
AnnaBridge | 145:64910690c574 | 1026 | uint32_t size, |
AnnaBridge | 145:64910690c574 | 1027 | const uint8_t iv[LTC_DES_IV_SIZE], |
AnnaBridge | 145:64910690c574 | 1028 | const uint8_t key1[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 1029 | const uint8_t key2[LTC_DES_KEY_SIZE], |
AnnaBridge | 145:64910690c574 | 1030 | const uint8_t key3[LTC_DES_KEY_SIZE]); |
AnnaBridge | 145:64910690c574 | 1031 | |
AnnaBridge | 145:64910690c574 | 1032 | /*! |
AnnaBridge | 145:64910690c574 | 1033 | *@} |
AnnaBridge | 145:64910690c574 | 1034 | */ |
AnnaBridge | 145:64910690c574 | 1035 | |
AnnaBridge | 145:64910690c574 | 1036 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 1037 | * HASH API |
AnnaBridge | 145:64910690c574 | 1038 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 1039 | |
AnnaBridge | 145:64910690c574 | 1040 | /*! |
AnnaBridge | 145:64910690c574 | 1041 | * @addtogroup ltc_driver_hash |
AnnaBridge | 145:64910690c574 | 1042 | * @{ |
AnnaBridge | 145:64910690c574 | 1043 | */ |
AnnaBridge | 145:64910690c574 | 1044 | /*! |
AnnaBridge | 145:64910690c574 | 1045 | * @brief Initialize HASH context |
AnnaBridge | 145:64910690c574 | 1046 | * |
AnnaBridge | 145:64910690c574 | 1047 | * This function initialize the HASH. |
AnnaBridge | 145:64910690c574 | 1048 | * Key shall be supplied if the underlaying algoritm is AES XCBC-MAC or CMAC. |
AnnaBridge | 145:64910690c574 | 1049 | * Key shall be NULL if the underlaying algoritm is SHA. |
AnnaBridge | 145:64910690c574 | 1050 | * |
AnnaBridge | 145:64910690c574 | 1051 | * For XCBC-MAC, the key length must be 16. For CMAC, the key length can be |
AnnaBridge | 145:64910690c574 | 1052 | * the AES key lengths supported by AES engine. For MDHA the key length argument |
AnnaBridge | 145:64910690c574 | 1053 | * is ignored. |
AnnaBridge | 145:64910690c574 | 1054 | * |
AnnaBridge | 145:64910690c574 | 1055 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1056 | * @param[out] ctx Output hash context |
AnnaBridge | 145:64910690c574 | 1057 | * @param algo Underlaying algorithm to use for hash computation. |
AnnaBridge | 145:64910690c574 | 1058 | * @param key Input key (NULL if underlaying algorithm is SHA) |
AnnaBridge | 145:64910690c574 | 1059 | * @param keySize Size of input key in bytes |
AnnaBridge | 145:64910690c574 | 1060 | * @return Status of initialization |
AnnaBridge | 145:64910690c574 | 1061 | */ |
AnnaBridge | 145:64910690c574 | 1062 | status_t LTC_HASH_Init(LTC_Type *base, ltc_hash_ctx_t *ctx, ltc_hash_algo_t algo, const uint8_t *key, uint32_t keySize); |
AnnaBridge | 145:64910690c574 | 1063 | |
AnnaBridge | 145:64910690c574 | 1064 | /*! |
AnnaBridge | 145:64910690c574 | 1065 | * @brief Add data to current HASH |
AnnaBridge | 145:64910690c574 | 1066 | * |
AnnaBridge | 145:64910690c574 | 1067 | * Add data to current HASH. This can be called repeatedly with an arbitrary amount of data to be |
AnnaBridge | 145:64910690c574 | 1068 | * hashed. |
AnnaBridge | 145:64910690c574 | 1069 | * |
AnnaBridge | 145:64910690c574 | 1070 | * @param[in,out] ctx HASH context |
AnnaBridge | 145:64910690c574 | 1071 | * @param input Input data |
AnnaBridge | 145:64910690c574 | 1072 | * @param inputSize Size of input data in bytes |
AnnaBridge | 145:64910690c574 | 1073 | * @return Status of the hash update operation |
AnnaBridge | 145:64910690c574 | 1074 | */ |
AnnaBridge | 145:64910690c574 | 1075 | status_t LTC_HASH_Update(ltc_hash_ctx_t *ctx, const uint8_t *input, uint32_t inputSize); |
AnnaBridge | 145:64910690c574 | 1076 | |
AnnaBridge | 145:64910690c574 | 1077 | /*! |
AnnaBridge | 145:64910690c574 | 1078 | * @brief Finalize hashing |
AnnaBridge | 145:64910690c574 | 1079 | * |
AnnaBridge | 145:64910690c574 | 1080 | * Outputs the final hash and erases the context. |
AnnaBridge | 145:64910690c574 | 1081 | * |
AnnaBridge | 145:64910690c574 | 1082 | * @param[in,out] ctx Input hash context |
AnnaBridge | 145:64910690c574 | 1083 | * @param[out] output Output hash data |
AnnaBridge | 145:64910690c574 | 1084 | * @param[out] outputSize Output parameter storing the size of the output hash in bytes |
AnnaBridge | 145:64910690c574 | 1085 | * @return Status of the hash finish operation |
AnnaBridge | 145:64910690c574 | 1086 | */ |
AnnaBridge | 145:64910690c574 | 1087 | status_t LTC_HASH_Finish(ltc_hash_ctx_t *ctx, uint8_t *output, uint32_t *outputSize); |
AnnaBridge | 145:64910690c574 | 1088 | |
AnnaBridge | 145:64910690c574 | 1089 | /*! |
AnnaBridge | 145:64910690c574 | 1090 | * @brief Create HASH on given data |
AnnaBridge | 145:64910690c574 | 1091 | * |
AnnaBridge | 145:64910690c574 | 1092 | * Perform the full keyed HASH in one function call. |
AnnaBridge | 145:64910690c574 | 1093 | * |
AnnaBridge | 145:64910690c574 | 1094 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1095 | * @param algo Block cipher algorithm to use for CMAC creation |
AnnaBridge | 145:64910690c574 | 1096 | * @param input Input data |
AnnaBridge | 145:64910690c574 | 1097 | * @param inputSize Size of input data in bytes |
AnnaBridge | 145:64910690c574 | 1098 | * @param key Input key |
AnnaBridge | 145:64910690c574 | 1099 | * @param keySize Size of input key in bytes |
AnnaBridge | 145:64910690c574 | 1100 | * @param[out] output Output hash data |
AnnaBridge | 145:64910690c574 | 1101 | * @param[out] outputSize Output parameter storing the size of the output hash in bytes |
AnnaBridge | 145:64910690c574 | 1102 | * @return Status of the one call hash operation. |
AnnaBridge | 145:64910690c574 | 1103 | */ |
AnnaBridge | 145:64910690c574 | 1104 | status_t LTC_HASH(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1105 | ltc_hash_algo_t algo, |
AnnaBridge | 145:64910690c574 | 1106 | const uint8_t *input, |
AnnaBridge | 145:64910690c574 | 1107 | uint32_t inputSize, |
AnnaBridge | 145:64910690c574 | 1108 | const uint8_t *key, |
AnnaBridge | 145:64910690c574 | 1109 | uint32_t keySize, |
AnnaBridge | 145:64910690c574 | 1110 | uint8_t *output, |
AnnaBridge | 145:64910690c574 | 1111 | uint32_t *outputSize); |
AnnaBridge | 145:64910690c574 | 1112 | /*! |
AnnaBridge | 145:64910690c574 | 1113 | *@} |
AnnaBridge | 145:64910690c574 | 1114 | */ |
AnnaBridge | 145:64910690c574 | 1115 | |
AnnaBridge | 145:64910690c574 | 1116 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 1117 | * PKHA API |
AnnaBridge | 145:64910690c574 | 1118 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 1119 | /*! |
AnnaBridge | 145:64910690c574 | 1120 | * @addtogroup ltc_driver_pkha |
AnnaBridge | 145:64910690c574 | 1121 | * @{ |
AnnaBridge | 145:64910690c574 | 1122 | */ |
AnnaBridge | 145:64910690c574 | 1123 | |
AnnaBridge | 145:64910690c574 | 1124 | /*! |
AnnaBridge | 145:64910690c574 | 1125 | * @brief Compare two PKHA big numbers. |
AnnaBridge | 145:64910690c574 | 1126 | * |
AnnaBridge | 145:64910690c574 | 1127 | * Compare two PKHA big numbers. Return 1 for a > b, -1 for a < b and 0 if they are same. |
AnnaBridge | 145:64910690c574 | 1128 | * PKHA big number is lsbyte first. Thus the comparison starts at msbyte which is the last member of tested arrays. |
AnnaBridge | 145:64910690c574 | 1129 | * |
AnnaBridge | 145:64910690c574 | 1130 | * @param a First integer represented as an array of bytes, lsbyte first. |
AnnaBridge | 145:64910690c574 | 1131 | * @param sizeA Size in bytes of the first integer. |
AnnaBridge | 145:64910690c574 | 1132 | * @param b Second integer represented as an array of bytes, lsbyte first. |
AnnaBridge | 145:64910690c574 | 1133 | * @param sizeB Size in bytes of the second integer. |
AnnaBridge | 145:64910690c574 | 1134 | * @return 1 if a > b. |
AnnaBridge | 145:64910690c574 | 1135 | * @return -1 if a < b. |
AnnaBridge | 145:64910690c574 | 1136 | * @return 0 if a = b. |
AnnaBridge | 145:64910690c574 | 1137 | */ |
AnnaBridge | 145:64910690c574 | 1138 | int LTC_PKHA_CompareBigNum(const uint8_t *a, size_t sizeA, const uint8_t *b, size_t sizeB); |
AnnaBridge | 145:64910690c574 | 1139 | |
AnnaBridge | 145:64910690c574 | 1140 | /*! |
AnnaBridge | 145:64910690c574 | 1141 | * @brief Converts from integer to Montgomery format. |
AnnaBridge | 145:64910690c574 | 1142 | * |
AnnaBridge | 145:64910690c574 | 1143 | * This function computes R2 mod N and optionally converts A or B into Montgomery format of A or B. |
AnnaBridge | 145:64910690c574 | 1144 | * |
AnnaBridge | 145:64910690c574 | 1145 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1146 | * @param N modulus |
AnnaBridge | 145:64910690c574 | 1147 | * @param sizeN size of N in bytes |
AnnaBridge | 145:64910690c574 | 1148 | * @param[in,out] A The first input in non-Montgomery format. Output Montgomery format of the first input. |
AnnaBridge | 145:64910690c574 | 1149 | * @param[in,out] sizeA pointer to size variable. On input it holds size of input A in bytes. On output it holds size of |
AnnaBridge | 145:64910690c574 | 1150 | * Montgomery format of A in bytes. |
AnnaBridge | 145:64910690c574 | 1151 | * @param[in,out] B Second input in non-Montgomery format. Output Montgomery format of the second input. |
AnnaBridge | 145:64910690c574 | 1152 | * @param[in,out] sizeB pointer to size variable. On input it holds size of input B in bytes. On output it holds size of |
AnnaBridge | 145:64910690c574 | 1153 | * Montgomery format of B in bytes. |
AnnaBridge | 145:64910690c574 | 1154 | * @param[out] R2 Output Montgomery factor R2 mod N. |
AnnaBridge | 145:64910690c574 | 1155 | * @param[out] sizeR2 pointer to size variable. On output it holds size of Montgomery factor R2 mod N in bytes. |
AnnaBridge | 145:64910690c574 | 1156 | * @param equalTime Run the function time equalized or no timing equalization. |
AnnaBridge | 145:64910690c574 | 1157 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1158 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1159 | */ |
AnnaBridge | 145:64910690c574 | 1160 | status_t LTC_PKHA_NormalToMontgomery(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1161 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1162 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1163 | uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1164 | uint16_t *sizeA, |
AnnaBridge | 145:64910690c574 | 1165 | uint8_t *B, |
AnnaBridge | 145:64910690c574 | 1166 | uint16_t *sizeB, |
AnnaBridge | 145:64910690c574 | 1167 | uint8_t *R2, |
AnnaBridge | 145:64910690c574 | 1168 | uint16_t *sizeR2, |
AnnaBridge | 145:64910690c574 | 1169 | ltc_pkha_timing_t equalTime, |
AnnaBridge | 145:64910690c574 | 1170 | ltc_pkha_f2m_t arithType); |
AnnaBridge | 145:64910690c574 | 1171 | |
AnnaBridge | 145:64910690c574 | 1172 | /*! |
AnnaBridge | 145:64910690c574 | 1173 | * @brief Converts from Montgomery format to int. |
AnnaBridge | 145:64910690c574 | 1174 | * |
AnnaBridge | 145:64910690c574 | 1175 | * This function converts Montgomery format of A or B into int A or B. |
AnnaBridge | 145:64910690c574 | 1176 | * |
AnnaBridge | 145:64910690c574 | 1177 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1178 | * @param N modulus. |
AnnaBridge | 145:64910690c574 | 1179 | * @param sizeN size of N modulus in bytes. |
AnnaBridge | 145:64910690c574 | 1180 | * @param[in,out] A Input first number in Montgomery format. Output is non-Montgomery format. |
AnnaBridge | 145:64910690c574 | 1181 | * @param[in,out] sizeA pointer to size variable. On input it holds size of the input A in bytes. On output it holds |
AnnaBridge | 145:64910690c574 | 1182 | * size of non-Montgomery A in bytes. |
AnnaBridge | 145:64910690c574 | 1183 | * @param[in,out] B Input first number in Montgomery format. Output is non-Montgomery format. |
AnnaBridge | 145:64910690c574 | 1184 | * @param[in,out] sizeB pointer to size variable. On input it holds size of the input B in bytes. On output it holds |
AnnaBridge | 145:64910690c574 | 1185 | * size of non-Montgomery B in bytes. |
AnnaBridge | 145:64910690c574 | 1186 | * @param equalTime Run the function time equalized or no timing equalization. |
AnnaBridge | 145:64910690c574 | 1187 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1188 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1189 | */ |
AnnaBridge | 145:64910690c574 | 1190 | status_t LTC_PKHA_MontgomeryToNormal(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1191 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1192 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1193 | uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1194 | uint16_t *sizeA, |
AnnaBridge | 145:64910690c574 | 1195 | uint8_t *B, |
AnnaBridge | 145:64910690c574 | 1196 | uint16_t *sizeB, |
AnnaBridge | 145:64910690c574 | 1197 | ltc_pkha_timing_t equalTime, |
AnnaBridge | 145:64910690c574 | 1198 | ltc_pkha_f2m_t arithType); |
AnnaBridge | 145:64910690c574 | 1199 | |
AnnaBridge | 145:64910690c574 | 1200 | /*! |
AnnaBridge | 145:64910690c574 | 1201 | * @brief Performs modular addition - (A + B) mod N. |
AnnaBridge | 145:64910690c574 | 1202 | * |
AnnaBridge | 145:64910690c574 | 1203 | * This function performs modular addition of (A + B) mod N, with either |
AnnaBridge | 145:64910690c574 | 1204 | * integer or binary polynomial (F2m) inputs. In the F2m form, this function is |
AnnaBridge | 145:64910690c574 | 1205 | * equivalent to a bitwise XOR and it is functionally the same as subtraction. |
AnnaBridge | 145:64910690c574 | 1206 | * |
AnnaBridge | 145:64910690c574 | 1207 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1208 | * @param A first addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1209 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1210 | * @param B second addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1211 | * @param sizeB Size of B in bytes |
AnnaBridge | 145:64910690c574 | 1212 | * @param N modulus. For F2m operation this can be NULL, as N is ignored during F2m polynomial addition. |
AnnaBridge | 145:64910690c574 | 1213 | * @param sizeN Size of N in bytes. This must be given for both integer and F2m polynomial additions. |
AnnaBridge | 145:64910690c574 | 1214 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1215 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1216 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1217 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1218 | */ |
AnnaBridge | 145:64910690c574 | 1219 | status_t LTC_PKHA_ModAdd(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1220 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1221 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1222 | const uint8_t *B, |
AnnaBridge | 145:64910690c574 | 1223 | uint16_t sizeB, |
AnnaBridge | 145:64910690c574 | 1224 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1225 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1226 | uint8_t *result, |
AnnaBridge | 145:64910690c574 | 1227 | uint16_t *resultSize, |
AnnaBridge | 145:64910690c574 | 1228 | ltc_pkha_f2m_t arithType); |
AnnaBridge | 145:64910690c574 | 1229 | |
AnnaBridge | 145:64910690c574 | 1230 | /*! |
AnnaBridge | 145:64910690c574 | 1231 | * @brief Performs modular subtraction - (A - B) mod N. |
AnnaBridge | 145:64910690c574 | 1232 | * |
AnnaBridge | 145:64910690c574 | 1233 | * This function performs modular subtraction of (A - B) mod N with |
AnnaBridge | 145:64910690c574 | 1234 | * integer inputs. |
AnnaBridge | 145:64910690c574 | 1235 | * |
AnnaBridge | 145:64910690c574 | 1236 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1237 | * @param A first addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1238 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1239 | * @param B second addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1240 | * @param sizeB Size of B in bytes |
AnnaBridge | 145:64910690c574 | 1241 | * @param N modulus |
AnnaBridge | 145:64910690c574 | 1242 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1243 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1244 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1245 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1246 | */ |
AnnaBridge | 145:64910690c574 | 1247 | status_t LTC_PKHA_ModSub1(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1248 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1249 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1250 | const uint8_t *B, |
AnnaBridge | 145:64910690c574 | 1251 | uint16_t sizeB, |
AnnaBridge | 145:64910690c574 | 1252 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1253 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1254 | uint8_t *result, |
AnnaBridge | 145:64910690c574 | 1255 | uint16_t *resultSize); |
AnnaBridge | 145:64910690c574 | 1256 | |
AnnaBridge | 145:64910690c574 | 1257 | /*! |
AnnaBridge | 145:64910690c574 | 1258 | * @brief Performs modular subtraction - (B - A) mod N. |
AnnaBridge | 145:64910690c574 | 1259 | * |
AnnaBridge | 145:64910690c574 | 1260 | * This function performs modular subtraction of (B - A) mod N, |
AnnaBridge | 145:64910690c574 | 1261 | * with integer inputs. |
AnnaBridge | 145:64910690c574 | 1262 | * |
AnnaBridge | 145:64910690c574 | 1263 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1264 | * @param A first addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1265 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1266 | * @param B second addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1267 | * @param sizeB Size of B in bytes |
AnnaBridge | 145:64910690c574 | 1268 | * @param N modulus |
AnnaBridge | 145:64910690c574 | 1269 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1270 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1271 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1272 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1273 | */ |
AnnaBridge | 145:64910690c574 | 1274 | status_t LTC_PKHA_ModSub2(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1275 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1276 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1277 | const uint8_t *B, |
AnnaBridge | 145:64910690c574 | 1278 | uint16_t sizeB, |
AnnaBridge | 145:64910690c574 | 1279 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1280 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1281 | uint8_t *result, |
AnnaBridge | 145:64910690c574 | 1282 | uint16_t *resultSize); |
AnnaBridge | 145:64910690c574 | 1283 | |
AnnaBridge | 145:64910690c574 | 1284 | /*! |
AnnaBridge | 145:64910690c574 | 1285 | * @brief Performs modular multiplication - (A x B) mod N. |
AnnaBridge | 145:64910690c574 | 1286 | * |
AnnaBridge | 145:64910690c574 | 1287 | * This function performs modular multiplication with either integer or |
AnnaBridge | 145:64910690c574 | 1288 | * binary polynomial (F2m) inputs. It can optionally specify whether inputs |
AnnaBridge | 145:64910690c574 | 1289 | * and/or outputs will be in Montgomery form or not. |
AnnaBridge | 145:64910690c574 | 1290 | * |
AnnaBridge | 145:64910690c574 | 1291 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1292 | * @param A first addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1293 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1294 | * @param B second addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1295 | * @param sizeB Size of B in bytes |
AnnaBridge | 145:64910690c574 | 1296 | * @param N modulus. |
AnnaBridge | 145:64910690c574 | 1297 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1298 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1299 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1300 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1301 | * @param montIn Format of inputs |
AnnaBridge | 145:64910690c574 | 1302 | * @param montOut Format of output |
AnnaBridge | 145:64910690c574 | 1303 | * @param equalTime Run the function time equalized or no timing equalization. This argument is ignored for F2m modular |
AnnaBridge | 145:64910690c574 | 1304 | * multiplication. |
AnnaBridge | 145:64910690c574 | 1305 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1306 | */ |
AnnaBridge | 145:64910690c574 | 1307 | status_t LTC_PKHA_ModMul(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1308 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1309 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1310 | const uint8_t *B, |
AnnaBridge | 145:64910690c574 | 1311 | uint16_t sizeB, |
AnnaBridge | 145:64910690c574 | 1312 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1313 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1314 | uint8_t *result, |
AnnaBridge | 145:64910690c574 | 1315 | uint16_t *resultSize, |
AnnaBridge | 145:64910690c574 | 1316 | ltc_pkha_f2m_t arithType, |
AnnaBridge | 145:64910690c574 | 1317 | ltc_pkha_montgomery_form_t montIn, |
AnnaBridge | 145:64910690c574 | 1318 | ltc_pkha_montgomery_form_t montOut, |
AnnaBridge | 145:64910690c574 | 1319 | ltc_pkha_timing_t equalTime); |
AnnaBridge | 145:64910690c574 | 1320 | |
AnnaBridge | 145:64910690c574 | 1321 | /*! |
AnnaBridge | 145:64910690c574 | 1322 | * @brief Performs modular exponentiation - (A^E) mod N. |
AnnaBridge | 145:64910690c574 | 1323 | * |
AnnaBridge | 145:64910690c574 | 1324 | * This function performs modular exponentiation with either integer or |
AnnaBridge | 145:64910690c574 | 1325 | * binary polynomial (F2m) inputs. |
AnnaBridge | 145:64910690c574 | 1326 | * |
AnnaBridge | 145:64910690c574 | 1327 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1328 | * @param A first addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1329 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1330 | * @param N modulus |
AnnaBridge | 145:64910690c574 | 1331 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1332 | * @param E exponent |
AnnaBridge | 145:64910690c574 | 1333 | * @param sizeE Size of E in bytes |
AnnaBridge | 145:64910690c574 | 1334 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1335 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1336 | * @param montIn Format of A input (normal or Montgomery) |
AnnaBridge | 145:64910690c574 | 1337 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1338 | * @param equalTime Run the function time equalized or no timing equalization. |
AnnaBridge | 145:64910690c574 | 1339 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1340 | */ |
AnnaBridge | 145:64910690c574 | 1341 | status_t LTC_PKHA_ModExp(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1342 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1343 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1344 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1345 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1346 | const uint8_t *E, |
AnnaBridge | 145:64910690c574 | 1347 | uint16_t sizeE, |
AnnaBridge | 145:64910690c574 | 1348 | uint8_t *result, |
AnnaBridge | 145:64910690c574 | 1349 | uint16_t *resultSize, |
AnnaBridge | 145:64910690c574 | 1350 | ltc_pkha_f2m_t arithType, |
AnnaBridge | 145:64910690c574 | 1351 | ltc_pkha_montgomery_form_t montIn, |
AnnaBridge | 145:64910690c574 | 1352 | ltc_pkha_timing_t equalTime); |
AnnaBridge | 145:64910690c574 | 1353 | |
AnnaBridge | 145:64910690c574 | 1354 | /*! |
AnnaBridge | 145:64910690c574 | 1355 | * @brief Performs modular reduction - (A) mod N. |
AnnaBridge | 145:64910690c574 | 1356 | * |
AnnaBridge | 145:64910690c574 | 1357 | * This function performs modular reduction with either integer or |
AnnaBridge | 145:64910690c574 | 1358 | * binary polynomial (F2m) inputs. |
AnnaBridge | 145:64910690c574 | 1359 | * |
AnnaBridge | 145:64910690c574 | 1360 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1361 | * @param A first addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1362 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1363 | * @param N modulus |
AnnaBridge | 145:64910690c574 | 1364 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1365 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1366 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1367 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1368 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1369 | */ |
AnnaBridge | 145:64910690c574 | 1370 | status_t LTC_PKHA_ModRed(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1371 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1372 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1373 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1374 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1375 | uint8_t *result, |
AnnaBridge | 145:64910690c574 | 1376 | uint16_t *resultSize, |
AnnaBridge | 145:64910690c574 | 1377 | ltc_pkha_f2m_t arithType); |
AnnaBridge | 145:64910690c574 | 1378 | |
AnnaBridge | 145:64910690c574 | 1379 | /*! |
AnnaBridge | 145:64910690c574 | 1380 | * @brief Performs modular inversion - (A^-1) mod N. |
AnnaBridge | 145:64910690c574 | 1381 | * |
AnnaBridge | 145:64910690c574 | 1382 | * This function performs modular inversion with either integer or |
AnnaBridge | 145:64910690c574 | 1383 | * binary polynomial (F2m) inputs. |
AnnaBridge | 145:64910690c574 | 1384 | * |
AnnaBridge | 145:64910690c574 | 1385 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1386 | * @param A first addend (integer or binary polynomial) |
AnnaBridge | 145:64910690c574 | 1387 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1388 | * @param N modulus |
AnnaBridge | 145:64910690c574 | 1389 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1390 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1391 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1392 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1393 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1394 | */ |
AnnaBridge | 145:64910690c574 | 1395 | status_t LTC_PKHA_ModInv(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1396 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1397 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1398 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1399 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1400 | uint8_t *result, |
AnnaBridge | 145:64910690c574 | 1401 | uint16_t *resultSize, |
AnnaBridge | 145:64910690c574 | 1402 | ltc_pkha_f2m_t arithType); |
AnnaBridge | 145:64910690c574 | 1403 | |
AnnaBridge | 145:64910690c574 | 1404 | /*! |
AnnaBridge | 145:64910690c574 | 1405 | * @brief Computes integer Montgomery factor R^2 mod N. |
AnnaBridge | 145:64910690c574 | 1406 | * |
AnnaBridge | 145:64910690c574 | 1407 | * This function computes a constant to assist in converting operands |
AnnaBridge | 145:64910690c574 | 1408 | * into the Montgomery residue system representation. |
AnnaBridge | 145:64910690c574 | 1409 | * |
AnnaBridge | 145:64910690c574 | 1410 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1411 | * @param N modulus |
AnnaBridge | 145:64910690c574 | 1412 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1413 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1414 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1415 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1416 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1417 | */ |
AnnaBridge | 145:64910690c574 | 1418 | status_t LTC_PKHA_ModR2( |
AnnaBridge | 145:64910690c574 | 1419 | LTC_Type *base, const uint8_t *N, uint16_t sizeN, uint8_t *result, uint16_t *resultSize, ltc_pkha_f2m_t arithType); |
AnnaBridge | 145:64910690c574 | 1420 | |
AnnaBridge | 145:64910690c574 | 1421 | /*! |
AnnaBridge | 145:64910690c574 | 1422 | * @brief Calculates the greatest common divisor - GCD (A, N). |
AnnaBridge | 145:64910690c574 | 1423 | * |
AnnaBridge | 145:64910690c574 | 1424 | * This function calculates the greatest common divisor of two inputs with |
AnnaBridge | 145:64910690c574 | 1425 | * either integer or binary polynomial (F2m) inputs. |
AnnaBridge | 145:64910690c574 | 1426 | * |
AnnaBridge | 145:64910690c574 | 1427 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1428 | * @param A first value (must be smaller than or equal to N) |
AnnaBridge | 145:64910690c574 | 1429 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1430 | * @param N second value (must be non-zero) |
AnnaBridge | 145:64910690c574 | 1431 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1432 | * @param[out] result Output array to store result of operation |
AnnaBridge | 145:64910690c574 | 1433 | * @param[out] resultSize Output size of operation in bytes |
AnnaBridge | 145:64910690c574 | 1434 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1435 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1436 | */ |
AnnaBridge | 145:64910690c574 | 1437 | status_t LTC_PKHA_GCD(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1438 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1439 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1440 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1441 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1442 | uint8_t *result, |
AnnaBridge | 145:64910690c574 | 1443 | uint16_t *resultSize, |
AnnaBridge | 145:64910690c574 | 1444 | ltc_pkha_f2m_t arithType); |
AnnaBridge | 145:64910690c574 | 1445 | |
AnnaBridge | 145:64910690c574 | 1446 | /*! |
AnnaBridge | 145:64910690c574 | 1447 | * @brief Executes Miller-Rabin primality test. |
AnnaBridge | 145:64910690c574 | 1448 | * |
AnnaBridge | 145:64910690c574 | 1449 | * This function calculates whether or not a candidate prime number is likely |
AnnaBridge | 145:64910690c574 | 1450 | * to be a prime. |
AnnaBridge | 145:64910690c574 | 1451 | * |
AnnaBridge | 145:64910690c574 | 1452 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1453 | * @param A initial random seed |
AnnaBridge | 145:64910690c574 | 1454 | * @param sizeA Size of A in bytes |
AnnaBridge | 145:64910690c574 | 1455 | * @param B number of trial runs |
AnnaBridge | 145:64910690c574 | 1456 | * @param sizeB Size of B in bytes |
AnnaBridge | 145:64910690c574 | 1457 | * @param N candidate prime integer |
AnnaBridge | 145:64910690c574 | 1458 | * @param sizeN Size of N in bytes |
AnnaBridge | 145:64910690c574 | 1459 | * @param[out] res True if the value is likely prime or false otherwise |
AnnaBridge | 145:64910690c574 | 1460 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1461 | */ |
AnnaBridge | 145:64910690c574 | 1462 | status_t LTC_PKHA_PrimalityTest(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1463 | const uint8_t *A, |
AnnaBridge | 145:64910690c574 | 1464 | uint16_t sizeA, |
AnnaBridge | 145:64910690c574 | 1465 | const uint8_t *B, |
AnnaBridge | 145:64910690c574 | 1466 | uint16_t sizeB, |
AnnaBridge | 145:64910690c574 | 1467 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1468 | uint16_t sizeN, |
AnnaBridge | 145:64910690c574 | 1469 | bool *res); |
AnnaBridge | 145:64910690c574 | 1470 | |
AnnaBridge | 145:64910690c574 | 1471 | /*! |
AnnaBridge | 145:64910690c574 | 1472 | * @brief Adds elliptic curve points - A + B. |
AnnaBridge | 145:64910690c574 | 1473 | * |
AnnaBridge | 145:64910690c574 | 1474 | * This function performs ECC point addition over a prime field (Fp) or binary field (F2m) using |
AnnaBridge | 145:64910690c574 | 1475 | * affine coordinates. |
AnnaBridge | 145:64910690c574 | 1476 | * |
AnnaBridge | 145:64910690c574 | 1477 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1478 | * @param A Left-hand point |
AnnaBridge | 145:64910690c574 | 1479 | * @param B Right-hand point |
AnnaBridge | 145:64910690c574 | 1480 | * @param N Prime modulus of the field |
AnnaBridge | 145:64910690c574 | 1481 | * @param R2modN NULL (the function computes R2modN internally) or pointer to pre-computed R2modN (obtained from |
AnnaBridge | 145:64910690c574 | 1482 | * LTC_PKHA_ModR2() function). |
AnnaBridge | 145:64910690c574 | 1483 | * @param aCurveParam A parameter from curve equation |
AnnaBridge | 145:64910690c574 | 1484 | * @param bCurveParam B parameter from curve equation (constant) |
AnnaBridge | 145:64910690c574 | 1485 | * @param size Size in bytes of curve points and parameters |
AnnaBridge | 145:64910690c574 | 1486 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1487 | * @param[out] result Result point |
AnnaBridge | 145:64910690c574 | 1488 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1489 | */ |
AnnaBridge | 145:64910690c574 | 1490 | status_t LTC_PKHA_ECC_PointAdd(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1491 | const ltc_pkha_ecc_point_t *A, |
AnnaBridge | 145:64910690c574 | 1492 | const ltc_pkha_ecc_point_t *B, |
AnnaBridge | 145:64910690c574 | 1493 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1494 | const uint8_t *R2modN, |
AnnaBridge | 145:64910690c574 | 1495 | const uint8_t *aCurveParam, |
AnnaBridge | 145:64910690c574 | 1496 | const uint8_t *bCurveParam, |
AnnaBridge | 145:64910690c574 | 1497 | uint8_t size, |
AnnaBridge | 145:64910690c574 | 1498 | ltc_pkha_f2m_t arithType, |
AnnaBridge | 145:64910690c574 | 1499 | ltc_pkha_ecc_point_t *result); |
AnnaBridge | 145:64910690c574 | 1500 | |
AnnaBridge | 145:64910690c574 | 1501 | /*! |
AnnaBridge | 145:64910690c574 | 1502 | * @brief Doubles elliptic curve points - B + B. |
AnnaBridge | 145:64910690c574 | 1503 | * |
AnnaBridge | 145:64910690c574 | 1504 | * This function performs ECC point doubling over a prime field (Fp) or binary field (F2m) using |
AnnaBridge | 145:64910690c574 | 1505 | * affine coordinates. |
AnnaBridge | 145:64910690c574 | 1506 | * |
AnnaBridge | 145:64910690c574 | 1507 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1508 | * @param B Point to double |
AnnaBridge | 145:64910690c574 | 1509 | * @param N Prime modulus of the field |
AnnaBridge | 145:64910690c574 | 1510 | * @param aCurveParam A parameter from curve equation |
AnnaBridge | 145:64910690c574 | 1511 | * @param bCurveParam B parameter from curve equation (constant) |
AnnaBridge | 145:64910690c574 | 1512 | * @param size Size in bytes of curve points and parameters |
AnnaBridge | 145:64910690c574 | 1513 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1514 | * @param[out] result Result point |
AnnaBridge | 145:64910690c574 | 1515 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1516 | */ |
AnnaBridge | 145:64910690c574 | 1517 | status_t LTC_PKHA_ECC_PointDouble(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1518 | const ltc_pkha_ecc_point_t *B, |
AnnaBridge | 145:64910690c574 | 1519 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1520 | const uint8_t *aCurveParam, |
AnnaBridge | 145:64910690c574 | 1521 | const uint8_t *bCurveParam, |
AnnaBridge | 145:64910690c574 | 1522 | uint8_t size, |
AnnaBridge | 145:64910690c574 | 1523 | ltc_pkha_f2m_t arithType, |
AnnaBridge | 145:64910690c574 | 1524 | ltc_pkha_ecc_point_t *result); |
AnnaBridge | 145:64910690c574 | 1525 | |
AnnaBridge | 145:64910690c574 | 1526 | /*! |
AnnaBridge | 145:64910690c574 | 1527 | * @brief Multiplies an elliptic curve point by a scalar - E x (A0, A1). |
AnnaBridge | 145:64910690c574 | 1528 | * |
AnnaBridge | 145:64910690c574 | 1529 | * This function performs ECC point multiplication to multiply an ECC point by |
AnnaBridge | 145:64910690c574 | 1530 | * a scalar integer multiplier over a prime field (Fp) or a binary field (F2m). |
AnnaBridge | 145:64910690c574 | 1531 | * |
AnnaBridge | 145:64910690c574 | 1532 | * @param base LTC peripheral base address |
AnnaBridge | 145:64910690c574 | 1533 | * @param A Point as multiplicand |
AnnaBridge | 145:64910690c574 | 1534 | * @param E Scalar multiple |
AnnaBridge | 145:64910690c574 | 1535 | * @param sizeE The size of E, in bytes |
AnnaBridge | 145:64910690c574 | 1536 | * @param N Modulus, a prime number for the Fp field or Irreducible polynomial for F2m field. |
AnnaBridge | 145:64910690c574 | 1537 | * @param R2modN NULL (the function computes R2modN internally) or pointer to pre-computed R2modN (obtained from |
AnnaBridge | 145:64910690c574 | 1538 | * LTC_PKHA_ModR2() function). |
AnnaBridge | 145:64910690c574 | 1539 | * @param aCurveParam A parameter from curve equation |
AnnaBridge | 145:64910690c574 | 1540 | * @param bCurveParam B parameter from curve equation (C parameter for operation over F2m). |
AnnaBridge | 145:64910690c574 | 1541 | * @param size Size in bytes of curve points and parameters |
AnnaBridge | 145:64910690c574 | 1542 | * @param equalTime Run the function time equalized or no timing equalization. |
AnnaBridge | 145:64910690c574 | 1543 | * @param arithType Type of arithmetic to perform (integer or F2m) |
AnnaBridge | 145:64910690c574 | 1544 | * @param[out] result Result point |
AnnaBridge | 145:64910690c574 | 1545 | * @param[out] infinity Output true if the result is point of infinity, and false otherwise. Writing of this output will |
AnnaBridge | 145:64910690c574 | 1546 | * be ignored if the argument is NULL. |
AnnaBridge | 145:64910690c574 | 1547 | * @return Operation status. |
AnnaBridge | 145:64910690c574 | 1548 | */ |
AnnaBridge | 145:64910690c574 | 1549 | status_t LTC_PKHA_ECC_PointMul(LTC_Type *base, |
AnnaBridge | 145:64910690c574 | 1550 | const ltc_pkha_ecc_point_t *A, |
AnnaBridge | 145:64910690c574 | 1551 | const uint8_t *E, |
AnnaBridge | 145:64910690c574 | 1552 | uint8_t sizeE, |
AnnaBridge | 145:64910690c574 | 1553 | const uint8_t *N, |
AnnaBridge | 145:64910690c574 | 1554 | const uint8_t *R2modN, |
AnnaBridge | 145:64910690c574 | 1555 | const uint8_t *aCurveParam, |
AnnaBridge | 145:64910690c574 | 1556 | const uint8_t *bCurveParam, |
AnnaBridge | 145:64910690c574 | 1557 | uint8_t size, |
AnnaBridge | 145:64910690c574 | 1558 | ltc_pkha_timing_t equalTime, |
AnnaBridge | 145:64910690c574 | 1559 | ltc_pkha_f2m_t arithType, |
AnnaBridge | 145:64910690c574 | 1560 | ltc_pkha_ecc_point_t *result, |
AnnaBridge | 145:64910690c574 | 1561 | bool *infinity); |
AnnaBridge | 145:64910690c574 | 1562 | |
AnnaBridge | 145:64910690c574 | 1563 | /*! |
AnnaBridge | 145:64910690c574 | 1564 | *@} |
AnnaBridge | 145:64910690c574 | 1565 | */ |
AnnaBridge | 145:64910690c574 | 1566 | |
AnnaBridge | 145:64910690c574 | 1567 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 1568 | } |
AnnaBridge | 145:64910690c574 | 1569 | #endif |
AnnaBridge | 145:64910690c574 | 1570 | |
AnnaBridge | 145:64910690c574 | 1571 | /*! |
AnnaBridge | 145:64910690c574 | 1572 | *@} |
AnnaBridge | 145:64910690c574 | 1573 | */ |
AnnaBridge | 145:64910690c574 | 1574 | |
AnnaBridge | 145:64910690c574 | 1575 | #endif /* _FSL_LTC_H_ */ |