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