1 /*************************************************************************** 2 * 3 * BSD LICENSE 4 * 5 * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * * Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in 16 * the documentation and/or other materials provided with the 17 * distribution. 18 * * Neither the name of Intel Corporation nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * 35 ***************************************************************************/ 36 37 /* 38 ***************************************************************************** 39 * Doxygen group definitions 40 ****************************************************************************/ 41 42 /** 43 ***************************************************************************** 44 * @file cpa_cy_ecsm2.h 45 * 46 * @defgroup cpaCyEcsm2 Elliptic Curve SM2 (ECSM2) API 47 * 48 * @ingroup cpaCy 49 * 50 * @description 51 * These functions specify the API for Public Key Encryption 52 * (Cryptography) SM2 operations. 53 * 54 * Chinese Public Key Algorithm based on Elliptic Curve Theory 55 * 56 * @note 57 * The naming, terms, and reference on SM2 elliptic curve, and their 58 * flow of algorithms inside this API header file are from the link 59 * below, please kindly refer to it for details. 60 * https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 61 * 62 *****************************************************************************/ 63 64 #ifndef CPA_CY_ECSM2_H_ 65 #define CPA_CY_ECSM2_H_ 66 67 #ifdef __cplusplus 68 extern "C" { 69 #endif 70 71 #include "cpa_cy_common.h" 72 #include "cpa_cy_ec.h" 73 74 /** 75 ***************************************************************************** 76 * @file cpa_cy_ecsm2.h 77 * @ingroup cpaCyEcsm2 78 * SM2 Encryption Operation Data. 79 * 80 * @description 81 * This structure contains the operation data for the cpaCyEcsm2Encrypt 82 * function. The client MUST allocate the memory for this structure and the 83 * items pointed to by this structure. When the structure is passed into 84 * the function, ownership of the memory passes to the function. Ownership 85 * of the memory returns to the client when this structure is returned in 86 * the callback function. 87 * 88 * For optimal performance all data buffers SHOULD be 8-byte aligned. 89 * 90 * All values in this structure are required to be in Most Significant Byte 91 * first order, e.g. a.pData[0] = MSB. 92 * 93 * @note 94 * If the client modifies or frees the memory referenced in this 95 * structure after it has been submitted to the cpaCyEcsm2Encrypt 96 * function, and before it has been returned in the callback, undefined 97 * behavior will result. 98 * 99 * @see 100 * cpaCyEcsm2Encrypt() 101 * 102 *****************************************************************************/ 103 typedef struct _CpaCyEcsm2EncryptOpData { 104 CpaFlatBuffer k; 105 /**< scalar multiplier (k > 0 and k < n) */ 106 CpaFlatBuffer xP; 107 /**< x coordinate of public key */ 108 CpaFlatBuffer yP; 109 /**< y coordinate of public key */ 110 CpaCyEcFieldType fieldType; 111 /**< field type for the operation */ 112 } CpaCyEcsm2EncryptOpData; 113 114 /** 115 ***************************************************************************** 116 * @file cpa_cy_ecsm2.h 117 * @ingroup cpaCyEcsm2 118 * SM2 Decryption Operation Data. 119 * 120 * @description 121 * This structure contains the operation data for the cpaCyEcsm2Decrypt 122 * function. The client MUST allocate the memory for this structure and the 123 * items pointed to by this structure. When the structure is passed into 124 * the function, ownership of the memory passes to the function. Ownership 125 * of the memory returns to the client when this structure is returned in 126 * the callback function. 127 * 128 * For optimal performance all data buffers SHOULD be 8-byte aligned. 129 * 130 * All values in this structure are required to be in Most Significant Byte 131 * first order, e.g. a.pData[0] = MSB. 132 * 133 * @note 134 * If the client modifies or frees the memory referenced in this 135 * structure after it has been submitted to the cpaCyEcsm2Decrypt 136 * function, and before it has been returned in the callback, undefined 137 * 138 * @note 139 * If the client modifies or frees the memory referenced in this 140 * structure after it has been submitted to the cpaCyEcsm2Decrypt 141 * function, and before it has been returned in the callback, undefined 142 * behavior will result. 143 * 144 * @see 145 * cpaCyEcsm2Decrypt() 146 * 147 *****************************************************************************/ 148 typedef struct _CpaCyEcsm2DecryptOpData { 149 CpaFlatBuffer d; 150 /**< private key (d > 0 and d < n) */ 151 CpaFlatBuffer x1; 152 /**< x coordinate of [k]G */ 153 CpaFlatBuffer y1; 154 /**< y coordinate of [k]G */ 155 CpaCyEcFieldType fieldType; 156 /**< field type for the operation */ 157 } CpaCyEcsm2DecryptOpData; 158 159 /** 160 ***************************************************************************** 161 * @file cpa_cy_ecsm2.h 162 * @ingroup cpaCyEcsm2 163 * SM2 Point Multiplication Operation Data. 164 * 165 * @description 166 * This structure contains the operation data for the cpaCyEcsm2PointMultiply 167 * function. The client MUST allocate the memory for this structure and the 168 * items pointed to by this structure. When the structure is passed into 169 * the function, ownership of the memory passes to the function. Ownership 170 * of the memory returns to the client when this structure is returned in 171 * the callback function. 172 * 173 * For optimal performance all data buffers SHOULD be 8-byte aligned. 174 * 175 * All values in this structure are required to be in Most Significant Byte 176 * first order, e.g. a.pData[0] = MSB. 177 * 178 * @note 179 * If the client modifies or frees the memory referenced in this 180 * structure after it has been submitted to the cpaCyEcsm2PointMultiply 181 * function, and before it has been returned in the callback, undefined 182 * behavior will result. 183 * 184 * @see 185 * cpaCyEcsm2PointMultiply() 186 * 187 *****************************************************************************/ 188 typedef struct _CpaCyEcsm2PointMultiplyOpData { 189 CpaFlatBuffer k; 190 /**< scalar multiplier (k > 0 and k < n) */ 191 CpaFlatBuffer x; 192 /**< x coordinate of a point on the curve */ 193 CpaFlatBuffer y; 194 /**< y coordinate of a point on the curve */ 195 CpaCyEcFieldType fieldType; 196 /**< field type for the operation */ 197 } CpaCyEcsm2PointMultiplyOpData; 198 199 /** 200 ***************************************************************************** 201 * @file cpa_cy_ecsm2.h 202 * @ingroup cpaCyEcsm2 203 * SM2 Generator Multiplication Operation Data. 204 * 205 * @description 206 * This structure contains the operation data for the 207 * cpaCyEcsm2GeneratorMultiply function. The client MUST allocate the 208 * memory for this structure and the items pointed to by this structure. 209 * When the structure is passed into the function, ownership of the 210 * memory passes to the function. Ownership of the memory returns to the 211 * client when this structure is returned in the callback function. 212 * 213 * For optimal performance all data buffers SHOULD be 8-byte aligned. 214 * 215 * All values in this structure are required to be in Most Significant Byte 216 * first order, e.g. a.pData[0] = MSB. 217 * 218 * @note 219 * If the client modifies or frees the memory referenced in this 220 * structure after it has been submitted to the cpaCyEcsm2GeneratorMultiply 221 * function, and before it has been returned in the callback, undefined 222 * behavior will result. 223 * 224 * @see 225 * cpaCyEcsm2GeneratorMultiply() 226 * 227 *****************************************************************************/ 228 typedef struct _CpaCyEcsm2GeneratorMultiplyOpData { 229 CpaFlatBuffer k; 230 /**< scalar multiplier (k > 0 and k < n) */ 231 CpaCyEcFieldType fieldType; 232 /**< field type for the operation */ 233 } CpaCyEcsm2GeneratorMultiplyOpData; 234 235 /** 236 ***************************************************************************** 237 * @file cpa_cy_ecsm2.h 238 * @ingroup cpaCyEcsm2 239 * SM2 Point Verify Operation Data. 240 * 241 * @description 242 * This structure contains the operation data for the cpaCyEcsm2PointVerify 243 * function. The client MUST allocate the memory for this structure and the 244 * items pointed to by this structure. When the structure is passed into 245 * the function, ownership of the memory passes to the function. Ownership 246 * of the memory returns to the client when this structure is returned in 247 * the callback function. 248 * 249 * For optimal performance all data buffers SHOULD be 8-byte aligned. 250 * 251 * All values in this structure are required to be in Most Significant Byte 252 * first order, e.g. a.pData[0] = MSB. 253 * 254 * @note 255 * If the client modifies or frees the memory referenced in this 256 * structure after it has been submitted to the cpaCyEcsm2PointVerify 257 * function, and before it has been returned in the callback, undefined 258 * behavior will result. 259 * 260 * @see 261 * cpaCyEcsm2PointVerify() 262 * 263 *****************************************************************************/ 264 typedef struct _CpaCyEcsm2PointVerifyOpData { 265 CpaFlatBuffer x; 266 /**< x coordinate of a point on the curve */ 267 CpaFlatBuffer y; 268 /**< y coordinate of a point on the curve */ 269 CpaCyEcFieldType fieldType; 270 /**< field type for the operation */ 271 } CpaCyEcsm2PointVerifyOpData; 272 273 /** 274 ***************************************************************************** 275 * @file cpa_cy_ecsm2.h 276 * @ingroup cpaCyEcsm2 277 * SM2 Signature Operation Data. 278 * 279 * @description 280 * This structure contains the operation data for the cpaCyEcsm2Sign 281 * function. The client MUST allocate the memory for this structure and the 282 * items pointed to by this structure. When the structure is passed into 283 * the function, ownership of the memory passes to the function. Ownership 284 * of the memory returns to the client when this structure is returned in 285 * the callback function. 286 * 287 * For optimal performance all data buffers SHOULD be 8-byte aligned. 288 * 289 * All values in this structure are required to be in Most Significant Byte 290 * first order, e.g. a.pData[0] = MSB. 291 * 292 * @note 293 * If the client modifies or frees the memory referenced in this 294 * structure after it has been submitted to the cpaCyEcsm2Sign 295 * function, and before it has been returned in the callback, undefined 296 * behavior will result. 297 * 298 * @see 299 * cpaCyEcsm2Sign() 300 * 301 *****************************************************************************/ 302 typedef struct _CpaCyEcsm2SignOpData { 303 CpaFlatBuffer k; 304 /**< scalar multiplier (k > 0 and k < n) */ 305 CpaFlatBuffer e; 306 /**< digest of the message */ 307 CpaFlatBuffer d; 308 /**< private key (d > 0 and d < n) */ 309 CpaCyEcFieldType fieldType; 310 /**< field type for the operation */ 311 } CpaCyEcsm2SignOpData; 312 313 /** 314 ***************************************************************************** 315 * @file cpa_cy_ecsm2.h 316 * @ingroup cpaCyEcsm2 317 * SM2 Signature Verify Operation Data. 318 * 319 * @description 320 * This structure contains the operation data for the cpaCyEcsm2Verify 321 * function. The client MUST allocate the memory for this structure and the 322 * items pointed to by this structure. When the structure is passed into 323 * the function, ownership of the memory passes to the function. Ownership 324 * of the memory returns to the client when this structure is returned in 325 * the callback function. 326 * 327 * For optimal performance all data buffers SHOULD be 8-byte aligned. 328 * 329 * All values in this structure are required to be in Most Significant Byte 330 * first order, e.g. a.pData[0] = MSB. 331 * 332 * @note 333 * If the client modifies or frees the memory referenced in this 334 * structure after it has been submitted to the cpaCyEcsm2Verify 335 * function, and before it has been returned in the callback, undefined 336 * behavior will result. 337 * 338 * @see 339 * cpaCyEcsm2Verify() 340 * 341 *****************************************************************************/ 342 typedef struct _CpaCyEcsm2VerifyOpData { 343 CpaFlatBuffer e; 344 /**< digest of the message */ 345 CpaFlatBuffer r; 346 /**< signature r */ 347 CpaFlatBuffer s; 348 /**< signature s */ 349 CpaFlatBuffer xP; 350 /**< x coordinate of public key */ 351 CpaFlatBuffer yP; 352 /**< y coordinate of public key */ 353 CpaCyEcFieldType fieldType; 354 /**< field type for the operation */ 355 } CpaCyEcsm2VerifyOpData; 356 357 /** 358 ***************************************************************************** 359 * @file cpa_cy_ecsm2.h 360 * @ingroup cpaCyEcsm2 361 * SM2 Key Exchange Phase 1 Operation Data. 362 * 363 * @description 364 * This structure contains the operation data for the cpaCyEcsm2KeyExPhase1 365 * function. The client MUST allocate the memory for this structure and the 366 * items pointed to by this structure. When the structure is passed into 367 * the function, ownership of the memory passes to the function. Ownership 368 * of the memory returns to the client when this structure is returned in 369 * the callback function. 370 * 371 * For optimal performance all data buffers SHOULD be 8-byte aligned. 372 * 373 * All values in this structure are required to be in Most Significant Byte 374 * first order, e.g. a.pData[0] = MSB. 375 * 376 * @note 377 * If the client modifies or frees the memory referenced in this 378 * structure after it has been submitted to the cpaCyEcsm2KeyExPhase1 379 * function, and before it has been returned in the callback, undefined 380 * behavior will result. 381 * 382 * @see 383 * cpaCyEcsm2KeyExPhase1() 384 * 385 *****************************************************************************/ 386 typedef struct _CpaCyEcsm2KeyExPhase1OpData { 387 CpaFlatBuffer r; 388 /**< scalar multiplier (r > 0 and r < n) */ 389 CpaCyEcFieldType fieldType; 390 /**< field type for the operation */ 391 } CpaCyEcsm2KeyExPhase1OpData; 392 393 /** 394 ***************************************************************************** 395 * @file cpa_cy_ecsm2.h 396 * @ingroup cpaCyEcsm2 397 * SM2 Key Exchange Phase 2 Operation Data. 398 * 399 * @description 400 * This structure contains the operation data for the cpaCyEcsm2KeyExPhase2 401 * function. The client MUST allocate the memory for this structure and the 402 * items pointed to by this structure. When the structure is passed into 403 * the function, ownership of the memory passes to the function. Ownership 404 * of the memory returns to the client when this structure is returned in 405 * the callback function. 406 * 407 * For optimal performance all data buffers SHOULD be 8-byte aligned. 408 * 409 * All values in this structure are required to be in Most Significant Byte 410 * first order, e.g. a.pData[0] = MSB. 411 * 412 * @note 413 * If the client modifies or frees the memory referenced in this 414 * structure after it has been submitted to the cpaCyEcsm2KeyExPhase2 415 * function, and before it has been returned in the callback, undefined 416 * behavior will result. 417 * 418 * @see 419 * cpaCyEcsm2KeyExPhase2() 420 * 421 *****************************************************************************/ 422 typedef struct _CpaCyEcsm2KeyExPhase2OpData { 423 CpaFlatBuffer r; 424 /**< scalar multiplier (r > 0 and r < n) */ 425 CpaFlatBuffer d; 426 /**< private key (d > 0 and d < n) */ 427 CpaFlatBuffer x1; 428 /**< x coordinate of a point on the curve from other side */ 429 CpaFlatBuffer x2; 430 /**< x coordinate of a point on the curve from phase 1 */ 431 CpaFlatBuffer y2; 432 /**< y coordinate of a point on the curve from phase 1 */ 433 CpaFlatBuffer xP; 434 /**< x coordinate of public key from other side */ 435 CpaFlatBuffer yP; 436 /**< y coordinate of public key from other side */ 437 CpaCyEcFieldType fieldType; 438 /**< field type for the operation */ 439 } CpaCyEcsm2KeyExPhase2OpData; 440 441 /** 442 ***************************************************************************** 443 * @file cpa_cy_ecsm2.h 444 * @ingroup cpaCyEcsm2 445 * SM2 Encryption Output Data. 446 * 447 * @description 448 * This structure contains the output data of the cpaCyEcsm2Encrypt 449 * function. The client MUST allocate the memory for this structure and the 450 * items pointed to by this structure. 451 * 452 * For optimal performance all data buffers SHOULD be 8-byte aligned. 453 * 454 * @see 455 * cpaCyEcsm2Encrypt() 456 * 457 *****************************************************************************/ 458 typedef struct _CpaCyEcsm2EncryptOutputData { 459 CpaFlatBuffer x1; 460 /**< x coordinate of [k]G */ 461 CpaFlatBuffer y1; 462 /**< y coordinate of [k]G */ 463 CpaFlatBuffer x2; 464 /**< x coordinate of [k]Pb */ 465 CpaFlatBuffer y2; 466 /**< y coordinate of [k]Pb */ 467 } CpaCyEcsm2EncryptOutputData; 468 469 /** 470 ***************************************************************************** 471 * @file cpa_cy_ecsm2.h 472 * @ingroup cpaCyEcsm2 473 * SM2 Decryption Output Data. 474 * 475 * @description 476 * This structure contains the output data of the cpaCyEcsm2Decrypt 477 * function. The client MUST allocate the memory for this structure and the 478 * items pointed to by this structure. 479 * 480 * For optimal performance all data buffers SHOULD be 8-byte aligned. 481 * 482 * @see 483 * cpaCyEcsm2Decrypt() 484 * 485 *****************************************************************************/ 486 typedef struct _CpaCyEcsm2DecryptOutputData { 487 CpaFlatBuffer x2; 488 /**< x coordinate of [k]Pb */ 489 CpaFlatBuffer y2; 490 /**< y coordinate of [k]Pb */ 491 } CpaCyEcsm2DecryptOutputData; 492 493 /** 494 ***************************************************************************** 495 * @file cpa_cy_ecsm2.h 496 * @ingroup cpaCyEcsm2 497 * SM2 Key Exchange (Phase 1 & Phase 2) Output Data. 498 * 499 * @description 500 * This structure contains the output data of the key exchange(phase 1 & 2) 501 * function. The client MUST allocate the memory for this structure and the 502 * items pointed to by this structure. 503 * 504 * For optimal performance all data buffers SHOULD be 8-byte aligned. 505 * 506 * @see 507 * cpaCyEcsm2KeyExPhase1(),cpaCyEcsm2KeyExPhase2() 508 * 509 *****************************************************************************/ 510 typedef struct _CpaCyEcsm2KeyExOutputData { 511 CpaFlatBuffer x; 512 /**< x coordinate of a point on the curve */ 513 CpaFlatBuffer y; 514 /**< y coordinate of a point on the curve */ 515 } CpaCyEcsm2KeyExOutputData; 516 517 /** 518 ***************************************************************************** 519 * @file cpa_cy_ecsm2.h 520 * @ingroup cpaCyEcsm2 521 * Cryptographic ECSM2 Statistics. 522 * @description 523 * This structure contains statistics on the Cryptographic ECSM2 524 * operations. Statistics are set to zero when the component is 525 * initialized, and are collected per instance. 526 * 527 ****************************************************************************/ 528 typedef struct _CpaCyEcsm2Stats64 { 529 Cpa64U numEcsm2PointMultiplyRequests; 530 /**< Total number of ECSM2 Point Multiplication operation requests. */ 531 Cpa64U numEcsm2PointMultiplyRequestErrors; 532 /**< Total number of ECSM2 Point Multiplication operation requests that 533 * had an error and could not be processed. */ 534 Cpa64U numEcsm2PointMultiplyCompleted; 535 /**< Total number of ECSM2 Point Multiplication operation requests that 536 * completed successfully. */ 537 Cpa64U numEcsm2PointMultiplyCompletedError; 538 /**< Total number of ECSM2 Point Multiplication operation requests that 539 * could not be completed successfully due to errors. */ 540 Cpa64U numEcsm2PointMultiplyCompletedOutputInvalid; 541 /**< Total number of ECSM2 Point Multiplication or Point Verify operation 542 * requests that could not be completed successfully due to an invalid 543 * output. Note that this does not indicate an error. */ 544 545 Cpa64U numEcsm2GeneratorMultiplyRequests; 546 /**< Total number of ECSM2 Generator Multiplication operation requests. */ 547 Cpa64U numEcsm2GeneratorMultiplyRequestErrors; 548 /**< Total number of ECSM2 Generator Multiplication operation requests that 549 * had an error and could not be processed. */ 550 Cpa64U numEcsm2GeneratorMultiplyCompleted; 551 /**< Total number of ECSM2 Generator Multiplication operation requests that 552 * completed successfully. */ 553 Cpa64U numEcsm2GeneratorMultiplyCompletedError; 554 /**< Total number of ECSM2 Generator Multiplication operation requests that 555 * could not be completed successfully due to errors. */ 556 Cpa64U numEcsm2GeneratorMultiplyCompletedOutputInvalid; 557 /**< Total number of ECSM2 Generator Multiplication or Point Verify 558 * operation requests that could not be completed successfully due to an 559 * invalid output. Note that this does not indicate an error. */ 560 561 Cpa64U numEcsm2PointVerifyRequests; 562 /**< Total number of ECSM2 Point Verify operation requests. */ 563 Cpa64U numEcsm2PointVerifyRequestErrors; 564 /**< Total number of ECSM2 Point Verify operation requests that had 565 * an error and could not be processed. */ 566 Cpa64U numEcsm2PointVerifyCompleted; 567 /**< Total number of ECSM2 Point Verify operation requests that 568 * completed successfully. */ 569 Cpa64U numEcsm2PointVerifyCompletedError; 570 /**< Total number of ECSM2 Point Verify operation requests that could 571 * not be completed successfully due to errors. */ 572 Cpa64U numEcsm2PointVerifyCompletedOutputInvalid; 573 /**< Total number of ECSM2 Point Verify operation 574 * requests that could not be completed successfully due to an invalid 575 * output. Note that this does not indicate an error. */ 576 577 Cpa64U numEcsm2SignRequests; 578 /**< Total number of ECSM2 Sign operation requests. */ 579 Cpa64U numEcsm2SignRequestErrors; 580 /**< Total number of ECSM2 Sign operation requests that had an error 581 * and could not be processed. */ 582 Cpa64U numEcsm2SignCompleted; 583 /**< Total number of ECSM2 Sign operation requests that completed 584 * successfully. */ 585 Cpa64U numEcsm2SignCompletedError; 586 /**< Total number of ECSM2 Sign operation requests that could 587 * not be completed successfully due to errors. */ 588 Cpa64U numEcsm2SignCompletedOutputInvalid; 589 /**< Total number of ECSM2 Sign operation 590 * requests that could not be completed successfully due to an invalid 591 * output. Note that this does not indicate an error. */ 592 593 Cpa64U numEcsm2VerifyRequests; 594 /**< Total number of ECSM2 Verify operation requests. */ 595 Cpa64U numEcsm2VerifyRequestErrors; 596 /**< Total number of ECSM2 Verify operation requests that had an error 597 * and could not be processed. */ 598 Cpa64U numEcsm2VerifyCompleted; 599 /**< Total number of ECSM2 Verify operation requests that completed 600 * successfully. */ 601 Cpa64U numEcsm2VerifyCompletedError; 602 /**< Total number of ECSM2 Verify operation requests that could 603 * not be completed successfully due to errors. */ 604 Cpa64U numEcsm2VerifyCompletedOutputInvalid; 605 /**< Total number of ECSM2 Verify operation 606 * requests that could not be completed successfully due to an invalid 607 * output. Note that this does not indicate an error. */ 608 609 Cpa64U numEcsm2EncryptRequests; 610 /**< Total number of ECSM2 Encryption requests. */ 611 Cpa64U numEcsm2EncryptRequestErrors; 612 /**< Total number of ECSM2 Point Encryption requests that had 613 * an error and could not be processed. */ 614 Cpa64U numEcsm2EncryptCompleted; 615 /**< Total number of ECSM2 Encryption operation requests that 616 * completed successfully. */ 617 Cpa64U numEcsm2EncryptCompletedError; 618 /**< Total number of ECSM2 Encryption operation requests that could 619 * not be completed successfully due to errors. */ 620 Cpa64U numEcsm2EncryptCompletedOutputInvalid; 621 /**< Total number of ECSM2 Encryption operation 622 * requests that could not be completed successfully due to an invalid 623 * output. Note that this does not indicate an error. */ 624 625 Cpa64U numEcsm2DecryptRequests; 626 /**< Total number of ECSM2 Decryption operation requests. */ 627 Cpa64U numEcsm2DecryptRequestErrors; 628 /**< Total number of ECSM2 Point Decryption requests that had 629 * an error and could not be processed. */ 630 Cpa64U numEcsm2DecryptCompleted; 631 /**< Total number of ECSM2 Decryption operation requests that 632 * completed successfully. */ 633 Cpa64U numEcsm2DecryptCompletedError; 634 /**< Total number of ECSM2 Decryption operation requests that could 635 * not be completed successfully due to errors. */ 636 Cpa64U numEcsm2DecryptCompletedOutputInvalid; 637 /**< Total number of ECSM2 Decryption operation 638 * requests that could not be completed successfully due to an invalid 639 * output. Note that this does not indicate an error. */ 640 641 Cpa64U numEcsm2KeyExPhase1Requests; 642 /**< Total number of ECSM2 Key Exchange Phase1 operation requests. */ 643 Cpa64U numEcsm2KeyExPhase1RequestErrors; 644 /**< Total number of ECSM2 Key Exchange Phase1 operation requests that 645 * had an error and could not be processed. */ 646 Cpa64U numEcsm2KeyExPhase1Completed; 647 /**< Total number of ECSM2 Key Exchange Phase1 operation requests that 648 * completed successfully. */ 649 Cpa64U numEcsm2KeyExPhase1CompletedError; 650 /**< Total number of ECSM2 Key Exchange Phase1 operation requests that 651 * could not be completed successfully due to errors. */ 652 Cpa64U numEcsm2KeyExPhase1CompletedOutputInvalid; 653 /**< Total number of ECSM2 Key Exchange Phase1 operation 654 * requests that could not be completed successfully due to an invalid 655 * output. Note that this does not indicate an error. */ 656 657 Cpa64U numEcsm2KeyExPhase2Requests; 658 /**< Total number of ECSM2 Key Exchange Phase2 operation requests. */ 659 Cpa64U numEcsm2KeyExPhase2RequestErrors; 660 /**< Total number of ECSM2 Key Exchange Phase2 operation requests that 661 * had an error and could not be processed. */ 662 Cpa64U numEcsm2KeyExPhase2Completed; 663 /**< Total number of ECSM2 Key Exchange Phase2 operation requests that 664 * completed successfully. */ 665 Cpa64U numEcsm2KeyExPhase2CompletedError; 666 /**< Total number of ECSM2 Key Exchange Phase2 operation requests that 667 * could not be completed successfully due to errors. */ 668 Cpa64U numEcsm2KeyExPhase2CompletedOutputInvalid; 669 /**< Total number of ECSM2 Key Exchange Phase2 operation 670 * requests that could not be completed successfully due to an invalid 671 * output. Note that this does not indicate an error. */ 672 } CpaCyEcsm2Stats64; 673 674 /** 675 ***************************************************************************** 676 * @file cpa_cy_ecsm2.h 677 * @ingroup cpaCyEcsm2 678 * Definition of callback function invoked for cpaCyEcsm2Sign 679 * requests. 680 * 681 * @description 682 * This is the callback function for: 683 * cpaCyEcsm2Sign 684 * 685 * @context 686 * This callback function can be executed in a context that DOES NOT 687 * permit sleeping to occur. 688 * @assumptions 689 * None 690 * @sideEffects 691 * None 692 * @reentrant 693 * No 694 * @threadSafe 695 * Yes 696 * 697 * @param[in] pCallbackTag User-supplied value to help identify request. 698 * @param[in] status Status of the operation. Valid values are 699 * CPA_STATUS_SUCCESS and CPA_STATUS_FAIL. 700 * @param[in] pOpData A pointer to Operation data supplied in 701 * request. 702 * @param[in] pass Indicate whether pOut is valid or not. 703 * CPA_TRUE == pass, pOut is valid 704 * CPA_FALSE == pass, pOut is invalid 705 * @param[in] pR Ecsm2 message signature r. 706 * @param[in] pS Ecsm2 message signature s. 707 * 708 * @retval 709 * None 710 * @pre 711 * Component has been initialized. 712 * @post 713 * None 714 * @note 715 * None 716 * @see 717 * cpaCyEcsm2GeneratorMultiply() 718 * 719 *****************************************************************************/ 720 typedef void (*CpaCyEcsm2SignCbFunc)(void *pCallbackTag, 721 CpaStatus status, 722 void *pOpData, 723 CpaBoolean pass, 724 CpaFlatBuffer *pR, 725 CpaFlatBuffer *pS); 726 727 /** 728 ***************************************************************************** 729 * @file cpa_cy_ecsm2.h 730 * @ingroup cpaCyEcsm2 731 * Definition of callback function invoked for cpaCyEcsm2Verify requests. 732 * 733 * @description 734 * This is the prototype for the CpaCyEcsm2VerifyCbFunc callback function. 735 * 736 * @context 737 * This callback function can be executed in a context that DOES NOT 738 * permit sleeping to occur. 739 * @assumptions 740 * None 741 * @sideEffects 742 * None 743 * @reentrant 744 * No 745 * @threadSafe 746 * Yes 747 * 748 * @param[in] pCallbackTag User-supplied value to help identify request. 749 * @param[in] status Status of the operation. Valid values are 750 * CPA_STATUS_SUCCESS and CPA_STATUS_FAIL. 751 * @param[in] pOpData Operation data pointer supplied in request. 752 * @param[in] verifyStatus The verification status. 753 * 754 * @retval 755 * None 756 * @pre 757 * Component has been initialized. 758 * @post 759 * None 760 * @note 761 * None 762 * @see 763 * cpaCyEcsm2Verify() 764 * 765 *****************************************************************************/ 766 typedef void (*CpaCyEcsm2VerifyCbFunc)(void *pCallbackTag, 767 CpaStatus status, 768 void *pOpData, 769 CpaBoolean verifyStatus); 770 771 /** 772 ***************************************************************************** 773 * @file cpa_cy_ecsm2.h 774 * @ingroup cpaCyEcsm2 775 * Perform SM2 Point Multiplication. 776 * 777 * @description 778 * This function performs SM2 Point Multiplication, multiply 779 * a point (P) by k (scalar) ([k]P). 780 * 781 * @context 782 * When called as an asynchronous function it cannot sleep. It can be 783 * executed in a context that does not permit sleeping. 784 * When called as a synchronous function it may sleep. It MUST NOT be 785 * executed in a context that DOES NOT permit sleeping. 786 * @assumptions 787 * None 788 * @sideEffects 789 * None 790 * @blocking 791 * Yes when configured to operate in synchronous mode. 792 * @reentrant 793 * No 794 * @threadSafe 795 * Yes 796 * 797 * @param[in] instanceHandle Instance handle. 798 * @param[in] pCb Callback function pointer. If this is set to 799 * a NULL value the function will operate 800 * synchronously. 801 * @param[in] pCallbackTag User-supplied value to help identify request. 802 * @param[in] pOpData Structure containing all the data needed to 803 * perform the operation. The client code 804 * allocates the memory for this structure. This 805 * component takes ownership of the memory until 806 * it is returned in the callback. 807 * @param[out] pMultiplyStatus Multiply status 808 * CPA_TRUE == pOutputData is valid 809 * CPA_FALSE == pOutputData is invalid 810 * @param[out] pXk x coordinate of the resulting point 811 * multiplication 812 * @param[out] pYk y coordinate of the resulting point 813 * multiplication 814 * 815 * @retval CPA_STATUS_SUCCESS Function executed successfully. 816 * @retval CPA_STATUS_FAIL Function failed. 817 * @retval CPA_STATUS_RETRY Resubmit the request. 818 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 819 * @retval CPA_STATUS_RESOURCE Error related to system resources. 820 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 821 * the request. 822 * 823 * @pre 824 * The component has been initialized via cpaCyStartInstance function. 825 * @post 826 * None 827 * @note 828 * When pCb is non-NULL an asynchronous callback of type 829 * CpaCyEcsm2PointMultiplyCbFunc is generated in response to this function call. 830 * For optimal performance, data pointers SHOULD be 8-byte aligned. 831 * 832 * @see 833 * CpaCyEcsm2PointMultiplyOpData, 834 * CpaCyEcPointMultiplyCbFunc 835 * 836 *****************************************************************************/ 837 CpaStatus 838 cpaCyEcsm2PointMultiply(const CpaInstanceHandle instanceHandle, 839 const CpaCyEcPointMultiplyCbFunc pCb, 840 void *pCallbackTag, 841 const CpaCyEcsm2PointMultiplyOpData *pOpData, 842 CpaBoolean *pMultiplyStatus, 843 CpaFlatBuffer *pXk, 844 CpaFlatBuffer *pYk); 845 846 /** 847 ***************************************************************************** 848 * @file cpa_cy_ecsm2.h 849 * @ingroup cpaCyEcsm2 850 * Perform SM2 Generator Multiplication. 851 * 852 * @description 853 * This function performs SM2 Generator Multiplication, multiply the 854 * generator point (G) by k (scalar) ([k]G). 855 * 856 * @context 857 * When called as an asynchronous function it cannot sleep. It can be 858 * executed in a context that does not permit sleeping. 859 * When called as a synchronous function it may sleep. It MUST NOT be 860 * executed in a context that DOES NOT permit sleeping. 861 * @assumptions 862 * None 863 * @sideEffects 864 * None 865 * @blocking 866 * Yes when configured to operate in synchronous mode. 867 * @reentrant 868 * No 869 * @threadSafe 870 * Yes 871 * 872 * @param[in] instanceHandle Instance handle. 873 * @param[in] pCb Callback function pointer. If this is set to 874 * a NULL value the function will operate 875 * synchronously. 876 * @param[in] pCallbackTag User-supplied value to help identify request. 877 * @param[in] pOpData Structure containing all the data needed to 878 * perform the operation. The client code 879 * allocates the memory for this structure. This 880 * component takes ownership of the memory until 881 * it is returned in the callback. 882 * @param[out] pMultiplyStatus Multiply status 883 * CPA_TRUE == pOutputData is valid 884 * CPA_FALSE == pOutputData is invalid 885 * @param[out] pXk x coordinate of the resulting point 886 * multiplication 887 * @param[out] pYk y coordinate of the resulting point 888 * multiplication 889 * 890 * @retval CPA_STATUS_SUCCESS Function executed successfully. 891 * @retval CPA_STATUS_FAIL Function failed. 892 * @retval CPA_STATUS_RETRY Resubmit the request. 893 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 894 * @retval CPA_STATUS_RESOURCE Error related to system resources. 895 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 896 * the request. 897 * 898 * @pre 899 * The component has been initialized via cpaCyStartInstance function. 900 * @post 901 * None 902 * @note 903 * When pCb is non-NULL an asynchronous callback of type 904 * CpaCyEcPointMultiplyCbFunc is generated in response to this function 905 * call. For optimal performance, data pointers SHOULD be 8-byte aligned. 906 * 907 * @see 908 * CpaCyEcsm2GeneratorMultiplyOpData, 909 * CpaCyEcPointMultiplyCbFunc 910 * 911 *****************************************************************************/ 912 CpaStatus 913 cpaCyEcsm2GeneratorMultiply(const CpaInstanceHandle instanceHandle, 914 const CpaCyEcPointMultiplyCbFunc pCb, 915 void *pCallbackTag, 916 const CpaCyEcsm2GeneratorMultiplyOpData *pOpData, 917 CpaBoolean *pMultiplyStatus, 918 CpaFlatBuffer *pXk, 919 CpaFlatBuffer *pYk); 920 921 /** 922 ***************************************************************************** 923 * @file cpa_cy_ec.h 924 * @ingroup cpaCyEcsm2 925 * Perform SM2 Point Verify. 926 * 927 * @description 928 * This function performs SM2 Point Verify, to check if the input point 929 * on the curve or not. 930 * 931 * @context 932 * When called as an asynchronous function it cannot sleep. It can be 933 * executed in a context that does not permit sleeping. 934 * When called as a synchronous function it may sleep. It MUST NOT be 935 * executed in a context that DOES NOT permit sleeping. 936 * @assumptions 937 * None 938 * @sideEffects 939 * None 940 * @blocking 941 * Yes when configured to operate in synchronous mode. 942 * @reentrant 943 * No 944 * @threadSafe 945 * Yes 946 * 947 * @param[in] instanceHandle Instance handle. 948 * @param[in] pCb Callback function pointer. If this is set to 949 * a NULL value the function will operate 950 * synchronously. 951 * @param[in] pCallbackTag User-supplied value to help identify request. 952 * @param[in] pOpData Structure containing all the data needed to 953 * perform the operation. The client code 954 * allocates the memory for this structure. This 955 * component takes ownership of the memory until 956 * it is returned in the callback. 957 * @param[out] pVerifyStatus Verification status 958 * CPA_TRUE == verify pass 959 * CPA_FALSE == verify fail 960 * 961 * @retval CPA_STATUS_SUCCESS Function executed successfully. 962 * @retval CPA_STATUS_FAIL Function failed. 963 * @retval CPA_STATUS_RETRY Resubmit the request. 964 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 965 * @retval CPA_STATUS_RESOURCE Error related to system resources. 966 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 967 * the request. 968 * 969 * @pre 970 * The component has been initialized via cpaCyStartInstance function. 971 * @post 972 * None 973 * @note 974 * When pCb is non-NULL an asynchronous callback of type 975 * CpaCyEcsm2VerifyCbFunc is generated in response to this function call. 976 * For optimal performance, data pointers SHOULD be 8-byte aligned. 977 * 978 * @see 979 * CpaCyEcsm2PointVerifyOpData, 980 * CpaCyEcPointVerifyCbFunc 981 * 982 *****************************************************************************/ 983 CpaStatus 984 cpaCyEcsm2PointVerify(const CpaInstanceHandle instanceHandle, 985 const CpaCyEcPointVerifyCbFunc pCb, 986 void *pCallbackTag, 987 const CpaCyEcsm2PointVerifyOpData *pOpData, 988 CpaBoolean *pVerifyStatus); 989 990 /** 991 ***************************************************************************** 992 * @file cpa_cy_ec.h 993 * @ingroup cpaCyEcsm2 994 * Perform SM2 Signature (Step A4 to A7). 995 * 996 * @description 997 * This function implements step A4 to A7 (in Section 5.2 in "Generation 998 * of Signature" Part 1). 999 * 1000 * @context 1001 * When called as an asynchronous function it cannot sleep. It can be 1002 * executed in a context that does not permit sleeping. 1003 * When called as a synchronous function it may sleep. It MUST NOT be 1004 * executed in a context that DOES NOT permit sleeping. 1005 * @assumptions 1006 * None 1007 * @sideEffects 1008 * None 1009 * @blocking 1010 * Yes when configured to operate in synchronous mode. 1011 * @reentrant 1012 * No 1013 * @threadSafe 1014 * Yes 1015 * 1016 * @param[in] instanceHandle Instance handle. 1017 * @param[in] pCb Callback function pointer. If this is set to 1018 * a NULL value the function will operate 1019 * synchronously. 1020 * @param[in] pCallbackTag User-supplied value to help identify request. 1021 * @param[in] pOpData Structure containing all the data needed to 1022 * perform the operation. The client code 1023 * allocates the memory for this structure. This 1024 * component takes ownership of the memory until 1025 * it is returned in the callback. 1026 * @param[out] pSignStatus Signature status 1027 * CPA_TRUE = pOutputData is valid 1028 * CPA_FALSE = pOutputData is invalid 1029 * @param[out] pR R output of the resulting signature operation 1030 * @param[out] pS S output of the resulting signature operation 1031 * 1032 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1033 * @retval CPA_STATUS_FAIL Function failed. 1034 * @retval CPA_STATUS_RETRY Resubmit the request. 1035 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 1036 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1037 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1038 * the request. 1039 * 1040 * @pre 1041 * The component has been initialized via cpaCyStartInstance function. 1042 * @post 1043 * None 1044 * @note 1045 * When pCb is non-NULL an asynchronous callback of type 1046 * CpaCyEcsm2SignCbFunc is generated in response to this function call. 1047 * For optimal performance, data pointers SHOULD be 8-byte aligned. 1048 * 1049 * @see 1050 * CpaCyEcsm2SignOpData, 1051 * CpaCyEcsm2SignCbFunc 1052 * 1053 *****************************************************************************/ 1054 CpaStatus 1055 cpaCyEcsm2Sign(const CpaInstanceHandle instanceHandle, 1056 const CpaCyEcsm2SignCbFunc pCb, 1057 void *pCallbackTag, 1058 const CpaCyEcsm2SignOpData *pOpData, 1059 CpaBoolean *pSignStatus, 1060 CpaFlatBuffer *pR, 1061 CpaFlatBuffer *pS); 1062 1063 /** 1064 ***************************************************************************** 1065 * @file cpa_cy_ec.h 1066 * @ingroup cpaCyEcsm2 1067 * Perform SM2 Signature Verify (Step B5 to B7). 1068 * 1069 * @description 1070 * This function implements step B5 to B7 (in Section 5.3 in "Verification 1071 * of Signature" Part 1). 1072 * 1073 * @context 1074 * When called as an asynchronous function it cannot sleep. It can be 1075 * executed in a context that does not permit sleeping. 1076 * When called as a synchronous function it may sleep. It MUST NOT be 1077 * executed in a context that DOES NOT permit sleeping. 1078 * @assumptions 1079 * None 1080 * @sideEffects 1081 * None 1082 * @blocking 1083 * Yes when configured to operate in synchronous mode. 1084 * @reentrant 1085 * No 1086 * @threadSafe 1087 * Yes 1088 * 1089 * @param[in] instanceHandle Instance handle. 1090 * @param[in] pCb Callback function pointer. If this is set to 1091 * a NULL value the function will operate 1092 * synchronously. 1093 * @param[in] pCallbackTag User-supplied value to help identify request. 1094 * @param[in] pOpData Structure containing all the data needed to 1095 * perform the operation. The client code 1096 * allocates the memory for this structure. This 1097 * component takes ownership of the memory until 1098 * it is returned in the callback. 1099 * @param[out] pVerifyStatus Status of the signature verification 1100 * CPA_TRUE == verify pass 1101 * CPA_FALSE == verify fail 1102 * 1103 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1104 * @retval CPA_STATUS_FAIL Function failed. 1105 * @retval CPA_STATUS_RETRY Resubmit the request. 1106 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 1107 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1108 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1109 * the request. 1110 * 1111 * @pre 1112 * The component has been initialized via cpaCyStartInstance function. 1113 * @post 1114 * None 1115 * @note 1116 * When pCb is non-NULL an asynchronous callback of type 1117 * CpaCyEcsm2VerifyCbFunc is generated in response to this function call. 1118 * For optimal performance, data pointers SHOULD be 8-byte aligned. 1119 * 1120 * @see 1121 * CpaCyEcsm2VerifyOpData, 1122 * CpaCyEcsm2VerifyCbFunc 1123 * 1124 *****************************************************************************/ 1125 CpaStatus 1126 cpaCyEcsm2Verify(const CpaInstanceHandle instanceHandle, 1127 const CpaCyEcsm2VerifyCbFunc pCb, 1128 void *pCallbackTag, 1129 const CpaCyEcsm2VerifyOpData *pOpData, 1130 CpaBoolean *pVerifyStatus); 1131 1132 /** 1133 ***************************************************************************** 1134 * @file cpa_cy_ec.h 1135 * @ingroup cpaCyEcsm2 1136 * Perform SM2 Encryption (Step A2 to A4). 1137 * 1138 * @description 1139 * This function implements step A2 to A4 (in Section 7.2 in 1140 * "Algorithm for Encryption and the Flow Chart" Part 1). 1141 * 1142 * @context 1143 * When called as an asynchronous function it cannot sleep. It can be 1144 * executed in a context that does not permit sleeping. 1145 * When called as a synchronous function it may sleep. It MUST NOT be 1146 * executed in a context that DOES NOT permit sleeping. 1147 * @assumptions 1148 * None 1149 * @sideEffects 1150 * None 1151 * @blocking 1152 * Yes when configured to operate in synchronous mode. 1153 * @reentrant 1154 * No 1155 * @threadSafe 1156 * Yes 1157 * 1158 * @param[in] instanceHandle Instance handle. 1159 * @param[in] pCb Callback function pointer. If this is set to 1160 * a NULL value the function will operate 1161 * synchronously. 1162 * @param[in] pCallbackTag User-supplied value to help identify request. 1163 * @param[in] pOpData Structure containing all the data needed to 1164 * perform the operation. The client code 1165 * allocates the memory for this structure. This 1166 * component takes ownership of the memory until 1167 * it is returned in the callback. 1168 * @param[out] pOutputData Ecrypted message 1169 * 1170 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1171 * @retval CPA_STATUS_FAIL Function failed. 1172 * @retval CPA_STATUS_RETRY Resubmit the request. 1173 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 1174 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1175 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1176 * the request. 1177 * 1178 * @pre 1179 * The component has been initialized via cpaCyStartInstance function. 1180 * @post 1181 * None 1182 * @note 1183 * When pCb is non-NULL an asynchronous callback of type 1184 * CpaCyGenFlatBufCbFunc is generated in response to this function call. 1185 * For optimal performance, data pointers SHOULD be 8-byte aligned. 1186 * 1187 * @see 1188 * CpaCyEcsm2EncryptOpData, 1189 * CpaCyEcsm2EncryptOutputData, 1190 * CpaCyGenFlatBufCbFunc 1191 * 1192 *****************************************************************************/ 1193 CpaStatus 1194 cpaCyEcsm2Encrypt(const CpaInstanceHandle instanceHandle, 1195 const CpaCyGenFlatBufCbFunc pCb, 1196 void *pCallbackTag, 1197 const CpaCyEcsm2EncryptOpData *pOpData, 1198 CpaCyEcsm2EncryptOutputData *pOutputData); 1199 1200 /** 1201 ***************************************************************************** 1202 * @file cpa_cy_ec.h 1203 * @ingroup cpaCyEcsm2 1204 * Perform SM2 Decryption (Step B1 to B3). 1205 * 1206 * @description 1207 * This function implements step B1 to B3 (in Section 7.3 in "Algorithm 1208 * for Decryption and the Flow Chart" Part 1). 1209 * 1210 * @context 1211 * When called as an asynchronous function it cannot sleep. It can be 1212 * executed in a context that does not permit sleeping. 1213 * When called as a synchronous function it may sleep. It MUST NOT be 1214 * executed in a context that DOES NOT permit sleeping. 1215 * @assumptions 1216 * None 1217 * @sideEffects 1218 * None 1219 * @blocking 1220 * Yes when configured to operate in synchronous mode. 1221 * @reentrant 1222 * No 1223 * @threadSafe 1224 * Yes 1225 * 1226 * @param[in] instanceHandle Instance handle. 1227 * @param[in] pCb Callback function pointer. If this is set to 1228 * a NULL value the function will operate 1229 * synchronously. 1230 * @param[in] pCallbackTag User-supplied value to help identify request. 1231 * @param[in] pOpData Structure containing all the data needed to 1232 * perform the operation. The client code 1233 * allocates the memory for this structure. This 1234 * component takes ownership of the memory until 1235 * it is returned in the callback. 1236 * @param[out] pOutputData Decrypted message 1237 * 1238 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1239 * @retval CPA_STATUS_FAIL Function failed. 1240 * @retval CPA_STATUS_RETRY Resubmit the request. 1241 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 1242 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1243 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1244 * the request. 1245 * 1246 * @pre 1247 * The component has been initialized via cpaCyStartInstance function. 1248 * @post 1249 * None 1250 * @note 1251 * When pCb is non-NULL an asynchronous callback of type 1252 * CpaCyGenFlatBufCbFunc is generated in response to this function call. 1253 * For optimal performance, data pointers SHOULD be 8-byte aligned. 1254 * 1255 * @see 1256 * CpaCyEcsm2DecryptOpData, 1257 * CpaCyEcsm2DecryptOutputData, 1258 * CpaCyGenFlatBufCbFunc 1259 * 1260 *****************************************************************************/ 1261 CpaStatus 1262 cpaCyEcsm2Decrypt(const CpaInstanceHandle instanceHandle, 1263 const CpaCyGenFlatBufCbFunc pCb, 1264 void *pCallbackTag, 1265 const CpaCyEcsm2DecryptOpData *pOpData, 1266 CpaCyEcsm2DecryptOutputData *pOutputData); 1267 1268 /** 1269 ***************************************************************************** 1270 * @file cpa_cy_ec.h 1271 * @ingroup cpaCyEcsm2 1272 * Perform SM2 Key Exchange Phase 1 (Step A2/B2). 1273 * 1274 * @description 1275 * This function implements step A2 (User A) or B2 (User B) 1276 * (in Section 6.2 in "Key Exchange Protocol and the Flow Chart" Part 1). 1277 * 1278 * @context 1279 * When called as an asynchronous function it cannot sleep. It can be 1280 * executed in a context that does not permit sleeping. 1281 * When called as a synchronous function it may sleep. It MUST NOT be 1282 * executed in a context that DOES NOT permit sleeping. 1283 * @assumptions 1284 * None 1285 * @sideEffects 1286 * None 1287 * @blocking 1288 * Yes when configured to operate in synchronous mode. 1289 * @reentrant 1290 * No 1291 * @threadSafe 1292 * Yes 1293 * 1294 * @param[in] instanceHandle Instance handle. 1295 * @param[in] pCb Callback function pointer. If this is set to 1296 * a NULL value the function will operate 1297 * synchronously. 1298 * @param[in] pCallbackTag User-supplied value to help identify request. 1299 * @param[in] pOpData Structure containing all the data needed to 1300 * perform the operation. The client code 1301 * allocates the memory for this structure. This 1302 * component takes ownership of the memory until 1303 * it is returned in the callback. 1304 * @param[out] pOutputData Output of key exchange phase 1 ([r]G) 1305 * 1306 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1307 * @retval CPA_STATUS_FAIL Function failed. 1308 * @retval CPA_STATUS_RETRY Resubmit the request. 1309 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 1310 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1311 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1312 * the request. 1313 * 1314 * @pre 1315 * The component has been initialized via cpaCyStartInstance function. 1316 * @post 1317 * None 1318 * @note 1319 * When pCb is non-NULL an asynchronous callback of type 1320 * CpaCyGenFlatBufCbFunc is generated in response to this function call. 1321 * For optimal performance, data pointers SHOULD be 8-byte aligned. 1322 * 1323 * @see 1324 * CpaCyEcsm2KeyExPhase1OpData, 1325 * CpaCyEcsm2KeyExOutputData, 1326 * CpaCyGenFlatBufCbFunc 1327 * 1328 *****************************************************************************/ 1329 CpaStatus 1330 cpaCyEcsm2KeyExPhase1(const CpaInstanceHandle instanceHandle, 1331 const CpaCyGenFlatBufCbFunc pCb, 1332 void *pCallbackTag, 1333 const CpaCyEcsm2KeyExPhase1OpData *pOpData, 1334 CpaCyEcsm2KeyExOutputData *pOutputData); 1335 /** 1336 ***************************************************************************** 1337 * @file cpa_cy_ec.h 1338 * @ingroup cpaCyEcsm2 1339 * Perform SM2 Key Exchange Phase 2 (Step A4 to A7, B3 to B6). 1340 * 1341 * @description 1342 * This function implements steps A4 to A7(User A) or B3 to B6(User B) 1343 * (in Section 6.2 in "Key Exchange Protocol and the Flow Chart" Part 1). 1344 * 1345 * @context 1346 * When called as an asynchronous function it cannot sleep. It can be 1347 * executed in a context that does not permit sleeping. 1348 * When called as a synchronous function it may sleep. It MUST NOT be 1349 * executed in a context that DOES NOT permit sleeping. 1350 * @assumptions 1351 * None 1352 * @sideEffects 1353 * None 1354 * @blocking 1355 * Yes when configured to operate in synchronous mode. 1356 * @reentrant 1357 * No 1358 * @threadSafe 1359 * Yes 1360 * 1361 * @param[in] instanceHandle Instance handle. 1362 * @param[in] pCb Callback function pointer. If this is set to 1363 * a NULL value the function will operate 1364 * synchronously. 1365 * @param[in] pCallbackTag User-supplied value to help identify request. 1366 * @param[in] pOpData Structure containing all the data needed to 1367 * perform the operation. The client code 1368 * allocates the memory for this structure. This 1369 * component takes ownership of the memory until 1370 * it is returned in the callback. 1371 * @param[out] pOutputData Output of key exchange phase2. 1372 * 1373 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1374 * @retval CPA_STATUS_FAIL Function failed. 1375 * @retval CPA_STATUS_RETRY Resubmit the request. 1376 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter in. 1377 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1378 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1379 * the request. 1380 * 1381 * @pre 1382 * The component has been initialized via cpaCyStartInstance function. 1383 * @post 1384 * None 1385 * @note 1386 * When pCb is non-NULL an asynchronous callback of type 1387 * CpaCyGenFlatBufCbFunc is generated in response to this function call. 1388 * For optimal performance, data pointers SHOULD be 8-byte aligned. 1389 * 1390 * @see 1391 * CpaCyEcsm2KeyExPhase2OpData, 1392 * CpaCyEcsm2KeyExOutputData, 1393 * CpaCyGenFlatBufCbFunc 1394 * 1395 *****************************************************************************/ 1396 CpaStatus 1397 cpaCyEcsm2KeyExPhase2(const CpaInstanceHandle instanceHandle, 1398 const CpaCyGenFlatBufCbFunc pCb, 1399 void *pCallbackTag, 1400 const CpaCyEcsm2KeyExPhase2OpData *pOpData, 1401 CpaCyEcsm2KeyExOutputData *pOutputData); 1402 /** 1403 ***************************************************************************** 1404 * @file cpa_cy_ecsm2.h 1405 * @ingroup cpaCyEcsm2 1406 * Query statistics for a specific ECSM2 instance. 1407 * 1408 * @description 1409 * This function will query a specific instance of the ECSM2 implementation 1410 * for statistics. The user MUST allocate the CpaCyEcsm2Stats64 structure 1411 * and pass the reference to that structure into this function call. This 1412 * function writes the statistic results into the passed in 1413 * CpaCyEcsm2Stats64 structure. 1414 * 1415 * Note: statistics returned by this function do not interrupt current data 1416 * processing and as such can be slightly out of sync with operations that 1417 * are in progress during the statistics retrieval process. 1418 * 1419 * @context 1420 * This is a synchronous function and it can sleep. It MUST NOT be 1421 * executed in a context that DOES NOT permit sleeping. 1422 * @assumptions 1423 * None 1424 * @sideEffects 1425 * None 1426 * @blocking 1427 * This function is synchronous and blocking. 1428 * @reentrant 1429 * No 1430 * @threadSafe 1431 * Yes 1432 * 1433 * @param[in] instanceHandle Instance handle. 1434 * @param[out] pEcsm2Stats Pointer to memory into which the statistics 1435 * will be written. 1436 * 1437 * @retval CPA_STATUS_SUCCESS Function executed successfully. 1438 * @retval CPA_STATUS_FAIL Function failed. 1439 * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 1440 * @retval CPA_STATUS_RESOURCE Error related to system resources. 1441 * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 1442 * the request. 1443 * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 1444 * 1445 * @pre 1446 * Component has been initialized. 1447 * @post 1448 * None 1449 * @note 1450 * This function operates in a synchronous manner and no asynchronous 1451 * callback will be generated. 1452 * @see 1453 * CpaCyEcsm2Stats64 1454 *****************************************************************************/ 1455 1456 CpaStatus 1457 cpaCyEcsm2QueryStats64(const CpaInstanceHandle instanceHandle_in, 1458 CpaCyEcsm2Stats64 *pEcsm2Stats); 1459 1460 #ifdef __cplusplus 1461 } /* close the extern "C" { */ 1462 #endif 1463 1464 #endif /*CPA_CY_ECSM2_H_*/ 1465