1 /* 2 * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 * Copyright 2016-2022 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #ifndef _FSL_CAAM_H_ 10 #define _FSL_CAAM_H_ 11 12 #include "fsl_common.h" 13 14 /*! 15 * @addtogroup caam_driver 16 * @{ 17 */ 18 19 /*! @brief CAAM status return codes. */ 20 enum 21 { 22 kStatus_CAAM_Again = MAKE_STATUS(kStatusGroup_CAAM, 0), /*!< Non-blocking function shall be called again. */ 23 kStatus_CAAM_DataOverflow = MAKE_STATUS(kStatusGroup_CAAM, 1), /*!< Input data too big. */ 24 25 }; 26 27 /******************************************************************************* 28 * Definitions 29 *******************************************************************************/ 30 31 /*! @name Driver version */ 32 /*@{*/ 33 /*! @brief CAAM driver version. Version 2.2.4. 34 * 35 * Current version: 2.2.4 36 * 37 * Change log: 38 * - Version 2.0.0 39 * - Initial version 40 * - Version 2.0.1 41 * - Add Job Ring 2 and 3. 42 * - Version 2.0.2 43 * - Add Data and Instruction Synchronization Barrier in caam_input_ring_set_jobs_added() 44 * to make sure that the descriptor will be loaded into CAAM correctly. 45 * - Version 2.0.3 46 * - Use MACRO instead of numbers in descriptor. 47 * - Correct descriptor size mask. 48 * - Version 2.1.0 49 * - Add return codes check and handling. 50 * - Version 2.1.1 51 * - Add DCACHE support. 52 * - Version 2.1.2 53 * - Add data offset feature to provide support for mirrored (high-speed) memory. 54 * - Version 2.1.3 55 * - Fix MISRA-2012 issues. 56 * - Version 2.1.4 57 * - Fix MISRA-2012 issues. 58 * - Version 2.1.5 59 * - Support EXTENDED data size for all AES, HASH and RNG operations. 60 * - Support multiple De-Initialization/Initialization of CAAM driver within one POR event. 61 * - Version 2.1.6 62 * - Improve DCACHE handling. Requires CAAM used and cached memory set in write-trough mode. 63 * - Version 2.2.0 64 * - Added API for Blob functions and CRC 65 * - Version 2.2.1 66 * - Fixed AES-CCM decrypt failing with TAG length bigger than 8 byte. 67 * - Version 2.2.2 68 * - Modify RNG to not reseed with each request. 69 * - Version 2.2.3 70 * - Fix DCACHE invalidation in CAAM_HASH_Finish(). 71 * - Version 2.2.4 72 * - Fix issue where the outputSize parameter of CAAM_HASH_Finish() has impact on hash calculation. 73 */ 74 #define FSL_CAAM_DRIVER_VERSION (MAKE_VERSION(2, 2, 4)) 75 /*@}*/ 76 77 /*! @brief CAAM callback function. */ 78 typedef struct _caam_job_callback 79 { 80 void (*JobCompleted)(void *userData); /*!< CAAM Job complete callback */ 81 } caam_job_callback_t; 82 83 /*! @brief CAAM job ring selection. */ 84 typedef enum _caam_job_ring_t 85 { 86 kCAAM_JobRing0 = 0u, /*!< CAAM Job ring 0 */ 87 kCAAM_JobRing1 = 1u, /*!< CAAM Job ring 1 */ 88 kCAAM_JobRing2 = 2u, /*!< CAAM Job ring 2 */ 89 kCAAM_JobRing3 = 3u, /*!< CAAM Job ring 3 */ 90 } caam_job_ring_t; 91 92 /*! @brief CAAM handle 93 * Specifies jobRing and optionally the user callback function. 94 * The user callback functions is invoked only if jobRing interrupt has been enabled by the user. 95 * By default the jobRing interrupt is disabled (default job complete test is polling CAAM output ring). 96 */ 97 typedef struct _caam_handle_t 98 { 99 caam_job_ring_t jobRing; 100 101 /* Callback functions */ 102 caam_job_callback_t callback; /*!< Callback function */ 103 void *userData; /*!< Parameter for CAAM job complete callback */ 104 } caam_handle_t; 105 106 /*! @brief CAAM driver wait mechanism 107 */ 108 typedef enum _caam_wait_mode 109 { 110 kCAAM_Blocking = 0u, /*!< CAAM_Wait blocking mode */ 111 kCAAM_Nonblocking = 1u, /*!< CAAM Wait non-blocking mode */ 112 } caam_wait_mode_t; 113 114 /*! @brief Memory buffer to hold CAAM descriptor for AESA ECB job */ 115 typedef uint32_t caam_desc_aes_ecb_t[64]; 116 117 /*! @brief Memory buffer to hold CAAM descriptor for AESA CBC job */ 118 typedef uint32_t caam_desc_aes_cbc_t[64]; 119 120 /*! @brief Memory buffer to hold CAAM descriptor for AESA CTR job */ 121 typedef uint32_t caam_desc_aes_ctr_t[64]; 122 123 /*! @brief Memory buffer to hold CAAM descriptor for AESA CCM job */ 124 typedef uint32_t caam_desc_aes_ccm_t[64]; 125 126 /*! @brief Memory buffer to hold CAAM descriptor for AESA GCM job */ 127 typedef uint32_t caam_desc_aes_gcm_t[64]; 128 129 /*! @brief Memory buffer to hold CAAM descriptor for MDHA job or AESA CMAC job */ 130 typedef uint32_t caam_desc_hash_t[64]; 131 132 /*! @brief Memory buffer to hold CAAM descriptor for RNG jobs */ 133 typedef uint32_t caam_desc_rng_t[64]; 134 135 /*! @brief Memory buffer to hold CAAM descriptor for DESA jobs */ 136 typedef uint32_t caam_desc_cipher_des_t[64]; 137 138 /*! @brief Memory buffer to hold CAAM descriptor for PKHA jobs */ 139 typedef uint32_t caam_desc_pkha_t[64]; 140 141 /*! @brief Memory buffer to hold CAAM descriptor for PKHA ECC jobs */ 142 typedef uint32_t caam_desc_pkha_ecc_t[64]; 143 144 /*! @brief Memory buffer to hold CAAM descriptor for performing key blackening jobs */ 145 typedef uint32_t caam_desc_key_black_t[64]; 146 147 /*! @brief Memory buffer to hold CAAM descriptor for performing generating dek blob jobs */ 148 typedef uint32_t caam_desc_gen_enc_blob_t[64]; 149 typedef uint32_t caam_desc_gen_dep_blob_t[64]; 150 151 typedef struct _caam_job_ring_interface 152 { 153 uint32_t inputJobRing[4]; 154 uint32_t outputJobRing[8]; 155 } caam_job_ring_interface_t; 156 157 /*! @brief CAAM RNG sample mode. Used by caam_config_t. */ 158 typedef enum _caam_rng_sample_mode 159 { 160 kCAAM_RNG_SampleModeVonNeumann = 0U, /*!< Use von Neumann data in both Entropy shifter and Statistical Checker. */ 161 kCAAM_RNG_SampleModeRaw = 1U, /*!< Use raw data into both Entropy shifter and Statistical Checker. */ 162 kCAAM_RNG_SampleModeVonNeumannRaw = 163 2U /*!< Use von Neumann data in Entropy shifter. Use raw data into Statistical Checker. */ 164 } caam_rng_sample_mode_t; 165 166 /*! @brief CAAM RNG ring oscillator divide. Used by caam_config_t. */ 167 typedef enum _caam_rng_ring_osc_div 168 { 169 kCAAM_RNG_RingOscDiv0 = 0U, /*!< Ring oscillator with no divide */ 170 kCAAM_RNG_RingOscDiv2 = 1U, /*!< Ring oscillator divided-by-2. */ 171 kCAAM_RNG_RingOscDiv4 = 2U, /*!< Ring oscillator divided-by-4. */ 172 kCAAM_RNG_RingOscDiv8 = 3U /*!< Ring oscillator divided-by-8. */ 173 } caam_rng_ring_osc_div_t; 174 175 /*! @brief CAAM Private Blob. Used by caam_config_t. */ 176 typedef enum _caam_priblob 177 { 178 kCAAM_PrivSecureBootBlobs = 0U, /*!< Private secure boot software blobs. */ 179 kCAAM_PrivProvisioningBlobsType1 = 1U, /*!< Private Provisioning Type 1 blobs. */ 180 kCAAM_PrivProvisioningBlobsType2 = 2U, /*!< Private Provisioning Type 2 blobs. */ 181 kCAAM_NormalOperationBlobs = 3U, /*!< Normal operation blobs. */ 182 } caam_priblob_t; 183 184 /*! @brief CAAM configuration structure. */ 185 typedef struct _caam_config 186 { 187 caam_job_ring_interface_t *jobRingInterface[4]; 188 caam_rng_sample_mode_t rngSampleMode; /*!< RTMCTL Sample Mode. */ 189 caam_rng_ring_osc_div_t rngRingOscDiv; /*!< RTMCTL Oscillator Divide. */ 190 bool scfgrLockTrngProgramMode; /*!< SCFGR Lock TRNG Program Mode. */ 191 bool scfgrEnableRandomDataBuffer; /*!< SCFGR Enable random data buffer. */ 192 bool scfgrRandomRngStateHandle0; /*!< SCFGR Random Number Generator State Handle 0. */ 193 bool scfgrRandomDpaResistance; /*!< SCFGR Random Differential Power Analysis Resistance. */ 194 caam_priblob_t scfgrPriblob; /*!< SCFGR Private Blob. */ 195 } caam_config_t; 196 197 /*! @brief CAAM External Key Transfer command SRC (The source from which the key will be obtained) */ 198 typedef enum _caam_ext_key_xfr_source 199 { 200 kCAAM_ExtKeyXfr_KeyRegisterClass1 = 1U, /*!< The Class 1 Key Register is the source. */ 201 kCAAM_ExtKeyXfr_KeyRegisterClass2 = 2U, /*!< The Class 2 Key Register is the source. */ 202 kCAAM_ExtKeyXfr_PkhaRamE = 3U, /*!< The PKHA E RAM is the source. */ 203 } caam_ext_key_xfr_source_t; 204 /*! @} */ /* end of caam_driver */ 205 206 /******************************************************************************* 207 * AES Definitions 208 *******************************************************************************/ 209 210 /*! 211 * @addtogroup caam_driver_aes 212 * @{ 213 */ 214 215 /*! AES block size in bytes */ 216 #define CAAM_AES_BLOCK_SIZE 16 217 218 /*! 219 *@} 220 */ /* end of caam_driver_aes */ 221 222 /******************************************************************************* 223 * DES Definitions 224 *******************************************************************************/ 225 /*! 226 * @addtogroup caam_driver_des 227 * @{ 228 */ 229 230 /*! @brief CAAM DES key size - 64 bits. */ 231 #define CAAM_DES_KEY_SIZE 8U 232 233 /*! @brief CAAM DES IV size - 8 bytes */ 234 #define CAAM_DES_IV_SIZE 8 235 236 /*! 237 *@} 238 */ /* end of caam_driver_des */ 239 240 /******************************************************************************* 241 * HASH Definitions 242 ******************************************************************************/ 243 /*! 244 * @addtogroup caam_driver_hash 245 * @{ 246 */ 247 248 /*! @brief Supported cryptographic block cipher functions for HASH creation */ 249 typedef enum _caam_hash_algo_t 250 { 251 kCAAM_XcbcMac = 0, /*!< XCBC-MAC (AES engine) */ 252 kCAAM_Cmac, /*!< CMAC (AES engine) */ 253 kCAAM_Sha1, /*!< SHA_1 (MDHA engine) */ 254 kCAAM_Sha224, /*!< SHA_224 (MDHA engine) */ 255 kCAAM_Sha256, /*!< SHA_256 (MDHA engine) */ 256 kCAAM_Sha384, /*!< SHA_384 (MDHA engine) */ 257 kCAAM_Sha512, /*!< SHA_512 (MDHA engine) */ 258 } caam_hash_algo_t; 259 260 /*! @brief CAAM HASH Context size. */ 261 #define CAAM_SHA_BLOCK_SIZE 128U /*!< up to SHA-512 block size */ 262 #define CAAM_HASH_BLOCK_SIZE CAAM_SHA_BLOCK_SIZE /*!< CAAM hash block size */ 263 264 /*! @brief CAAM HASH Context size. */ 265 #define CAAM_HASH_CTX_SIZE 58 266 267 /*! @brief Storage type used to save hash context. */ 268 typedef uint32_t caam_hash_ctx_t[CAAM_HASH_CTX_SIZE]; 269 270 /*! 271 *@} 272 */ /* end of caam_driver_hash */ 273 274 /******************************************************************************* 275 * CRC Definitions 276 ******************************************************************************/ 277 /*! @brief Supported CRC modes */ 278 typedef enum _caam_crc_algo_t 279 { 280 kCAAM_CrcIEEE, /*!< IEE 802 CRC32 (CRCA engine) */ 281 kCAAM_CrciSCSI, /*!< iSCSI CRC32 (CRCA engine) */ 282 kCAAM_CrcCUSTPOLY, /*!< Custom polynomial mode (CRCA engine) */ 283 } caam_crc_algo_t; 284 285 typedef enum _caam_aai_crc_alg 286 { 287 kCAAM_CRC_ModeIEEE802 = 0x01U << 4, /* IEE 802 mode */ 288 kCAAM_CRC_ModeIETF3385 = 0x02U << 4, /* iSCSI mode */ 289 kCAAM_CRC_ModeCUSTPOLY = 290 0x04U << 4, /* Custom polynomial programmed into Key register. Can be 1-32bits. Must be left justified */ 291 kCAAM_CRC_ModeDefault = 0x0U << 4, /* Input data is bit-swapped, Out data is bit and byte swapped and complemented 292 and init value is FFFFFFFFh*/ 293 kCAAM_CRC_ModeDIS = 0x10U << 4, /* Turn off input bit-swapping */ 294 kCAAM_CRC_ModeDOS = 0x20U << 4, /* Turn off output bit-swapping */ 295 kCAAM_CRC_ModeDOC = 0x40U << 4, /* Turn of complementing CRC output data*/ 296 kCAAM_CRC_ModeIVZ = 0x80U << 4, /* Initial value is zero */ 297 } caam_aai_crc_alg_t; 298 299 /*! @brief Storage type used to save crc context. */ 300 #define caam_crc_ctx_t caam_hash_ctx_t 301 302 /******************************************************************************* 303 * RNG Definitions 304 ******************************************************************************/ 305 /*! 306 * @addtogroup caam_driver_rng 307 * @{ 308 */ 309 310 /*! @brief CAAM RNG state handle */ 311 typedef enum _caam_rng_state_handle 312 { 313 kCAAM_RngStateHandle0 = 0u, /*!< CAAM RNG state handle 0 */ 314 kCAAM_RngStateHandle1 = 1u, /*!< CAAM RNG state handle 1 */ 315 } caam_rng_state_handle_t; 316 317 /*! @brief Type of random data to generate */ 318 typedef enum _caam_rng_random_type 319 { 320 kCAAM_RngDataAny = 0u, /*!< CAAM RNG any random data bytes */ 321 kCAAM_RngDataOddParity = 1u, /*!< CAAM RNG odd parity random data bytes */ 322 kCAAM_RngDataNonZero = 2u, /*!< CAAM RNG non zero random data bytes */ 323 } caam_rng_random_type_t; 324 325 /*! @brief 256-bit value used as optional additional entropy input */ 326 typedef uint32_t caam_rng_generic256_t[256 / sizeof(uint32_t)]; 327 328 /*! @brief CAAM RNG configuration */ 329 typedef struct _caam_rng_user_config 330 { 331 uint32_t autoReseedInterval; /*!< Automatic reseed internal. If set to zero, CAAM RNG will use hardware default 332 interval of 10.000.000 generate requests. */ 333 caam_rng_generic256_t *personalString; /*!< NULL or pointer to optional personalization string */ 334 } caam_rng_config_t; 335 336 /*! 337 *@} 338 */ /* end of caam_driver_rng */ 339 340 /******************************************************************************* 341 * BLLOBS Definitions 342 ******************************************************************************/ 343 /*! 344 * @addtogroup caam_driver_blob 345 * @{ 346 */ 347 348 typedef enum _caam_fifost_type 349 { 350 kCAAM_FIFOST_Type_Kek_Kek = 0x24, /*!< Key Register, encrypted using AES-ECB with the job 351 descriptor key encryption key. */ 352 kCAAM_FIFOST_Type_Kek_TKek = 0x25, /*!< Key Register, encrypted using AES-ECB with the 353 trusted descriptor key encryption key. */ 354 kCAAM_FIFOST_Type_Kek_Cmm_Jkek = 0x14, /*!< Key Register, encrypted using AES-CCM with the 355 job descriptor key encryption key. */ 356 kCAAM_FIFOST_Type_Kek_Cmm_Tkek = 0x15, /*!< Key register, encrypted using AES-CCM with the 357 trusted descriptor key encryption key. */ 358 } caam_fifost_type_t; 359 360 typedef enum _caam_desc_type 361 { 362 kCAAM_Descriptor_Type_Kek_Kek = 0x0, /*!< Key Register, encrypted using AES-ECB with the job 363 descriptor key encryption key. */ 364 kCAAM_Descriptor_Type_Kek_TKek = 0x2, /*!< Key Register, encrypted using AES-ECB with the 365 trusted descriptor key encryption key. */ 366 kCAAM_Descriptor_Type_Kek_Ccm_Jkek = 0x1, /*!< Key Register, encrypted using AES-CCM with the 367 job descriptor key encryption key. */ 368 kCAAM_Descriptor_Type_Kek_Ccm_Tkek = 0x3, /*!< Key register, encrypted using AES-CCM with the 369 trusted descriptor key encryption key. */ 370 } caam_desc_type_t; 371 372 //#define KEYBLOB_USE_SECURE_MEMORY 1 // Define when secure memory mode is used 373 374 /*! 375 *@} 376 */ /* end of caam_driver_blob */ 377 378 /******************************************************************************* 379 * PKHA Definitions 380 ******************************************************************************/ 381 /*! 382 * @addtogroup caam_driver_pkha 383 * @{ 384 */ 385 /*! PKHA ECC point structure */ 386 typedef struct _caam_pkha_ecc_point_t 387 { 388 uint8_t *X; /*!< X coordinate (affine) */ 389 uint8_t *Y; /*!< Y coordinate (affine) */ 390 } caam_pkha_ecc_point_t; 391 392 /*! @brief Use of timing equalized version of a PKHA function. */ 393 typedef enum _caam_pkha_timing_t 394 { 395 kCAAM_PKHA_NoTimingEqualized = 0U, /*!< Normal version of a PKHA operation */ 396 kCAAM_PKHA_TimingEqualized = 1U /*!< Timing-equalized version of a PKHA operation */ 397 } caam_pkha_timing_t; 398 399 /*! @brief Integer vs binary polynomial arithmetic selection. */ 400 typedef enum _caam_pkha_f2m_t 401 { 402 kCAAM_PKHA_IntegerArith = 0U, /*!< Use integer arithmetic */ 403 kCAAM_PKHA_F2mArith = 1U /*!< Use binary polynomial arithmetic */ 404 } caam_pkha_f2m_t; 405 406 /*! @brief Montgomery or normal PKHA input format. */ 407 typedef enum _caam_pkha_montgomery_form_t 408 { 409 kCAAM_PKHA_NormalValue = 0U, /*!< PKHA number is normal integer */ 410 kCAAM_PKHA_MontgomeryFormat = 1U /*!< PKHA number is in montgomery format */ 411 } caam_pkha_montgomery_form_t; 412 413 /*! 414 *@} 415 */ /* end of caam_driver_pkha */ 416 417 /******************************************************************************* 418 * API 419 ******************************************************************************/ 420 #if defined(__cplusplus) 421 extern "C" { 422 #endif 423 424 /*! 425 * @addtogroup caam_driver 426 * @{ 427 */ 428 429 /*! 430 * @brief Initializes the CAAM driver. 431 * 432 * This function initializes the CAAM driver, including CAAM's internal RNG. 433 * @param base CAAM peripheral base address 434 * @param config Pointer to configuration structure. 435 * @return kStatus_Success the CAAM Init has completed with zero termination status word 436 * @return kStatus_Fail the CAAM Init has completed with non-zero termination status word 437 */ 438 status_t CAAM_Init(CAAM_Type *base, const caam_config_t *config); 439 440 /*! 441 * @brief Deinitializes the CAAM driver. 442 * This function deinitializes the CAAM driver. 443 * @param base CAAM peripheral base address 444 * @return kStatus_Success the CAAM Deinit has completed with zero termination status word 445 * @return kStatus_Fail the CAAM Deinit has completed with non-zero termination status word 446 */ 447 status_t CAAM_Deinit(CAAM_Type *base); 448 449 /*! 450 * @brief Gets the default configuration structure. 451 * 452 * This function initializes the CAAM configuration structure to a default value. The default 453 * values are as follows. 454 * caamConfig->rngSampleMode = kCAAM_RNG_SampleModeVonNeumann; 455 * caamConfig->rngRingOscDiv = kCAAM_RNG_RingOscDiv4; 456 * 457 * @param[out] config Pointer to configuration structure. 458 */ 459 void CAAM_GetDefaultConfig(caam_config_t *config); 460 461 /*! 462 * @brief Wait for a CAAM job to complete. 463 * 464 * This function polls CAAM output ring for a specific job. 465 * 466 * The CAAM job ring is specified by the jobRing field in the caam_handle_t structure. 467 * The job to be waited is specified by it's descriptor address. 468 * 469 * This function has two modes, determined by the mode argument. 470 * In blocking mode, the function polls the specified jobRing until the descriptor 471 * is available in the CAAM output job ring. 472 * In non-blocking mode, it polls the output ring once and returns status 473 * immediately. 474 * 475 * The function can be called from multiple threads or interrupt service routines, 476 * as internally it uses global critical section (global interrupt disable enable) 477 * to protect it's operation against concurrent accesses. 478 * The global interrupt is disabled only when the descriptor is found 479 * in the output ring, for a very short time, to remove the descriptor from the output ring 480 * safely. 481 * 482 * @param base CAAM peripheral base address 483 * @param handle Data structure with CAAM jobRing used for this request 484 * @param descriptor 485 * @param mode Blocking and non-blocking mode. Zero is blocking. Non-zero is non-blocking. 486 * @return kStatus_Success the CAAM job has completed with zero job termination status word 487 * @return kStatus_Fail the CAAM job has completed with non-zero job termination status word 488 * @return kStatus_Again In non-blocking mode, the job is not ready in the CAAM Output Ring 489 */ 490 status_t CAAM_Wait(CAAM_Type *base, caam_handle_t *handle, uint32_t *descriptor, caam_wait_mode_t mode); 491 492 /*! 493 * @brief External Key Transfer. 494 * 495 * This function loads the given key source to an CAAM external destination via a private interface, 496 * such as Inline Encryption Engine IEE Private Key bus. 497 * 498 * The CAAM job ring is specified by the jobRing field in the caam_handle_t structure. 499 * 500 * This function is blocking. 501 * 502 * @param base CAAM peripheral base address 503 * @param handle Data structure with CAAM jobRing used for this request. 504 * @param keySource The source from which the key will be obtained. 505 * @param keySize Size of the key in bytes. 506 * @return kStatus_Success the CAAM job has completed with zero job termination status word 507 * @return kStatus_Fail the CAAM job has completed with non-zero job termination status word 508 */ 509 status_t CAAM_ExternalKeyTransfer(CAAM_Type *base, 510 caam_handle_t *handle, 511 caam_ext_key_xfr_source_t keySource, 512 size_t keySize); 513 514 /*! 515 *@} 516 */ /* end of caam_driver */ 517 518 /******************************************************************************* 519 * AES API 520 ******************************************************************************/ 521 522 /*! 523 * @addtogroup caam_driver_aes 524 * @{ 525 */ 526 527 /*! 528 * @brief Encrypts AES using the ECB block mode. 529 * 530 * Encrypts AES using the ECB block mode. 531 * 532 * @param base CAAM peripheral base address 533 * @param handle Handle used for this request. Specifies jobRing. 534 * @param plaintext Input plain text to encrypt 535 * @param[out] ciphertext Output cipher text 536 * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. 537 * @param key Input key to use for encryption 538 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 539 * @return Status from encrypt operation 540 */ 541 status_t CAAM_AES_EncryptEcb(CAAM_Type *base, 542 caam_handle_t *handle, 543 const uint8_t *plaintext, 544 uint8_t *ciphertext, 545 size_t size, 546 const uint8_t *key, 547 size_t keySize); 548 549 /*! 550 * @brief Decrypts AES using ECB block mode. 551 * 552 * Decrypts AES using ECB block mode. 553 * 554 * @param base CAAM peripheral base address 555 * @param handle Handle used for this request. Specifies jobRing. 556 * @param ciphertext Input cipher text to decrypt 557 * @param[out] plaintext Output plain text 558 * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. 559 * @param key Input key. 560 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 561 * @return Status from decrypt operation 562 */ 563 status_t CAAM_AES_DecryptEcb(CAAM_Type *base, 564 caam_handle_t *handle, 565 const uint8_t *ciphertext, 566 uint8_t *plaintext, 567 size_t size, 568 const uint8_t *key, 569 size_t keySize); 570 571 /*! 572 * @brief Encrypts AES using CBC block mode. 573 * 574 * @param base CAAM peripheral base address 575 * @param handle Handle used for this request. Specifies jobRing. 576 * @param plaintext Input plain text to encrypt 577 * @param[out] ciphertext Output cipher text 578 * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. 579 * @param iv Input initial vector to combine with the first input block. 580 * @param key Input key to use for encryption 581 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 582 * @return Status from encrypt operation 583 */ 584 status_t CAAM_AES_EncryptCbc(CAAM_Type *base, 585 caam_handle_t *handle, 586 const uint8_t *plaintext, 587 uint8_t *ciphertext, 588 size_t size, 589 const uint8_t iv[CAAM_AES_BLOCK_SIZE], 590 const uint8_t *key, 591 size_t keySize); 592 593 /*! 594 * @brief Decrypts AES using CBC block mode. 595 * 596 * @param base CAAM peripheral base address 597 * @param handle Handle used for this request. Specifies jobRing. 598 * @param ciphertext Input cipher text to decrypt 599 * @param[out] plaintext Output plain text 600 * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. 601 * @param iv Input initial vector to combine with the first input block. 602 * @param key Input key to use for decryption 603 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 604 * @return Status from decrypt operation 605 */ 606 status_t CAAM_AES_DecryptCbc(CAAM_Type *base, 607 caam_handle_t *handle, 608 const uint8_t *ciphertext, 609 uint8_t *plaintext, 610 size_t size, 611 const uint8_t iv[CAAM_AES_BLOCK_SIZE], 612 const uint8_t *key, 613 size_t keySize); 614 615 /*! 616 * @brief Encrypts or decrypts AES using CTR block mode. 617 * 618 * Encrypts or decrypts AES using CTR block mode. 619 * AES CTR mode uses only forward AES cipher and same algorithm for encryption and decryption. 620 * The only difference between encryption and decryption is that, for encryption, the input argument 621 * is plain text and the output argument is cipher text. For decryption, the input argument is cipher text 622 * and the output argument is plain text. 623 * 624 * @param base CAAM peripheral base address 625 * @param handle Handle used for this request. Specifies jobRing. 626 * @param input Input data for CTR block mode 627 * @param[out] output Output data for CTR block mode 628 * @param size Size of input and output data in bytes 629 * @param[in,out] counter Input counter (updates on return) 630 * @param key Input key to use for forward AES cipher 631 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 632 * @param[out] counterlast Output cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are 633 * not used. 634 * @param[out] szLeft Output number of bytes in left unused in counterlast block. NULL can be passed if chained calls 635 * are not used. 636 * @return Status from encrypt operation 637 */ 638 status_t CAAM_AES_CryptCtr(CAAM_Type *base, 639 caam_handle_t *handle, 640 const uint8_t *input, 641 uint8_t *output, 642 size_t size, 643 uint8_t counter[CAAM_AES_BLOCK_SIZE], 644 const uint8_t *key, 645 size_t keySize, 646 uint8_t counterlast[CAAM_AES_BLOCK_SIZE], 647 size_t *szLeft); 648 649 /*! 650 * @brief Encrypts AES and tags using CCM block mode. 651 * 652 * Encrypts AES and optionally tags using CCM block mode. 653 * 654 * @param base CAAM peripheral base address 655 * @param handle Handle used for this request. Specifies jobRing. 656 * @param plaintext Input plain text to encrypt 657 * @param[out] ciphertext Output cipher text. 658 * @param size Size of input and output data in bytes. Zero means authentication only. 659 * @param iv Nonce 660 * @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13. 661 * @param aad Input additional authentication data. Can be NULL if aadSize is zero. 662 * @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication skipped). 663 * @param key Input key to use for encryption 664 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 665 * @param[out] tag Generated output tag. Set to NULL to skip tag processing. 666 * @param tagSize Input size of the tag to generate, in bytes. Must be 4, 6, 8, 10, 12, 14, or 16. 667 * @return Status from encrypt operation 668 */ 669 status_t CAAM_AES_EncryptTagCcm(CAAM_Type *base, 670 caam_handle_t *handle, 671 const uint8_t *plaintext, 672 uint8_t *ciphertext, 673 size_t size, 674 const uint8_t *iv, 675 size_t ivSize, 676 const uint8_t *aad, 677 size_t aadSize, 678 const uint8_t *key, 679 size_t keySize, 680 uint8_t *tag, 681 size_t tagSize); 682 683 /*! 684 * @brief Decrypts AES and authenticates using CCM block mode. 685 * 686 * Decrypts AES and optionally authenticates using CCM block mode. 687 * 688 * @param base CAAM peripheral base address 689 * @param handle Handle used for this request. Specifies jobRing. 690 * @param ciphertext Input cipher text to decrypt 691 * @param[out] plaintext Output plain text. 692 * @param size Size of input and output data in bytes. Zero means authentication data only. 693 * @param iv Nonce 694 * @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13. 695 * @param aad Input additional authentication data. Can be NULL if aadSize is zero. 696 * @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication data skipped). 697 * @param key Input key to use for decryption 698 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 699 * @param tag Received tag. Set to NULL to skip tag processing. 700 * @param tagSize Input size of the received tag to compare with the computed tag, in bytes. Must be 4, 6, 8, 10, 12, 701 * 14, or 16. 702 * @return Status from decrypt operation 703 */ 704 status_t CAAM_AES_DecryptTagCcm(CAAM_Type *base, 705 caam_handle_t *handle, 706 const uint8_t *ciphertext, 707 uint8_t *plaintext, 708 size_t size, 709 const uint8_t *iv, 710 size_t ivSize, 711 const uint8_t *aad, 712 size_t aadSize, 713 const uint8_t *key, 714 size_t keySize, 715 const uint8_t *tag, 716 size_t tagSize); 717 718 /*! 719 * @brief Encrypts AES and tags using GCM block mode. 720 * 721 * Encrypts AES and optionally tags using GCM block mode. If plaintext is NULL, only the GHASH is calculated and output 722 * in the 'tag' field. 723 * 724 * @param base CAAM peripheral base address 725 * @param handle Handle used for this request. Specifies jobRing. 726 * @param plaintext Input plain text to encrypt 727 * @param[out] ciphertext Output cipher text. 728 * @param size Size of input and output data in bytes 729 * @param iv Input initial vector 730 * @param ivSize Size of the IV 731 * @param aad Input additional authentication data 732 * @param aadSize Input size in bytes of AAD 733 * @param key Input key to use for encryption 734 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 735 * @param[out] tag Output hash tag. Set to NULL to skip tag processing. 736 * @param tagSize Input size of the tag to generate, in bytes. Must be 4,8,12,13,14,15 or 16. 737 * @return Status from encrypt operation 738 */ 739 status_t CAAM_AES_EncryptTagGcm(CAAM_Type *base, 740 caam_handle_t *handle, 741 const uint8_t *plaintext, 742 uint8_t *ciphertext, 743 size_t size, 744 const uint8_t *iv, 745 size_t ivSize, 746 const uint8_t *aad, 747 size_t aadSize, 748 const uint8_t *key, 749 size_t keySize, 750 uint8_t *tag, 751 size_t tagSize); 752 753 /*! 754 * @brief Decrypts AES and authenticates using GCM block mode. 755 * 756 * Decrypts AES and optionally authenticates using GCM block mode. If ciphertext is NULL, only the GHASH is calculated 757 * and compared with the received GHASH in 'tag' field. 758 * 759 * @param base CAAM peripheral base address 760 * @param handle Handle used for this request. Specifies jobRing. 761 * @param ciphertext Input cipher text to decrypt 762 * @param[out] plaintext Output plain text. 763 * @param size Size of input and output data in bytes 764 * @param iv Input initial vector 765 * @param ivSize Size of the IV 766 * @param aad Input additional authentication data 767 * @param aadSize Input size in bytes of AAD 768 * @param key Input key to use for encryption 769 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 770 * @param tag Input hash tag to compare. Set to NULL to skip tag processing. 771 * @param tagSize Input size of the tag, in bytes. Must be 4, 8, 12, 13, 14, 15, or 16. 772 * @return Status from decrypt operation 773 */ 774 status_t CAAM_AES_DecryptTagGcm(CAAM_Type *base, 775 caam_handle_t *handle, 776 const uint8_t *ciphertext, 777 uint8_t *plaintext, 778 size_t size, 779 const uint8_t *iv, 780 size_t ivSize, 781 const uint8_t *aad, 782 size_t aadSize, 783 const uint8_t *key, 784 size_t keySize, 785 const uint8_t *tag, 786 size_t tagSize); 787 /*! 788 *@} 789 */ /* end of caam_driver_aes */ 790 791 /*! 792 * @addtogroup caam_nonblocking_driver_aes 793 * @{ 794 */ 795 /*! 796 * @brief Encrypts AES using the ECB block mode. 797 * 798 * Puts AES ECB encrypt descriptor to CAAM input job ring. 799 * 800 * @param base CAAM peripheral base address 801 * @param handle Handle used for this request. Specifies jobRing. 802 * @param plaintext Input plain text to encrypt 803 * @param[out] descriptor Memory for the CAAM descriptor. 804 * @param[out] ciphertext Output cipher text 805 * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. 806 * @param key Input key to use for encryption 807 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 808 * @return Status from job descriptor push 809 */ 810 status_t CAAM_AES_EncryptEcbNonBlocking(CAAM_Type *base, 811 caam_handle_t *handle, 812 caam_desc_aes_ecb_t descriptor, 813 const uint8_t *plaintext, 814 uint8_t *ciphertext, 815 size_t size, 816 const uint8_t *key, 817 size_t keySize); 818 819 /*! 820 * @brief Decrypts AES using ECB block mode. 821 * 822 * Puts AES ECB decrypt descriptor to CAAM input job ring. 823 * 824 * @param base CAAM peripheral base address 825 * @param handle Handle used for this request. Specifies jobRing. 826 * @param[out] descriptor Memory for the CAAM descriptor. 827 * @param ciphertext Input cipher text to decrypt 828 * @param[out] plaintext Output plain text 829 * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. 830 * @param key Input key. 831 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 832 * @return Status from job descriptor push 833 */ 834 status_t CAAM_AES_DecryptEcbNonBlocking(CAAM_Type *base, 835 caam_handle_t *handle, 836 caam_desc_aes_ecb_t descriptor, 837 const uint8_t *ciphertext, 838 uint8_t *plaintext, 839 size_t size, 840 const uint8_t *key, 841 size_t keySize); 842 843 /*! 844 * @brief Encrypts AES using CBC block mode. 845 * 846 * Puts AES CBC encrypt descriptor to CAAM input job ring. 847 * 848 * @param base CAAM peripheral base address 849 * @param handle Handle used for this request. Specifies jobRing. 850 * @param[out] descriptor Memory for the CAAM descriptor. 851 * @param plaintext Input plain text to encrypt 852 * @param[out] ciphertext Output cipher text 853 * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. 854 * @param iv Input initial vector to combine with the first input block. 855 * @param key Input key to use for encryption 856 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 857 * @return Status from job descriptor push 858 */ 859 status_t CAAM_AES_EncryptCbcNonBlocking(CAAM_Type *base, 860 caam_handle_t *handle, 861 caam_desc_aes_cbc_t descriptor, 862 const uint8_t *plaintext, 863 uint8_t *ciphertext, 864 size_t size, 865 const uint8_t *iv, 866 const uint8_t *key, 867 size_t keySize); 868 869 /*! 870 * @brief Decrypts AES using CBC block mode. 871 * 872 * Puts AES CBC decrypt descriptor to CAAM input job ring. 873 * 874 * @param base CAAM peripheral base address 875 * @param handle Handle used for this request. Specifies jobRing. 876 * @param[out] descriptor Memory for the CAAM descriptor. 877 * @param ciphertext Input cipher text to decrypt 878 * @param[out] plaintext Output plain text 879 * @param size Size of input and output data in bytes. Must be multiple of 16 bytes. 880 * @param iv Input initial vector to combine with the first input block. 881 * @param key Input key to use for decryption 882 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 883 * @return Status from job descriptor push 884 */ 885 status_t CAAM_AES_DecryptCbcNonBlocking(CAAM_Type *base, 886 caam_handle_t *handle, 887 caam_desc_aes_cbc_t descriptor, 888 const uint8_t *ciphertext, 889 uint8_t *plaintext, 890 size_t size, 891 const uint8_t *iv, 892 const uint8_t *key, 893 size_t keySize); 894 895 /*! 896 * @brief Encrypts or decrypts AES using CTR block mode. 897 * 898 * Encrypts or decrypts AES using CTR block mode. 899 * AES CTR mode uses only forward AES cipher and same algorithm for encryption and decryption. 900 * The only difference between encryption and decryption is that, for encryption, the input argument 901 * is plain text and the output argument is cipher text. For decryption, the input argument is cipher text 902 * and the output argument is plain text. 903 * 904 * Puts AES CTR crypt descriptor to CAAM input job ring. 905 * 906 * @param base CAAM peripheral base address 907 * @param handle Handle used for this request. Specifies jobRing. 908 * @param[out] descriptor Memory for the CAAM descriptor. 909 * @param input Input data for CTR block mode 910 * @param[out] output Output data for CTR block mode 911 * @param size Size of input and output data in bytes 912 * @param[in,out] counter Input counter (updates on return) 913 * @param key Input key to use for forward AES cipher 914 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 915 * @param[out] counterlast Output cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are 916 * not used. 917 * @param[out] szLeft Output number of bytes in left unused in counterlast block. NULL can be passed if chained calls 918 * are not used. 919 * @return Status from job descriptor push 920 */ 921 status_t CAAM_AES_CryptCtrNonBlocking(CAAM_Type *base, 922 caam_handle_t *handle, 923 caam_desc_aes_ctr_t descriptor, 924 const uint8_t *input, 925 uint8_t *output, 926 size_t size, 927 uint8_t *counter, 928 const uint8_t *key, 929 size_t keySize, 930 uint8_t *counterlast, 931 size_t *szLeft); 932 933 /*! 934 * @brief Encrypts AES and tags using CCM block mode. 935 * 936 * Puts AES CCM encrypt and tag descriptor to CAAM input job ring. 937 * 938 * @param base CAAM peripheral base address 939 * @param handle Handle used for this request. Specifies jobRing. 940 * @param[out] descriptor Memory for the CAAM descriptor. 941 * @param plaintext Input plain text to encrypt 942 * @param[out] ciphertext Output cipher text. 943 * @param size Size of input and output data in bytes. Zero means authentication only. 944 * @param iv Nonce 945 * @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13. 946 * @param aad Input additional authentication data. Can be NULL if aadSize is zero. 947 * @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication skipped). 948 * @param key Input key to use for encryption 949 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 950 * @param[out] tag Generated output tag. Set to NULL to skip tag processing. 951 * @param tagSize Input size of the tag to generate, in bytes. Must be 4, 6, 8, 10, 12, 14, or 16. 952 * @return Status from job descriptor push 953 */ 954 status_t CAAM_AES_EncryptTagCcmNonBlocking(CAAM_Type *base, 955 caam_handle_t *handle, 956 caam_desc_aes_ccm_t descriptor, 957 const uint8_t *plaintext, 958 uint8_t *ciphertext, 959 size_t size, 960 const uint8_t *iv, 961 size_t ivSize, 962 const uint8_t *aad, 963 size_t aadSize, 964 const uint8_t *key, 965 size_t keySize, 966 uint8_t *tag, 967 size_t tagSize); 968 969 /*! 970 * @brief Decrypts AES and authenticates using CCM block mode. 971 * 972 * Puts AES CCM decrypt and check tag descriptor to CAAM input job ring. 973 * 974 * @param base CAAM peripheral base address 975 * @param handle Handle used for this request. Specifies jobRing. 976 * @param[out] descriptor Memory for the CAAM descriptor. 977 * @param ciphertext Input cipher text to decrypt 978 * @param[out] plaintext Output plain text. 979 * @param size Size of input and output data in bytes. Zero means authentication data only. 980 * @param iv Nonce 981 * @param ivSize Length of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13. 982 * @param aad Input additional authentication data. Can be NULL if aadSize is zero. 983 * @param aadSize Input size in bytes of AAD. Zero means data mode only (authentication data skipped). 984 * @param key Input key to use for decryption 985 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 986 * @param tag Received tag. Set to NULL to skip tag processing. 987 * @param tagSize Input size of the received tag to compare with the computed tag, in bytes. Must be 4, 6, 8, 10, 12, 988 * 14, or 16. 989 * @return Status from job descriptor push 990 */ 991 992 status_t CAAM_AES_DecryptTagCcmNonBlocking(CAAM_Type *base, 993 caam_handle_t *handle, 994 caam_desc_aes_ccm_t descriptor, 995 const uint8_t *ciphertext, 996 uint8_t *plaintext, 997 size_t size, 998 const uint8_t *iv, 999 size_t ivSize, 1000 const uint8_t *aad, 1001 size_t aadSize, 1002 const uint8_t *key, 1003 size_t keySize, 1004 const uint8_t *tag, 1005 size_t tagSize); 1006 1007 /*! 1008 * @brief Encrypts AES and tags using GCM block mode. 1009 * 1010 * Encrypts AES and optionally tags using GCM block mode. If plaintext is NULL, only the GHASH is calculated and output 1011 * in the 'tag' field. 1012 * Puts AES GCM encrypt and tag descriptor to CAAM input job ring. 1013 * 1014 * @param base CAAM peripheral base address 1015 * @param handle Handle used for this request. Specifies jobRing. 1016 * @param[out] descriptor Memory for the CAAM descriptor. 1017 * @param plaintext Input plain text to encrypt 1018 * @param[out] ciphertext Output cipher text. 1019 * @param size Size of input and output data in bytes 1020 * @param iv Input initial vector 1021 * @param ivSize Size of the IV 1022 * @param aad Input additional authentication data 1023 * @param aadSize Input size in bytes of AAD 1024 * @param key Input key to use for encryption 1025 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 1026 * @param[out] tag Output hash tag. Set to NULL to skip tag processing. 1027 * @param tagSize Input size of the tag to generate, in bytes. Must be 4,8,12,13,14,15 or 16. 1028 * @return Status from job descriptor push 1029 */ 1030 status_t CAAM_AES_EncryptTagGcmNonBlocking(CAAM_Type *base, 1031 caam_handle_t *handle, 1032 caam_desc_aes_gcm_t descriptor, 1033 const uint8_t *plaintext, 1034 uint8_t *ciphertext, 1035 size_t size, 1036 const uint8_t *iv, 1037 size_t ivSize, 1038 const uint8_t *aad, 1039 size_t aadSize, 1040 const uint8_t *key, 1041 size_t keySize, 1042 uint8_t *tag, 1043 size_t tagSize); 1044 1045 /*! 1046 * @brief Decrypts AES and authenticates using GCM block mode. 1047 * 1048 * Decrypts AES and optionally authenticates using GCM block mode. If ciphertext is NULL, only the GHASH is calculated 1049 * and compared with the received GHASH in 'tag' field. 1050 * Puts AES GCM decrypt and check tag descriptor to CAAM input job ring. 1051 * 1052 * @param base CAAM peripheral base address 1053 * @param handle Handle used for this request. Specifies jobRing. 1054 * @param[out] descriptor Memory for the CAAM descriptor. 1055 * @param ciphertext Input cipher text to decrypt 1056 * @param[out] plaintext Output plain text. 1057 * @param size Size of input and output data in bytes 1058 * @param iv Input initial vector 1059 * @param ivSize Size of the IV 1060 * @param aad Input additional authentication data 1061 * @param aadSize Input size in bytes of AAD 1062 * @param key Input key to use for encryption 1063 * @param keySize Size of the input key, in bytes. Must be 16, 24, or 32. 1064 * @param tag Input hash tag to compare. Set to NULL to skip tag processing. 1065 * @param tagSize Input size of the tag, in bytes. Must be 4, 8, 12, 13, 14, 15, or 16. 1066 * @return Status from job descriptor push 1067 */ 1068 status_t CAAM_AES_DecryptTagGcmNonBlocking(CAAM_Type *base, 1069 caam_handle_t *handle, 1070 caam_desc_aes_gcm_t descriptor, 1071 const uint8_t *ciphertext, 1072 uint8_t *plaintext, 1073 size_t size, 1074 const uint8_t *iv, 1075 size_t ivSize, 1076 const uint8_t *aad, 1077 size_t aadSize, 1078 const uint8_t *key, 1079 size_t keySize, 1080 const uint8_t *tag, 1081 size_t tagSize); 1082 /*! 1083 *@} 1084 */ /* end of caam_nonblocking_driver_aes */ 1085 1086 /******************************************************************************* 1087 * HASH API 1088 ******************************************************************************/ 1089 1090 /*! 1091 * @addtogroup caam_driver_hash 1092 * @{ 1093 */ 1094 /*! 1095 * @brief Initialize HASH context 1096 * 1097 * This function initializes the HASH. 1098 * Key shall be supplied if the underlaying algoritm is AES XCBC-MAC or CMAC. 1099 * Key shall be NULL if the underlaying algoritm is SHA. 1100 * 1101 * For XCBC-MAC, the key length must be 16. For CMAC, the key length can be 1102 * the AES key lengths supported by AES engine. For MDHA the key length argument 1103 * is ignored. 1104 * 1105 * This functions is used to initialize the context for both blocking and non-blocking 1106 * CAAM_HASH API. 1107 * For blocking CAAM HASH API, the HASH context contains all information required for context switch, 1108 * such as running hash or MAC. For non-blocking CAAM HASH API, the HASH context is used 1109 * to hold SGT. Therefore, the HASH context cannot be shared between blocking and non-blocking HASH API. 1110 * With one HASH context, either use only blocking HASH API or only non-blocking HASH API. 1111 * 1112 * 1113 * @param base CAAM peripheral base address 1114 * @param handle Handle used for this request. 1115 * @param[out] ctx Output hash context 1116 * @param algo Underlaying algorithm to use for hash computation. 1117 * @param key Input key (NULL if underlaying algorithm is SHA) 1118 * @param keySize Size of input key in bytes 1119 * @return Status of initialization 1120 */ 1121 status_t CAAM_HASH_Init(CAAM_Type *base, 1122 caam_handle_t *handle, 1123 caam_hash_ctx_t *ctx, 1124 caam_hash_algo_t algo, 1125 const uint8_t *key, 1126 size_t keySize); 1127 1128 /*! 1129 * @brief Add data to current HASH 1130 * 1131 * Add data to current HASH. This can be called repeatedly with an arbitrary amount of data to be 1132 * hashed. The functions blocks. If it returns kStatus_Success, the running hash or mac 1133 * has been updated (CAAM has processed the input data), so the memory at input pointer 1134 * can be released back to system. The context is updated with the running hash or mac 1135 * and with all necessary information to support possible context switch. 1136 * 1137 * @param[in,out] ctx HASH context 1138 * @param input Input data 1139 * @param inputSize Size of input data in bytes 1140 * @return Status of the hash update operation 1141 */ 1142 status_t CAAM_HASH_Update(caam_hash_ctx_t *ctx, const uint8_t *input, size_t inputSize); 1143 1144 /*! 1145 * @brief Finalize hashing 1146 * 1147 * Outputs the final hash (computed by CAAM_HASH_Update()) and erases the context. 1148 * 1149 * @param[in,out] ctx Input hash context 1150 * @param[out] output Output hash data 1151 * @param[out] outputSize Output parameter storing the size of the output hash in bytes 1152 * @return Status of the hash finish operation 1153 */ 1154 status_t CAAM_HASH_Finish(caam_hash_ctx_t *ctx, uint8_t *output, size_t *outputSize); 1155 1156 /*! 1157 * @brief Create HASH on given data 1158 * 1159 * Perform the full keyed XCBC-MAC/CMAC or SHA in one function call. 1160 * 1161 * Key shall be supplied if the underlaying algoritm is AES XCBC-MAC or CMAC. 1162 * Key shall be NULL if the underlaying algoritm is SHA. 1163 * 1164 * For XCBC-MAC, the key length must be 16. For CMAC, the key length can be 1165 * the AES key lengths supported by AES engine. For MDHA the key length argument 1166 * is ignored. 1167 * 1168 * The function is blocking. 1169 * 1170 * @param base CAAM peripheral base address 1171 * @param handle Handle used for this request. 1172 * @param algo Underlaying algorithm to use for hash computation. 1173 * @param input Input data 1174 * @param inputSize Size of input data in bytes 1175 * @param key Input key (NULL if underlaying algorithm is SHA) 1176 * @param keySize Size of input key in bytes 1177 * @param[out] output Output hash data 1178 * @param[out] outputSize Output parameter storing the size of the output hash in bytes 1179 * @return Status of the one call hash operation. 1180 */ 1181 status_t CAAM_HASH(CAAM_Type *base, 1182 caam_handle_t *handle, 1183 caam_hash_algo_t algo, 1184 const uint8_t *input, 1185 size_t inputSize, 1186 const uint8_t *key, 1187 size_t keySize, 1188 uint8_t *output, 1189 size_t *outputSize); 1190 /*! 1191 *@} 1192 */ /* end of caam_driver_hash */ 1193 1194 /*! 1195 * @addtogroup caam_nonblocking_driver_hash 1196 * @{ 1197 */ 1198 1199 /*! 1200 * @brief Add input address and size to input data table 1201 * 1202 * Add data input pointer to a table maintained internally in the context. 1203 * Each call of this function creates one entry in the table. 1204 * The entry consists of the input pointer and inputSize. 1205 * All entries created by one or multiple calls of this function can be processed 1206 * in one call to CAAM_HASH_FinishNonBlocking() function. 1207 * Individual entries can point to non-continuous data in the memory. 1208 * The processing will occur in the order in which the CAAM_HASH_UpdateNonBlocking() 1209 * have been called. 1210 * 1211 * Memory pointers will be later accessed by CAAM (at time of CAAM_HASH_FinishNonBlocking()), 1212 * so the memory must stay valid 1213 * until CAAM_HASH_FinishNonBlocking() has been called and CAAM completes the processing. 1214 * 1215 * @param[in,out] ctx HASH context 1216 * @param input Input data 1217 * @param inputSize Size of input data in bytes 1218 * @return Status of the hash update operation 1219 */ 1220 status_t CAAM_HASH_UpdateNonBlocking(caam_hash_ctx_t *ctx, const uint8_t *input, size_t inputSize); 1221 1222 /*! 1223 * @brief Finalize hashing 1224 * 1225 * The actual algorithm is computed with all input data, the memory pointers 1226 * are accessed by CAAM after the function returns. 1227 * The input data chunks have been specified by prior calls to CAAM_HASH_UpdateNonBlocking(). 1228 * The function schedules the request at CAAM, then returns. 1229 * After a while, when the CAAM completes processing of the input data chunks, 1230 * the result is written to the output[] array, outputSize is written and the context 1231 * is cleared. 1232 * 1233 * @param[in,out] ctx Input hash context 1234 * @param[out] descriptor Memory for the CAAM descriptor. 1235 * @param[out] output Output hash data 1236 * @param[out] outputSize Output parameter storing the size of the output hash in bytes 1237 * @return Status of the hash finish operation 1238 */ 1239 status_t CAAM_HASH_FinishNonBlocking(caam_hash_ctx_t *ctx, 1240 caam_desc_hash_t descriptor, 1241 uint8_t *output, 1242 size_t *outputSize); 1243 1244 /*! 1245 * @brief Create HASH on given data 1246 * 1247 * Perform the full keyed XCBC-MAC/CMAC or SHA in one function call. 1248 * 1249 * Key shall be supplied if the underlaying algoritm is AES XCBC-MAC or CMAC. 1250 * Key shall be NULL if the underlaying algoritm is SHA. 1251 * 1252 * For XCBC-MAC, the key length must be 16. For CMAC, the key length can be 1253 * the AES key lengths supported by AES engine. For MDHA the key length argument 1254 * is ignored. 1255 * 1256 * The function is non-blocking. The request is scheduled at CAAM. 1257 * 1258 * @param base CAAM peripheral base address 1259 * @param handle Handle used for this request. 1260 * @param[out] descriptor Memory for the CAAM descriptor. 1261 * @param algo Underlaying algorithm to use for hash computation. 1262 * @param input Input data 1263 * @param inputSize Size of input data in bytes 1264 * @param key Input key (NULL if underlaying algorithm is SHA) 1265 * @param keySize Size of input key in bytes 1266 * @param[out] output Output hash data 1267 * @param[out] outputSize Output parameter storing the size of the output hash in bytes 1268 * @return Status of the one call hash operation. 1269 */ 1270 status_t CAAM_HASH_NonBlocking(CAAM_Type *base, 1271 caam_handle_t *handle, 1272 caam_desc_hash_t descriptor, 1273 caam_hash_algo_t algo, 1274 const uint8_t *input, 1275 size_t inputSize, 1276 const uint8_t *key, 1277 size_t keySize, 1278 uint8_t *output, 1279 size_t *outputSize); 1280 1281 /*! 1282 *@} 1283 */ /* end of caam_nonblocking_driver_hash */ 1284 1285 /******************************************************************************* 1286 * CRC API 1287 ******************************************************************************/ 1288 1289 /*! 1290 * @addtogroup caam_driver_crc 1291 * @{ 1292 */ 1293 /*! 1294 * @brief Initialize CRC context 1295 * 1296 * This function initializes the CRC context. 1297 * polynomial shall be supplied if the underlaying algoritm is kCAAM_CrcCUSTPOLY. 1298 * polynomial shall be NULL if the underlaying algoritm is kCAAM_CrcIEEE or kCAAM_CrciSCSI. 1299 * 1300 * This functions is used to initialize the context for CAAM_CRC API 1301 * 1302 * @param base CAAM peripheral base address 1303 * @param handle Handle used for this request. 1304 * @param[out] ctx Output crc context 1305 * @param algo Underlaying algorithm to use for CRC computation 1306 * @param polynomial CRC polynomial (NULL if underlaying algorithm is kCAAM_CrcIEEE or kCAAM_CrciSCSI) 1307 * @param polynomialSize Size of polynomial in bytes (0u if underlaying algorithm is kCAAM_CrcIEEE or kCAAM_CrciSCSI) 1308 * @param mode Specify how CRC engine manipulates its input and output data 1309 * @return Status of initialization 1310 */ 1311 status_t CAAM_CRC_Init(CAAM_Type *base, 1312 caam_handle_t *handle, 1313 caam_crc_ctx_t *ctx, 1314 caam_crc_algo_t algo, 1315 const uint8_t *polynomial, 1316 size_t polynomialSize, 1317 caam_aai_crc_alg_t mode); 1318 1319 /*! 1320 * @brief Add data to current CRC 1321 * 1322 * Add data to current CRC. This can be called repeatedly. The functions blocks. If it returns kStatus_Success, the 1323 * running CRC has been updated (CAAM has processed the input data), so the memory at input pointer can be released back 1324 * to system. The context is updated with the running CRC and with all necessary information to support possible context 1325 * switch. 1326 * 1327 * @param[in,out] ctx CRC context 1328 * @param input Input data 1329 * @param inputSize Size of input data in bytes 1330 * @return Status of the crc update operation 1331 */ 1332 status_t CAAM_CRC_Update(caam_crc_ctx_t *ctx, const uint8_t *input, size_t inputSize); 1333 1334 /*! 1335 * @brief Finalize CRC 1336 * 1337 * Outputs the final CRC (computed by CAAM_CRC_Update()) and erases the context. 1338 * 1339 * @param[in,out] ctx Input crc context 1340 * @param[out] output Output crc data 1341 * @param[out] outputSize Output parameter storing the size of the output crc in bytes 1342 * @return Status of the crc finish operation 1343 */ 1344 status_t CAAM_CRC_Finish(caam_crc_ctx_t *ctx, uint8_t *output, size_t *outputSize); 1345 1346 /*! 1347 * @brief Create CRC on given data 1348 * 1349 * Perform CRC in one function call. 1350 * 1351 * Polynomial shall be supplied if underlaying algorithm is kCAAM_CrcCUSTPOLY. 1352 * Polynomial shall be NULL if underlaying algorithm is kCAAM_CrcIEEE or kCAAM_CrciSCSI. 1353 * 1354 * 1355 * The function is blocking. 1356 * 1357 * @param base CAAM peripheral base address 1358 * @param handle Handle used for this request. 1359 * @param algo Underlaying algorithm to use for crc computation. 1360 * @param mode Specify how CRC engine manipulates its input and output data. 1361 * @param input Input data 1362 * @param inputSize Size of input data in bytes 1363 * @param polynomial CRC polynomial (NULL if underlaying algorithm is kCAAM_CrcIEEE or kCAAM_CrciSCSI) 1364 * @param polynomialSize Size of input polynomial in bytes (0U if underlaying algorithm is kCAAM_CrcIEEE or 1365 * kCAAM_CrciSCSI) 1366 * @param[out] output Output crc data 1367 * @param[out] outputSize Output parameter storing the size of the output crc in bytes 1368 * @return Status of the one call crc operation. 1369 */ 1370 status_t CAAM_CRC(CAAM_Type *base, 1371 caam_handle_t *handle, 1372 caam_crc_algo_t algo, 1373 caam_aai_crc_alg_t mode, 1374 const uint8_t *input, 1375 size_t inputSize, 1376 const uint8_t *polynomial, 1377 size_t polynomialSize, 1378 uint8_t *output, 1379 size_t *outputSize); 1380 1381 /*! 1382 * @brief Create CRC on given data 1383 * 1384 * Perform CRC in one function call. 1385 * 1386 * Polynomial shall be supplied if underlaying algorithm is kCAAM_CrcCUSTPOLY. 1387 * Polynomial shall be NULL if underlaying algorithm is kCAAM_CrcIEEE or kCAAM_CrciSCSI. 1388 * 1389 * The function is non-blocking. The request is scheduled at CAAM. 1390 * 1391 * @param base CAAM peripheral base address 1392 * @param handle Handle used for this request. 1393 * @param[out] descriptor Memory for the CAAM descriptor. 1394 * @param algo Underlaying algorithm to use for crc computation. 1395 * @param mode Specify how CRC engine manipulates its input and output data. 1396 * @param input Input data 1397 * @param inputSize Size of input data in bytes 1398 * @param polynomial CRC polynomial (NULL if underlaying algorithm is kCAAM_CrcIEEE or kCAAM_CrciSCSI) 1399 * @param polynomialSize Size of input polynomial in bytes (0U if underlaying algorithm is kCAAM_CrcIEEE or 1400 * kCAAM_CrciSCSI) 1401 * @param[out] output Output crc data 1402 * @param[out] outputSize Output parameter storing the size of the output crc in bytes 1403 * @return Status of the one call crc operation. 1404 */ 1405 status_t CAAM_CRC_NonBlocking(CAAM_Type *base, 1406 caam_handle_t *handle, 1407 caam_desc_hash_t descriptor, 1408 caam_crc_algo_t algo, 1409 caam_aai_crc_alg_t mode, 1410 const uint8_t *input, 1411 size_t inputSize, 1412 const uint8_t *polynomial, 1413 size_t polynomialSize, 1414 uint8_t *output, 1415 size_t *outputSize); 1416 1417 /*! 1418 *@} 1419 */ /* end of caam_driver_crc */ 1420 /******************************************************************************* 1421 * RNG API 1422 ******************************************************************************/ 1423 1424 /*! 1425 * @addtogroup caam_driver_rng 1426 * @{ 1427 */ 1428 1429 /*! 1430 * @brief Initializes user configuration structure to default. 1431 * 1432 * This function initializes the configure structure to default value. the default 1433 * value are: 1434 * @code 1435 * config->autoReseedInterval = 0; 1436 * config->personalString = NULL; 1437 * @endcode 1438 * 1439 * @param config User configuration structure. 1440 * @return status of the request 1441 */ 1442 status_t CAAM_RNG_GetDefaultConfig(caam_rng_config_t *config); 1443 1444 /*! 1445 * @brief Instantiate the CAAM RNG state handle 1446 * 1447 * This function instantiates CAAM RNG state handle. 1448 * The function is blocking and returns after CAAM has processed the request. 1449 * 1450 * @param base CAAM peripheral base address 1451 * @param handle CAAM jobRing used for this request 1452 * @param stateHandle RNG state handle to instantiate 1453 * @param config Pointer to configuration structure. 1454 * @return Status of the request 1455 */ 1456 status_t CAAM_RNG_Init(CAAM_Type *base, 1457 caam_handle_t *handle, 1458 caam_rng_state_handle_t stateHandle, 1459 const caam_rng_config_t *config); 1460 1461 /*! 1462 * @brief Uninstantiate the CAAM RNG state handle 1463 * 1464 * This function uninstantiates CAAM RNG state handle. 1465 * The function is blocking and returns after CAAM has processed the request. 1466 * 1467 * @param base CAAM peripheral base address 1468 * @param handle jobRing used for this request. 1469 * @param stateHandle RNG state handle to uninstantiate 1470 * @return Status of the request 1471 */ 1472 status_t CAAM_RNG_Deinit(CAAM_Type *base, caam_handle_t *handle, caam_rng_state_handle_t stateHandle); 1473 1474 /*! 1475 * @brief Generate Secure Key 1476 * 1477 * This function generates random data writes it to Secure Key registers. 1478 * The function is blocking and returns after CAAM has processed the request. 1479 * RNG state handle 0 is always used. 1480 * 1481 * @param base CAAM peripheral base address 1482 * @param handle jobRing used for this request 1483 * @param additionalEntropy NULL or Pointer to optional 256-bit additional entropy. 1484 * @return Status of the request 1485 */ 1486 status_t CAAM_RNG_GenerateSecureKey(CAAM_Type *base, caam_handle_t *handle, caam_rng_generic256_t additionalEntropy); 1487 1488 /*! 1489 * @brief Reseed the CAAM RNG state handle 1490 * 1491 * This function reseeds the CAAM RNG state handle. 1492 * For a state handle in nondeterministic mode, the DRNG is seeded with 384 bits of 1493 * entropy from the TRNG and an optional 256-bit additional input from the descriptor 1494 * via the Class 1 Context Register. 1495 * 1496 * The function is blocking and returns after CAAM has processed the request. 1497 * 1498 * @param base CAAM peripheral base address 1499 * @param handle jobRing used for this request 1500 * @param stateHandle RNG state handle to reseed 1501 * @param additionalEntropy NULL or Pointer to optional 256-bit additional entropy. 1502 * @return Status of the request 1503 */ 1504 status_t CAAM_RNG_Reseed(CAAM_Type *base, 1505 caam_handle_t *handle, 1506 caam_rng_state_handle_t stateHandle, 1507 caam_rng_generic256_t additionalEntropy); 1508 1509 /*! 1510 * @brief Get random data 1511 * 1512 * This function gets random data from CAAM RNG. 1513 * 1514 * The function is blocking and returns after CAAM has generated the requested data or an error occurred. 1515 * 1516 * @param base CAAM peripheral base address 1517 * @param handle jobRing used for this request 1518 * @param stateHandle RNG state handle used to generate random data 1519 * @param[out] data Pointer address used to store random data 1520 * @param dataSize Size of the buffer pointed by the data parameter 1521 * @param dataType Type of random data to be generated 1522 * @param additionalEntropy NULL or Pointer to optional 256-bit additional entropy. 1523 * @return Status of the request 1524 */ 1525 status_t CAAM_RNG_GetRandomData(CAAM_Type *base, 1526 caam_handle_t *handle, 1527 caam_rng_state_handle_t stateHandle, 1528 uint8_t *data, 1529 size_t dataSize, 1530 caam_rng_random_type_t dataType, 1531 caam_rng_generic256_t additionalEntropy); 1532 1533 /*! 1534 *@} 1535 */ /* end of caam_driver_rng */ 1536 1537 /*! 1538 * @addtogroup caam_nonblocking_driver_rng 1539 * @{ 1540 */ 1541 1542 /*! 1543 * @brief Request random data 1544 * 1545 * This function schedules the request for random data from CAAM RNG. 1546 * Memory at memory pointers will be accessed by CAAM shortly after this function 1547 * returns, according to actual CAAM schedule. 1548 * 1549 * @param base CAAM peripheral base address 1550 * @param handle RNG handle used for this request 1551 * @param stateHandle RNG state handle used to generate random data 1552 * @param[out] descriptor memory for CAAM commands 1553 * @param[out] data Pointer address used to store random data 1554 * @param dataSize Size of the buffer pointed by the data parameter, in bytes. 1555 * @param dataType Type of random data to be generated. 1556 * @param additionalEntropy NULL or Pointer to optional 256-bit additional entropy. 1557 * @return status of the request 1558 */ 1559 status_t CAAM_RNG_GetRandomDataNonBlocking(CAAM_Type *base, 1560 caam_handle_t *handle, 1561 caam_rng_state_handle_t stateHandle, 1562 caam_desc_rng_t descriptor, 1563 void *data, 1564 size_t dataSize, 1565 caam_rng_random_type_t dataType, 1566 caam_rng_generic256_t additionalEntropy); 1567 1568 /*! 1569 *@} 1570 */ /* end of caam_nonblocking_driver_rng */ 1571 1572 /******************************************************************************* 1573 * Black key API 1574 ******************************************************************************/ 1575 /*! 1576 * @addtogroup caam_driver_black 1577 * @{ 1578 */ 1579 1580 /*! 1581 * @brief Construct a black key 1582 * 1583 * This function constructs a job descriptor capable of performing 1584 * a key blackening operation on a plaintext secure memory resident object. 1585 * 1586 * @param base CAAM peripheral base address 1587 * @param handle jobRing used for this request 1588 * @param data Pointer address uses to pointed the plaintext. 1589 * @param dataSize Size of the buffer pointed by the data parameter 1590 * @param fifostType Type of AES-CBC or AEC-CCM to encrypt plaintext 1591 * @param keyregType Type uses to be stored 1592 * @param[out] blackdata Pointer address uses to pointed the black key 1593 * @return Status of the request 1594 */ 1595 status_t CAAM_BLACK_GetKeyBlacken(CAAM_Type *base, 1596 caam_handle_t *handle, 1597 const uint8_t *data, 1598 size_t dataSize, 1599 caam_fifost_type_t fifostType, 1600 uint8_t *blackdata); 1601 1602 /*! 1603 *@} 1604 */ /* end of caam_driver_black */ 1605 1606 /******************************************************************************* 1607 * Key blob API 1608 ******************************************************************************/ 1609 /*! 1610 * @addtogroup caam_driver_blob 1611 * @{ 1612 */ 1613 /*! 1614 * @brief Construct a encrypted Red Blob 1615 * 1616 * This function constructs a job descriptor capable of performing 1617 * a encrypted blob operation on a plaintext object. 1618 * 1619 * @param base CAAM peripheral base address 1620 * @param handle Handle used for this request. Specifies jobRing. 1621 * @param keyModifier Address of the random key modifier generated by RNG 1622 * @param keyModifierSize Size of keyModifier buffer in bytes 1623 * @param data Data adress 1624 * @param dataSize Size of the buffer pointed by the data parameter 1625 * @param[out] blob_data Output blob data adress 1626 * @return Status of the request 1627 */ 1628 status_t CAAM_RedBlob_Encapsule(CAAM_Type *base, 1629 caam_handle_t *handle, 1630 const uint8_t *keyModifier, 1631 size_t keyModifierSize, 1632 const uint8_t *data, 1633 size_t dataSize, 1634 uint8_t *blob_data); 1635 1636 /*! @brief Decrypt red blob 1637 * 1638 * This function constructs a job descriptor capable of performing 1639 * decrypting red blob . 1640 * 1641 * @param base CAAM peripheral base address 1642 * @param handle Handle used for this request. Specifies jobRing. 1643 * @param keyModifier Address of the random key modifier generated by RNG 1644 * @param keyModifierSize Size of keyModifier buffer in bytes 1645 * @param blob_data Address of blob data 1646 * @param[out] data Output data adress. 1647 * @param dataSize Size of the buffer pointed by the data parameter in bytes 1648 * @return Status of the request 1649 */ 1650 status_t CAAM_RedBlob_Decapsule(CAAM_Type *base, 1651 caam_handle_t *handle, 1652 const uint8_t *keyModifier, 1653 size_t keyModifierSize, 1654 const uint8_t *blob_data, 1655 uint8_t *data, 1656 size_t dataSize); 1657 1658 /*! 1659 * @brief Construct a encrypted Black Blob 1660 * 1661 * This function constructs a job descriptor capable of performing 1662 * a encrypted blob operation on a plaintext object. 1663 * 1664 * @param base CAAM peripheral base address 1665 * @param handle Handle used for this request. Specifies jobRing. 1666 * @param keyModifier Address of the random key modifier generated by RNG 1667 * @param keyModifierSize Size of keyModifier buffer in bytes 1668 * @param data Data adress 1669 * @param dataSize Size of the buffer pointed by the data parameter 1670 * @param[out] blob_data Output blob data adress 1671 * @param blackKeyType Type of black key see enum caam_desc_type_t for more info 1672 * @return Status of the request 1673 */ 1674 status_t CAAM_BlackBlob_Encapsule(CAAM_Type *base, 1675 caam_handle_t *handle, 1676 const uint8_t *keyModifier, 1677 size_t keyModifierSize, 1678 const uint8_t *data, 1679 size_t dataSize, 1680 uint8_t *blob_data, 1681 caam_desc_type_t blackKeyType); 1682 1683 /*! @brief Construct a decrypted black blob 1684 * 1685 * This function constructs a job descriptor capable of performing 1686 * decrypting black blob. 1687 * 1688 * @param base CAAM peripheral base address 1689 * @param handle Handle used for this request. Specifies jobRing. 1690 * @param keyModifier Address of the random key modifier generated by RNG 1691 * @param keyModifierSize Size of keyModifier buffer in bytes 1692 * @param blob_data Address of blob data 1693 * @param[out] data Output data adress. 1694 * @param dataSize Size of the buffer pointed by the data parameter in bytes 1695 * @param blackKeyType Type of black key see enum caam_desc_type_t for more info 1696 * @return Status of the request 1697 */ 1698 status_t CAAM_BlackBlob_Decapsule(CAAM_Type *base, 1699 caam_handle_t *handle, 1700 const uint8_t *keyModifier, 1701 size_t keyModifierSize, 1702 const uint8_t *blob_data, 1703 uint8_t *data, 1704 size_t dataSize, 1705 caam_desc_type_t blackKeyType); 1706 1707 /*! 1708 *@} 1709 */ /* end of caam_driver_blob */ 1710 1711 /******************************************************************************* 1712 * DES API 1713 ******************************************************************************/ 1714 1715 /*! 1716 * @addtogroup caam_driver_des 1717 * @{ 1718 */ 1719 1720 /*! 1721 * @brief Encrypts DES using ECB block mode. 1722 * 1723 * Encrypts DES using ECB block mode. 1724 * 1725 * @param base CAAM peripheral base address 1726 * @param handle Handle used for this request. Specifies jobRing. 1727 * @param plaintext Input plaintext to encrypt 1728 * @param[out] ciphertext Output ciphertext 1729 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 1730 * @param key Input key to use for encryption 1731 * @return Status from encrypt/decrypt operation 1732 */ 1733 status_t CAAM_DES_EncryptEcb(CAAM_Type *base, 1734 caam_handle_t *handle, 1735 const uint8_t *plaintext, 1736 uint8_t *ciphertext, 1737 size_t size, 1738 const uint8_t key[CAAM_DES_KEY_SIZE]); 1739 1740 /*! 1741 * @brief Decrypts DES using ECB block mode. 1742 * 1743 * Decrypts DES using ECB block mode. 1744 * 1745 * @param base CAAM peripheral base address 1746 * @param handle Handle used for this request. Specifies jobRing. 1747 * @param ciphertext Input ciphertext to decrypt 1748 * @param[out] plaintext Output plaintext 1749 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 1750 * @param key Input key to use for decryption 1751 * @return Status from encrypt/decrypt operation 1752 */ 1753 status_t CAAM_DES_DecryptEcb(CAAM_Type *base, 1754 caam_handle_t *handle, 1755 const uint8_t *ciphertext, 1756 uint8_t *plaintext, 1757 size_t size, 1758 const uint8_t key[CAAM_DES_KEY_SIZE]); 1759 1760 /*! 1761 * @brief Encrypts DES using CBC block mode. 1762 * 1763 * Encrypts DES using CBC block mode. 1764 * 1765 * @param base CAAM peripheral base address 1766 * @param handle Handle used for this request. Specifies jobRing. 1767 * @param plaintext Input plaintext to encrypt 1768 * @param[out] ciphertext Ouput ciphertext 1769 * @param size Size of input and output data in bytes 1770 * @param iv Input initial vector to combine with the first plaintext block. 1771 * The iv does not need to be secret, but it must be unpredictable. 1772 * @param key Input key to use for encryption 1773 * @return Status from encrypt/decrypt operation 1774 */ 1775 status_t CAAM_DES_EncryptCbc(CAAM_Type *base, 1776 caam_handle_t *handle, 1777 const uint8_t *plaintext, 1778 uint8_t *ciphertext, 1779 size_t size, 1780 const uint8_t iv[CAAM_DES_IV_SIZE], 1781 const uint8_t key[CAAM_DES_KEY_SIZE]); 1782 1783 /*! 1784 * @brief Decrypts DES using CBC block mode. 1785 * 1786 * Decrypts DES using CBC block mode. 1787 * 1788 * @param base CAAM peripheral base address 1789 * @param handle Handle used for this request. Specifies jobRing. 1790 * @param ciphertext Input ciphertext to decrypt 1791 * @param[out] plaintext Output plaintext 1792 * @param size Size of input data in bytes 1793 * @param iv Input initial vector to combine with the first plaintext block. 1794 * The iv does not need to be secret, but it must be unpredictable. 1795 * @param key Input key to use for decryption 1796 * @return Status from encrypt/decrypt operation 1797 */ 1798 status_t CAAM_DES_DecryptCbc(CAAM_Type *base, 1799 caam_handle_t *handle, 1800 const uint8_t *ciphertext, 1801 uint8_t *plaintext, 1802 size_t size, 1803 const uint8_t iv[CAAM_DES_IV_SIZE], 1804 const uint8_t key[CAAM_DES_KEY_SIZE]); 1805 1806 /*! 1807 * @brief Encrypts DES using CFB block mode. 1808 * 1809 * Encrypts DES using CFB block mode. 1810 * 1811 * @param base CAAM peripheral base address 1812 * @param handle Handle used for this request. Specifies jobRing. 1813 * @param plaintext Input plaintext to encrypt 1814 * @param size Size of input data in bytes 1815 * @param iv Input initial block. 1816 * @param key Input key to use for encryption 1817 * @param[out] ciphertext Output ciphertext 1818 * @return Status from encrypt/decrypt operation 1819 */ 1820 status_t CAAM_DES_EncryptCfb(CAAM_Type *base, 1821 caam_handle_t *handle, 1822 const uint8_t *plaintext, 1823 uint8_t *ciphertext, 1824 size_t size, 1825 const uint8_t iv[CAAM_DES_IV_SIZE], 1826 const uint8_t key[CAAM_DES_KEY_SIZE]); 1827 1828 /*! 1829 * @brief Decrypts DES using CFB block mode. 1830 * 1831 * Decrypts DES using CFB block mode. 1832 * 1833 * @param base CAAM peripheral base address 1834 * @param handle Handle used for this request. Specifies jobRing. 1835 * @param ciphertext Input ciphertext to decrypt 1836 * @param[out] plaintext Output plaintext 1837 * @param size Size of input and output data in bytes 1838 * @param iv Input initial block. 1839 * @param key Input key to use for decryption 1840 * @return Status from encrypt/decrypt operation 1841 */ 1842 status_t CAAM_DES_DecryptCfb(CAAM_Type *base, 1843 caam_handle_t *handle, 1844 const uint8_t *ciphertext, 1845 uint8_t *plaintext, 1846 size_t size, 1847 const uint8_t iv[CAAM_DES_IV_SIZE], 1848 const uint8_t key[CAAM_DES_KEY_SIZE]); 1849 1850 /*! 1851 * @brief Encrypts DES using OFB block mode. 1852 * 1853 * Encrypts DES using OFB block mode. 1854 * 1855 * @param base CAAM peripheral base address 1856 * @param handle Handle used for this request. Specifies jobRing. 1857 * @param plaintext Input plaintext to encrypt 1858 * @param[out] ciphertext Output ciphertext 1859 * @param size Size of input and output data in bytes 1860 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 1861 * for each execution of the mode under the given key. 1862 * @param key Input key to use for encryption 1863 * @return Status from encrypt/decrypt operation 1864 */ 1865 status_t CAAM_DES_EncryptOfb(CAAM_Type *base, 1866 caam_handle_t *handle, 1867 const uint8_t *plaintext, 1868 uint8_t *ciphertext, 1869 size_t size, 1870 const uint8_t iv[CAAM_DES_IV_SIZE], 1871 const uint8_t key[CAAM_DES_KEY_SIZE]); 1872 1873 /*! 1874 * @brief Decrypts DES using OFB block mode. 1875 * 1876 * Decrypts DES using OFB block mode. 1877 * 1878 * @param base CAAM peripheral base address 1879 * @param handle Handle used for this request. Specifies jobRing. 1880 * @param ciphertext Input ciphertext to decrypt 1881 * @param[out] plaintext Output plaintext 1882 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 1883 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 1884 * for each execution of the mode under the given key. 1885 * @param key Input key to use for decryption 1886 * @return Status from encrypt/decrypt operation 1887 */ 1888 status_t CAAM_DES_DecryptOfb(CAAM_Type *base, 1889 caam_handle_t *handle, 1890 const uint8_t *ciphertext, 1891 uint8_t *plaintext, 1892 size_t size, 1893 const uint8_t iv[CAAM_DES_IV_SIZE], 1894 const uint8_t key[CAAM_DES_KEY_SIZE]); 1895 1896 /*! 1897 * @brief Encrypts triple DES using ECB block mode with two keys. 1898 * 1899 * Encrypts triple DES using ECB block mode with two keys. 1900 * 1901 * @param base CAAM peripheral base address 1902 * @param handle Handle used for this request. Specifies jobRing. 1903 * @param plaintext Input plaintext to encrypt 1904 * @param[out] ciphertext Output ciphertext 1905 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 1906 * @param key1 First input key for key bundle 1907 * @param key2 Second input key for key bundle 1908 * @return Status from encrypt/decrypt operation 1909 */ 1910 status_t CAAM_DES2_EncryptEcb(CAAM_Type *base, 1911 caam_handle_t *handle, 1912 const uint8_t *plaintext, 1913 uint8_t *ciphertext, 1914 size_t size, 1915 const uint8_t key1[CAAM_DES_KEY_SIZE], 1916 const uint8_t key2[CAAM_DES_KEY_SIZE]); 1917 1918 /*! 1919 * @brief Decrypts triple DES using ECB block mode with two keys. 1920 * 1921 * Decrypts triple DES using ECB block mode with two keys. 1922 * 1923 * @param base CAAM peripheral base address 1924 * @param handle Handle used for this request. Specifies jobRing. 1925 * @param ciphertext Input ciphertext to decrypt 1926 * @param[out] plaintext Output plaintext 1927 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 1928 * @param key1 First input key for key bundle 1929 * @param key2 Second input key for key bundle 1930 * @return Status from encrypt/decrypt operation 1931 */ 1932 status_t CAAM_DES2_DecryptEcb(CAAM_Type *base, 1933 caam_handle_t *handle, 1934 const uint8_t *ciphertext, 1935 uint8_t *plaintext, 1936 size_t size, 1937 const uint8_t key1[CAAM_DES_KEY_SIZE], 1938 const uint8_t key2[CAAM_DES_KEY_SIZE]); 1939 1940 /*! 1941 * @brief Encrypts triple DES using CBC block mode with two keys. 1942 * 1943 * Encrypts triple DES using CBC block mode with two keys. 1944 * 1945 * @param base CAAM peripheral base address 1946 * @param handle Handle used for this request. Specifies jobRing. 1947 * @param plaintext Input plaintext to encrypt 1948 * @param[out] ciphertext Output ciphertext 1949 * @param size Size of input and output data in bytes 1950 * @param iv Input initial vector to combine with the first plaintext block. 1951 * The iv does not need to be secret, but it must be unpredictable. 1952 * @param key1 First input key for key bundle 1953 * @param key2 Second input key for key bundle 1954 * @return Status from encrypt/decrypt operation 1955 */ 1956 status_t CAAM_DES2_EncryptCbc(CAAM_Type *base, 1957 caam_handle_t *handle, 1958 const uint8_t *plaintext, 1959 uint8_t *ciphertext, 1960 size_t size, 1961 const uint8_t iv[CAAM_DES_IV_SIZE], 1962 const uint8_t key1[CAAM_DES_KEY_SIZE], 1963 const uint8_t key2[CAAM_DES_KEY_SIZE]); 1964 1965 /*! 1966 * @brief Decrypts triple DES using CBC block mode with two keys. 1967 * 1968 * Decrypts triple DES using CBC block mode with two keys. 1969 * 1970 * @param base CAAM peripheral base address 1971 * @param handle Handle used for this request. Specifies jobRing. 1972 * @param ciphertext Input ciphertext to decrypt 1973 * @param[out] plaintext Output plaintext 1974 * @param size Size of input and output data in bytes 1975 * @param iv Input initial vector to combine with the first plaintext block. 1976 * The iv does not need to be secret, but it must be unpredictable. 1977 * @param key1 First input key for key bundle 1978 * @param key2 Second input key for key bundle 1979 * @return Status from encrypt/decrypt operation 1980 */ 1981 status_t CAAM_DES2_DecryptCbc(CAAM_Type *base, 1982 caam_handle_t *handle, 1983 const uint8_t *ciphertext, 1984 uint8_t *plaintext, 1985 size_t size, 1986 const uint8_t iv[CAAM_DES_IV_SIZE], 1987 const uint8_t key1[CAAM_DES_KEY_SIZE], 1988 const uint8_t key2[CAAM_DES_KEY_SIZE]); 1989 1990 /*! 1991 * @brief Encrypts triple DES using CFB block mode with two keys. 1992 * 1993 * Encrypts triple DES using CFB block mode with two keys. 1994 * 1995 * @param base CAAM peripheral base address 1996 * @param handle Handle used for this request. Specifies jobRing. 1997 * @param plaintext Input plaintext to encrypt 1998 * @param[out] ciphertext Output ciphertext 1999 * @param size Size of input and output data in bytes 2000 * @param iv Input initial block. 2001 * @param key1 First input key for key bundle 2002 * @param key2 Second input key for key bundle 2003 * @return Status from encrypt/decrypt operation 2004 */ 2005 status_t CAAM_DES2_EncryptCfb(CAAM_Type *base, 2006 caam_handle_t *handle, 2007 const uint8_t *plaintext, 2008 uint8_t *ciphertext, 2009 size_t size, 2010 const uint8_t iv[CAAM_DES_IV_SIZE], 2011 const uint8_t key1[CAAM_DES_KEY_SIZE], 2012 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2013 2014 /*! 2015 * @brief Decrypts triple DES using CFB block mode with two keys. 2016 * 2017 * Decrypts triple DES using CFB block mode with two keys. 2018 * 2019 * @param base CAAM peripheral base address 2020 * @param handle Handle used for this request. Specifies jobRing. 2021 * @param ciphertext Input ciphertext to decrypt 2022 * @param[out] plaintext Output plaintext 2023 * @param size Size of input and output data in bytes 2024 * @param iv Input initial block. 2025 * @param key1 First input key for key bundle 2026 * @param key2 Second input key for key bundle 2027 * @return Status from encrypt/decrypt operation 2028 */ 2029 status_t CAAM_DES2_DecryptCfb(CAAM_Type *base, 2030 caam_handle_t *handle, 2031 const uint8_t *ciphertext, 2032 uint8_t *plaintext, 2033 size_t size, 2034 const uint8_t iv[CAAM_DES_IV_SIZE], 2035 const uint8_t key1[CAAM_DES_KEY_SIZE], 2036 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2037 2038 /*! 2039 * @brief Encrypts triple DES using OFB block mode with two keys. 2040 * 2041 * Encrypts triple DES using OFB block mode with two keys. 2042 * 2043 * @param base CAAM peripheral base address 2044 * @param handle Handle used for this request. Specifies jobRing. 2045 * @param plaintext Input plaintext to encrypt 2046 * @param[out] ciphertext Output ciphertext 2047 * @param size Size of input and output data in bytes 2048 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2049 * for each execution of the mode under the given key. 2050 * @param key1 First input key for key bundle 2051 * @param key2 Second input key for key bundle 2052 * @return Status from encrypt/decrypt operation 2053 */ 2054 status_t CAAM_DES2_EncryptOfb(CAAM_Type *base, 2055 caam_handle_t *handle, 2056 const uint8_t *plaintext, 2057 uint8_t *ciphertext, 2058 size_t size, 2059 const uint8_t iv[CAAM_DES_IV_SIZE], 2060 const uint8_t key1[CAAM_DES_KEY_SIZE], 2061 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2062 2063 /*! 2064 * @brief Decrypts triple DES using OFB block mode with two keys. 2065 * 2066 * Decrypts triple DES using OFB block mode with two keys. 2067 * 2068 * @param base CAAM peripheral base address 2069 * @param handle Handle used for this request. Specifies jobRing. 2070 * @param ciphertext Input ciphertext to decrypt 2071 * @param[out] plaintext Output plaintext 2072 * @param size Size of input and output data in bytes 2073 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2074 * for each execution of the mode under the given key. 2075 * @param key1 First input key for key bundle 2076 * @param key2 Second input key for key bundle 2077 * @return Status from encrypt/decrypt operation 2078 */ 2079 status_t CAAM_DES2_DecryptOfb(CAAM_Type *base, 2080 caam_handle_t *handle, 2081 const uint8_t *ciphertext, 2082 uint8_t *plaintext, 2083 size_t size, 2084 const uint8_t iv[CAAM_DES_IV_SIZE], 2085 const uint8_t key1[CAAM_DES_KEY_SIZE], 2086 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2087 2088 /*! 2089 * @brief Encrypts triple DES using ECB block mode with three keys. 2090 * 2091 * Encrypts triple DES using ECB block mode with three keys. 2092 * 2093 * @param base CAAM peripheral base address 2094 * @param handle Handle used for this request. Specifies jobRing. 2095 * @param plaintext Input plaintext to encrypt 2096 * @param[out] ciphertext Output ciphertext 2097 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2098 * @param key1 First input key for key bundle 2099 * @param key2 Second input key for key bundle 2100 * @param key3 Third input key for key bundle 2101 * @return Status from encrypt/decrypt operation 2102 */ 2103 status_t CAAM_DES3_EncryptEcb(CAAM_Type *base, 2104 caam_handle_t *handle, 2105 const uint8_t *plaintext, 2106 uint8_t *ciphertext, 2107 size_t size, 2108 const uint8_t key1[CAAM_DES_KEY_SIZE], 2109 const uint8_t key2[CAAM_DES_KEY_SIZE], 2110 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2111 2112 /*! 2113 * @brief Decrypts triple DES using ECB block mode with three keys. 2114 * 2115 * Decrypts triple DES using ECB block mode with three keys. 2116 * 2117 * @param base CAAM peripheral base address 2118 * @param handle Handle used for this request. Specifies jobRing. 2119 * @param ciphertext Input ciphertext to decrypt 2120 * @param[out] plaintext Output plaintext 2121 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2122 * @param key1 First input key for key bundle 2123 * @param key2 Second input key for key bundle 2124 * @param key3 Third input key for key bundle 2125 * @return Status from encrypt/decrypt operation 2126 */ 2127 status_t CAAM_DES3_DecryptEcb(CAAM_Type *base, 2128 caam_handle_t *handle, 2129 const uint8_t *ciphertext, 2130 uint8_t *plaintext, 2131 size_t size, 2132 const uint8_t key1[CAAM_DES_KEY_SIZE], 2133 const uint8_t key2[CAAM_DES_KEY_SIZE], 2134 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2135 2136 /*! 2137 * @brief Encrypts triple DES using CBC block mode with three keys. 2138 * 2139 * Encrypts triple DES using CBC block mode with three keys. 2140 * 2141 * @param base CAAM peripheral base address 2142 * @param handle Handle used for this request. Specifies jobRing. 2143 * @param plaintext Input plaintext to encrypt 2144 * @param[out] ciphertext Output ciphertext 2145 * @param size Size of input data in bytes 2146 * @param iv Input initial vector to combine with the first plaintext block. 2147 * The iv does not need to be secret, but it must be unpredictable. 2148 * @param key1 First input key for key bundle 2149 * @param key2 Second input key for key bundle 2150 * @param key3 Third input key for key bundle 2151 * @return Status from encrypt/decrypt operation 2152 */ 2153 status_t CAAM_DES3_EncryptCbc(CAAM_Type *base, 2154 caam_handle_t *handle, 2155 const uint8_t *plaintext, 2156 uint8_t *ciphertext, 2157 size_t size, 2158 const uint8_t iv[CAAM_DES_IV_SIZE], 2159 const uint8_t key1[CAAM_DES_KEY_SIZE], 2160 const uint8_t key2[CAAM_DES_KEY_SIZE], 2161 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2162 2163 /*! 2164 * @brief Decrypts triple DES using CBC block mode with three keys. 2165 * 2166 * Decrypts triple DES using CBC block mode with three keys. 2167 * 2168 * @param base CAAM peripheral base address 2169 * @param handle Handle used for this request. Specifies jobRing. 2170 * @param ciphertext Input ciphertext to decrypt 2171 * @param[out] plaintext Output plaintext 2172 * @param size Size of input and output data in bytes 2173 * @param iv Input initial vector to combine with the first plaintext block. 2174 * The iv does not need to be secret, but it must be unpredictable. 2175 * @param key1 First input key for key bundle 2176 * @param key2 Second input key for key bundle 2177 * @param key3 Third input key for key bundle 2178 * @return Status from encrypt/decrypt operation 2179 */ 2180 status_t CAAM_DES3_DecryptCbc(CAAM_Type *base, 2181 caam_handle_t *handle, 2182 const uint8_t *ciphertext, 2183 uint8_t *plaintext, 2184 size_t size, 2185 const uint8_t iv[CAAM_DES_IV_SIZE], 2186 const uint8_t key1[CAAM_DES_KEY_SIZE], 2187 const uint8_t key2[CAAM_DES_KEY_SIZE], 2188 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2189 2190 /*! 2191 * @brief Encrypts triple DES using CFB block mode with three keys. 2192 * 2193 * Encrypts triple DES using CFB block mode with three keys. 2194 * 2195 * @param base CAAM peripheral base address 2196 * @param handle Handle used for this request. Specifies jobRing. 2197 * @param plaintext Input plaintext to encrypt 2198 * @param[out] ciphertext Output ciphertext 2199 * @param size Size of input and ouput data in bytes 2200 * @param iv Input initial block. 2201 * @param key1 First input key for key bundle 2202 * @param key2 Second input key for key bundle 2203 * @param key3 Third input key for key bundle 2204 * @return Status from encrypt/decrypt operation 2205 */ 2206 status_t CAAM_DES3_EncryptCfb(CAAM_Type *base, 2207 caam_handle_t *handle, 2208 const uint8_t *plaintext, 2209 uint8_t *ciphertext, 2210 size_t size, 2211 const uint8_t iv[CAAM_DES_IV_SIZE], 2212 const uint8_t key1[CAAM_DES_KEY_SIZE], 2213 const uint8_t key2[CAAM_DES_KEY_SIZE], 2214 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2215 2216 /*! 2217 * @brief Decrypts triple DES using CFB block mode with three keys. 2218 * 2219 * Decrypts triple DES using CFB block mode with three keys. 2220 * 2221 * @param base CAAM peripheral base address 2222 * @param handle Handle used for this request. Specifies jobRing. 2223 * @param ciphertext Input ciphertext to decrypt 2224 * @param[out] plaintext Output plaintext 2225 * @param size Size of input data in bytes 2226 * @param iv Input initial block. 2227 * @param key1 First input key for key bundle 2228 * @param key2 Second input key for key bundle 2229 * @param key3 Third input key for key bundle 2230 * @return Status from encrypt/decrypt operation 2231 */ 2232 status_t CAAM_DES3_DecryptCfb(CAAM_Type *base, 2233 caam_handle_t *handle, 2234 const uint8_t *ciphertext, 2235 uint8_t *plaintext, 2236 size_t size, 2237 const uint8_t iv[CAAM_DES_IV_SIZE], 2238 const uint8_t key1[CAAM_DES_KEY_SIZE], 2239 const uint8_t key2[CAAM_DES_KEY_SIZE], 2240 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2241 2242 /*! 2243 * @brief Encrypts triple DES using OFB block mode with three keys. 2244 * 2245 * Encrypts triple DES using OFB block mode with three keys. 2246 * 2247 * @param base CAAM peripheral base address 2248 * @param handle Handle used for this request. Specifies jobRing. 2249 * @param plaintext Input plaintext to encrypt 2250 * @param[out] ciphertext Output ciphertext 2251 * @param size Size of input and output data in bytes 2252 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2253 * for each execution of the mode under the given key. 2254 * @param key1 First input key for key bundle 2255 * @param key2 Second input key for key bundle 2256 * @param key3 Third input key for key bundle 2257 * @return Status from encrypt/decrypt operation 2258 */ 2259 status_t CAAM_DES3_EncryptOfb(CAAM_Type *base, 2260 caam_handle_t *handle, 2261 const uint8_t *plaintext, 2262 uint8_t *ciphertext, 2263 size_t size, 2264 const uint8_t iv[CAAM_DES_IV_SIZE], 2265 const uint8_t key1[CAAM_DES_KEY_SIZE], 2266 const uint8_t key2[CAAM_DES_KEY_SIZE], 2267 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2268 2269 /*! 2270 * @brief Decrypts triple DES using OFB block mode with three keys. 2271 * 2272 * Decrypts triple DES using OFB block mode with three keys. 2273 * 2274 * @param base CAAM peripheral base address 2275 * @param handle Handle used for this request. Specifies jobRing. 2276 * @param ciphertext Input ciphertext to decrypt 2277 * @param[out] plaintext Output plaintext 2278 * @param size Size of input and output data in bytes 2279 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2280 * for each execution of the mode under the given key. 2281 * @param key1 First input key for key bundle 2282 * @param key2 Second input key for key bundle 2283 * @param key3 Third input key for key bundle 2284 * @return Status from encrypt/decrypt operation 2285 */ 2286 status_t CAAM_DES3_DecryptOfb(CAAM_Type *base, 2287 caam_handle_t *handle, 2288 const uint8_t *ciphertext, 2289 uint8_t *plaintext, 2290 size_t size, 2291 const uint8_t iv[CAAM_DES_IV_SIZE], 2292 const uint8_t key1[CAAM_DES_KEY_SIZE], 2293 const uint8_t key2[CAAM_DES_KEY_SIZE], 2294 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2295 2296 /*! 2297 *@} 2298 */ /* end of caam_driver_des */ 2299 2300 /*! 2301 * @addtogroup caam_nonblocking_driver_des 2302 * @{ 2303 */ 2304 2305 /*! 2306 * @brief Encrypts DES using ECB block mode. 2307 * 2308 * Encrypts DES using ECB block mode. 2309 * 2310 * @param base CAAM peripheral base address 2311 * @param handle Handle used for this request. Specifies jobRing. 2312 * @param[out] descriptor memory for CAAM commands 2313 * @param plaintext Input plaintext to encrypt 2314 * @param[out] ciphertext Output ciphertext 2315 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2316 * @param key Input key to use for encryption 2317 * @return Status from descriptor push 2318 */ 2319 status_t CAAM_DES_EncryptEcbNonBlocking(CAAM_Type *base, 2320 caam_handle_t *handle, 2321 caam_desc_cipher_des_t descriptor, 2322 const uint8_t *plaintext, 2323 uint8_t *ciphertext, 2324 size_t size, 2325 const uint8_t key[CAAM_DES_KEY_SIZE]); 2326 2327 /*! 2328 * @brief Decrypts DES using ECB block mode. 2329 * 2330 * Decrypts DES using ECB block mode. 2331 * 2332 * @param base CAAM peripheral base address 2333 * @param handle Handle used for this request. Specifies jobRing. 2334 * @param[out] descriptor memory for CAAM commands 2335 * @param ciphertext Input ciphertext to decrypt 2336 * @param[out] plaintext Output plaintext 2337 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2338 * @param key Input key to use for decryption 2339 * @return Status from descriptor push 2340 */ 2341 status_t CAAM_DES_DecryptEcbNonBlocking(CAAM_Type *base, 2342 caam_handle_t *handle, 2343 caam_desc_cipher_des_t descriptor, 2344 const uint8_t *ciphertext, 2345 uint8_t *plaintext, 2346 size_t size, 2347 const uint8_t key[CAAM_DES_KEY_SIZE]); 2348 2349 /*! 2350 * @brief Encrypts DES using CBC block mode. 2351 * 2352 * Encrypts DES using CBC block mode. 2353 * 2354 * @param base CAAM peripheral base address 2355 * @param handle Handle used for this request. Specifies jobRing. 2356 * @param[out] descriptor memory for CAAM commands 2357 * @param plaintext Input plaintext to encrypt 2358 * @param[out] ciphertext Ouput ciphertext 2359 * @param size Size of input and output data in bytes 2360 * @param iv Input initial vector to combine with the first plaintext block. 2361 * The iv does not need to be secret, but it must be unpredictable. 2362 * @param key Input key to use for encryption 2363 * @return Status from descriptor push 2364 */ 2365 status_t CAAM_DES_EncryptCbcNonBlocking(CAAM_Type *base, 2366 caam_handle_t *handle, 2367 caam_desc_cipher_des_t descriptor, 2368 const uint8_t *plaintext, 2369 uint8_t *ciphertext, 2370 size_t size, 2371 const uint8_t iv[CAAM_DES_IV_SIZE], 2372 const uint8_t key[CAAM_DES_KEY_SIZE]); 2373 2374 /*! 2375 * @brief Decrypts DES using CBC block mode. 2376 * 2377 * Decrypts DES using CBC block mode. 2378 * 2379 * @param base CAAM peripheral base address 2380 * @param handle Handle used for this request. Specifies jobRing. 2381 * @param[out] descriptor memory for CAAM commands 2382 * @param ciphertext Input ciphertext to decrypt 2383 * @param[out] plaintext Output plaintext 2384 * @param size Size of input data in bytes 2385 * @param iv Input initial vector to combine with the first plaintext block. 2386 * The iv does not need to be secret, but it must be unpredictable. 2387 * @param key Input key to use for decryption 2388 * @return Status from descriptor push 2389 */ 2390 status_t CAAM_DES_DecryptCbcNonBlocking(CAAM_Type *base, 2391 caam_handle_t *handle, 2392 caam_desc_cipher_des_t descriptor, 2393 const uint8_t *ciphertext, 2394 uint8_t *plaintext, 2395 size_t size, 2396 const uint8_t iv[CAAM_DES_IV_SIZE], 2397 const uint8_t key[CAAM_DES_KEY_SIZE]); 2398 2399 /*! 2400 * @brief Encrypts DES using CFB block mode. 2401 * 2402 * Encrypts DES using CFB block mode. 2403 * 2404 * @param base CAAM peripheral base address 2405 * @param handle Handle used for this request. Specifies jobRing. 2406 * @param[out] descriptor memory for CAAM commands 2407 * @param plaintext Input plaintext to encrypt 2408 * @param size Size of input data in bytes 2409 * @param iv Input initial block. 2410 * @param key Input key to use for encryption 2411 * @param[out] ciphertext Output ciphertext 2412 * @return Status from descriptor push 2413 */ 2414 status_t CAAM_DES_EncryptCfbNonBlocking(CAAM_Type *base, 2415 caam_handle_t *handle, 2416 caam_desc_cipher_des_t descriptor, 2417 const uint8_t *plaintext, 2418 uint8_t *ciphertext, 2419 size_t size, 2420 const uint8_t iv[CAAM_DES_IV_SIZE], 2421 const uint8_t key[CAAM_DES_KEY_SIZE]); 2422 2423 /*! 2424 * @brief Decrypts DES using CFB block mode. 2425 * 2426 * Decrypts DES using CFB block mode. 2427 * 2428 * @param base CAAM peripheral base address 2429 * @param handle Handle used for this request. Specifies jobRing. 2430 * @param[out] descriptor memory for CAAM commands 2431 * @param ciphertext Input ciphertext to decrypt 2432 * @param[out] plaintext Output plaintext 2433 * @param size Size of input and output data in bytes 2434 * @param iv Input initial block. 2435 * @param key Input key to use for decryption 2436 * @return Status from descriptor push 2437 */ 2438 status_t CAAM_DES_DecryptCfbNonBlocking(CAAM_Type *base, 2439 caam_handle_t *handle, 2440 caam_desc_cipher_des_t descriptor, 2441 const uint8_t *ciphertext, 2442 uint8_t *plaintext, 2443 size_t size, 2444 const uint8_t iv[CAAM_DES_IV_SIZE], 2445 const uint8_t key[CAAM_DES_KEY_SIZE]); 2446 2447 /*! 2448 * @brief Encrypts DES using OFB block mode. 2449 * 2450 * Encrypts DES using OFB block mode. 2451 * 2452 * @param base CAAM peripheral base address 2453 * @param handle Handle used for this request. Specifies jobRing. 2454 * @param[out] descriptor memory for CAAM commands 2455 * @param plaintext Input plaintext to encrypt 2456 * @param[out] ciphertext Output ciphertext 2457 * @param size Size of input and output data in bytes 2458 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2459 * for each execution of the mode under the given key. 2460 * @param key Input key to use for encryption 2461 * @return Status from descriptor push 2462 */ 2463 status_t CAAM_DES_EncryptOfbNonBlocking(CAAM_Type *base, 2464 caam_handle_t *handle, 2465 caam_desc_cipher_des_t descriptor, 2466 const uint8_t *plaintext, 2467 uint8_t *ciphertext, 2468 size_t size, 2469 const uint8_t iv[CAAM_DES_IV_SIZE], 2470 const uint8_t key[CAAM_DES_KEY_SIZE]); 2471 2472 /*! 2473 * @brief Decrypts DES using OFB block mode. 2474 * 2475 * Decrypts DES using OFB block mode. 2476 * 2477 * @param base CAAM peripheral base address 2478 * @param handle Handle used for this request. Specifies jobRing. 2479 * @param[out] descriptor memory for CAAM commands 2480 * @param ciphertext Input ciphertext to decrypt 2481 * @param[out] plaintext Output plaintext 2482 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2483 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2484 * for each execution of the mode under the given key. 2485 * @param key Input key to use for decryption 2486 * @return Status from descriptor push 2487 */ 2488 status_t CAAM_DES_DecryptOfbNonBlocking(CAAM_Type *base, 2489 caam_handle_t *handle, 2490 caam_desc_cipher_des_t descriptor, 2491 const uint8_t *ciphertext, 2492 uint8_t *plaintext, 2493 size_t size, 2494 const uint8_t iv[CAAM_DES_IV_SIZE], 2495 const uint8_t key[CAAM_DES_KEY_SIZE]); 2496 2497 /*! 2498 * @brief Encrypts triple DES using ECB block mode with two keys. 2499 * 2500 * Encrypts triple DES using ECB block mode with two keys. 2501 * 2502 * @param base CAAM peripheral base address 2503 * @param handle Handle used for this request. Specifies jobRing. 2504 * @param[out] descriptor memory for CAAM commands 2505 * @param plaintext Input plaintext to encrypt 2506 * @param[out] ciphertext Output ciphertext 2507 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2508 * @param key1 First input key for key bundle 2509 * @param key2 Second input key for key bundle 2510 * @return Status from descriptor push 2511 */ 2512 status_t CAAM_DES2_EncryptEcbNonBlocking(CAAM_Type *base, 2513 caam_handle_t *handle, 2514 caam_desc_cipher_des_t descriptor, 2515 const uint8_t *plaintext, 2516 uint8_t *ciphertext, 2517 size_t size, 2518 const uint8_t key1[CAAM_DES_KEY_SIZE], 2519 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2520 2521 /*! 2522 * @brief Decrypts triple DES using ECB block mode with two keys. 2523 * 2524 * Decrypts triple DES using ECB block mode with two keys. 2525 * 2526 * @param base CAAM peripheral base address 2527 * @param handle Handle used for this request. Specifies jobRing. 2528 * @param[out] descriptor memory for CAAM commands 2529 * @param ciphertext Input ciphertext to decrypt 2530 * @param[out] plaintext Output plaintext 2531 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2532 * @param key1 First input key for key bundle 2533 * @param key2 Second input key for key bundle 2534 * @return Status from descriptor push 2535 */ 2536 status_t CAAM_DES2_DecryptEcbNonBlocking(CAAM_Type *base, 2537 caam_handle_t *handle, 2538 caam_desc_cipher_des_t descriptor, 2539 const uint8_t *ciphertext, 2540 uint8_t *plaintext, 2541 size_t size, 2542 const uint8_t key1[CAAM_DES_KEY_SIZE], 2543 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2544 2545 /*! 2546 * @brief Encrypts triple DES using CBC block mode with two keys. 2547 * 2548 * Encrypts triple DES using CBC block mode with two keys. 2549 * 2550 * @param base CAAM peripheral base address 2551 * @param handle Handle used for this request. Specifies jobRing. 2552 * @param[out] descriptor memory for CAAM commands 2553 * @param plaintext Input plaintext to encrypt 2554 * @param[out] ciphertext Output ciphertext 2555 * @param size Size of input and output data in bytes 2556 * @param iv Input initial vector to combine with the first plaintext block. 2557 * The iv does not need to be secret, but it must be unpredictable. 2558 * @param key1 First input key for key bundle 2559 * @param key2 Second input key for key bundle 2560 * @return Status from descriptor push 2561 */ 2562 status_t CAAM_DES2_EncryptCbcNonBlocking(CAAM_Type *base, 2563 caam_handle_t *handle, 2564 caam_desc_cipher_des_t descriptor, 2565 const uint8_t *plaintext, 2566 uint8_t *ciphertext, 2567 size_t size, 2568 const uint8_t iv[CAAM_DES_IV_SIZE], 2569 const uint8_t key1[CAAM_DES_KEY_SIZE], 2570 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2571 2572 /*! 2573 * @brief Decrypts triple DES using CBC block mode with two keys. 2574 * 2575 * Decrypts triple DES using CBC block mode with two keys. 2576 * 2577 * @param base CAAM peripheral base address 2578 * @param handle Handle used for this request. Specifies jobRing. 2579 * @param[out] descriptor memory for CAAM commands 2580 * @param ciphertext Input ciphertext to decrypt 2581 * @param[out] plaintext Output plaintext 2582 * @param size Size of input and output data in bytes 2583 * @param iv Input initial vector to combine with the first plaintext block. 2584 * The iv does not need to be secret, but it must be unpredictable. 2585 * @param key1 First input key for key bundle 2586 * @param key2 Second input key for key bundle 2587 * @return Status from descriptor push 2588 */ 2589 status_t CAAM_DES2_DecryptCbcNonBlocking(CAAM_Type *base, 2590 caam_handle_t *handle, 2591 caam_desc_cipher_des_t descriptor, 2592 const uint8_t *ciphertext, 2593 uint8_t *plaintext, 2594 size_t size, 2595 const uint8_t iv[CAAM_DES_IV_SIZE], 2596 const uint8_t key1[CAAM_DES_KEY_SIZE], 2597 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2598 2599 /*! 2600 * @brief Encrypts triple DES using CFB block mode with two keys. 2601 * 2602 * Encrypts triple DES using CFB block mode with two keys. 2603 * 2604 * @param base CAAM peripheral base address 2605 * @param handle Handle used for this request. Specifies jobRing. 2606 * @param[out] descriptor memory for CAAM commands 2607 * @param plaintext Input plaintext to encrypt 2608 * @param[out] ciphertext Output ciphertext 2609 * @param size Size of input and output data in bytes 2610 * @param iv Input initial block. 2611 * @param key1 First input key for key bundle 2612 * @param key2 Second input key for key bundle 2613 * @return Status from descriptor push 2614 */ 2615 status_t CAAM_DES2_EncryptCfbNonBlocking(CAAM_Type *base, 2616 caam_handle_t *handle, 2617 caam_desc_cipher_des_t descriptor, 2618 const uint8_t *plaintext, 2619 uint8_t *ciphertext, 2620 size_t size, 2621 const uint8_t iv[CAAM_DES_IV_SIZE], 2622 const uint8_t key1[CAAM_DES_KEY_SIZE], 2623 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2624 2625 /*! 2626 * @brief Decrypts triple DES using CFB block mode with two keys. 2627 * 2628 * Decrypts triple DES using CFB block mode with two keys. 2629 * 2630 * @param base CAAM peripheral base address 2631 * @param handle Handle used for this request. Specifies jobRing. 2632 * @param[out] descriptor memory for CAAM commands 2633 * @param ciphertext Input ciphertext to decrypt 2634 * @param[out] plaintext Output plaintext 2635 * @param size Size of input and output data in bytes 2636 * @param iv Input initial block. 2637 * @param key1 First input key for key bundle 2638 * @param key2 Second input key for key bundle 2639 * @return Status from descriptor push 2640 */ 2641 status_t CAAM_DES2_DecryptCfbNonBlocking(CAAM_Type *base, 2642 caam_handle_t *handle, 2643 caam_desc_cipher_des_t descriptor, 2644 const uint8_t *ciphertext, 2645 uint8_t *plaintext, 2646 size_t size, 2647 const uint8_t iv[CAAM_DES_IV_SIZE], 2648 const uint8_t key1[CAAM_DES_KEY_SIZE], 2649 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2650 2651 /*! 2652 * @brief Encrypts triple DES using OFB block mode with two keys. 2653 * 2654 * Encrypts triple DES using OFB block mode with two keys. 2655 * 2656 * @param base CAAM peripheral base address 2657 * @param handle Handle used for this request. Specifies jobRing. 2658 * @param[out] descriptor memory for CAAM commands 2659 * @param plaintext Input plaintext to encrypt 2660 * @param[out] ciphertext Output ciphertext 2661 * @param size Size of input and output data in bytes 2662 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2663 * for each execution of the mode under the given key. 2664 * @param key1 First input key for key bundle 2665 * @param key2 Second input key for key bundle 2666 * @return Status from descriptor push 2667 */ 2668 status_t CAAM_DES2_EncryptOfbNonBlocking(CAAM_Type *base, 2669 caam_handle_t *handle, 2670 caam_desc_cipher_des_t descriptor, 2671 const uint8_t *plaintext, 2672 uint8_t *ciphertext, 2673 size_t size, 2674 const uint8_t iv[CAAM_DES_IV_SIZE], 2675 const uint8_t key1[CAAM_DES_KEY_SIZE], 2676 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2677 2678 /*! 2679 * @brief Decrypts triple DES using OFB block mode with two keys. 2680 * 2681 * Decrypts triple DES using OFB block mode with two keys. 2682 * 2683 * @param base CAAM peripheral base address 2684 * @param handle Handle used for this request. Specifies jobRing. 2685 * @param[out] descriptor memory for CAAM commands 2686 * @param ciphertext Input ciphertext to decrypt 2687 * @param[out] plaintext Output plaintext 2688 * @param size Size of input and output data in bytes 2689 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2690 * for each execution of the mode under the given key. 2691 * @param key1 First input key for key bundle 2692 * @param key2 Second input key for key bundle 2693 * @return Status from descriptor push 2694 */ 2695 status_t CAAM_DES2_DecryptOfbNonBlocking(CAAM_Type *base, 2696 caam_handle_t *handle, 2697 caam_desc_cipher_des_t descriptor, 2698 const uint8_t *ciphertext, 2699 uint8_t *plaintext, 2700 size_t size, 2701 const uint8_t iv[CAAM_DES_IV_SIZE], 2702 const uint8_t key1[CAAM_DES_KEY_SIZE], 2703 const uint8_t key2[CAAM_DES_KEY_SIZE]); 2704 2705 /*! 2706 * @brief Encrypts triple DES using ECB block mode with three keys. 2707 * 2708 * Encrypts triple DES using ECB block mode with three keys. 2709 * 2710 * @param base CAAM peripheral base address 2711 * @param handle Handle used for this request. Specifies jobRing. 2712 * @param[out] descriptor memory for CAAM commands 2713 * @param plaintext Input plaintext to encrypt 2714 * @param[out] ciphertext Output ciphertext 2715 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2716 * @param key1 First input key for key bundle 2717 * @param key2 Second input key for key bundle 2718 * @param key3 Third input key for key bundle 2719 * @return Status from descriptor push 2720 */ 2721 status_t CAAM_DES3_EncryptEcbNonBlocking(CAAM_Type *base, 2722 caam_handle_t *handle, 2723 caam_desc_cipher_des_t descriptor, 2724 const uint8_t *plaintext, 2725 uint8_t *ciphertext, 2726 size_t size, 2727 const uint8_t key1[CAAM_DES_KEY_SIZE], 2728 const uint8_t key2[CAAM_DES_KEY_SIZE], 2729 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2730 2731 /*! 2732 * @brief Decrypts triple DES using ECB block mode with three keys. 2733 * 2734 * Decrypts triple DES using ECB block mode with three keys. 2735 * 2736 * @param base CAAM peripheral base address 2737 * @param handle Handle used for this request. Specifies jobRing. 2738 * @param[out] descriptor memory for CAAM commands 2739 * @param ciphertext Input ciphertext to decrypt 2740 * @param[out] plaintext Output plaintext 2741 * @param size Size of input and output data in bytes. Must be multiple of 8 bytes. 2742 * @param key1 First input key for key bundle 2743 * @param key2 Second input key for key bundle 2744 * @param key3 Third input key for key bundle 2745 * @return Status from descriptor push 2746 */ 2747 status_t CAAM_DES3_DecryptEcbNonBlocking(CAAM_Type *base, 2748 caam_handle_t *handle, 2749 caam_desc_cipher_des_t descriptor, 2750 const uint8_t *ciphertext, 2751 uint8_t *plaintext, 2752 size_t size, 2753 const uint8_t key1[CAAM_DES_KEY_SIZE], 2754 const uint8_t key2[CAAM_DES_KEY_SIZE], 2755 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2756 2757 /*! 2758 * @brief Encrypts triple DES using CBC block mode with three keys. 2759 * 2760 * Encrypts triple DES using CBC block mode with three keys. 2761 * 2762 * @param base CAAM peripheral base address 2763 * @param handle Handle used for this request. Specifies jobRing. 2764 * @param[out] descriptor memory for CAAM commands 2765 * @param plaintext Input plaintext to encrypt 2766 * @param[out] ciphertext Output ciphertext 2767 * @param size Size of input data in bytes 2768 * @param iv Input initial vector to combine with the first plaintext block. 2769 * The iv does not need to be secret, but it must be unpredictable. 2770 * @param key1 First input key for key bundle 2771 * @param key2 Second input key for key bundle 2772 * @param key3 Third input key for key bundle 2773 * @return Status from descriptor push 2774 */ 2775 status_t CAAM_DES3_EncryptCbcNonBlocking(CAAM_Type *base, 2776 caam_handle_t *handle, 2777 caam_desc_cipher_des_t descriptor, 2778 const uint8_t *plaintext, 2779 uint8_t *ciphertext, 2780 size_t size, 2781 const uint8_t iv[CAAM_DES_IV_SIZE], 2782 const uint8_t key1[CAAM_DES_KEY_SIZE], 2783 const uint8_t key2[CAAM_DES_KEY_SIZE], 2784 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2785 2786 /*! 2787 * @brief Decrypts triple DES using CBC block mode with three keys. 2788 * 2789 * Decrypts triple DES using CBC block mode with three keys. 2790 * 2791 * @param base CAAM peripheral base address 2792 * @param handle Handle used for this request. Specifies jobRing. 2793 * @param[out] descriptor memory for CAAM commands 2794 * @param ciphertext Input ciphertext to decrypt 2795 * @param[out] plaintext Output plaintext 2796 * @param size Size of input and output data in bytes 2797 * @param iv Input initial vector to combine with the first plaintext block. 2798 * The iv does not need to be secret, but it must be unpredictable. 2799 * @param key1 First input key for key bundle 2800 * @param key2 Second input key for key bundle 2801 * @param key3 Third input key for key bundle 2802 * @return Status from descriptor push 2803 */ 2804 status_t CAAM_DES3_DecryptCbcNonBlocking(CAAM_Type *base, 2805 caam_handle_t *handle, 2806 caam_desc_cipher_des_t descriptor, 2807 const uint8_t *ciphertext, 2808 uint8_t *plaintext, 2809 size_t size, 2810 const uint8_t iv[CAAM_DES_IV_SIZE], 2811 const uint8_t key1[CAAM_DES_KEY_SIZE], 2812 const uint8_t key2[CAAM_DES_KEY_SIZE], 2813 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2814 2815 /*! 2816 * @brief Encrypts triple DES using CFB block mode with three keys. 2817 * 2818 * Encrypts triple DES using CFB block mode with three keys. 2819 * 2820 * @param base CAAM peripheral base address 2821 * @param handle Handle used for this request. Specifies jobRing. 2822 * @param[out] descriptor memory for CAAM commands 2823 * @param plaintext Input plaintext to encrypt 2824 * @param[out] ciphertext Output ciphertext 2825 * @param size Size of input and ouput data in bytes 2826 * @param iv Input initial block. 2827 * @param key1 First input key for key bundle 2828 * @param key2 Second input key for key bundle 2829 * @param key3 Third input key for key bundle 2830 * @return Status from descriptor push 2831 */ 2832 status_t CAAM_DES3_EncryptCfbNonBlocking(CAAM_Type *base, 2833 caam_handle_t *handle, 2834 caam_desc_cipher_des_t descriptor, 2835 const uint8_t *plaintext, 2836 uint8_t *ciphertext, 2837 size_t size, 2838 const uint8_t iv[CAAM_DES_IV_SIZE], 2839 const uint8_t key1[CAAM_DES_KEY_SIZE], 2840 const uint8_t key2[CAAM_DES_KEY_SIZE], 2841 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2842 2843 /*! 2844 * @brief Decrypts triple DES using CFB block mode with three keys. 2845 * 2846 * Decrypts triple DES using CFB block mode with three keys. 2847 * 2848 * @param base CAAM peripheral base address 2849 * @param handle Handle used for this request. Specifies jobRing. 2850 * @param[out] descriptor memory for CAAM commands 2851 * @param ciphertext Input ciphertext to decrypt 2852 * @param[out] plaintext Output plaintext 2853 * @param size Size of input data in bytes 2854 * @param iv Input initial block. 2855 * @param key1 First input key for key bundle 2856 * @param key2 Second input key for key bundle 2857 * @param key3 Third input key for key bundle 2858 * @return Status from descriptor push 2859 */ 2860 status_t CAAM_DES3_DecryptCfbNonBlocking(CAAM_Type *base, 2861 caam_handle_t *handle, 2862 caam_desc_cipher_des_t descriptor, 2863 const uint8_t *ciphertext, 2864 uint8_t *plaintext, 2865 size_t size, 2866 const uint8_t iv[CAAM_DES_IV_SIZE], 2867 const uint8_t key1[CAAM_DES_KEY_SIZE], 2868 const uint8_t key2[CAAM_DES_KEY_SIZE], 2869 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2870 2871 /*! 2872 * @brief Encrypts triple DES using OFB block mode with three keys. 2873 * 2874 * Encrypts triple DES using OFB block mode with three keys. 2875 * 2876 * @param base CAAM peripheral base address 2877 * @param handle Handle used for this request. Specifies jobRing. 2878 * @param[out] descriptor memory for CAAM commands 2879 * @param plaintext Input plaintext to encrypt 2880 * @param[out] ciphertext Output ciphertext 2881 * @param size Size of input and output data in bytes 2882 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2883 * for each execution of the mode under the given key. 2884 * @param key1 First input key for key bundle 2885 * @param key2 Second input key for key bundle 2886 * @param key3 Third input key for key bundle 2887 * @return Status from descriptor push 2888 */ 2889 status_t CAAM_DES3_EncryptOfbNonBlocking(CAAM_Type *base, 2890 caam_handle_t *handle, 2891 caam_desc_cipher_des_t descriptor, 2892 const uint8_t *plaintext, 2893 uint8_t *ciphertext, 2894 size_t size, 2895 const uint8_t iv[CAAM_DES_IV_SIZE], 2896 const uint8_t key1[CAAM_DES_KEY_SIZE], 2897 const uint8_t key2[CAAM_DES_KEY_SIZE], 2898 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2899 2900 /*! 2901 * @brief Decrypts triple DES using OFB block mode with three keys. 2902 * 2903 * Decrypts triple DES using OFB block mode with three keys. 2904 * 2905 * @param base CAAM peripheral base address 2906 * @param handle Handle used for this request. Specifies jobRing. 2907 * @param[out] descriptor memory for CAAM commands 2908 * @param ciphertext Input ciphertext to decrypt 2909 * @param[out] plaintext Output plaintext 2910 * @param size Size of input and output data in bytes 2911 * @param iv Input unique input vector. The OFB mode requires that the IV be unique 2912 * for each execution of the mode under the given key. 2913 * @param key1 First input key for key bundle 2914 * @param key2 Second input key for key bundle 2915 * @param key3 Third input key for key bundle 2916 * @return Status from descriptor push 2917 */ 2918 status_t CAAM_DES3_DecryptOfbNonBlocking(CAAM_Type *base, 2919 caam_handle_t *handle, 2920 caam_desc_cipher_des_t descriptor, 2921 const uint8_t *ciphertext, 2922 uint8_t *plaintext, 2923 size_t size, 2924 const uint8_t iv[CAAM_DES_IV_SIZE], 2925 const uint8_t key1[CAAM_DES_KEY_SIZE], 2926 const uint8_t key2[CAAM_DES_KEY_SIZE], 2927 const uint8_t key3[CAAM_DES_KEY_SIZE]); 2928 2929 /*! 2930 *@} 2931 */ /* end of caam_nonblocking_driver_des */ 2932 2933 /*! 2934 * @addtogroup caam_driver_pkha 2935 * @{ 2936 */ 2937 2938 int CAAM_PKHA_CompareBigNum(const uint8_t *a, size_t sizeA, const uint8_t *b, size_t sizeB); 2939 2940 /*! 2941 * @brief Converts from integer to Montgomery format. 2942 * 2943 * This function computes R2 mod N and optionally converts A or B into Montgomery format of A or B. 2944 * 2945 * @param base CAAM peripheral base address 2946 * @param handle Handle used for this request. Specifies jobRing. 2947 * @param N modulus 2948 * @param sizeN size of N in bytes 2949 * @param[in,out] A The first input in non-Montgomery format. Output Montgomery format of the first input. 2950 * @param[in,out] sizeA pointer to size variable. On input it holds size of input A in bytes. On output it holds size of 2951 * Montgomery format of A in bytes. 2952 * @param[in,out] B Second input in non-Montgomery format. Output Montgomery format of the second input. 2953 * @param[in,out] sizeB pointer to size variable. On input it holds size of input B in bytes. On output it holds size of 2954 * Montgomery format of B in bytes. 2955 * @param[out] R2 Output Montgomery factor R2 mod N. 2956 * @param[out] sizeR2 pointer to size variable. On output it holds size of Montgomery factor R2 mod N in bytes. 2957 * @param equalTime Run the function time equalized or no timing equalization. 2958 * @param arithType Type of arithmetic to perform (integer or F2m) 2959 * @return Operation status. 2960 */ 2961 status_t CAAM_PKHA_NormalToMontgomery(CAAM_Type *base, 2962 caam_handle_t *handle, 2963 const uint8_t *N, 2964 size_t sizeN, 2965 uint8_t *A, 2966 size_t *sizeA, 2967 uint8_t *B, 2968 size_t *sizeB, 2969 uint8_t *R2, 2970 size_t *sizeR2, 2971 caam_pkha_timing_t equalTime, 2972 caam_pkha_f2m_t arithType); 2973 2974 /*! 2975 * @brief Converts from Montgomery format to int. 2976 * 2977 * This function converts Montgomery format of A or B into int A or B. 2978 * 2979 * @param base CAAM peripheral base address 2980 * @param handle Handle used for this request. Specifies jobRing. 2981 * @param N modulus. 2982 * @param sizeN size of N modulus in bytes. 2983 * @param[in,out] A Input first number in Montgomery format. Output is non-Montgomery format. 2984 * @param[in,out] sizeA pointer to size variable. On input it holds size of the input A in bytes. On output it holds 2985 * size of non-Montgomery A in bytes. 2986 * @param[in,out] B Input first number in Montgomery format. Output is non-Montgomery format. 2987 * @param[in,out] sizeB pointer to size variable. On input it holds size of the input B in bytes. On output it holds 2988 * size of non-Montgomery B in bytes. 2989 * @param equalTime Run the function time equalized or no timing equalization. 2990 * @param arithType Type of arithmetic to perform (integer or F2m) 2991 * @return Operation status. 2992 */ 2993 status_t CAAM_PKHA_MontgomeryToNormal(CAAM_Type *base, 2994 caam_handle_t *handle, 2995 const uint8_t *N, 2996 size_t sizeN, 2997 uint8_t *A, 2998 size_t *sizeA, 2999 uint8_t *B, 3000 size_t *sizeB, 3001 caam_pkha_timing_t equalTime, 3002 caam_pkha_f2m_t arithType); 3003 3004 /*! 3005 * @brief Performs modular addition - (A + B) mod N. 3006 * 3007 * This function performs modular addition of (A + B) mod N, with either 3008 * integer or binary polynomial (F2m) inputs. In the F2m form, this function is 3009 * equivalent to a bitwise XOR and it is functionally the same as subtraction. 3010 * 3011 * @param base CAAM peripheral base address 3012 * @param handle Handle used for this request. Specifies jobRing. 3013 * @param A first addend (integer or binary polynomial) 3014 * @param sizeA Size of A in bytes 3015 * @param B second addend (integer or binary polynomial) 3016 * @param sizeB Size of B in bytes 3017 * @param N modulus. 3018 * @param sizeN Size of N in bytes. 3019 * @param[out] result Output array to store result of operation 3020 * @param[out] resultSize Output size of operation in bytes 3021 * @param arithType Type of arithmetic to perform (integer or F2m) 3022 * @return Operation status. 3023 */ 3024 status_t CAAM_PKHA_ModAdd(CAAM_Type *base, 3025 caam_handle_t *handle, 3026 const uint8_t *A, 3027 size_t sizeA, 3028 const uint8_t *B, 3029 size_t sizeB, 3030 const uint8_t *N, 3031 size_t sizeN, 3032 uint8_t *result, 3033 size_t *resultSize, 3034 caam_pkha_f2m_t arithType); 3035 3036 /*! 3037 * @brief Performs modular subtraction - (A - B) mod N. 3038 * 3039 * This function performs modular subtraction of (A - B) mod N with 3040 * integer inputs. 3041 * 3042 * @param base CAAM peripheral base address 3043 * @param handle Handle used for this request. Specifies jobRing. 3044 * @param A first addend (integer or binary polynomial) 3045 * @param sizeA Size of A in bytes 3046 * @param B second addend (integer or binary polynomial) 3047 * @param sizeB Size of B in bytes 3048 * @param N modulus 3049 * @param sizeN Size of N in bytes 3050 * @param[out] result Output array to store result of operation 3051 * @param[out] resultSize Output size of operation in bytes 3052 * @return Operation status. 3053 */ 3054 status_t CAAM_PKHA_ModSub1(CAAM_Type *base, 3055 caam_handle_t *handle, 3056 const uint8_t *A, 3057 size_t sizeA, 3058 const uint8_t *B, 3059 size_t sizeB, 3060 const uint8_t *N, 3061 size_t sizeN, 3062 uint8_t *result, 3063 size_t *resultSize); 3064 3065 /*! 3066 * @brief Performs modular subtraction - (B - A) mod N. 3067 * 3068 * This function performs modular subtraction of (B - A) mod N, 3069 * with integer inputs. 3070 * 3071 * @param base CAAM peripheral base address 3072 * @param handle Handle used for this request. Specifies jobRing. 3073 * @param A first addend (integer or binary polynomial) 3074 * @param sizeA Size of A in bytes 3075 * @param B second addend (integer or binary polynomial) 3076 * @param sizeB Size of B in bytes 3077 * @param N modulus 3078 * @param sizeN Size of N in bytes 3079 * @param[out] result Output array to store result of operation 3080 * @param[out] resultSize Output size of operation in bytes 3081 * @return Operation status. 3082 */ 3083 status_t CAAM_PKHA_ModSub2(CAAM_Type *base, 3084 caam_handle_t *handle, 3085 const uint8_t *A, 3086 size_t sizeA, 3087 const uint8_t *B, 3088 size_t sizeB, 3089 const uint8_t *N, 3090 size_t sizeN, 3091 uint8_t *result, 3092 size_t *resultSize); 3093 3094 /*! 3095 * @brief Performs modular multiplication - (A x B) mod N. 3096 * 3097 * This function performs modular multiplication with either integer or 3098 * binary polynomial (F2m) inputs. It can optionally specify whether inputs 3099 * and/or outputs will be in Montgomery form or not. 3100 * 3101 * @param base CAAM peripheral base address 3102 * @param handle Handle used for this request. Specifies jobRing. 3103 * @param A first addend (integer or binary polynomial) 3104 * @param sizeA Size of A in bytes 3105 * @param B second addend (integer or binary polynomial) 3106 * @param sizeB Size of B in bytes 3107 * @param N modulus. 3108 * @param sizeN Size of N in bytes 3109 * @param[out] result Output array to store result of operation 3110 * @param[out] resultSize Output size of operation in bytes 3111 * @param arithType Type of arithmetic to perform (integer or F2m) 3112 * @param montIn Format of inputs 3113 * @param montOut Format of output 3114 * @param equalTime Run the function time equalized or no timing equalization. This argument is ignored for F2m modular 3115 * multiplication. 3116 * @return Operation status. 3117 */ 3118 status_t CAAM_PKHA_ModMul(CAAM_Type *base, 3119 caam_handle_t *handle, 3120 const uint8_t *A, 3121 size_t sizeA, 3122 const uint8_t *B, 3123 size_t sizeB, 3124 const uint8_t *N, 3125 size_t sizeN, 3126 uint8_t *result, 3127 size_t *resultSize, 3128 caam_pkha_f2m_t arithType, 3129 caam_pkha_montgomery_form_t montIn, 3130 caam_pkha_montgomery_form_t montOut, 3131 caam_pkha_timing_t equalTime); 3132 3133 /*! 3134 * @brief Performs modular exponentiation - (A^E) mod N. 3135 * 3136 * This function performs modular exponentiation with either integer or 3137 * binary polynomial (F2m) inputs. 3138 * 3139 * @param base CAAM peripheral base address 3140 * @param handle Handle used for this request. Specifies jobRing. 3141 * @param A first addend (integer or binary polynomial) 3142 * @param sizeA Size of A in bytes 3143 * @param N modulus 3144 * @param sizeN Size of N in bytes 3145 * @param E exponent 3146 * @param sizeE Size of E in bytes 3147 * @param[out] result Output array to store result of operation 3148 * @param[out] resultSize Output size of operation in bytes 3149 * @param montIn Format of A input (normal or Montgomery) 3150 * @param arithType Type of arithmetic to perform (integer or F2m) 3151 * @param equalTime Run the function time equalized or no timing equalization. 3152 * @return Operation status. 3153 */ 3154 status_t CAAM_PKHA_ModExp(CAAM_Type *base, 3155 caam_handle_t *handle, 3156 const uint8_t *A, 3157 size_t sizeA, 3158 const uint8_t *N, 3159 size_t sizeN, 3160 const uint8_t *E, 3161 size_t sizeE, 3162 uint8_t *result, 3163 size_t *resultSize, 3164 caam_pkha_f2m_t arithType, 3165 caam_pkha_montgomery_form_t montIn, 3166 caam_pkha_timing_t equalTime); 3167 3168 /*! 3169 * @brief Performs modular reduction - (A) mod N. 3170 * 3171 * This function performs modular reduction with either integer or 3172 * binary polynomial (F2m) inputs. 3173 * 3174 * @param base CAAM peripheral base address 3175 * @param handle Handle used for this request. Specifies jobRing. 3176 * @param A first addend (integer or binary polynomial) 3177 * @param sizeA Size of A in bytes 3178 * @param N modulus 3179 * @param sizeN Size of N in bytes 3180 * @param[out] result Output array to store result of operation 3181 * @param[out] resultSize Output size of operation in bytes 3182 * @param arithType Type of arithmetic to perform (integer or F2m) 3183 * @return Operation status. 3184 */ 3185 status_t CAAM_PKHA_ModRed(CAAM_Type *base, 3186 caam_handle_t *handle, 3187 const uint8_t *A, 3188 size_t sizeA, 3189 const uint8_t *N, 3190 size_t sizeN, 3191 uint8_t *result, 3192 size_t *resultSize, 3193 caam_pkha_f2m_t arithType); 3194 3195 /*! 3196 * @brief Performs modular inversion - (A^-1) mod N. 3197 * 3198 * This function performs modular inversion with either integer or 3199 * binary polynomial (F2m) inputs. 3200 * 3201 * @param base CAAM peripheral base address 3202 * @param handle Handle used for this request. Specifies jobRing. 3203 * @param A first addend (integer or binary polynomial) 3204 * @param sizeA Size of A in bytes 3205 * @param N modulus 3206 * @param sizeN Size of N in bytes 3207 * @param[out] result Output array to store result of operation 3208 * @param[out] resultSize Output size of operation in bytes 3209 * @param arithType Type of arithmetic to perform (integer or F2m) 3210 * @return Operation status. 3211 */ 3212 status_t CAAM_PKHA_ModInv(CAAM_Type *base, 3213 caam_handle_t *handle, 3214 const uint8_t *A, 3215 size_t sizeA, 3216 const uint8_t *N, 3217 size_t sizeN, 3218 uint8_t *result, 3219 size_t *resultSize, 3220 caam_pkha_f2m_t arithType); 3221 3222 /*! 3223 * @brief Computes integer Montgomery factor R^2 mod N. 3224 * 3225 * This function computes a constant to assist in converting operands 3226 * into the Montgomery residue system representation. 3227 * 3228 * @param base CAAM peripheral base address 3229 * @param handle Handle used for this request. Specifies jobRing. 3230 * @param N modulus 3231 * @param sizeN Size of N in bytes 3232 * @param[out] result Output array to store result of operation 3233 * @param[out] resultSize Output size of operation in bytes 3234 * @param arithType Type of arithmetic to perform (integer or F2m) 3235 * @return Operation status. 3236 */ 3237 status_t CAAM_PKHA_ModR2(CAAM_Type *base, 3238 caam_handle_t *handle, 3239 const uint8_t *N, 3240 size_t sizeN, 3241 uint8_t *result, 3242 size_t *resultSize, 3243 caam_pkha_f2m_t arithType); 3244 3245 /*! 3246 * @brief Calculates the greatest common divisor - GCD (A, N). 3247 * 3248 * This function calculates the greatest common divisor of two inputs with 3249 * either integer or binary polynomial (F2m) inputs. 3250 * 3251 * @param base CAAM peripheral base address 3252 * @param handle Handle used for this request. Specifies jobRing. 3253 * @param A first value (must be smaller than or equal to N) 3254 * @param sizeA Size of A in bytes 3255 * @param N second value (must be non-zero) 3256 * @param sizeN Size of N in bytes 3257 * @param[out] result Output array to store result of operation 3258 * @param[out] resultSize Output size of operation in bytes 3259 * @param arithType Type of arithmetic to perform (integer or F2m) 3260 * @return Operation status. 3261 */ 3262 status_t CAAM_PKHA_ModGcd(CAAM_Type *base, 3263 caam_handle_t *handle, 3264 const uint8_t *A, 3265 size_t sizeA, 3266 const uint8_t *N, 3267 size_t sizeN, 3268 uint8_t *result, 3269 size_t *resultSize, 3270 caam_pkha_f2m_t arithType); 3271 3272 /*! 3273 * @brief Executes Miller-Rabin primality test. 3274 * 3275 * This function calculates whether or not a candidate prime number is likely 3276 * to be a prime. 3277 * 3278 * @param base CAAM peripheral base address 3279 * @param handle Handle used for this request. Specifies jobRing. 3280 * @param A initial random seed 3281 * @param sizeA Size of A in bytes 3282 * @param B number of trial runs 3283 * @param sizeB Size of B in bytes 3284 * @param N candidate prime integer 3285 * @param sizeN Size of N in bytes 3286 * @param[out] res True if the value is likely prime or false otherwise 3287 * @return Operation status. 3288 */ 3289 status_t CAAM_PKHA_PrimalityTest(CAAM_Type *base, 3290 caam_handle_t *handle, 3291 const uint8_t *A, 3292 size_t sizeA, 3293 const uint8_t *B, 3294 size_t sizeB, 3295 const uint8_t *N, 3296 size_t sizeN, 3297 bool *res); 3298 3299 /*! 3300 * @brief Adds elliptic curve points - A + B. 3301 * 3302 * This function performs ECC point addition over a prime field (Fp) or binary field (F2m) using 3303 * affine coordinates. 3304 * 3305 * @param base CAAM peripheral base address 3306 * @param handle Handle used for this request. Specifies jobRing. 3307 * @param A Left-hand point 3308 * @param B Right-hand point 3309 * @param N Prime modulus of the field 3310 * @param R2modN NULL (the function computes R2modN internally) or pointer to pre-computed R2modN (obtained from 3311 * CAAM_PKHA_ModR2() function). 3312 * @param aCurveParam A parameter from curve equation 3313 * @param bCurveParam B parameter from curve equation (constant) 3314 * @param size Size in bytes of curve points and parameters 3315 * @param arithType Type of arithmetic to perform (integer or F2m) 3316 * @param[out] result Result point 3317 * @return Operation status. 3318 */ 3319 status_t CAAM_PKHA_ECC_PointAdd(CAAM_Type *base, 3320 caam_handle_t *handle, 3321 const caam_pkha_ecc_point_t *A, 3322 const caam_pkha_ecc_point_t *B, 3323 const uint8_t *N, 3324 const uint8_t *R2modN, 3325 const uint8_t *aCurveParam, 3326 const uint8_t *bCurveParam, 3327 size_t size, 3328 caam_pkha_f2m_t arithType, 3329 caam_pkha_ecc_point_t *result); 3330 3331 /*! 3332 * @brief Doubles elliptic curve points - B + B. 3333 * 3334 * This function performs ECC point doubling over a prime field (Fp) or binary field (F2m) using 3335 * affine coordinates. 3336 * 3337 * @param base CAAM peripheral base address 3338 * @param handle Handle used for this request. Specifies jobRing. 3339 * @param B Point to double 3340 * @param N Prime modulus of the field 3341 * @param aCurveParam A parameter from curve equation 3342 * @param bCurveParam B parameter from curve equation (constant) 3343 * @param size Size in bytes of curve points and parameters 3344 * @param arithType Type of arithmetic to perform (integer or F2m) 3345 * @param[out] result Result point 3346 * @return Operation status. 3347 */ 3348 status_t CAAM_PKHA_ECC_PointDouble(CAAM_Type *base, 3349 caam_handle_t *handle, 3350 const caam_pkha_ecc_point_t *B, 3351 const uint8_t *N, 3352 const uint8_t *aCurveParam, 3353 const uint8_t *bCurveParam, 3354 size_t size, 3355 caam_pkha_f2m_t arithType, 3356 caam_pkha_ecc_point_t *result); 3357 3358 /*! 3359 * @brief Multiplies an elliptic curve point by a scalar - E x (A0, A1). 3360 * 3361 * This function performs ECC point multiplication to multiply an ECC point by 3362 * a scalar integer multiplier over a prime field (Fp) or a binary field (F2m). 3363 * 3364 * @param base CAAM peripheral base address 3365 * @param handle Handle used for this request. Specifies jobRing. 3366 * @param A Point as multiplicand 3367 * @param E Scalar multiple 3368 * @param sizeE The size of E, in bytes 3369 * @param N Modulus, a prime number for the Fp field or Irreducible polynomial for F2m field. 3370 * @param R2modN NULL (the function computes R2modN internally) or pointer to pre-computed R2modN (obtained from 3371 * CAAM_PKHA_ModR2() function). 3372 * @param aCurveParam A parameter from curve equation 3373 * @param bCurveParam B parameter from curve equation (C parameter for operation over F2m). 3374 * @param size Size in bytes of curve points and parameters 3375 * @param equalTime Run the function time equalized or no timing equalization. 3376 * @param arithType Type of arithmetic to perform (integer or F2m) 3377 * @param[out] result Result point 3378 * @return Operation status. 3379 */ 3380 status_t CAAM_PKHA_ECC_PointMul(CAAM_Type *base, 3381 caam_handle_t *handle, 3382 const caam_pkha_ecc_point_t *A, 3383 const uint8_t *E, 3384 size_t sizeE, 3385 const uint8_t *N, 3386 const uint8_t *R2modN, 3387 const uint8_t *aCurveParam, 3388 const uint8_t *bCurveParam, 3389 size_t size, 3390 caam_pkha_timing_t equalTime, 3391 caam_pkha_f2m_t arithType, 3392 caam_pkha_ecc_point_t *result); 3393 3394 /*! 3395 *@} 3396 */ /* end of caam_driver_pkha */ 3397 3398 #if defined(__cplusplus) 3399 } 3400 #endif 3401 3402 #endif /* _FSL_CAAM_H_ */ 3403