1 /***************************************************************************//** 2 * \file cy_cryptolite_aes.h 3 * \version 2.50 4 * 5 * \brief 6 * This file provides common constants and parameters 7 * for the Cryptolite AES driver. 8 * 9 ******************************************************************************** 10 * Copyright 2022 Cypress Semiconductor Corporation 11 * SPDX-License-Identifier: Apache-2.0 12 * 13 * Licensed under the Apache License, Version 2.0 (the "License"); 14 * you may not use this file except in compliance with the License. 15 * You may obtain a copy of the License at 16 * 17 * http://www.apache.org/licenses/LICENSE-2.0 18 * 19 * Unless required by applicable law or agreed to in writing, software 20 * distributed under the License is distributed on an "AS IS" BASIS, 21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 * See the License for the specific language governing permissions and 23 * limitations under the License. 24 *******************************************************************************/ 25 26 #if !defined (CY_CRYPTOLITE_AES_H) 27 #define CY_CRYPTOLITE_AES_H 28 29 #include "cy_device.h" 30 31 #if defined (CY_IP_MXCRYPTOLITE) 32 33 #if defined(__cplusplus) 34 extern "C" { 35 #endif 36 37 #include "cy_cryptolite_common.h" 38 39 #if (CRYPTOLITE_AES_PRESENT == 1) 40 #if defined(CY_CRYPTOLITE_CFG_AES_C) 41 42 43 /** Defines the Cryptolite AES block size (in bytes) */ 44 /** Only 128 bit key supported **/ 45 #define CY_CRYPTOLITE_AES_BLOCK_SIZE (16u) 46 47 /** Defines the Cryptolite AES_128 key maximum size (in bytes) */ 48 #define CY_CRYPTOLITE_AES_128_KEY_SIZE (16u) 49 50 /** Defines the Cryptolite AES key maximum size (in bytes) */ 51 #define CY_CRYPTOLITE_AES_MAX_KEY_SIZE (16u) 52 53 /** Defines the Cryptolite AES_128 key maximum size (in four-byte words) */ 54 #define CY_CRYPTOLITE_AES_MAX_KEY_SIZE_U32 (uint32_t)(CY_CRYPTOLITE_AES_128_KEY_SIZE / 4UL) 55 56 /** Defines size of the AES block, in four-byte words */ 57 #define CY_CRYPTOLITE_AES_BLOCK_SIZE_U32 (uint32_t)(CY_CRYPTOLITE_AES_BLOCK_SIZE / 4UL) 58 59 #define CY_CRYPTO_AES_CTR_CNT_POS (0x02U) 60 61 /** 62 * \addtogroup group_cryptolite_data_structures 63 * \{ 64 */ 65 /* The structure to define used memory buffers */ 66 typedef struct 67 { 68 /** \cond INTERNAL */ 69 CY_ALIGN(4) uint32_t key[CY_CRYPTOLITE_AES_MAX_KEY_SIZE_U32]; 70 71 CY_ALIGN(4) uint32_t src[CY_CRYPTOLITE_AES_MAX_KEY_SIZE_U32]; 72 CY_ALIGN(4) uint32_t dst[CY_CRYPTOLITE_AES_MAX_KEY_SIZE_U32]; 73 74 #if defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CBC) || defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CFB) || defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CTR) 75 CY_ALIGN(4) uint32_t block0[CY_CRYPTOLITE_AES_MAX_KEY_SIZE_U32]; 76 #endif 77 78 #if defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CFB) || defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CTR) 79 CY_ALIGN(4) uint32_t block1[CY_CRYPTOLITE_AES_MAX_KEY_SIZE_U32]; 80 #endif 81 82 #if defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CTR) 83 CY_ALIGN(4) uint32_t block2[CY_CRYPTOLITE_AES_MAX_KEY_SIZE_U32]; 84 CY_ALIGN(4) uint32_t block3[CY_CRYPTOLITE_AES_MAX_KEY_SIZE_U32]; 85 #endif 86 87 CY_ALIGN(4) uint8_t unProcessedData[CY_CRYPTOLITE_AES_BLOCK_SIZE]; 88 CY_ALIGN(4) uint8_t iv[CY_CRYPTOLITE_AES_BLOCK_SIZE]; 89 90 #if defined (CY_CRYPTOLITE_CFG_CIPHER_MODE_CBC) 91 CY_ALIGN(4) uint8_t temp[CY_CRYPTOLITE_AES_BLOCK_SIZE]; 92 #endif 93 94 /*Assigned dummy byte for the 4 byte alignment*/ 95 CY_ALIGN(4) uint32_t dummy[1u]; 96 /** \endcond */ 97 } cy_stc_cryptolite_aes_buffers_t; 98 99 100 101 102 /* The structure to define used memory buffers */ 103 typedef struct 104 { 105 /** \cond INTERNAL */ 106 cy_stc_cryptolite_aes_buffers_t aesCbcMac_buffer; 107 cy_stc_cryptolite_aes_buffers_t aesCtr_buffer; 108 CY_ALIGN(4) uint8_t temp_buffer[CY_CRYPTOLITE_AES_BLOCK_SIZE]; 109 CY_ALIGN(4) uint8_t ctr[CY_CRYPTOLITE_AES_BLOCK_SIZE]; 110 CY_ALIGN(4) uint8_t y[CY_CRYPTOLITE_AES_BLOCK_SIZE]; 111 112 /** \endcond */ 113 } cy_stc_cryptolite_aes_ccm_buffers_t; 114 115 /** \cond INTERNAL */ 116 /** The cryptolite AES128 IP descriptor structure. 117 * All fields for the structure are internal. Firmware never reads or 118 * writes these values. 119 */ 120 typedef struct 121 { 122 uint32_t key; 123 uint32_t plainText; 124 uint32_t cipherText; 125 } cy_stc_cryptolite_aes_descr_t; 126 /** \endcond */ 127 128 /** The structure for storing the AES context. 129 * All fields for the context structure are internal. Firmware never reads or 130 * writes these values. Firmware allocates the structure and provides the 131 * address of the structure to the driver in the function calls. Firmware must 132 * ensure that the defined instance of this structure remains in scope 133 * while the drive is in use. 134 */ 135 typedef struct 136 { 137 /** \cond INTERNAL */ 138 /** AES state data */ 139 /** Pointer to AES work buffers */ 140 cy_stc_cryptolite_aes_buffers_t *buffers; 141 /** Operation data descriptors */ 142 cy_stc_cryptolite_aes_descr_t message_encrypt_struct; 143 /** AES unprocessed message block*/ 144 uint32_t unProcessedBytes; 145 /** AES ivSize*/ 146 uint16_t ivSize; 147 /** Is MAC*/ 148 bool isMac; 149 /** AES mode*/ 150 cy_en_cryptolite_dir_mode_t dirMode; 151 /** \endcond */ 152 } cy_stc_cryptolite_aes_state_t; 153 154 typedef struct 155 { 156 /** \cond INTERNAL */ 157 /** AES state data */ 158 cy_en_cryptolite_dir_mode_t dirMode; 159 /** Pointer to AES work buffers */ 160 cy_stc_cryptolite_aes_state_t aesCbcMacState; 161 /** Operation data descriptors */ 162 cy_stc_cryptolite_aes_state_t aesCtrState; 163 /** pointer to temp buffer */ 164 uint8_t *temp; 165 /** pointer to ctr buffer */ 166 uint8_t *ctr; 167 /** pointer to y buffer */ 168 uint8_t *y; 169 /** Length field Size*/ 170 uint32_t L; 171 /** Total text size*/ 172 uint32_t textLength; 173 /** Total AAD size*/ 174 uint32_t aadLength; 175 /** Total tag size*/ 176 uint8_t tagLength; 177 /** AAD size processed*/ 178 uint32_t aadLengthProcessed; 179 /** AAD processed flag*/ 180 bool isAadProcessed; 181 /** IV set flag*/ 182 bool isIvSet; 183 /** Length Set flag*/ 184 bool isLengthSet; 185 /** \endcond */ 186 } cy_stc_cryptolite_aes_ccm_state_t; 187 188 /** \} group_cryptolite_data_structures */ 189 190 191 /** 192 * \addtogroup group_cryptolite_lld_aes_functions 193 * \{ 194 */ 195 196 /******************************************************************************* 197 * Function Name: Cy_Cryptolite_Aes_ProcessBlock 198 ****************************************************************************//** 199 * 200 * Performs the AES block cipher. 201 * 202 * \param base 203 * The pointer to the CRYPTOLITE instance. 204 * 205 * \param aesState 206 * the pointer to the cy_stc_cryptolite_aes_state_t structure that stores all 207 * internal variables for Cryptolite driver. 208 * 209 * \param dstBlock 210 * The pointer to the cipher text. 211 * 212 * \param srcBlock 213 * The pointer to the plain text. Must be 4-Byte aligned! 214 * 215 * \return 216 * \ref cy_en_cryptolite_status_t 217 *******************************************************************************/ 218 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_ProcessBlock(CRYPTOLITE_Type *base, 219 cy_stc_cryptolite_aes_state_t *aesState, 220 uint32_t *dstBlock, 221 uint32_t const *srcBlock); 222 223 224 225 /******************************************************************************* 226 * Function Name: Cy_Cryptolite_Aes_Init 227 ****************************************************************************//** 228 * 229 * Sets AES key and the buffers. 230 * 231 * \param base 232 * The pointer to the CRYPTOLITE instance. 233 * 234 * \param key 235 * The pointer to the encryption/decryption key. The key must align in 4 byte boundary. 236 * 237 * \param aesState 238 * The pointer to the AES state structure allocated by the user. The user 239 * must not modify anything in this structure. 240 * 241 * \param aesBuffers 242 * The pointer to the memory buffers storage. 243 * 244 * \return 245 * \ref cy_en_cryptolite_status_t 246 * 247 * \funcusage 248 * \snippet cryptolite/snippet/main.c snippet_Cy_Cryptolite_Aes_Ecb 249 *******************************************************************************/ 250 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Init(CRYPTOLITE_Type *base, 251 uint8_t const *key, 252 cy_stc_cryptolite_aes_state_t *aesState, 253 cy_stc_cryptolite_aes_buffers_t *aesBuffers); 254 255 /******************************************************************************* 256 * Function Name: Cy_Cryptolite_Aes_Free 257 ****************************************************************************//** 258 * 259 * Clears AES operation context. 260 * 261 * \param base 262 * The pointer to the CRYPTOLITE instance. 263 * 264 * \param aesState 265 * The pointer to the AES state structure allocated by the user. The user 266 * must not modify anything in this structure. 267 * 268 * \return 269 * \ref cy_en_cryptolite_status_t 270 * 271 * \funcusage 272 * \snippet cryptolite/snippet/main.c snippet_Cy_Cryptolite_Aes_Ecb 273 *******************************************************************************/ 274 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Free(CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *aesState); 275 276 /******************************************************************************* 277 * Function Name: Cy_Cryptolite_Aes_Ecb 278 ****************************************************************************//** 279 * 280 * Performs an AES operation on one block. 281 * 282 * \param base 283 * The pointer to the CRYPTOLITE instance. 284 * 285 * 286 * \param dst 287 * The pointer to a destination cipher block. 288 * 289 * \param src 290 * The pointer to a source block. 291 * 292 * \param aesState 293 * The pointer to the AES state structure allocated by the user. The user 294 * must not modify anything in this structure. 295 * 296 * \return 297 * \ref cy_en_cryptolite_status_t 298 * 299 * \funcusage 300 * \snippet cryptolite/snippet/main.c snippet_Cy_Cryptolite_Aes_Ecb 301 *******************************************************************************/ 302 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ecb(CRYPTOLITE_Type *base, 303 uint8_t *dst, 304 uint8_t const *src, 305 cy_stc_cryptolite_aes_state_t *aesState); 306 307 308 /******************************************************************************* 309 * Function Name: Cy_Cryptolite_Aes_Ecb_Setup 310 ****************************************************************************//** 311 * 312 * Performs an AES ECB setup operation. 313 * 314 * \param base 315 * The pointer to the CRYPTOLITE instance. 316 * 317 * \param aesState 318 * The pointer to the AES state structure allocated by the user. The user 319 * must not modify anything in this structure. 320 * 321 * \return 322 * \ref cy_en_cryptolite_status_t 323 * 324 ******************************************************************************/ 325 326 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ecb_Setup(CRYPTOLITE_Type *base, 327 cy_stc_cryptolite_aes_state_t *aesState); 328 329 330 /******************************************************************************* 331 * Function Name: Cy_Cryptolite_Aes_Ecb_Update 332 ****************************************************************************//** 333 * 334 * Performs an AES ECB Multistage update operation. 335 * 336 * \param base 337 * The pointer to the CRYPTOLITE instance. 338 * 339 * \param srcSize 340 * The size of the source block. 341 * 342 * \param dst 343 * The pointer to a destination cipher block. 344 * 345 * \param src 346 * The pointer to a source block. 347 * 348 * \param dstLength 349 * The size of the calculated cipher block. 350 * 351 * \param aesState 352 * The pointer to the AES state structure allocated by the user. The user 353 * must not modify anything in this structure. 354 * 355 * \return 356 * \ref cy_en_cryptolite_status_t 357 * 358 *******************************************************************************/ 359 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ecb_Update(CRYPTOLITE_Type *base, 360 uint32_t srcSize, 361 uint8_t *dst, 362 uint8_t const *src, 363 uint32_t *dstLength, 364 cy_stc_cryptolite_aes_state_t *aesState); 365 366 367 /******************************************************************************* 368 * Function Name: Cy_Cryptolite_Aes_Ecb_Finish 369 ****************************************************************************//** 370 * 371 * Performs an AES ECB finish operation. 372 * 373 * \param base 374 * The pointer to the CRYPTOLITE instance. 375 * 376 * \param aesState 377 * The pointer to the AES state structure allocated by the user. The user 378 * must not modify anything in this structure. 379 * 380 * \return 381 * \ref cy_en_cryptolite_status_t 382 * 383 *******************************************************************************/ 384 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ecb_Finish(CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *aesState); 385 386 387 #if defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CBC) 388 /******************************************************************************* 389 * Function Name: Cy_Cryptolite_Aes_Cbc 390 ****************************************************************************//** 391 * 392 * Performs AES operation on a plain text with Cipher Block Chaining (CBC). 393 * 394 * \param base 395 * The pointer to the CRYPTOLITE instance. 396 * 397 * \param srcSize 398 * The size of the source plain text. 399 * 400 * \param ivPtr 401 * The pointer to the initial vector. 402 * 403 * \param dst 404 * The pointer to a destination cipher text. 405 * 406 * \param src 407 * The pointer to a source plain text. 408 * 409 * \param aesState 410 * The pointer to the AES state structure allocated by the user. The user 411 * must not modify anything in this structure. 412 * 413 * \return 414 * \ref cy_en_cryptolite_status_t 415 * 416 * \funcusage 417 * \snippet cryptolite/snippet/main.c snippet_Cy_Cryptolite_Aes_Cbc 418 *******************************************************************************/ 419 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cbc(CRYPTOLITE_Type *base, 420 uint32_t srcSize, 421 uint8_t *ivPtr, 422 uint8_t *dst, 423 uint8_t const *src, 424 cy_stc_cryptolite_aes_state_t *aesState); 425 426 427 /******************************************************************************* 428 * Function Name: Cy_Cryptolite_Aes_Cbc_Setup 429 ****************************************************************************//** 430 * 431 * Performs an AES CBC setup operation. 432 * 433 * \param base 434 * The pointer to the CRYPTOLITE instance. 435 * 436 * \param aesState 437 * The pointer to the AES state structure allocated by the user. The user 438 * must not modify anything in this structure. 439 * 440 * \return 441 * \ref cy_en_cryptolite_status_t 442 * 443 *******************************************************************************/ 444 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cbc_Setup(CRYPTOLITE_Type *base, 445 cy_stc_cryptolite_aes_state_t *aesState); 446 447 /******************************************************************************* 448 * Function Name: Cy_Cryptolite_Aes_Cbc_Set_IV 449 ****************************************************************************//** 450 * 451 * Function to set AES CBC IV. 452 * 453 * \param base 454 * The pointer to the CRYPTOLITE instance. 455 * 456 * \param iv 457 * The pointer to the IV. 458 * 459 * \param aesState 460 * The pointer to the AES state structure allocated by the user. The user 461 * must not modify anything in this structure. 462 * 463 * \return 464 * \ref cy_en_cryptolite_status_t 465 * 466 *******************************************************************************/ 467 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cbc_Set_IV(CRYPTOLITE_Type *base, 468 uint8_t const * iv, 469 cy_stc_cryptolite_aes_state_t *aesState); 470 471 /******************************************************************************* 472 * Function Name: Cy_Cryptolite_Aes_Cbc_Update 473 ****************************************************************************//** 474 * 475 * Performs an AES CBC Multistage update operation. 476 * 477 * \param base 478 * The pointer to the CRYPTOLITE instance. 479 * 480 * \param srcSize 481 * The size of the source block. 482 * 483 * \param dst 484 * The pointer to a destination cipher block. 485 * 486 * \param src 487 * The pointer to a source block. 488 * 489 * \param dstLength 490 * The size of the calculated dst block. 491 * 492 * \param aesState 493 * The pointer to the AES state structure allocated by the user. The user 494 * must not modify anything in this structure. 495 * 496 * \return 497 * \ref cy_en_cryptolite_status_t 498 * 499 *******************************************************************************/ 500 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cbc_Update(CRYPTOLITE_Type *base, 501 uint32_t srcSize, 502 uint8_t *dst, 503 uint8_t const *src, 504 uint32_t *dstLength, 505 cy_stc_cryptolite_aes_state_t *aesState); 506 507 508 /******************************************************************************* 509 * Function Name: Cy_Cryptolite_Aes_Cbc_Finish 510 ****************************************************************************//** 511 * 512 * Performs an AES CBC finish operation. 513 * 514 * \param base 515 * The pointer to the CRYPTOLITE instance. 516 * 517 * \param aesState 518 * The pointer to the AES state structure allocated by the user. The user 519 * must not modify anything in this structure. 520 * 521 * \return 522 * \ref cy_en_cryptolite_status_t 523 * 524 *******************************************************************************/ 525 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cbc_Finish(CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *aesState); 526 527 528 529 #if defined(CY_CRYPTOLITE_CFG_CBC_MAC_C) 530 531 /******************************************************************************* 532 * Function Name: Cy_Cryptolite_Aes_CbcMac_Setup 533 ****************************************************************************//** 534 * 535 * Performs an AES CBC MAC setup operation. 536 * 537 * \param base 538 * The pointer to the CRYPTOLITE instance. 539 * 540 * \param aesState 541 * The pointer to the AES state structure allocated by the user. The user 542 * must not modify anything in this structure. 543 * 544 * \return 545 * \ref cy_en_cryptolite_status_t 546 * 547 *******************************************************************************/ 548 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_CbcMac_Setup(CRYPTOLITE_Type *base, 549 cy_stc_cryptolite_aes_state_t *aesState); 550 551 552 /******************************************************************************* 553 * Function Name: Cy_Cryptolite_Aes_CbcMac_Update 554 ****************************************************************************//** 555 * 556 * Performs an AES CBC MAC Multistage update operation. 557 * 558 * \param base 559 * The pointer to the CRYPTOLITE instance. 560 * 561 * \param srcSize 562 * The size of the source block. 563 * 564 * \param src 565 * The pointer to a source block. 566 * 567 * \param aesState 568 * The pointer to the AES state structure allocated by the user. The user 569 * must not modify anything in this structure. 570 * 571 * \return 572 * \ref cy_en_cryptolite_status_t 573 * 574 *******************************************************************************/ 575 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_CbcMac_Update(CRYPTOLITE_Type *base, 576 uint32_t srcSize, 577 uint8_t const *src, 578 cy_stc_cryptolite_aes_state_t *aesState); 579 580 581 /******************************************************************************* 582 * Function Name: Cy_Cryptolite_Aes_CbcMac_Finish 583 ****************************************************************************//** 584 * 585 * Performs an AES CBC MAC finish operation. 586 * 587 * \param base 588 * The pointer to the CRYPTOLITE instance. 589 * 590 * \param mac 591 * The pointer to store the calculated mac. 592 * 593 * \param aesState 594 * The pointer to the AES state structure allocated by the user. The user 595 * must not modify anything in this structure. 596 * 597 * \return 598 * \ref cy_en_cryptolite_status_t 599 * 600 *******************************************************************************/ 601 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_CbcMac_Finish(CRYPTOLITE_Type *base, uint8_t * mac, cy_stc_cryptolite_aes_state_t *aesState); 602 #endif /*CY_CRYPTOLITE_CFG_CBC_MAC_C*/ 603 604 #endif /*CY_CRYPTOLITE_CFG_CIPHER_MODE_CBC*/ 605 606 607 608 #if defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CFB) 609 /******************************************************************************* 610 * Function Name: Cy_Cryptolite_Aes_Cfb 611 ********************************************************************************//** 612 * 613 * Performs AES operation on a plain text with the Cipher Feedback Block method (CFB). 614 * 615 * \param base 616 * The pointer to the CRYPTOLITE instance. 617 * 618 * \param dirMode 619 * \ref cy_en_cryptolite_dir_mode_t 620 * 621 * \param srcSize 622 * The size of the source plain text. 623 * 624 * \param ivPtr 625 * The pointer to the initial vector. 626 * 627 * \param dst 628 * The pointer to a destination cipher text. 629 * 630 * \param src 631 * The pointer to a source plain text. 632 * 633 * \param aesState 634 * The pointer to the AES state structure allocated by the user. The user must 635 * must not modify anything in this structure. 636 * 637 * \return 638 * \ref cy_en_cryptolite_status_t 639 * 640 * \funcusage 641 * \snippet cryptolite/snippet/main.c snippet_Cy_Cryptolite_Aes_Cfb 642 *******************************************************************************/ 643 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cfb(CRYPTOLITE_Type *base, 644 cy_en_cryptolite_dir_mode_t dirMode, 645 uint32_t srcSize, 646 uint8_t *ivPtr, 647 uint8_t *dst, 648 uint8_t const *src, 649 cy_stc_cryptolite_aes_state_t *aesState); 650 651 652 /******************************************************************************* 653 * Function Name: Cy_Cryptolite_Aes_Cfb_Setup 654 ****************************************************************************//** 655 * 656 * Performs an AES CFB setup operation. 657 * 658 * \param base 659 * The pointer to the CRYPTO instance. 660 * 661 * \param dirMode 662 * Can be \ref CY_CRYPTOLITE_ENCRYPT or \ref CY_CRYPTO_DECRYPT 663 * (\ref cy_en_cryptolite_dir_mode_t). 664 * 665 * \param aesState 666 * The pointer to the AES state structure allocated by the user. The user 667 * must not modify anything in this structure. 668 * 669 * \return 670 * \ref cy_en_cryptolite_status_t 671 * 672 *******************************************************************************/ 673 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cfb_Setup(CRYPTOLITE_Type *base, 674 cy_en_cryptolite_dir_mode_t dirMode, 675 cy_stc_cryptolite_aes_state_t *aesState); 676 677 678 /******************************************************************************* 679 * Function Name: Cy_Cryptolite_Aes_Cfb_Set_IV 680 ****************************************************************************//** 681 * 682 * Sets IV for AES CFB mode. 683 * 684 * \param base 685 * The pointer to the CRYPTO instance. 686 * 687 * \param iv 688 * The pointer to iv. 689 * 690 * \param aesState 691 * The pointer to the AES state structure allocated by the user. The user 692 * must not modify anything in this structure. 693 * 694 * \return 695 * \ref cy_en_cryptolite_status_t 696 * 697 *******************************************************************************/ 698 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cfb_Set_IV(CRYPTOLITE_Type *base, 699 uint8_t const * iv, 700 cy_stc_cryptolite_aes_state_t *aesState); 701 702 /******************************************************************************* 703 * Function Name: Cy_Cryptolite_Aes_Cfb_Update 704 ****************************************************************************//** 705 * 706 * Performs an AES CFB Multistage update operation. 707 * 708 * \param base 709 * The pointer to the CRYPTO instance. 710 * 711 * \param srcSize 712 * The size of the source block. 713 * 714 * \param dst 715 * The pointer to a destination cipher block. 716 * 717 * \param src 718 * The pointer to a source block. 719 * 720 * \param aesState 721 * The pointer to the AES state structure allocated by the user. The user 722 * must not modify anything in this structure. 723 * 724 * \return 725 * \ref cy_en_cryptolite_status_t 726 * 727 *******************************************************************************/ 728 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cfb_Update(CRYPTOLITE_Type *base, 729 uint32_t srcSize, 730 uint8_t *dst, 731 uint8_t const *src, 732 cy_stc_cryptolite_aes_state_t *aesState); 733 734 735 /******************************************************************************* 736 * Function Name: Cy_Cryptolite_Aes_Cfb_Finish 737 ****************************************************************************//** 738 * 739 * Performs an AES CFB finish operation. 740 * 741 * \param base 742 * The pointer to the CRYPTO instance. 743 * 744 * \param aesState 745 * The pointer to the AES state structure allocated by the user. The user 746 * must not modify anything in this structure. 747 * 748 * \return 749 * \ref cy_en_cryptolite_status_t 750 * 751 *******************************************************************************/ 752 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Cfb_Finish(CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *aesState); 753 754 #endif /*CY_CRYPTOLITE_CFG_CIPHER_MODE_CFB*/ 755 756 757 #if defined(CY_CRYPTOLITE_CFG_CIPHER_MODE_CTR) 758 /******************************************************************************* 759 * Function Name: Cy_Cryptolite_Aes_Ctr 760 ********************************************************************************//** 761 * 762 * Performs an AES operation on a plain text using the counter method (CTR). 763 * 764 * \param base 765 * The pointer to the CRYPTOLITE instance. 766 * 767 * \param srcSize 768 * The size of a source plain text. 769 * 770 * \param srcOffset 771 * The size of an offset within the current block stream for resuming within the 772 * current cipher stream. 773 * 774 * \param ivPtr 775 * The 128-bit initial vector that contains a 64-bit nonce and 64-bit counter. 776 * 777 * \param dst 778 * The pointer to a destination cipher text. 779 * 780 * \param src 781 * The pointer to a source plain text. Must be 4-Byte aligned. 782 * 783 * \param aesState 784 * The pointer to the AES state structure allocated by the user. The user must 785 * must not modify anything in this structure. 786 * 787 * \return 788 * \ref cy_en_cryptolite_status_t 789 * 790 * \funcusage 791 * \snippet cryptolite/snippet/main.c snippet_Cy_Cryptolite_Aes_Ctr 792 *******************************************************************************/ 793 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ctr(CRYPTOLITE_Type *base, 794 uint32_t srcSize, 795 uint32_t *srcOffset, 796 uint8_t *ivPtr, 797 uint8_t *dst, 798 uint8_t const *src, 799 cy_stc_cryptolite_aes_state_t *aesState); 800 801 /******************************************************************************* 802 * Function Name: Cy_Cryptolite_Aes_Ctr_Setup 803 ****************************************************************************//** 804 * 805 * Performs an AES CTR setup operation. 806 * 807 * \param base 808 * The pointer to the CRYPTOLITE instance. 809 * 810 * \param aesState 811 * The pointer to the AES state structure allocated by the user. The user 812 * must not modify anything in this structure. 813 * 814 * \return 815 * \ref cy_en_crypto_status_t 816 * 817 *******************************************************************************/ 818 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ctr_Setup(CRYPTOLITE_Type *base, 819 cy_stc_cryptolite_aes_state_t *aesState); 820 821 /******************************************************************************* 822 * Function Name: Cy_Cryptolite_Aes_Ctr_Set_IV 823 ****************************************************************************//** 824 * 825 * Sets IV for the AES CTR operation. 826 * 827 * \param base 828 * The pointer to the CRYPTOLITE instance. 829 * 830 * \param iv 831 * The pointer to iv. 832 * 833 * \param aesState 834 * The pointer to the AES state structure allocated by the user. The user 835 * must not modify anything in this structure. 836 * 837 * \return 838 * \ref cy_en_cryptolite_status_t 839 * 840 *******************************************************************************/ 841 842 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ctr_Set_IV(CRYPTOLITE_Type *base, 843 const uint8_t *iv, 844 cy_stc_cryptolite_aes_state_t *aesState); 845 846 /******************************************************************************* 847 * Function Name: Cy_Cryptolite_Aes_Ctr_Update 848 ****************************************************************************//** 849 * 850 * Performs an AES CTR Multistage update operation. 851 * 852 * \param base 853 * The pointer to the CRYPTOLITE instance. 854 * 855 * \param srcSize 856 * The size of the source block. 857 * 858 * \param dst 859 * The pointer to a destination cipher block. 860 * 861 * \param src 862 * The pointer to a source block. 863 * 864 * \param aesState 865 * The pointer to the AES state structure allocated by the user. The user 866 * must not modify anything in this structure. 867 * 868 * \return 869 * \ref cy_en_cryptolite_status_t 870 * 871 *******************************************************************************/ 872 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ctr_Update(CRYPTOLITE_Type *base, 873 uint32_t srcSize, 874 uint8_t *dst, 875 uint8_t const *src, 876 cy_stc_cryptolite_aes_state_t *aesState); 877 878 879 /******************************************************************************* 880 * Function Name: Cy_Cryptolite_Aes_Ctr_Finish 881 ****************************************************************************//** 882 * 883 * Performs an AES CTR Finish operation. 884 * 885 * \param base 886 * The pointer to the CRYPTOLITE instance. 887 * 888 * \param aesState 889 * The pointer to the AES state structure allocated by the user. The user 890 * must not modify anything in this structure. 891 * 892 * \return 893 * \ref cy_en_cryptolite_status_t 894 * 895 *******************************************************************************/ 896 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ctr_Finish(CRYPTOLITE_Type *base, cy_stc_cryptolite_aes_state_t *aesState); 897 898 /******************************************************************************* 899 * Function Name: Cy_Cryptolite_Aes_Ctr_Zeropad 900 ********************************************************************************//** 901 * 902 * Performs an AES operation on a plain text using the counter method (CTR). 903 * 904 * \param base 905 * The pointer to the CRYPTOLITE instance. 906 * 907 * \param srcSize 908 * The size of a source plain text. 909 * 910 * \param ivPtr 911 * The 128-bit initial vector that contains a 64-bit nonce and 64-bit counter. 912 * 913 * \param dst 914 * The pointer to a destination cipher text. 915 * 916 * \param src 917 * The pointer to a source plain text. Must be 4-Byte aligned. 918 * 919 * \param aesState 920 * The pointer to the AES state structure allocated by the user. The user must 921 * must not modify anything in this structure. 922 * 923 * \return 924 * \ref cy_en_cryptolite_status_t 925 * 926 *******************************************************************************/ 927 cy_en_cryptolite_status_t Cy_Cryptolite_Aes_Ctr_Zeropad(CRYPTOLITE_Type *base, 928 uint32_t srcSize, 929 uint8_t *ivPtr, 930 uint8_t *dst, 931 uint8_t const *src, 932 cy_stc_cryptolite_aes_state_t *aesState); 933 934 935 #endif /*CY_CRYPTOLITE_CFG_CIPHER_MODE_CTR*/ 936 937 #endif /* #if (CY_CRYPTOLITE_CFG_AES_C)*/ 938 #endif /* #if CRYPTOLITE_AES_PRESENT*/ 939 940 /** \} group_cryptolite_lld_aes_functions */ 941 #if defined(__cplusplus) 942 } 943 #endif 944 945 #endif /* CY_IP_MXCRYPTOLITE */ 946 947 #endif /* #if !defined (CY_CRYPTOLITE_AES_H) */ 948 949 /* [] END OF FILE */ 950