Mistake on this page?
Report an issue in GitHub or email us
crys_rsa_prim.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_PRIM_H
38 #define CRYS_RSA_PRIM_H
39 
40 #include "crys_rsa_types.h"
41 
42 #ifdef __cplusplus
43 extern "C"
44 {
45 #endif
46 
47 /*!
48 @file
49 @brief This module defines the API that implements the [PKCS1_2.1] primitive functions.
50 @defgroup crys_rsa_prim CryptoCell RSA primitive APIs
51 @{
52 @ingroup crys_rsa
53 
54 
55 \note Direct use of primitive functions, rather than schemes to protect data, is strongly discouraged as primitive functions are
56 susceptible to well-known attacks.
57 */
58 
59 
60 
61 /**********************************************************************************/
62 /*!
63 @brief Implements the RSAEP algorithm, as defined in [PKCS1_2.1] - 6.1.1.
64 
65 @return CRYS_OK on success.
66 @return A non-zero value from crys_rsa_error.h on failure.
67  */
69  CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [in] Pointer to the public key data structure. */
70  CRYS_RSAPrimeData_t *PrimeData_ptr, /*!< [in] Pointer to a temporary structure containing internal buffers. */
71  uint8_t *Data_ptr, /*!< [in] Pointer to the data to encrypt. */
72  uint16_t DataSize, /*!< [in] The size (in bytes) of input data must be &le; modulus size. If is smaller,
73  then the function padds it by zeros on left side up to the modulus size
74  and therefore, after further decrypt operation, its result will contain
75  zero-padding also. If the function is used for recovering the plain data
76  from result of inverse function (CRYS_RSA_PRIM_Decrypt), the input size
77  must be equal to modulus size exactly. */
78  uint8_t *Output_ptr /*!< [out] Pointer to the encrypted data. The buffer size must be &ge; the modulus size. */
79 );
80 
81 
82 /**********************************************************************************/
83 /*!
84 @brief Implements the RSADP algorithm, as defined in [PKCS1_2.1] - 6.1.2.
85 
86 @return CRYS_OK on success.
87 @return A non-zero value from crys_rsa_error.h on failure.
88 
89 */
91  CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [in] Pointer to the private key data structure.
92  The key representation (pair or quintuple) and hence the RSA algorithm
93  (CRT or not-CRT) is determined by enum value in the structure
94  ::CRYS_RSA_Build_PrivKey or ::CRYS_RSA_Build_PrivKeyCRT. */
95  CRYS_RSAPrimeData_t *PrimeData_ptr, /*!< [in] Pointer to a temporary structure containing internal buffers required for
96  the RSA operation. */
97  uint8_t *Data_ptr, /*!< [in] Pointer to the data to be decrypted. */
98  uint16_t DataSize, /*!< [in] The size (in bytes) of input data must be &le; modulus size.
99  If the size is smaller (not recommendet), then the data will be zero-padded
100  by the function on left side up to the modulus size and therefore, after further
101  decrypt operation,its result will contain zero-padding also. If the function is used
102  for recovering the plain data from result of inverse function (CRYS_RSA_PRIM_Encrypt),
103  the input size must be equal to modulus size exactly. */
104  uint8_t *Output_ptr /*!< [out] Pointer to the decrypted data. The buffer size must be &le; the modulus size. */
105 );
106 
107 
108 /*!
109 @brief Implements the RSASP1 algorithm, as defined in [PKCS1_2.1] - 6.2.1, as a call to ::CRYS_RSA_PRIM_Decrypt,
110 since the signature primitive is identical to the decryption primitive.
111 */
112 #define CRYS_RSA_PRIM_Sign CRYS_RSA_PRIM_Decrypt
113 
114 /*!
115 @brief Implements the RSAVP1 algorithm, as defined in [PKCS1_2.1] - 6.2.2, as a call to ::CRYS_RSA_PRIM_Encrypt.
116 */
117 #define CRYS_RSA_PRIM_Verify CRYS_RSA_PRIM_Encrypt
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 /**
123 @}
124  */
125 #endif
CRYSError_t CRYS_RSA_PRIM_Encrypt(CRYS_RSAUserPubKey_t *UserPubKey_ptr, CRYS_RSAPrimeData_t *PrimeData_ptr, uint8_t *Data_ptr, uint16_t DataSize, uint8_t *Output_ptr)
Implements the RSAEP algorithm, as defined in [PKCS1_2.1] - 6.1.1.
CRYSError_t CRYS_RSA_PRIM_Decrypt(CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, CRYS_RSAPrimeData_t *PrimeData_ptr, uint8_t *Data_ptr, uint16_t DataSize, uint8_t *Output_ptr)
Implements the RSADP algorithm, as defined in [PKCS1_2.1] - 6.1.2.
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...
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.