Ben Katz / mbed-dev-f303

Dependents:   Hobbyking_Cheetah_Compact Hobbyking_Cheetah_Compact_DRV8323_14bit Hobbyking_Cheetah_Compact_DRV8323_V51_201907 HKC_MiniCheetah ... more

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Wed Jan 04 16:58:05 2017 +0000
Revision:
154:37f96f9d4de2
This updates the lib to the mbed lib v133

Who changed what in which revision?

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