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