178ee8d1cSJulian Grajkowski /*************************************************************************** 278ee8d1cSJulian Grajkowski * 378ee8d1cSJulian Grajkowski * BSD LICENSE 478ee8d1cSJulian Grajkowski * 5266b0663SKrzysztof Zdziarski * Copyright(c) 2007-2023 Intel Corporation. All rights reserved. 678ee8d1cSJulian Grajkowski * All rights reserved. 778ee8d1cSJulian Grajkowski * 878ee8d1cSJulian Grajkowski * Redistribution and use in source and binary forms, with or without 978ee8d1cSJulian Grajkowski * modification, are permitted provided that the following conditions 1078ee8d1cSJulian Grajkowski * are met: 1178ee8d1cSJulian Grajkowski * 1278ee8d1cSJulian Grajkowski * * Redistributions of source code must retain the above copyright 1378ee8d1cSJulian Grajkowski * notice, this list of conditions and the following disclaimer. 1478ee8d1cSJulian Grajkowski * * Redistributions in binary form must reproduce the above copyright 1578ee8d1cSJulian Grajkowski * notice, this list of conditions and the following disclaimer in 1678ee8d1cSJulian Grajkowski * the documentation and/or other materials provided with the 1778ee8d1cSJulian Grajkowski * distribution. 1878ee8d1cSJulian Grajkowski * * Neither the name of Intel Corporation nor the names of its 1978ee8d1cSJulian Grajkowski * contributors may be used to endorse or promote products derived 2078ee8d1cSJulian Grajkowski * from this software without specific prior written permission. 2178ee8d1cSJulian Grajkowski * 2278ee8d1cSJulian Grajkowski * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2378ee8d1cSJulian Grajkowski * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2478ee8d1cSJulian Grajkowski * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2578ee8d1cSJulian Grajkowski * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2678ee8d1cSJulian Grajkowski * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2778ee8d1cSJulian Grajkowski * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2878ee8d1cSJulian Grajkowski * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2978ee8d1cSJulian Grajkowski * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3078ee8d1cSJulian Grajkowski * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3178ee8d1cSJulian Grajkowski * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3278ee8d1cSJulian Grajkowski * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3378ee8d1cSJulian Grajkowski * 3478ee8d1cSJulian Grajkowski * 3578ee8d1cSJulian Grajkowski ***************************************************************************/ 3678ee8d1cSJulian Grajkowski 3778ee8d1cSJulian Grajkowski /* 3878ee8d1cSJulian Grajkowski ***************************************************************************** 3978ee8d1cSJulian Grajkowski * Doxygen group definitions 4078ee8d1cSJulian Grajkowski ****************************************************************************/ 4178ee8d1cSJulian Grajkowski 4278ee8d1cSJulian Grajkowski /** 4378ee8d1cSJulian Grajkowski ***************************************************************************** 4478ee8d1cSJulian Grajkowski * @file cpa_cy_rsa.h 4578ee8d1cSJulian Grajkowski * 4678ee8d1cSJulian Grajkowski * @defgroup cpaCyRsa RSA API 4778ee8d1cSJulian Grajkowski * 4878ee8d1cSJulian Grajkowski * @ingroup cpaCy 4978ee8d1cSJulian Grajkowski * 5078ee8d1cSJulian Grajkowski * @description 5178ee8d1cSJulian Grajkowski * These functions specify the API for Public Key Encryption 5278ee8d1cSJulian Grajkowski * (Cryptography) RSA operations. The PKCS #1 V2.1 specification is 5378ee8d1cSJulian Grajkowski * supported, however the support is limited to "two-prime" mode. RSA 5478ee8d1cSJulian Grajkowski * multi-prime is not supported. 5578ee8d1cSJulian Grajkowski * 5678ee8d1cSJulian Grajkowski * @note 5778ee8d1cSJulian Grajkowski * These functions implement RSA cryptographic primitives. RSA padding 5878ee8d1cSJulian Grajkowski * schemes are not implemented. For padding schemes that require the mgf 5978ee8d1cSJulian Grajkowski * function see @ref cpaCyKeyGen. 6078ee8d1cSJulian Grajkowski * 6178ee8d1cSJulian Grajkowski * @note 6278ee8d1cSJulian Grajkowski * Large numbers are represented on the QuickAssist API as described 6378ee8d1cSJulian Grajkowski * in the Large Number API (@ref cpaCyLn). 6478ee8d1cSJulian Grajkowski *****************************************************************************/ 6578ee8d1cSJulian Grajkowski 6678ee8d1cSJulian Grajkowski #ifndef CPA_CY_RSA_H 6778ee8d1cSJulian Grajkowski #define CPA_CY_RSA_H 6878ee8d1cSJulian Grajkowski 6978ee8d1cSJulian Grajkowski #ifdef __cplusplus 7078ee8d1cSJulian Grajkowski extern "C" { 7178ee8d1cSJulian Grajkowski #endif 7278ee8d1cSJulian Grajkowski 7378ee8d1cSJulian Grajkowski #include "cpa_cy_common.h" 7478ee8d1cSJulian Grajkowski 7578ee8d1cSJulian Grajkowski /** 7678ee8d1cSJulian Grajkowski ***************************************************************************** 7778ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 7878ee8d1cSJulian Grajkowski * RSA Version. 7978ee8d1cSJulian Grajkowski * @description 8078ee8d1cSJulian Grajkowski * This enumeration lists the version identifier for the PKCS #1 V2.1 8178ee8d1cSJulian Grajkowski * standard. 8278ee8d1cSJulian Grajkowski * @note 8378ee8d1cSJulian Grajkowski * Multi-prime (more than two primes) is not supported. 8478ee8d1cSJulian Grajkowski * 8578ee8d1cSJulian Grajkowski *****************************************************************************/ 8678ee8d1cSJulian Grajkowski typedef enum _CpaCyRsaVersion 8778ee8d1cSJulian Grajkowski { 8878ee8d1cSJulian Grajkowski CPA_CY_RSA_VERSION_TWO_PRIME = 1 8978ee8d1cSJulian Grajkowski /**< The version supported is "two-prime". */ 9078ee8d1cSJulian Grajkowski } CpaCyRsaVersion; 9178ee8d1cSJulian Grajkowski 9278ee8d1cSJulian Grajkowski /** 9378ee8d1cSJulian Grajkowski ***************************************************************************** 9478ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 9578ee8d1cSJulian Grajkowski * RSA Public Key Structure. 9678ee8d1cSJulian Grajkowski * @description 9778ee8d1cSJulian Grajkowski * This structure contains the two components which comprise the RSA 9878ee8d1cSJulian Grajkowski * public key as defined in the PKCS #1 V2.1 standard. 9978ee8d1cSJulian Grajkowski * All values in this structure are required to be in Most Significant Byte 10078ee8d1cSJulian Grajkowski * first order, e.g. modulusN.pData[0] = MSB. 10178ee8d1cSJulian Grajkowski * 10278ee8d1cSJulian Grajkowski *****************************************************************************/ 10378ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaPublicKey { 10478ee8d1cSJulian Grajkowski CpaFlatBuffer modulusN; 10578ee8d1cSJulian Grajkowski /**< The modulus (n). 10678ee8d1cSJulian Grajkowski * For key generation operations, the client MUST allocate the memory 10778ee8d1cSJulian Grajkowski * for this parameter; its value is generated. 10878ee8d1cSJulian Grajkowski * For encrypt operations this parameter is an input. */ 10978ee8d1cSJulian Grajkowski CpaFlatBuffer publicExponentE; 11078ee8d1cSJulian Grajkowski /**< The public exponent (e). 11178ee8d1cSJulian Grajkowski * For key generation operations, this field is unused. It is NOT 11278ee8d1cSJulian Grajkowski * generated by the interface; it is the responsibility of the client 11378ee8d1cSJulian Grajkowski * to set this to the same value as the corresponding parameter on 11478ee8d1cSJulian Grajkowski * the CpaCyRsaKeyGenOpData structure before using the key for 11578ee8d1cSJulian Grajkowski * encryption. 11678ee8d1cSJulian Grajkowski * For encrypt operations this parameter is an input. */ 11778ee8d1cSJulian Grajkowski } CpaCyRsaPublicKey; 11878ee8d1cSJulian Grajkowski 11978ee8d1cSJulian Grajkowski /** 12078ee8d1cSJulian Grajkowski ***************************************************************************** 12178ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 12278ee8d1cSJulian Grajkowski * RSA Private Key Structure For Representation 1. 12378ee8d1cSJulian Grajkowski * @description 12478ee8d1cSJulian Grajkowski * This structure contains the first representation that can be used for 12578ee8d1cSJulian Grajkowski * describing the RSA private key, represented by the tuple of the 12678ee8d1cSJulian Grajkowski * modulus (n) and the private exponent (d). 12778ee8d1cSJulian Grajkowski * All values in this structure are required to be in Most Significant Byte 12878ee8d1cSJulian Grajkowski * first order, e.g. modulusN.pData[0] = MSB. 12978ee8d1cSJulian Grajkowski * 13078ee8d1cSJulian Grajkowski *****************************************************************************/ 13178ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaPrivateKeyRep1 { 13278ee8d1cSJulian Grajkowski CpaFlatBuffer modulusN; 13378ee8d1cSJulian Grajkowski /**< The modulus (n). For key generation operations the memory MUST 13478ee8d1cSJulian Grajkowski * be allocated by the client and the value is generated. For other 13578ee8d1cSJulian Grajkowski * operations this is an input. Permitted lengths are: 13678ee8d1cSJulian Grajkowski * 13778ee8d1cSJulian Grajkowski * - 512 bits (64 bytes), 13878ee8d1cSJulian Grajkowski * - 1024 bits (128 bytes), 13978ee8d1cSJulian Grajkowski * - 1536 bits (192 bytes), 14078ee8d1cSJulian Grajkowski * - 2048 bits (256 bytes), 141266b0663SKrzysztof Zdziarski * - 3072 bits (384 bytes), 142266b0663SKrzysztof Zdziarski * - 4096 bits (512 bytes), or 143266b0663SKrzysztof Zdziarski * - 8192 bits (1024 bytes). 14478ee8d1cSJulian Grajkowski */ 14578ee8d1cSJulian Grajkowski CpaFlatBuffer privateExponentD; 14678ee8d1cSJulian Grajkowski /**< The private exponent (d). For key generation operations the 14778ee8d1cSJulian Grajkowski * memory MUST be allocated by the client and the value is generated. For 14878ee8d1cSJulian Grajkowski * other operations this is an input. 14978ee8d1cSJulian Grajkowski * NOTE: It is important that the value D is big enough. It is STRONGLY 15078ee8d1cSJulian Grajkowski * recommended that this value is at least half the length of the modulus 15178ee8d1cSJulian Grajkowski * N to protect against the Wiener attack. */ 15278ee8d1cSJulian Grajkowski } CpaCyRsaPrivateKeyRep1; 15378ee8d1cSJulian Grajkowski 15478ee8d1cSJulian Grajkowski /** 15578ee8d1cSJulian Grajkowski ***************************************************************************** 15678ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 15778ee8d1cSJulian Grajkowski * RSA Private Key Structure For Representation 2. 15878ee8d1cSJulian Grajkowski * @description 15978ee8d1cSJulian Grajkowski * This structure contains the second representation that can be used for 16078ee8d1cSJulian Grajkowski * describing the RSA private key. The quintuple of p, q, dP, dQ, and qInv 16178ee8d1cSJulian Grajkowski * (explained below and in the spec) are required for the second 16278ee8d1cSJulian Grajkowski * representation. The optional sequence of triplets are not included. 16378ee8d1cSJulian Grajkowski * All values in this structure are required to be in Most Significant Byte 16478ee8d1cSJulian Grajkowski * first order, e.g. prime1P.pData[0] = MSB. 16578ee8d1cSJulian Grajkowski * 16678ee8d1cSJulian Grajkowski *****************************************************************************/ 16778ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaPrivateKeyRep2 { 16878ee8d1cSJulian Grajkowski CpaFlatBuffer prime1P; 16978ee8d1cSJulian Grajkowski /**< The first large prime (p). 17078ee8d1cSJulian Grajkowski * For key generation operations, this field is unused. */ 17178ee8d1cSJulian Grajkowski CpaFlatBuffer prime2Q; 17278ee8d1cSJulian Grajkowski /**< The second large prime (q). 17378ee8d1cSJulian Grajkowski * For key generation operations, this field is unused. */ 17478ee8d1cSJulian Grajkowski CpaFlatBuffer exponent1Dp; 17578ee8d1cSJulian Grajkowski /**< The first factor CRT exponent (dP). d mod (p-1). */ 17678ee8d1cSJulian Grajkowski CpaFlatBuffer exponent2Dq; 17778ee8d1cSJulian Grajkowski /**< The second factor CRT exponent (dQ). d mod (q-1). */ 17878ee8d1cSJulian Grajkowski CpaFlatBuffer coefficientQInv; 17978ee8d1cSJulian Grajkowski /**< The (first) Chinese Remainder Theorem (CRT) coefficient (qInv). 18078ee8d1cSJulian Grajkowski * (inverse of q) mod p. */ 18178ee8d1cSJulian Grajkowski } CpaCyRsaPrivateKeyRep2; 18278ee8d1cSJulian Grajkowski 18378ee8d1cSJulian Grajkowski /** 18478ee8d1cSJulian Grajkowski ***************************************************************************** 18578ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 18678ee8d1cSJulian Grajkowski * RSA private key representation type. 18778ee8d1cSJulian Grajkowski * @description 18878ee8d1cSJulian Grajkowski * This enumeration lists which PKCS V2.1 representation of the private 18978ee8d1cSJulian Grajkowski * key is being used. 19078ee8d1cSJulian Grajkowski * 19178ee8d1cSJulian Grajkowski *****************************************************************************/ 19278ee8d1cSJulian Grajkowski typedef enum _CpaCyRsaPrivateKeyRepType 19378ee8d1cSJulian Grajkowski { 19478ee8d1cSJulian Grajkowski CPA_CY_RSA_PRIVATE_KEY_REP_TYPE_1= 1, 19578ee8d1cSJulian Grajkowski /**< The first representation of the RSA private key. */ 19678ee8d1cSJulian Grajkowski CPA_CY_RSA_PRIVATE_KEY_REP_TYPE_2 19778ee8d1cSJulian Grajkowski /**< The second representation of the RSA private key. */ 19878ee8d1cSJulian Grajkowski } CpaCyRsaPrivateKeyRepType; 19978ee8d1cSJulian Grajkowski 20078ee8d1cSJulian Grajkowski /** 20178ee8d1cSJulian Grajkowski ***************************************************************************** 20278ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 20378ee8d1cSJulian Grajkowski * RSA Private Key Structure. 20478ee8d1cSJulian Grajkowski * @description 20578ee8d1cSJulian Grajkowski * This structure contains the two representations that can be used for 20678ee8d1cSJulian Grajkowski * describing the RSA private key. The privateKeyRepType will be used to 20778ee8d1cSJulian Grajkowski * identify which representation is to be used. Typically, using the 20878ee8d1cSJulian Grajkowski * second representation results in faster decryption operations. 20978ee8d1cSJulian Grajkowski * 21078ee8d1cSJulian Grajkowski *****************************************************************************/ 21178ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaPrivateKey { 21278ee8d1cSJulian Grajkowski CpaCyRsaVersion version; 21378ee8d1cSJulian Grajkowski /**< Indicates the version of the PKCS #1 specification that is 21478ee8d1cSJulian Grajkowski * supported. 21578ee8d1cSJulian Grajkowski * Note that this applies to both representations. */ 21678ee8d1cSJulian Grajkowski CpaCyRsaPrivateKeyRepType privateKeyRepType; 21778ee8d1cSJulian Grajkowski /**< This value is used to identify which of the private key 21878ee8d1cSJulian Grajkowski * representation types in this structure is relevant. 21978ee8d1cSJulian Grajkowski * When performing key generation operations for Type 2 representations, 22078ee8d1cSJulian Grajkowski * memory must also be allocated for the type 1 representations, and values 22178ee8d1cSJulian Grajkowski * for both will be returned. */ 22278ee8d1cSJulian Grajkowski CpaCyRsaPrivateKeyRep1 privateKeyRep1; 22378ee8d1cSJulian Grajkowski /**< This is the first representation of the RSA private key as 22478ee8d1cSJulian Grajkowski * defined in the PKCS #1 V2.1 specification. For key generation operations 22578ee8d1cSJulian Grajkowski * the memory for this structure is allocated by the client and the 22678ee8d1cSJulian Grajkowski * specific values are generated. For other operations this is an input 22778ee8d1cSJulian Grajkowski * parameter. */ 22878ee8d1cSJulian Grajkowski CpaCyRsaPrivateKeyRep2 privateKeyRep2; 22978ee8d1cSJulian Grajkowski /**< This is the second representation of the RSA private key as 23078ee8d1cSJulian Grajkowski * defined in the PKCS #1 V2.1 specification. For key generation operations 23178ee8d1cSJulian Grajkowski * the memory for this structure is allocated by the client and the 23278ee8d1cSJulian Grajkowski * specific values are generated. For other operations this is an input 23378ee8d1cSJulian Grajkowski * parameter. */ 23478ee8d1cSJulian Grajkowski } CpaCyRsaPrivateKey; 23578ee8d1cSJulian Grajkowski 23678ee8d1cSJulian Grajkowski /** 23778ee8d1cSJulian Grajkowski ***************************************************************************** 23878ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 23978ee8d1cSJulian Grajkowski * RSA Key Generation Data. 24078ee8d1cSJulian Grajkowski * @description 24178ee8d1cSJulian Grajkowski * This structure lists the different items that are required in the 24278ee8d1cSJulian Grajkowski * cpaCyRsaGenKey function. The client MUST allocate the memory for this 24378ee8d1cSJulian Grajkowski * structure. When the structure is passed into the function, ownership of 24478ee8d1cSJulian Grajkowski * the memory passes to the function. Ownership of the memory returns to 24578ee8d1cSJulian Grajkowski * the client when this structure is returned in the 24678ee8d1cSJulian Grajkowski * CpaCyRsaKeyGenCbFunc callback function. 24778ee8d1cSJulian Grajkowski * 24878ee8d1cSJulian Grajkowski * @note 24978ee8d1cSJulian Grajkowski * If the client modifies or frees the memory referenced in this structure 25078ee8d1cSJulian Grajkowski * after it has been submitted to the cpaCyRsaGenKey function, and 25178ee8d1cSJulian Grajkowski * before it has been returned in the callback, undefined behavior will 25278ee8d1cSJulian Grajkowski * result. 25378ee8d1cSJulian Grajkowski * All values in this structure are required to be in Most Significant Byte 25478ee8d1cSJulian Grajkowski * first order, e.g. prime1P.pData[0] = MSB. 25578ee8d1cSJulian Grajkowski * 25678ee8d1cSJulian Grajkowski * The following limitations on the permutations of the supported bit 25778ee8d1cSJulian Grajkowski * lengths of p, q and n (written as {p, q, n}) apply: 25878ee8d1cSJulian Grajkowski * 25978ee8d1cSJulian Grajkowski * - {256, 256, 512} or 26078ee8d1cSJulian Grajkowski * - {512, 512, 1024} or 26178ee8d1cSJulian Grajkowski * - {768, 768, 1536} or 26278ee8d1cSJulian Grajkowski * - {1024, 1024, 2048} or 26378ee8d1cSJulian Grajkowski * - {1536, 1536, 3072} or 26478ee8d1cSJulian Grajkowski * - {2048, 2048, 4096}. 26578ee8d1cSJulian Grajkowski * 26678ee8d1cSJulian Grajkowski *****************************************************************************/ 26778ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaKeyGenOpData { 26878ee8d1cSJulian Grajkowski CpaFlatBuffer prime1P; 26978ee8d1cSJulian Grajkowski /**< A large random prime number (p). This MUST be created by the 27078ee8d1cSJulian Grajkowski * client. Permitted bit lengths are: 256, 512, 768, 1024, 1536 or 2048. 27178ee8d1cSJulian Grajkowski * Limitations apply - refer to the description above for details. */ 27278ee8d1cSJulian Grajkowski CpaFlatBuffer prime2Q; 27378ee8d1cSJulian Grajkowski /**< A large random prime number (q). This MUST be created by the 27478ee8d1cSJulian Grajkowski * client. Permitted bit lengths are: 256, 512, 768, 1024, 1536 or 2048. 27578ee8d1cSJulian Grajkowski * Limitations apply - refer to the description above for details. If the 27678ee8d1cSJulian Grajkowski * private key representation type is 2, then this pointer will be assigned 27778ee8d1cSJulian Grajkowski * to the relevant structure member of the representation 2 private key. */ 27878ee8d1cSJulian Grajkowski Cpa32U modulusLenInBytes; 27978ee8d1cSJulian Grajkowski /**< The bit length of the modulus (n). This is the modulus length for 28078ee8d1cSJulian Grajkowski * both the private and public keys. The length of the modulus N parameter 28178ee8d1cSJulian Grajkowski * for the private key representation 1 structure and the public key 28278ee8d1cSJulian Grajkowski * structures will be assigned to this value. References to the strength of 28378ee8d1cSJulian Grajkowski * RSA actually refer to this bit length. Recommended minimum is 1024 bits. 28478ee8d1cSJulian Grajkowski * Permitted lengths are: 28578ee8d1cSJulian Grajkowski * - 512 bits (64 bytes), 28678ee8d1cSJulian Grajkowski * - 1024 bits (128 bytes), 28778ee8d1cSJulian Grajkowski * - 1536 bits (192 bytes), 28878ee8d1cSJulian Grajkowski * - 2048 bits (256 bytes), 28978ee8d1cSJulian Grajkowski * - 3072 bits (384 bytes), or 29078ee8d1cSJulian Grajkowski * - 4096 bits (512 bytes). 29178ee8d1cSJulian Grajkowski * Limitations apply - refer to description above for details. */ 29278ee8d1cSJulian Grajkowski CpaCyRsaVersion version; 29378ee8d1cSJulian Grajkowski /**< Indicates the version of the PKCS #1 specification that is 29478ee8d1cSJulian Grajkowski * supported. 29578ee8d1cSJulian Grajkowski * Note that this applies to both representations. */ 29678ee8d1cSJulian Grajkowski CpaCyRsaPrivateKeyRepType privateKeyRepType; 29778ee8d1cSJulian Grajkowski /**< This value is used to identify which of the private key 29878ee8d1cSJulian Grajkowski * representation types is required to be generated. */ 29978ee8d1cSJulian Grajkowski CpaFlatBuffer publicExponentE; 30078ee8d1cSJulian Grajkowski /**< The public exponent (e). */ 30178ee8d1cSJulian Grajkowski } CpaCyRsaKeyGenOpData; 30278ee8d1cSJulian Grajkowski 30378ee8d1cSJulian Grajkowski /** 30478ee8d1cSJulian Grajkowski ***************************************************************************** 30578ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 30678ee8d1cSJulian Grajkowski * RSA Encryption Primitive Operation Data 30778ee8d1cSJulian Grajkowski * @description 30878ee8d1cSJulian Grajkowski * This structure lists the different items that are required in the 30978ee8d1cSJulian Grajkowski * cpaCyRsaEncrypt function. As the RSA encryption primitive and 31078ee8d1cSJulian Grajkowski * verification primitive operations are mathematically identical this 31178ee8d1cSJulian Grajkowski * structure may also be used to perform an RSA verification primitive 31278ee8d1cSJulian Grajkowski * operation. 31378ee8d1cSJulian Grajkowski * When performing an RSA encryption primitive operation, the input data 31478ee8d1cSJulian Grajkowski * is the message and the output data is the cipher text. 31578ee8d1cSJulian Grajkowski * When performing an RSA verification primitive operation, the input data 31678ee8d1cSJulian Grajkowski * is the signature and the output data is the message. 31778ee8d1cSJulian Grajkowski * The client MUST allocate the memory for this structure. When the 31878ee8d1cSJulian Grajkowski * structure is passed into the function, ownership of the memory passes 31978ee8d1cSJulian Grajkowski * to the function. Ownership of the memory returns to the client when 32078ee8d1cSJulian Grajkowski * this structure is returned in the CpaCyRsaEncryptCbFunc 32178ee8d1cSJulian Grajkowski * callback function. 32278ee8d1cSJulian Grajkowski * 32378ee8d1cSJulian Grajkowski * @note 32478ee8d1cSJulian Grajkowski * If the client modifies or frees the memory referenced in this structure 32578ee8d1cSJulian Grajkowski * after it has been submitted to the cpaCyRsaEncrypt function, and 32678ee8d1cSJulian Grajkowski * before it has been returned in the callback, undefined behavior will 32778ee8d1cSJulian Grajkowski * result. 32878ee8d1cSJulian Grajkowski * All values in this structure are required to be in Most Significant Byte 32978ee8d1cSJulian Grajkowski * first order, e.g. inputData.pData[0] = MSB. 33078ee8d1cSJulian Grajkowski * 33178ee8d1cSJulian Grajkowski *****************************************************************************/ 33278ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaEncryptOpData { 33378ee8d1cSJulian Grajkowski CpaCyRsaPublicKey *pPublicKey; 33478ee8d1cSJulian Grajkowski /**< Pointer to the public key. */ 33578ee8d1cSJulian Grajkowski CpaFlatBuffer inputData; 33678ee8d1cSJulian Grajkowski /**< The input data that the RSA encryption primitive operation is 33778ee8d1cSJulian Grajkowski * performed on. The data pointed to is an integer that MUST be in big- 33878ee8d1cSJulian Grajkowski * endian order. The value MUST be between 0 and the modulus n - 1. */ 33978ee8d1cSJulian Grajkowski } CpaCyRsaEncryptOpData; 34078ee8d1cSJulian Grajkowski 34178ee8d1cSJulian Grajkowski /** 34278ee8d1cSJulian Grajkowski ***************************************************************************** 34378ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 34478ee8d1cSJulian Grajkowski * RSA Decryption Primitive Operation Data 34578ee8d1cSJulian Grajkowski * @description 34678ee8d1cSJulian Grajkowski * This structure lists the different items that are required in the 34778ee8d1cSJulian Grajkowski * cpaCyRsaDecrypt function. As the RSA decryption primitive and 34878ee8d1cSJulian Grajkowski * signature primitive operations are mathematically identical this 34978ee8d1cSJulian Grajkowski * structure may also be used to perform an RSA signature primitive 35078ee8d1cSJulian Grajkowski * operation. 35178ee8d1cSJulian Grajkowski * When performing an RSA decryption primitive operation, the input data 35278ee8d1cSJulian Grajkowski * is the cipher text and the output data is the message text. 35378ee8d1cSJulian Grajkowski * When performing an RSA signature primitive operation, the input data 35478ee8d1cSJulian Grajkowski * is the message and the output data is the signature. 35578ee8d1cSJulian Grajkowski * The client MUST allocate the memory for this structure. When the 35678ee8d1cSJulian Grajkowski * structure is passed into the function, ownership of the memory passes 35778ee8d1cSJulian Grajkowski * to he function. Ownership of the memory returns to the client when 35878ee8d1cSJulian Grajkowski * this structure is returned in the CpaCyRsaDecryptCbFunc 35978ee8d1cSJulian Grajkowski * callback function. 36078ee8d1cSJulian Grajkowski * 36178ee8d1cSJulian Grajkowski * @note 36278ee8d1cSJulian Grajkowski * If the client modifies or frees the memory referenced in this structure 36378ee8d1cSJulian Grajkowski * after it has been submitted to the cpaCyRsaDecrypt function, and 36478ee8d1cSJulian Grajkowski * before it has been returned in the callback, undefined behavior will 36578ee8d1cSJulian Grajkowski * result. 36678ee8d1cSJulian Grajkowski * All values in this structure are required to be in Most Significant Byte 36778ee8d1cSJulian Grajkowski * first order, e.g. inputData.pData[0] = MSB. 36878ee8d1cSJulian Grajkowski * 36978ee8d1cSJulian Grajkowski *****************************************************************************/ 37078ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaDecryptOpData { 37178ee8d1cSJulian Grajkowski CpaCyRsaPrivateKey *pRecipientPrivateKey; 37278ee8d1cSJulian Grajkowski /**< Pointer to the recipient's RSA private key. */ 37378ee8d1cSJulian Grajkowski CpaFlatBuffer inputData; 37478ee8d1cSJulian Grajkowski /**< The input data that the RSA decryption primitive operation is 37578ee8d1cSJulian Grajkowski * performed on. The data pointed to is an integer that MUST be in big- 37678ee8d1cSJulian Grajkowski * endian order. The value MUST be between 0 and the modulus n - 1. */ 37778ee8d1cSJulian Grajkowski } CpaCyRsaDecryptOpData; 37878ee8d1cSJulian Grajkowski 37978ee8d1cSJulian Grajkowski /** 38078ee8d1cSJulian Grajkowski ***************************************************************************** 38178ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 38278ee8d1cSJulian Grajkowski * RSA Statistics. 38378ee8d1cSJulian Grajkowski * @deprecated 38478ee8d1cSJulian Grajkowski * As of v1.3 of the Crypto API, this structure has been deprecated, 38578ee8d1cSJulian Grajkowski * replaced by @ref CpaCyRsaStats64. 38678ee8d1cSJulian Grajkowski * @description 38778ee8d1cSJulian Grajkowski * This structure contains statistics on the RSA operations. 38878ee8d1cSJulian Grajkowski * Statistics are set to zero when the component is initialized, and are 38978ee8d1cSJulian Grajkowski * collected per instance. 39078ee8d1cSJulian Grajkowski ****************************************************************************/ 39178ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaStats { 39278ee8d1cSJulian Grajkowski Cpa32U numRsaKeyGenRequests; 39378ee8d1cSJulian Grajkowski /**< Total number of successful RSA key generation requests. */ 39478ee8d1cSJulian Grajkowski Cpa32U numRsaKeyGenRequestErrors; 39578ee8d1cSJulian Grajkowski /**< Total number of RSA key generation requests that had an error and 39678ee8d1cSJulian Grajkowski * could not be processed. */ 39778ee8d1cSJulian Grajkowski Cpa32U numRsaKeyGenCompleted; 39878ee8d1cSJulian Grajkowski /**< Total number of RSA key generation operations that completed 39978ee8d1cSJulian Grajkowski * successfully. */ 40078ee8d1cSJulian Grajkowski Cpa32U numRsaKeyGenCompletedErrors; 40178ee8d1cSJulian Grajkowski /**< Total number of RSA key generation operations that could not be 40278ee8d1cSJulian Grajkowski * completed successfully due to errors. */ 40378ee8d1cSJulian Grajkowski Cpa32U numRsaEncryptRequests; 40478ee8d1cSJulian Grajkowski /**< Total number of successful RSA encrypt operation requests. */ 40578ee8d1cSJulian Grajkowski Cpa32U numRsaEncryptRequestErrors; 40678ee8d1cSJulian Grajkowski /**< Total number of RSA encrypt requests that had an error and could 40778ee8d1cSJulian Grajkowski * not be processed. */ 40878ee8d1cSJulian Grajkowski Cpa32U numRsaEncryptCompleted; 40978ee8d1cSJulian Grajkowski /**< Total number of RSA encrypt operations that completed 41078ee8d1cSJulian Grajkowski * successfully. */ 41178ee8d1cSJulian Grajkowski Cpa32U numRsaEncryptCompletedErrors; 41278ee8d1cSJulian Grajkowski /**< Total number of RSA encrypt operations that could not be 41378ee8d1cSJulian Grajkowski * completed successfully due to errors. */ 41478ee8d1cSJulian Grajkowski Cpa32U numRsaDecryptRequests; 41578ee8d1cSJulian Grajkowski /**< Total number of successful RSA decrypt operation requests. */ 41678ee8d1cSJulian Grajkowski Cpa32U numRsaDecryptRequestErrors; 41778ee8d1cSJulian Grajkowski /**< Total number of RSA decrypt requests that had an error and could 41878ee8d1cSJulian Grajkowski * not be processed. */ 41978ee8d1cSJulian Grajkowski Cpa32U numRsaDecryptCompleted; 42078ee8d1cSJulian Grajkowski /**< Total number of RSA decrypt operations that completed 42178ee8d1cSJulian Grajkowski * successfully. */ 42278ee8d1cSJulian Grajkowski Cpa32U numRsaDecryptCompletedErrors; 42378ee8d1cSJulian Grajkowski /**< Total number of RSA decrypt operations that could not be 42478ee8d1cSJulian Grajkowski * completed successfully due to errors. */ 42578ee8d1cSJulian Grajkowski } CpaCyRsaStats CPA_DEPRECATED; 42678ee8d1cSJulian Grajkowski 42778ee8d1cSJulian Grajkowski /** 42878ee8d1cSJulian Grajkowski ***************************************************************************** 42978ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 43078ee8d1cSJulian Grajkowski * RSA Statistics (64-bit version). 43178ee8d1cSJulian Grajkowski * @description 43278ee8d1cSJulian Grajkowski * This structure contains 64-bit version of the statistics on the RSA 43378ee8d1cSJulian Grajkowski * operations. 43478ee8d1cSJulian Grajkowski * Statistics are set to zero when the component is initialized, and are 43578ee8d1cSJulian Grajkowski * collected per instance. 43678ee8d1cSJulian Grajkowski ****************************************************************************/ 43778ee8d1cSJulian Grajkowski typedef struct _CpaCyRsaStats64 { 43878ee8d1cSJulian Grajkowski Cpa64U numRsaKeyGenRequests; 43978ee8d1cSJulian Grajkowski /**< Total number of successful RSA key generation requests. */ 44078ee8d1cSJulian Grajkowski Cpa64U numRsaKeyGenRequestErrors; 44178ee8d1cSJulian Grajkowski /**< Total number of RSA key generation requests that had an error and 44278ee8d1cSJulian Grajkowski * could not be processed. */ 44378ee8d1cSJulian Grajkowski Cpa64U numRsaKeyGenCompleted; 44478ee8d1cSJulian Grajkowski /**< Total number of RSA key generation operations that completed 44578ee8d1cSJulian Grajkowski * successfully. */ 44678ee8d1cSJulian Grajkowski Cpa64U numRsaKeyGenCompletedErrors; 44778ee8d1cSJulian Grajkowski /**< Total number of RSA key generation operations that could not be 44878ee8d1cSJulian Grajkowski * completed successfully due to errors. */ 44978ee8d1cSJulian Grajkowski Cpa64U numRsaEncryptRequests; 45078ee8d1cSJulian Grajkowski /**< Total number of successful RSA encrypt operation requests. */ 45178ee8d1cSJulian Grajkowski Cpa64U numRsaEncryptRequestErrors; 45278ee8d1cSJulian Grajkowski /**< Total number of RSA encrypt requests that had an error and could 45378ee8d1cSJulian Grajkowski * not be processed. */ 45478ee8d1cSJulian Grajkowski Cpa64U numRsaEncryptCompleted; 45578ee8d1cSJulian Grajkowski /**< Total number of RSA encrypt operations that completed 45678ee8d1cSJulian Grajkowski * successfully. */ 45778ee8d1cSJulian Grajkowski Cpa64U numRsaEncryptCompletedErrors; 45878ee8d1cSJulian Grajkowski /**< Total number of RSA encrypt operations that could not be 45978ee8d1cSJulian Grajkowski * completed successfully due to errors. */ 46078ee8d1cSJulian Grajkowski Cpa64U numRsaDecryptRequests; 46178ee8d1cSJulian Grajkowski /**< Total number of successful RSA decrypt operation requests. */ 46278ee8d1cSJulian Grajkowski Cpa64U numRsaDecryptRequestErrors; 46378ee8d1cSJulian Grajkowski /**< Total number of RSA decrypt requests that had an error and could 46478ee8d1cSJulian Grajkowski * not be processed. */ 46578ee8d1cSJulian Grajkowski Cpa64U numRsaDecryptCompleted; 46678ee8d1cSJulian Grajkowski /**< Total number of RSA decrypt operations that completed 46778ee8d1cSJulian Grajkowski * successfully. */ 46878ee8d1cSJulian Grajkowski Cpa64U numRsaDecryptCompletedErrors; 46978ee8d1cSJulian Grajkowski /**< Total number of RSA decrypt operations that could not be 47078ee8d1cSJulian Grajkowski * completed successfully due to errors. */ 471266b0663SKrzysztof Zdziarski Cpa64U numKptRsaDecryptRequests; 472266b0663SKrzysztof Zdziarski /**< Total number of successful KPT RSA decrypt operation requests. */ 473266b0663SKrzysztof Zdziarski Cpa64U numKptRsaDecryptRequestErrors; 474266b0663SKrzysztof Zdziarski /**< Total number of KPT RSA decrypt requests that had an error and could 475266b0663SKrzysztof Zdziarski * not be processed. */ 476266b0663SKrzysztof Zdziarski Cpa64U numKptRsaDecryptCompleted; 477266b0663SKrzysztof Zdziarski /**< Total number of KPT RSA decrypt operations that completed 478266b0663SKrzysztof Zdziarski * successfully. */ 479266b0663SKrzysztof Zdziarski Cpa64U numKptRsaDecryptCompletedErrors; 480266b0663SKrzysztof Zdziarski /**< Total number of KPT RSA decrypt operations that could not be 481266b0663SKrzysztof Zdziarski * completed successfully due to errors. */ 48278ee8d1cSJulian Grajkowski } CpaCyRsaStats64; 48378ee8d1cSJulian Grajkowski 48478ee8d1cSJulian Grajkowski /** 48578ee8d1cSJulian Grajkowski ***************************************************************************** 48678ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 48778ee8d1cSJulian Grajkowski * Definition of the RSA key generation callback function. 48878ee8d1cSJulian Grajkowski * 48978ee8d1cSJulian Grajkowski * @description 49078ee8d1cSJulian Grajkowski * This is the prototype for the RSA key generation callback function. The 49178ee8d1cSJulian Grajkowski * callback function pointer is passed in as a parameter to the 49278ee8d1cSJulian Grajkowski * cpaCyRsaGenKey function. It will be invoked once the request has 49378ee8d1cSJulian Grajkowski * completed. 49478ee8d1cSJulian Grajkowski * 49578ee8d1cSJulian Grajkowski * @context 49678ee8d1cSJulian Grajkowski * This callback function can be executed in a context that DOES NOT 49778ee8d1cSJulian Grajkowski * permit sleeping to occur. 49878ee8d1cSJulian Grajkowski * @assumptions 49978ee8d1cSJulian Grajkowski * None 50078ee8d1cSJulian Grajkowski * @sideEffects 50178ee8d1cSJulian Grajkowski * None 50278ee8d1cSJulian Grajkowski * @reentrant 50378ee8d1cSJulian Grajkowski * No 50478ee8d1cSJulian Grajkowski * @threadSafe 50578ee8d1cSJulian Grajkowski * Yes 50678ee8d1cSJulian Grajkowski * 50778ee8d1cSJulian Grajkowski * @param[in] pCallbackTag Opaque value provided by user while making 50878ee8d1cSJulian Grajkowski * individual function calls. 50978ee8d1cSJulian Grajkowski * @param[in] status Status of the operation. Valid values are 51078ee8d1cSJulian Grajkowski * CPA_STATUS_SUCCESS, CPA_STATUS_FAIL and 51178ee8d1cSJulian Grajkowski * CPA_STATUS_UNSUPPORTED. 51278ee8d1cSJulian Grajkowski * @param[in] pKeyGenOpData Structure with output params for callback. 51378ee8d1cSJulian Grajkowski * @param[in] pPrivateKey Structure which contains pointers to the memory 51478ee8d1cSJulian Grajkowski * into which the generated private key will be 51578ee8d1cSJulian Grajkowski * written. 51678ee8d1cSJulian Grajkowski * @param[in] pPublicKey Structure which contains pointers to the memory 51778ee8d1cSJulian Grajkowski * into which the generated public key will be 51878ee8d1cSJulian Grajkowski * written. The pointer to the public exponent (e) 51978ee8d1cSJulian Grajkowski * that is returned in this structure is equal to 52078ee8d1cSJulian Grajkowski * the input public exponent. 52178ee8d1cSJulian Grajkowski * @retval 52278ee8d1cSJulian Grajkowski * None 52378ee8d1cSJulian Grajkowski * @pre 52478ee8d1cSJulian Grajkowski * Component has been initialized. 52578ee8d1cSJulian Grajkowski * @post 52678ee8d1cSJulian Grajkowski * None 52778ee8d1cSJulian Grajkowski * @note 52878ee8d1cSJulian Grajkowski * None 52978ee8d1cSJulian Grajkowski * @see 53078ee8d1cSJulian Grajkowski * CpaCyRsaPrivateKey, 53178ee8d1cSJulian Grajkowski * CpaCyRsaPublicKey, 53278ee8d1cSJulian Grajkowski * cpaCyRsaGenKey() 53378ee8d1cSJulian Grajkowski * 53478ee8d1cSJulian Grajkowski *****************************************************************************/ 53578ee8d1cSJulian Grajkowski typedef void (*CpaCyRsaKeyGenCbFunc)(void *pCallbackTag, 53678ee8d1cSJulian Grajkowski CpaStatus status, 53778ee8d1cSJulian Grajkowski void *pKeyGenOpData, 53878ee8d1cSJulian Grajkowski CpaCyRsaPrivateKey *pPrivateKey, 53978ee8d1cSJulian Grajkowski CpaCyRsaPublicKey *pPublicKey); 54078ee8d1cSJulian Grajkowski 54178ee8d1cSJulian Grajkowski /** 54278ee8d1cSJulian Grajkowski ***************************************************************************** 54378ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 54478ee8d1cSJulian Grajkowski * Generate RSA keys. 54578ee8d1cSJulian Grajkowski * 54678ee8d1cSJulian Grajkowski * @description 54778ee8d1cSJulian Grajkowski * This function will generate private and public keys for RSA as specified 54878ee8d1cSJulian Grajkowski * in the PKCS #1 V2.1 standard. Both representation types of the private 54978ee8d1cSJulian Grajkowski * key may be generated. 55078ee8d1cSJulian Grajkowski * 55178ee8d1cSJulian Grajkowski * @context 55278ee8d1cSJulian Grajkowski * When called as an asynchronous function it cannot sleep. It can be 55378ee8d1cSJulian Grajkowski * executed in a context that does not permit sleeping. 55478ee8d1cSJulian Grajkowski * When called as a synchronous function it may sleep. It MUST NOT be 55578ee8d1cSJulian Grajkowski * executed in a context that DOES NOT permit sleeping. 55678ee8d1cSJulian Grajkowski * @assumptions 55778ee8d1cSJulian Grajkowski * None 55878ee8d1cSJulian Grajkowski * @sideEffects 55978ee8d1cSJulian Grajkowski * None 56078ee8d1cSJulian Grajkowski * @blocking 56178ee8d1cSJulian Grajkowski * Yes when configured to operate in synchronous mode. 56278ee8d1cSJulian Grajkowski * @reentrant 56378ee8d1cSJulian Grajkowski * No 56478ee8d1cSJulian Grajkowski * @threadSafe 56578ee8d1cSJulian Grajkowski * Yes 56678ee8d1cSJulian Grajkowski * 56778ee8d1cSJulian Grajkowski * @param[in] instanceHandle Instance handle. 56878ee8d1cSJulian Grajkowski * @param[in] pRsaKeyGenCb Pointer to the callback function to be invoked 56978ee8d1cSJulian Grajkowski * when the operation is complete. If this is 57078ee8d1cSJulian Grajkowski * set to a NULL value the function will operate 57178ee8d1cSJulian Grajkowski * synchronously. 57278ee8d1cSJulian Grajkowski * @param[in] pCallbackTag Opaque User Data for this specific call. Will 57378ee8d1cSJulian Grajkowski * be returned unchanged in the callback. 57478ee8d1cSJulian Grajkowski * @param[in] pKeyGenOpData Structure containing all the data needed to 57578ee8d1cSJulian Grajkowski * perform the RSA key generation operation. The 57678ee8d1cSJulian Grajkowski * client code allocates the memory for this 57778ee8d1cSJulian Grajkowski * structure. This component takes ownership of 57878ee8d1cSJulian Grajkowski * the memory until it is returned in the 57978ee8d1cSJulian Grajkowski * callback. 58078ee8d1cSJulian Grajkowski * @param[out] pPrivateKey Structure which contains pointers to the memory 58178ee8d1cSJulian Grajkowski * into which the generated private key will be 58278ee8d1cSJulian Grajkowski * written. The client MUST allocate memory 58378ee8d1cSJulian Grajkowski * for this structure, and for the pointers 58478ee8d1cSJulian Grajkowski * within it, recursively; on return, these will 58578ee8d1cSJulian Grajkowski * be populated. 58678ee8d1cSJulian Grajkowski * @param[out] pPublicKey Structure which contains pointers to the memory 58778ee8d1cSJulian Grajkowski * into which the generated public key will be 58878ee8d1cSJulian Grajkowski * written. The memory for this structure and 58978ee8d1cSJulian Grajkowski * for the modulusN parameter MUST be allocated 59078ee8d1cSJulian Grajkowski * by the client, and will be populated on return 59178ee8d1cSJulian Grajkowski * from the call. The field publicExponentE 59278ee8d1cSJulian Grajkowski * is not modified or touched in any way; it is 59378ee8d1cSJulian Grajkowski * the responsibility of the client to set this 59478ee8d1cSJulian Grajkowski * to the same value as the corresponding 59578ee8d1cSJulian Grajkowski * parameter on the CpaCyRsaKeyGenOpData 59678ee8d1cSJulian Grajkowski * structure before using the key for encryption. 59778ee8d1cSJulian Grajkowski * 59878ee8d1cSJulian Grajkowski * @retval CPA_STATUS_SUCCESS Function executed successfully. 59978ee8d1cSJulian Grajkowski * @retval CPA_STATUS_FAIL Function failed. 60078ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RETRY Resubmit the request. 60178ee8d1cSJulian Grajkowski * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 60278ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESOURCE Error related to system resources. 60378ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 60478ee8d1cSJulian Grajkowski * the request. 60578ee8d1cSJulian Grajkowski * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 60678ee8d1cSJulian Grajkowski * 60778ee8d1cSJulian Grajkowski * @pre 60878ee8d1cSJulian Grajkowski * The component has been initialized via cpaCyStartInstance function. 60978ee8d1cSJulian Grajkowski * @post 61078ee8d1cSJulian Grajkowski * None 61178ee8d1cSJulian Grajkowski * @note 61278ee8d1cSJulian Grajkowski * When pRsaKeyGenCb is non-NULL, an asynchronous callback of type is 61378ee8d1cSJulian Grajkowski * generated in response to this function call. 61478ee8d1cSJulian Grajkowski * Any errors generated during processing are reported as part of the 61578ee8d1cSJulian Grajkowski * callback status code. For optimal performance, data pointers SHOULD be 61678ee8d1cSJulian Grajkowski * 8-byte aligned. 61778ee8d1cSJulian Grajkowski * @see 61878ee8d1cSJulian Grajkowski * CpaCyRsaKeyGenOpData, 61978ee8d1cSJulian Grajkowski * CpaCyRsaKeyGenCbFunc, 62078ee8d1cSJulian Grajkowski * cpaCyRsaEncrypt(), 62178ee8d1cSJulian Grajkowski * cpaCyRsaDecrypt() 62278ee8d1cSJulian Grajkowski * 62378ee8d1cSJulian Grajkowski *****************************************************************************/ 62478ee8d1cSJulian Grajkowski CpaStatus 62578ee8d1cSJulian Grajkowski cpaCyRsaGenKey(const CpaInstanceHandle instanceHandle, 62678ee8d1cSJulian Grajkowski const CpaCyRsaKeyGenCbFunc pRsaKeyGenCb, 62778ee8d1cSJulian Grajkowski void *pCallbackTag, 62878ee8d1cSJulian Grajkowski const CpaCyRsaKeyGenOpData *pKeyGenOpData, 62978ee8d1cSJulian Grajkowski CpaCyRsaPrivateKey *pPrivateKey, 63078ee8d1cSJulian Grajkowski CpaCyRsaPublicKey *pPublicKey); 63178ee8d1cSJulian Grajkowski 63278ee8d1cSJulian Grajkowski /** 63378ee8d1cSJulian Grajkowski ***************************************************************************** 63478ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 63578ee8d1cSJulian Grajkowski * Perform the RSA encrypt (or verify) primitive operation on the input 63678ee8d1cSJulian Grajkowski * data. 63778ee8d1cSJulian Grajkowski * 63878ee8d1cSJulian Grajkowski * @description 63978ee8d1cSJulian Grajkowski * This function will perform an RSA encryption primitive operation on the 64078ee8d1cSJulian Grajkowski * input data using the specified RSA public key. As the RSA encryption 64178ee8d1cSJulian Grajkowski * primitive and verification primitive operations are mathematically 64278ee8d1cSJulian Grajkowski * identical this function may also be used to perform an RSA verification 64378ee8d1cSJulian Grajkowski * primitive operation. 64478ee8d1cSJulian Grajkowski * 64578ee8d1cSJulian Grajkowski * @context 64678ee8d1cSJulian Grajkowski * When called as an asynchronous function it cannot sleep. It can be 64778ee8d1cSJulian Grajkowski * executed in a context that does not permit sleeping. 64878ee8d1cSJulian Grajkowski * When called as a synchronous function it may sleep. It MUST NOT be 64978ee8d1cSJulian Grajkowski * executed in a context that DOES NOT permit sleeping. 65078ee8d1cSJulian Grajkowski * @assumptions 65178ee8d1cSJulian Grajkowski * None 65278ee8d1cSJulian Grajkowski * @sideEffects 65378ee8d1cSJulian Grajkowski * None 65478ee8d1cSJulian Grajkowski * @blocking 65578ee8d1cSJulian Grajkowski * Yes when configured to operate in synchronous mode. 65678ee8d1cSJulian Grajkowski * @reentrant 65778ee8d1cSJulian Grajkowski * No 65878ee8d1cSJulian Grajkowski * @threadSafe 65978ee8d1cSJulian Grajkowski * Yes 66078ee8d1cSJulian Grajkowski * 66178ee8d1cSJulian Grajkowski * @param[in] instanceHandle Instance handle. 66278ee8d1cSJulian Grajkowski * @param[in] pRsaEncryptCb Pointer to callback function to be invoked 66378ee8d1cSJulian Grajkowski * when the operation is complete. If this is 66478ee8d1cSJulian Grajkowski * set to a NULL value the function will operate 66578ee8d1cSJulian Grajkowski * synchronously. 66678ee8d1cSJulian Grajkowski * @param[in] pCallbackTag Opaque User Data for this specific call. Will 66778ee8d1cSJulian Grajkowski * be returned unchanged in the callback. 66878ee8d1cSJulian Grajkowski * @param[in] pEncryptOpData Structure containing all the data needed to 66978ee8d1cSJulian Grajkowski * perform the RSA encryption operation. The 67078ee8d1cSJulian Grajkowski * client code allocates the memory for this 67178ee8d1cSJulian Grajkowski * structure. This component takes ownership of 67278ee8d1cSJulian Grajkowski * the memory until it is returned in the 67378ee8d1cSJulian Grajkowski * callback. 67478ee8d1cSJulian Grajkowski * @param[out] pOutputData Pointer to structure into which the result of 67578ee8d1cSJulian Grajkowski * the RSA encryption primitive is written. The 67678ee8d1cSJulian Grajkowski * client MUST allocate this memory. The data 67778ee8d1cSJulian Grajkowski * pointed to is an integer in big-endian order. 67878ee8d1cSJulian Grajkowski * The value will be between 0 and the modulus 67978ee8d1cSJulian Grajkowski * n - 1. 68078ee8d1cSJulian Grajkowski * On invocation the callback function will 68178ee8d1cSJulian Grajkowski * contain this parameter in the pOut parameter. 68278ee8d1cSJulian Grajkowski * 68378ee8d1cSJulian Grajkowski * @retval CPA_STATUS_SUCCESS Function executed successfully. 68478ee8d1cSJulian Grajkowski * @retval CPA_STATUS_FAIL Function failed. 68578ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RETRY Resubmit the request. 68678ee8d1cSJulian Grajkowski * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 68778ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESOURCE Error related to system resources. 68878ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 68978ee8d1cSJulian Grajkowski * the request. 69078ee8d1cSJulian Grajkowski * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 69178ee8d1cSJulian Grajkowski * 69278ee8d1cSJulian Grajkowski * @pre 69378ee8d1cSJulian Grajkowski * The component has been initialized via cpaCyStartInstance function. 69478ee8d1cSJulian Grajkowski * @post 69578ee8d1cSJulian Grajkowski * None 69678ee8d1cSJulian Grajkowski * @note 69778ee8d1cSJulian Grajkowski * When pRsaEncryptCb is non-NULL an asynchronous callback of type is 69878ee8d1cSJulian Grajkowski * generated in response to this function call. 69978ee8d1cSJulian Grajkowski * Any errors generated during processing are reported as part of the 70078ee8d1cSJulian Grajkowski * callback status code. For optimal performance, data pointers SHOULD be 70178ee8d1cSJulian Grajkowski * 8-byte aligned. 70278ee8d1cSJulian Grajkowski * @see 70378ee8d1cSJulian Grajkowski * CpaCyGenFlatBufCbFunc 70478ee8d1cSJulian Grajkowski * CpaCyRsaEncryptOpData 70578ee8d1cSJulian Grajkowski * cpaCyRsaGenKey() 70678ee8d1cSJulian Grajkowski * cpaCyRsaDecrypt() 70778ee8d1cSJulian Grajkowski * 70878ee8d1cSJulian Grajkowski *****************************************************************************/ 70978ee8d1cSJulian Grajkowski CpaStatus 71078ee8d1cSJulian Grajkowski cpaCyRsaEncrypt(const CpaInstanceHandle instanceHandle, 71178ee8d1cSJulian Grajkowski const CpaCyGenFlatBufCbFunc pRsaEncryptCb, 71278ee8d1cSJulian Grajkowski void *pCallbackTag, 71378ee8d1cSJulian Grajkowski const CpaCyRsaEncryptOpData *pEncryptOpData, 71478ee8d1cSJulian Grajkowski CpaFlatBuffer *pOutputData); 71578ee8d1cSJulian Grajkowski 71678ee8d1cSJulian Grajkowski /** 71778ee8d1cSJulian Grajkowski ***************************************************************************** 71878ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 71978ee8d1cSJulian Grajkowski * Perform the RSA decrypt (or sign) primitive operation on the input 72078ee8d1cSJulian Grajkowski * data. 72178ee8d1cSJulian Grajkowski * 72278ee8d1cSJulian Grajkowski * @description 72378ee8d1cSJulian Grajkowski * This function will perform an RSA decryption primitive operation on the 72478ee8d1cSJulian Grajkowski * input data using the specified RSA private key. As the RSA decryption 72578ee8d1cSJulian Grajkowski * primitive and signing primitive operations are mathematically identical 72678ee8d1cSJulian Grajkowski * this function may also be used to perform an RSA signing primitive 72778ee8d1cSJulian Grajkowski * operation. 72878ee8d1cSJulian Grajkowski * 72978ee8d1cSJulian Grajkowski * @context 73078ee8d1cSJulian Grajkowski * When called as an asynchronous function it cannot sleep. It can be 73178ee8d1cSJulian Grajkowski * executed in a context that does not permit sleeping. 73278ee8d1cSJulian Grajkowski * When called as a synchronous function it may sleep. It MUST NOT be 73378ee8d1cSJulian Grajkowski * executed in a context that DOES NOT permit sleeping. 73478ee8d1cSJulian Grajkowski * @assumptions 73578ee8d1cSJulian Grajkowski * None 73678ee8d1cSJulian Grajkowski * @sideEffects 73778ee8d1cSJulian Grajkowski * None 73878ee8d1cSJulian Grajkowski * @blocking 73978ee8d1cSJulian Grajkowski * Yes when configured to operate in synchronous mode. 74078ee8d1cSJulian Grajkowski * @reentrant 74178ee8d1cSJulian Grajkowski * No 74278ee8d1cSJulian Grajkowski * @threadSafe 74378ee8d1cSJulian Grajkowski * Yes 74478ee8d1cSJulian Grajkowski * 74578ee8d1cSJulian Grajkowski * @param[in] instanceHandle Instance handle. 74678ee8d1cSJulian Grajkowski * @param[in] pRsaDecryptCb Pointer to callback function to be invoked 74778ee8d1cSJulian Grajkowski * when the operation is complete. If this is 74878ee8d1cSJulian Grajkowski * set to a NULL value the function will operate 74978ee8d1cSJulian Grajkowski * synchronously. 75078ee8d1cSJulian Grajkowski * @param[in] pCallbackTag Opaque User Data for this specific call. 75178ee8d1cSJulian Grajkowski * Will be returned unchanged in the callback. 75278ee8d1cSJulian Grajkowski * @param[in] pDecryptOpData Structure containing all the data needed to 75378ee8d1cSJulian Grajkowski * perform the RSA decrypt operation. The 75478ee8d1cSJulian Grajkowski * client code allocates the memory for this 75578ee8d1cSJulian Grajkowski * structure. This component takes ownership 75678ee8d1cSJulian Grajkowski * of the memory until it is returned in the 75778ee8d1cSJulian Grajkowski * callback. 75878ee8d1cSJulian Grajkowski * @param[out] pOutputData Pointer to structure into which the result of 75978ee8d1cSJulian Grajkowski * the RSA decryption primitive is written. The 76078ee8d1cSJulian Grajkowski * client MUST allocate this memory. The data 76178ee8d1cSJulian Grajkowski * pointed to is an integer in big-endian order. 76278ee8d1cSJulian Grajkowski * The value will be between 0 and the modulus 76378ee8d1cSJulian Grajkowski * n - 1. 76478ee8d1cSJulian Grajkowski * On invocation the callback function will 76578ee8d1cSJulian Grajkowski * contain this parameter in the pOut parameter. 76678ee8d1cSJulian Grajkowski * 76778ee8d1cSJulian Grajkowski * @retval CPA_STATUS_SUCCESS Function executed successfully. 76878ee8d1cSJulian Grajkowski * @retval CPA_STATUS_FAIL Function failed. 76978ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RETRY Resubmit the request. 77078ee8d1cSJulian Grajkowski * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 77178ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESOURCE Error related to system resources. 77278ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 77378ee8d1cSJulian Grajkowski * the request. 77478ee8d1cSJulian Grajkowski * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 77578ee8d1cSJulian Grajkowski * 77678ee8d1cSJulian Grajkowski * @pre 77778ee8d1cSJulian Grajkowski * The component has been initialized via cpaCyStartInstance function. 77878ee8d1cSJulian Grajkowski * @post 77978ee8d1cSJulian Grajkowski * None 78078ee8d1cSJulian Grajkowski * @note 78178ee8d1cSJulian Grajkowski * When pRsaDecryptCb is non-NULL an asynchronous callback is generated in 78278ee8d1cSJulian Grajkowski * response to this function call. 78378ee8d1cSJulian Grajkowski * Any errors generated during processing are reported as part of the 78478ee8d1cSJulian Grajkowski * callback status code. For optimal performance, data pointers SHOULD be 78578ee8d1cSJulian Grajkowski * 8-byte aligned. 78678ee8d1cSJulian Grajkowski * @see 78778ee8d1cSJulian Grajkowski * CpaCyRsaDecryptOpData, 78878ee8d1cSJulian Grajkowski * CpaCyGenFlatBufCbFunc, 78978ee8d1cSJulian Grajkowski * cpaCyRsaGenKey(), 79078ee8d1cSJulian Grajkowski * cpaCyRsaEncrypt() 79178ee8d1cSJulian Grajkowski * 79278ee8d1cSJulian Grajkowski *****************************************************************************/ 79378ee8d1cSJulian Grajkowski CpaStatus 79478ee8d1cSJulian Grajkowski cpaCyRsaDecrypt(const CpaInstanceHandle instanceHandle, 79578ee8d1cSJulian Grajkowski const CpaCyGenFlatBufCbFunc pRsaDecryptCb, 79678ee8d1cSJulian Grajkowski void *pCallbackTag, 79778ee8d1cSJulian Grajkowski const CpaCyRsaDecryptOpData *pDecryptOpData, 79878ee8d1cSJulian Grajkowski CpaFlatBuffer * pOutputData); 79978ee8d1cSJulian Grajkowski 80078ee8d1cSJulian Grajkowski /** 80178ee8d1cSJulian Grajkowski ***************************************************************************** 80278ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 80378ee8d1cSJulian Grajkowski * Query statistics for a specific RSA instance. 80478ee8d1cSJulian Grajkowski * 80578ee8d1cSJulian Grajkowski * @deprecated 80678ee8d1cSJulian Grajkowski * As of v1.3 of the Crypto API, this function has been deprecated, 80778ee8d1cSJulian Grajkowski * replaced by @ref cpaCyRsaQueryStats64(). 80878ee8d1cSJulian Grajkowski * 80978ee8d1cSJulian Grajkowski * @description 81078ee8d1cSJulian Grajkowski * This function will query a specific instance for RSA statistics. The 81178ee8d1cSJulian Grajkowski * user MUST allocate the CpaCyRsaStats structure and pass the 81278ee8d1cSJulian Grajkowski * reference to that into this function call. This function will write the 81378ee8d1cSJulian Grajkowski * statistic results into the passed in CpaCyRsaStats structure. 81478ee8d1cSJulian Grajkowski * 81578ee8d1cSJulian Grajkowski * Note: statistics returned by this function do not interrupt current data 81678ee8d1cSJulian Grajkowski * processing and as such can be slightly out of sync with operations that 81778ee8d1cSJulian Grajkowski * are in progress during the statistics retrieval process. 81878ee8d1cSJulian Grajkowski * 81978ee8d1cSJulian Grajkowski * @context 82078ee8d1cSJulian Grajkowski * This is a synchronous function and it can sleep. It MUST NOT be 82178ee8d1cSJulian Grajkowski * executed in a context that DOES NOT permit sleeping. 82278ee8d1cSJulian Grajkowski * @assumptions 82378ee8d1cSJulian Grajkowski * None 82478ee8d1cSJulian Grajkowski * @sideEffects 82578ee8d1cSJulian Grajkowski * None 82678ee8d1cSJulian Grajkowski * @blocking 82778ee8d1cSJulian Grajkowski * This function is synchronous and blocking. 82878ee8d1cSJulian Grajkowski * @reentrant 82978ee8d1cSJulian Grajkowski * No 83078ee8d1cSJulian Grajkowski * @threadSafe 83178ee8d1cSJulian Grajkowski * Yes 83278ee8d1cSJulian Grajkowski * 83378ee8d1cSJulian Grajkowski * @param[in] instanceHandle Instance handle. 83478ee8d1cSJulian Grajkowski * @param[out] pRsaStats Pointer to memory into which the statistics 83578ee8d1cSJulian Grajkowski * will be written. 83678ee8d1cSJulian Grajkowski * 83778ee8d1cSJulian Grajkowski * @retval CPA_STATUS_SUCCESS Function executed successfully. 83878ee8d1cSJulian Grajkowski * @retval CPA_STATUS_FAIL Function failed. 83978ee8d1cSJulian Grajkowski * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 84078ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESOURCE Error related to system resources. 84178ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 84278ee8d1cSJulian Grajkowski * the request. 84378ee8d1cSJulian Grajkowski * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 84478ee8d1cSJulian Grajkowski * 84578ee8d1cSJulian Grajkowski * @pre 84678ee8d1cSJulian Grajkowski * Component has been initialized. 84778ee8d1cSJulian Grajkowski * @post 84878ee8d1cSJulian Grajkowski * None 84978ee8d1cSJulian Grajkowski * @note 85078ee8d1cSJulian Grajkowski * This function operates in a synchronous manner and no asynchronous 85178ee8d1cSJulian Grajkowski * callback will be generated. 85278ee8d1cSJulian Grajkowski * @see 85378ee8d1cSJulian Grajkowski * CpaCyRsaStats 85478ee8d1cSJulian Grajkowski * 85578ee8d1cSJulian Grajkowski *****************************************************************************/ 85678ee8d1cSJulian Grajkowski CpaStatus CPA_DEPRECATED 85778ee8d1cSJulian Grajkowski cpaCyRsaQueryStats(const CpaInstanceHandle instanceHandle, 85878ee8d1cSJulian Grajkowski struct _CpaCyRsaStats *pRsaStats); 85978ee8d1cSJulian Grajkowski 86078ee8d1cSJulian Grajkowski /** 86178ee8d1cSJulian Grajkowski ***************************************************************************** 86278ee8d1cSJulian Grajkowski * @ingroup cpaCyRsa 86378ee8d1cSJulian Grajkowski * Query statistics (64-bit version) for a specific RSA instance. 86478ee8d1cSJulian Grajkowski * 86578ee8d1cSJulian Grajkowski * @description 86678ee8d1cSJulian Grajkowski * This function will query a specific instance for RSA statistics. The 86778ee8d1cSJulian Grajkowski * user MUST allocate the CpaCyRsaStats64 structure and pass the 86878ee8d1cSJulian Grajkowski * reference to that into this function call. This function will write the 86978ee8d1cSJulian Grajkowski * statistic results into the passed in CpaCyRsaStats64 structure. 87078ee8d1cSJulian Grajkowski * 87178ee8d1cSJulian Grajkowski * Note: statistics returned by this function do not interrupt current data 87278ee8d1cSJulian Grajkowski * processing and as such can be slightly out of sync with operations that 87378ee8d1cSJulian Grajkowski * are in progress during the statistics retrieval process. 87478ee8d1cSJulian Grajkowski * 87578ee8d1cSJulian Grajkowski * @context 87678ee8d1cSJulian Grajkowski * This is a synchronous function and it can sleep. It MUST NOT be 87778ee8d1cSJulian Grajkowski * executed in a context that DOES NOT permit sleeping. 87878ee8d1cSJulian Grajkowski * @assumptions 87978ee8d1cSJulian Grajkowski * None 88078ee8d1cSJulian Grajkowski * @sideEffects 88178ee8d1cSJulian Grajkowski * None 88278ee8d1cSJulian Grajkowski * @blocking 88378ee8d1cSJulian Grajkowski * This function is synchronous and blocking. 88478ee8d1cSJulian Grajkowski * @reentrant 88578ee8d1cSJulian Grajkowski * No 88678ee8d1cSJulian Grajkowski * @threadSafe 88778ee8d1cSJulian Grajkowski * Yes 88878ee8d1cSJulian Grajkowski * 88978ee8d1cSJulian Grajkowski * @param[in] instanceHandle Instance handle. 89078ee8d1cSJulian Grajkowski * @param[out] pRsaStats Pointer to memory into which the statistics 89178ee8d1cSJulian Grajkowski * will be written. 89278ee8d1cSJulian Grajkowski * 89378ee8d1cSJulian Grajkowski * @retval CPA_STATUS_SUCCESS Function executed successfully. 89478ee8d1cSJulian Grajkowski * @retval CPA_STATUS_FAIL Function failed. 89578ee8d1cSJulian Grajkowski * @retval CPA_STATUS_INVALID_PARAM Invalid parameter passed in. 89678ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESOURCE Error related to system resources. 89778ee8d1cSJulian Grajkowski * @retval CPA_STATUS_RESTARTING API implementation is restarting. Resubmit 89878ee8d1cSJulian Grajkowski * the request. 89978ee8d1cSJulian Grajkowski * @retval CPA_STATUS_UNSUPPORTED Function is not supported. 90078ee8d1cSJulian Grajkowski * 90178ee8d1cSJulian Grajkowski * @pre 90278ee8d1cSJulian Grajkowski * Component has been initialized. 90378ee8d1cSJulian Grajkowski * @post 90478ee8d1cSJulian Grajkowski * None 90578ee8d1cSJulian Grajkowski * @note 90678ee8d1cSJulian Grajkowski * This function operates in a synchronous manner and no asynchronous 90778ee8d1cSJulian Grajkowski * callback will be generated. 90878ee8d1cSJulian Grajkowski * @see 90978ee8d1cSJulian Grajkowski * CpaCyRsaStats64 91078ee8d1cSJulian Grajkowski *****************************************************************************/ 91178ee8d1cSJulian Grajkowski CpaStatus 91278ee8d1cSJulian Grajkowski cpaCyRsaQueryStats64(const CpaInstanceHandle instanceHandle, 91378ee8d1cSJulian Grajkowski CpaCyRsaStats64 *pRsaStats); 91478ee8d1cSJulian Grajkowski 91578ee8d1cSJulian Grajkowski #ifdef __cplusplus 91678ee8d1cSJulian Grajkowski } /* close the extern "C" { */ 91778ee8d1cSJulian Grajkowski #endif 91878ee8d1cSJulian Grajkowski 91978ee8d1cSJulian Grajkowski #endif /* CPA_CY_RSA_H */ 920