Mistake on this page?
Report an issue in GitHub or email us
crys_rsa_kg.h
Go to the documentation of this file.
1 /**************************************************************************************
2 * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
3 * *
4 * This file and the related binary are licensed under the following license: *
5 * *
6 * ARM Object Code and Header Files License, v1.0 Redistribution. *
7 * *
8 * Redistribution and use of object code, header files, and documentation, without *
9 * modification, are permitted provided that the following conditions are met: *
10 * *
11 * 1) Redistributions must reproduce the above copyright notice and the *
12 * following disclaimer in the documentation and/or other materials *
13 * provided with the distribution. *
14 * *
15 * 2) Unless to the extent explicitly permitted by law, no reverse *
16 * engineering, decompilation, or disassembly of is permitted. *
17 * *
18 * 3) Redistribution and use is permitted solely for the purpose of *
19 * developing or executing applications that are targeted for use *
20 * on an ARM-based product. *
21 * *
22 * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
23 * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
24 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
25 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
28 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
33 **************************************************************************************/
34 
35 
36 
37 
38 #ifndef CRYS_RSA_KG_H
39 #define CRYS_RSA_KG_H
40 
41 #include "crys_rsa_types.h"
42 #include "crys_rnd.h"
43 
44 #ifdef __cplusplus
45 extern "C"
46 {
47 #endif
48 
49 /*!
50 @file
51 @brief Generates a RSA pair of public and private keys.
52 @defgroup crys_rsa_kg CryptoCell RSA key generation APIs
53 @{
54 @ingroup crys_rsa
55 */
56 
57 /************************ Defines ******************************/
58 
59 /* Max allowed size and values of public exponent for key generation in CRYS */
60 /*! Maximal public exponent size in bits. */
61 #define CRYS_RSA_KG_PUB_EXP_MAX_SIZE_BITS 17
62 /*! Definition of public exponent value. */
63 #define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_1 0x000003
64 /*! Definition of public exponent value. */
65 #define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_2 0x000011
66 /*! Definition of public exponent value. */
67 #define CRYS_RSA_KG_PUB_EXP_ALLOW_VAL_3 0x010001
68 
69 
70 
71 
72 /***********************************************************************************************/
73 
74 /*!
75 @brief CRYS_RSA_KG_GenerateKeyPair generates a Pair of public and private keys on non CRT mode according to [ANS X9.31].
76 
77 \note To be FIPS 186-4 [5.1] compliant use only the following key sizes (in bits): 1024, 2048 and 3072.
78 
79 @return CRYS_OK on success.
80 @return A non-zero value from crys_rsa_error.h or crys_rnd_error.h on failure.
81 
82 */
83 
85  void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */
86  SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */
87  uint8_t *pubExp_ptr, /*!< [in] The pointer to the public exponent (public key). */
88  uint16_t pubExpSizeInBytes, /*!< [in] The public exponent size in bytes. */
89  uint32_t keySize, /*!< [in] The size of the key, in bits. Supported sizes are
90  512, 1024, 2048, 3072 and 4096 bit. */
91  CRYS_RSAUserPrivKey_t *userPrivKey_ptr, /*!< [out] Pointer to the private key structure. */
92  CRYS_RSAUserPubKey_t *userPubKey_ptr, /*!< [out] Pointer to the public key structure. */
93  CRYS_RSAKGData_t *keyGenData_ptr, /*!< [in] Pointer to a temporary structure required for the KeyGen operation. */
94  CRYS_RSAKGFipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */
95 );
96 
97 /***********************************************************************************************/
98 /*!
99 @brief Generates a pair of public and private keys on CRT mode according to [ANS X9.31].
100 
101 \note To be FIPS 186-4 [5.1] compliant use only the following key sizes (in bits): 1024, 2048 and 3072.
102 
103 @return CRYS_OK on success.
104 @return A non-zero value from crys_rsa_error.h or crys_rnd_error.h on failure.
105 */
106 
108  void *rndState_ptr, /*!< [in/out] Pointer to the RND state structure. */
109  SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, /*!< [in] Pointer to the random vector generation function. */
110  uint8_t *pubExp_ptr, /*!< [in] The pointer to the public exponent (public key). */
111  uint16_t pubExpSizeInBytes, /*!< [in] The public exponent size in bytes. */
112  uint32_t keySize, /*!< [in] The size of the key, in bits. Supported sizes are
113  512, 1024, 2048, 3072 and 4096 bit. */
114  CRYS_RSAUserPrivKey_t *userPrivKey_ptr, /*!< [out] Pointer to the private key structure. */
115  CRYS_RSAUserPubKey_t *userPubKey_ptr, /*!< [out] Pointer to the public key structure. */
116  CRYS_RSAKGData_t *keyGenData_ptr, /*!< [in] Pointer to a temporary structure required for the KeyGen operation. */
117  CRYS_RSAKGFipsContext_t *pFipsCtx /*!< [in] Pointer to temporary buffer used in case FIPS certification if required. */
118 );
119 
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 /**
125 @}
126  */
127 #endif
128 
129 
CRYSError_t CRYS_RSA_KG_GenerateKeyPairCRT(void *rndState_ptr, SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, uint8_t *pubExp_ptr, uint16_t pubExpSizeInBytes, uint32_t keySize, CRYS_RSAUserPrivKey_t *userPrivKey_ptr, CRYS_RSAUserPubKey_t *userPubKey_ptr, CRYS_RSAKGData_t *keyGenData_ptr, CRYS_RSAKGFipsContext_t *pFipsCtx)
Generates a pair of public and private keys on CRT mode according to [ANS X9.31]. ...
CRYSError_t CRYS_RSA_KG_GenerateKeyPair(void *rndState_ptr, SaSiRndGenerateVectWorkFunc_t rndGenerateVectFunc, uint8_t *pubExp_ptr, uint16_t pubExpSizeInBytes, uint32_t keySize, CRYS_RSAUserPrivKey_t *userPrivKey_ptr, CRYS_RSAUserPubKey_t *userPubKey_ptr, CRYS_RSAKGData_t *keyGenData_ptr, CRYS_RSAKGFipsContext_t *pFipsCtx)
CRYS_RSA_KG_GenerateKeyPair generates a Pair of public and private keys on non CRT mode according to ...
This file contains the CRYS APIs used for random number generation. The random-number generation modu...
uint32_t CRYSError_t
Definition: crys_error.h:253
This file contains all of the enums and definitions that are used for the CRYS RSA APIs...
uint32_t(* SaSiRndGenerateVectWorkFunc_t)(void *rndState_ptr, uint16_t outSizeBytes, uint8_t *out_ptr)
Definition: crys_rnd.h:206
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.