Mistake on this page?
Report an issue in GitHub or email us
ccsw_crys_rsa_shared_types.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 #ifndef SW_CRYS_RSA_SHARED_TYPES_H
37 #define SW_CRYS_RSA_SHARED_TYPES_H
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif
43 
44 
45 /** @file
46  * @brief This file contains the types for the CCSW RSA module.
47  */
48 
49 /************************ Defines ******************************/
50 
51 /************************************************************************/
52 /* the following definitions are only relevant for RSA code on SW */
53 /************************************************************************/
54 /* Define the maximal allowed width of the exponentiation sliding window
55 in range 2...6. This define is actual for projects on soft platform.
56 To minimize code size use the minimum value. To optimize performance
57 choose the maximum value */
58 
59 /* The valid key size in bits */
60 #define SW_CRYS_RSA_MIN_VALID_KEY_SIZE_VALUE_IN_BITS 512
61 
62 #ifndef CRYS_NO_RSA_MAX_KEY_SIZE_4096_BIT_SUPPORT
63 #define SW_CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 4096
64 #define SW_CRYS_RSA_MAX_KEY_GENERATION_SIZE_BITS 4096
65 #else
66 #ifndef CRYS_NO_RSA_MAX_KEY_SIZE_3072_BIT_SUPPORT
67 #define SW_CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 3072
68 #define SW_CRYS_RSA_MAX_KEY_GENERATION_SIZE_BITS 3072
69 #else
70 #define SW_CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS 2048
71 #define SW_CRYS_RSA_MAX_KEY_GENERATION_SIZE_BITS 2048
72 #endif
73 #endif
74 
75 
76 
77 
78 
79 /* Define the size of the exponentiation temp buffer, used in LLF_PKI exponentiation and NON DEPENDED on
80  width of the sliding window. The size defined in units equaled to maximal RSA modulus size */
81 #define PKI_EXP_CONST_TEMP_BUFF_SIZE_IN_MODULUS_UNITS 7
82 
83 #define PKI_EXP_SLIDING_WINDOW_MAX_VALUE 2
84 
85  /* The maximum buffer size for the 'H' value */
86 #define SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS ((SW_CRYS_RSA_MAX_VALID_KEY_SIZE_VALUE_IN_BITS + 64UL ) / 32 )
87 
88 
89 /* definition of PKI_KEY_GEN_TEMP_BUFF_SIZE_WORDS IS DEPENDED on width of the sliding window*/
90 #if( PKI_EXP_SLIDING_WINDOW_MAX_VALUE > 2 )
91 #define PKI_KEY_GEN_TEMP_BUFF_SIZE_WORDS \
92  ((4 + (1<<(PKI_EXP_SLIDING_WINDOW_MAX_VALUE-2))) * SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS)
93 #else
94 #define PKI_KEY_GEN_TEMP_BUFF_SIZE_WORDS \
95  (16 * SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS)
96 #endif
97 
98 #ifndef PKI_EXP_WINDOW_TEMP_BUFFER_SIZE_IN_MODULUS_UNITS
99 #define PKI_EXP_WINDOW_TEMP_BUFFER_SIZE_IN_MODULUS_UNITS (3 + (1 << (PKI_EXP_SLIDING_WINDOW_MAX_VALUE-1)))
100 #endif
101 
102 
103 /* Define the size of the temp buffer, used in LLF_PKI exponentiation and DEPENDED on
104  width of the sliding window in words */
105 #if (PKI_EXP_CONST_TEMP_BUFF_SIZE_IN_MODULUS_UNITS > PKI_EXP_WINDOW_TEMP_BUFFER_SIZE_IN_MODULUS_UNITS )
106 #define PKI_EXP_TEMP_BUFFER_SIZE_IN_WORDS \
107  (PKI_EXP_CONST_TEMP_BUFF_SIZE_IN_MODULUS_UNITS * SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS + 2 )
108 #else
109 #define PKI_EXP_TEMP_BUFFER_SIZE_IN_WORDS \
110  (PKI_EXP_WINDOW_TEMP_BUFFER_SIZE_IN_MODULUS_UNITS * SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS + 2 )
111 #endif
112 
113 /* the RSA data type */
115  /* The aligned input and output data buffers */
116  uint32_t DataIn[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS];
117  uint32_t DataOut[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS];
118 
119  /* #include specific fields that are used by the low level */
120  struct {
121  union {
122  struct { /* Temporary buffers used for the exponent calculation */
123  uint32_t Tempbuff1[PKI_EXP_TEMP_BUFFER_SIZE_IN_WORDS];
124  uint32_t Tempbuff2[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS * 2];
125  /* Temporary buffer for self-test support */
126  uint32_t TempBuffer[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS];
127  }NonCrt;
128 
129  struct { /* Temporary buffers used for the exponent calculation */
130  uint32_t Tempbuff1[PKI_EXP_TEMP_BUFFER_SIZE_IN_WORDS];
131  uint32_t Tempbuff2[SW_CRYS_RSA_MAXIMUM_MOD_BUFFER_SIZE_IN_WORDS * 2];
132  }Crt;
133  }Data;
134  }LLF;
135 
137 
138 
139 
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 #endif
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.