Mistake on this page?
Report an issue in GitHub or email us
crys_rsa_build.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 #ifndef CRYS_RSA_BUILD_H
38 #define CRYS_RSA_BUILD_H
39 
40 
41 #include "crys_error.h"
42 #include "crys_rsa_types.h"
43 
44 #ifdef __cplusplus
45 extern "C"
46 {
47 #endif
48 
49 /*!
50 @defgroup crys_rsa CryptoCell RSA APIs
51 @{
52 @ingroup cryptocell_api
53 @brief This group is the cryptocell ECC root group
54 @}
55 
56 @file
57 @brief This module defines some utility functions for working with RSA cryptography.
58 @defgroup crys_rsa_build CryptoCell RSA Utility APIs
59 @{
60 @ingroup crys_rsa
61 */
62 
63 /******************************************************************************************/
64 /*!
65 @brief Builds a ::CRYSRSAPubKey_t public key structure with the provided modulus and exponent.
66 
67 @return CRYS_OK on success.
68 @return A non-zero value from crys_rsa_error.h on failure.
69 */
71  CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [out] Pointer to the public key structure. */
72  uint8_t *Exponent_ptr, /*!< [in] Pointer to the exponent stream of bytes (Big-Endian format). */
73  uint16_t ExponentSize, /*!< [in] The size of the exponent (in bytes). */
74  uint8_t *Modulus_ptr, /*!< [in] Pointer to the modulus stream of bytes (Big-Endian format).
75  The most significant bit (MSB) must be set to '1'. */
76  uint16_t ModulusSize /*!< [in] The modulus size in bytes. Supported sizes are 64, 128, 256, 384 and 512. */
77 );
78 
79 
80 /******************************************************************************************/
81 /*!
82 @brief Builds a ::CRYSRSAPrivKey_t private key structure with the provided modulus and exponent, marking the key as a non-CRT key.
83 
84 @return CRYS_OK on success.
85 @return A non-zero value from crys_rsa_error.h on failure.
86 */
88  CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [out] Pointer to the public key structure.*/
89  uint8_t *PrivExponent_ptr, /*!< [in] Pointer to the private exponent stream of bytes (Big-Endian format). */
90  uint16_t PrivExponentSize, /*!< [in] The size of the private exponent (in bytes). */
91  uint8_t *PubExponent_ptr, /*!< [in] Pointer to the public exponent stream of bytes (Big-Endian format). */
92  uint16_t PubExponentSize, /*!< [in] The size of the public exponent (in bytes). */
93  uint8_t *Modulus_ptr, /*!< [in] Pointer to the modulus stream of bytes (Big-Endian format).
94  The most significant bit must be set to '1'. */
95  uint16_t ModulusSize /*!< [in] The modulus size in bytes. Supported sizes are 64, 128, 256, 384 and 512. */
96 );
97 
98 /******************************************************************************************/
99 /*!
100 @brief Builds a ::CRYSRSAPrivKey_t private key structure with the provided parameters, marking the key as a CRT key.
101 
102 @return CRYS_OK on success.
103 @return A non-zero value from crys_rsa_error.h on failure.
104 */
106  CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [out] Pointer to the public key structure. */
107  uint8_t *P_ptr, /*!< [in] Pointer to the first factor stream of bytes (Big-Endian format). */
108  uint16_t PSize, /*!< [in] The size of the first factor (in bytes). */
109  uint8_t *Q_ptr, /*!< [in] Pointer to the second factor stream of bytes (Big-Endian format). */
110  uint16_t QSize, /*!< [in] The size of the second factor (in bytes). */
111  uint8_t *dP_ptr, /*!< [in] Pointer to the first factor's CRT exponent stream of bytes
112  (Big-Endian format). */
113  uint16_t dPSize, /*!< [in] The size of the first factor's CRT exponent (in bytes). */
114  uint8_t *dQ_ptr, /*!< [in] Pointer to the second factor's CRT exponent stream of bytes
115  (Big-Endian format). */
116  uint16_t dQSize, /*!< [in] The size of the second factor's CRT exponent (in bytes). */
117  uint8_t *qInv_ptr, /*!< [in] Pointer to the first CRT coefficient stream of bytes (Big-Endian format). */
118  uint16_t qInvSize /*!< [in] The size of the first CRT coefficient (in bytes). */
119 );
120 
121 
122 /******************************************************************************************/
123 /*!
124 @brief The function gets the e,n public key parameters from the input
125 CRYS_RSAUserPubKey_t structure. The function can also be used to retrieve the
126 modulus and exponent sizes only (Exponent_ptr AND Modulus_ptr must be set to
127 NULL).
128 
129 \note All members of input UserPubKey_ptr structure must be initialized.
130 
131 @return CRYS_OK on success.
132 @return A non-zero value from crys_rsa_error.h on failure.
133 */
135  CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [in] A pointer to the public key structure. */
136  uint8_t *Exponent_ptr, /*!< [out] A pointer to the exponent stream of bytes (Big-Endian format). */
137  uint16_t *ExponentSize_ptr, /*!< [in/out] the size of the exponent buffer in bytes,
138  it is updated to the actual size of the exponent, in bytes. */
139  uint8_t *Modulus_ptr, /*!< [out] A pointer to the modulus stream of bytes (Big-Endian format).
140  The MS (most significant) bit must be set to '1'. */
141  uint16_t *ModulusSize_ptr /*!< [in/out] the size of the modulus buffer in bytes, it is updated to the actual
142  size of the modulus, in bytes. */
143 );
144 
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 /**
150 @}
151  */
152 #endif
CRYSError_t CRYS_RSA_Get_PubKey(CRYS_RSAUserPubKey_t *UserPubKey_ptr, uint8_t *Exponent_ptr, uint16_t *ExponentSize_ptr, uint8_t *Modulus_ptr, uint16_t *ModulusSize_ptr)
The function gets the e,n public key parameters from the input CRYS_RSAUserPubKey_t structure...
CRYSError_t CRYS_RSA_Build_PrivKey(CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, uint8_t *PrivExponent_ptr, uint16_t PrivExponentSize, uint8_t *PubExponent_ptr, uint16_t PubExponentSize, uint8_t *Modulus_ptr, uint16_t ModulusSize)
Builds a CRYSRSAPrivKey_t private key structure with the provided modulus and exponent, marking the key as a non-CRT key.
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...
CRYSError_t CRYS_RSA_Build_PubKey(CRYS_RSAUserPubKey_t *UserPubKey_ptr, uint8_t *Exponent_ptr, uint16_t ExponentSize, uint8_t *Modulus_ptr, uint16_t ModulusSize)
Builds a CRYSRSAPubKey_t public key structure with the provided modulus and exponent.
CRYSError_t CRYS_RSA_Build_PrivKeyCRT(CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, uint8_t *P_ptr, uint16_t PSize, uint8_t *Q_ptr, uint16_t QSize, uint8_t *dP_ptr, uint16_t dPSize, uint8_t *dQ_ptr, uint16_t dQSize, uint8_t *qInv_ptr, uint16_t qInvSize)
Builds a CRYSRSAPrivKey_t private key structure with the provided parameters, marking the key as a CR...
This module defines the error return code types and the numbering spaces of the error codes for each ...
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.