le_iks_rsa_common.h

Go to the documentation of this file.
1 
2 /*
3  * ====================== WARNING ======================
4  *
5  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
6  * DO NOT MODIFY IN ANY WAY.
7  *
8  * ====================== WARNING ======================
9  */
10 /**
11  * @file le_iks_rsa_common.h
12  *
13  * Type definitions for le_iks_rsa.
14  *
15  */
16 #ifndef LE_IKS_RSA_COMMON_H_INCLUDE_GUARD
17 #define LE_IKS_RSA_COMMON_H_INCLUDE_GUARD
18 
19 
20 #include "legato.h"
21 
22 // Interface specific includes
23 #include "le_iks_common.h"
24 
25 #define IFGEN_LE_IKS_RSA_PROTOCOL_ID "11801f0fa970c47c6b090fc9cbbbbadc"
26 #define IFGEN_LE_IKS_RSA_MSG_SIZE 4382
27 /** @addtogroup le_iks_rsa
28  * @{ **/
29 
30 
31 //--------------------------------------------------------------------------------------------------
32 /**
33  * The RSA public exponent used by all IOT Key Store RSA functions.
34  */
35 //--------------------------------------------------------------------------------------------------
36 #define LE_IKS_RSA_PUB_EXP 65537
37 
38 //--------------------------------------------------------------------------------------------------
39 /**
40  * The RSA public exponent used by all IOT Key Store RSA functions.
41  */
42 //--------------------------------------------------------------------------------------------------
43 #define LE_IKS_RSA_MAX_LABEL_SIZE 256
44 
45 
46 //--------------------------------------------------------------------------------------------------
47 /**
48  * Get if this client bound locally.
49  */
50 //--------------------------------------------------------------------------------------------------
51 LE_SHARED bool ifgen_le_iks_rsa_HasLocalBinding
52 (
53  void
54 );
55 
56 
57 //--------------------------------------------------------------------------------------------------
58 /**
59  * Init data that is common across all threads
60  */
61 //--------------------------------------------------------------------------------------------------
62 LE_SHARED void ifgen_le_iks_rsa_InitCommonData
63 (
64  void
65 );
66 
67 
68 //--------------------------------------------------------------------------------------------------
69 /**
70  * Perform common initialization and open a session
71  */
72 //--------------------------------------------------------------------------------------------------
73 LE_SHARED le_result_t ifgen_le_iks_rsa_OpenSession
74 (
75  le_msg_SessionRef_t _ifgen_sessionRef,
76  bool isBlocking
77 );
78 
79 //--------------------------------------------------------------------------------------------------
80 /**
81  * Encrypts a message with RSAES-OAEP (RSA Encryption Scheme - Optimal Asymmetric Encryption
82  * Padding).
83  *
84  * The maximum plaintext size (pLen bytes) depends on the key size (kLen bytes) and the hash digest
85  * size (hLen bytes) according to the equation: pLen = kLen - 2*hLen - 2
86  * For example, with a 2048 bit key using SHA-224 the maximum plaintext size is 226 bytes.
87  *
88  * An optional label associated with the message can be added. The label is restricted to less than
89  * or equal to MAX_LABEL_SIZE. The same label must be provided during decryption.
90  *
91  * The ciphertext size is always kLen bytes (key size) and the ciphertextPtr buffer should be large
92  * enough to hold the ciphertext.
93  *
94  * @return
95  * LE_OK if successful.
96  * LE_BAD_PARAMETER if the key reference is invalid
97  * of if the key type is invalid
98  * or if plaintextPtr, ciphertextPtr or ciphertextSizePtr is NULL.
99  * LE_OUT_OF_RANGE if either the labelSize or the plaintextSize is too big.
100  * LE_OVERFLOW if the ciphertext buffer is too small.
101  * LE_FAULT if there was an internal error.
102  */
103 //--------------------------------------------------------------------------------------------------
104 LE_SHARED le_result_t ifgen_le_iks_rsa_Oaep_Encrypt
105 (
106  le_msg_SessionRef_t _ifgen_sessionRef,
107  uint64_t keyRef,
108  ///< [IN] Key reference.
109  const uint8_t* labelPtr,
110  ///< [IN] Label. NULL if not used.
111  size_t labelSize,
112  ///< [IN]
113  const uint8_t* plaintextPtr,
114  ///< [IN] Plaintext. NULL if not used.
115  size_t plaintextSize,
116  ///< [IN]
117  uint8_t* ciphertextPtr,
118  ///< [OUT] Buffer to hold the ciphertext.
119  size_t* ciphertextSizePtr
120  ///< [INOUT]
121 );
122 
123 //--------------------------------------------------------------------------------------------------
124 /**
125  * Decrypts a message with RSAES-OAEP (RSA Encryption Scheme - Optimal Asymmetric Encryption
126  * Padding).
127  *
128  * The maximum plaintext size (pLen bytes) depends on the key size (kLen bytes) and the hash digest
129  * size (hLen bytes) according to the equation: pLen = kLen - 2*hLen - 2
130  * For example, with a 2048 bit key using SHA-224 the maximum plaintext size is 226 bytes.
131  * The plaintextPtr buffer is assumed to be large enough to hold the plaintext. A safe size for
132  * this buffer is kLen.
133  *
134  * The optional label associated with the message is restricted to less than or equal to
135  * MAX_LABEL_SIZE and should be the same label used for encryption.
136  *
137  * The ciphertext size is expected to be the same as the key size (kLen).
138  *
139  * @return
140  * LE_OK if successful.
141  * LE_BAD_PARAMETER if the key reference is invalid
142  * or if the key type is invalid
143  * or if the either the ciphertextPtr or plaintextSizePtr is NULL.
144  * LE_OUT_OF_RANGE if the labelSize is too big.
145  * LE_FORMAT_ERROR if the ciphertextSize does not match the key size.
146  * LE_OVERFLOW if the plaintextSizePtr is too small to hold the plaintext.
147  * LE_FAULT if the decryption failed.
148  */
149 //--------------------------------------------------------------------------------------------------
150 LE_SHARED le_result_t ifgen_le_iks_rsa_Oaep_Decrypt
151 (
152  le_msg_SessionRef_t _ifgen_sessionRef,
153  uint64_t keyRef,
154  ///< [IN] Key reference.
155  const uint8_t* labelPtr,
156  ///< [IN] Label. NULL if not used.
157  size_t labelSize,
158  ///< [IN]
159  const uint8_t* ciphertextPtr,
160  ///< [IN] Ciphertext.
161  size_t ciphertextSize,
162  ///< [IN]
163  uint8_t* plaintextPtr,
164  ///< [OUT] Buffer to hold the plaintext.
165  size_t* plaintextSizePtr
166  ///< [INOUT]
167 );
168 
169 //--------------------------------------------------------------------------------------------------
170 /**
171  * Generates a signature on the hash digest of a message with RSASSA-PSS (RSA Signature Scheme with
172  * Appendix - Probabilistic Signature Scheme).
173  *
174  * Signatures are generally only created on a hash of a message rather than directly on the message
175  * itself this function follows this paradigm. However, the same hash function used to create the
176  * signature must be used to create the digest of the message. For example, if the key type is
177  * LE_IKS_KEY_TYPE_PRIV_RSASSA_PSS_SHA512 then SHA512 muust be used to create the digest for the
178  * message. The digest size should be the output size of the hash function being used.
179  *
180  * The salt size should generally be small between 8 and 16 bytes. Strictly, it must be less than
181  * keySize - hLen - 2 where hLen is the output size of the hash function used to create the
182  * signature.
183  *
184  * The signature size is always the size of the key. The signature buffer should be large enough to
185  * hold the signature.
186  *
187  * @return
188  * LE_OK if successful.
189  * LE_BAD_PARAMETER if the key reference is invalid
190  * or if the key type is invalid
191  * or if digestPtr, signaturePtr or signatureSizePtr are NULL.
192  * LE_OUT_OF_RANGE if either the saltSize or the digestSize is too big.
193  * LE_OVERFLOW if the signature buffer is too small.
194  * LE_FAULT if there was an internal error.
195  */
196 //--------------------------------------------------------------------------------------------------
197 LE_SHARED le_result_t ifgen_le_iks_rsa_Pss_GenSig
198 (
199  le_msg_SessionRef_t _ifgen_sessionRef,
200  uint64_t keyRef,
201  ///< [IN] Key reference.
202  uint32_t saltSize,
203  ///< [IN] Salt size.
204  const uint8_t* digestPtr,
205  ///< [IN] Digest to sign.
206  size_t digestSize,
207  ///< [IN]
208  uint8_t* signaturePtr,
209  ///< [OUT] Buffer to hold the signature.
210  size_t* signatureSizePtr
211  ///< [INOUT]
212 );
213 
214 //--------------------------------------------------------------------------------------------------
215 /**
216  * Verifies a signature of the hash digest of a message with RSASSA-PSS (RSA Signature Scheme with
217  * Appendix - Probabilistic Signature Scheme).
218  *
219  * Signatures are generally only created on a hash of a message rather than directly on the message
220  * itself this function follows this paradigm. However, the same hash function used to create the
221  * signature must be used to create the digest of the message. For example, if the key type is
222  * LE_IKS_KEY_TYPE_PRIV_RSASSA_PSS_SHA512 then SHA512 muust be used to create the digest for the
223  * message. The digest size should be the output size of the hash function being used.
224  *
225  * The salt size should generally be small between 8 and 16 bytes. Strictly, it must be less than
226  * keySize - hLen - 2 where hLen is the output size of the hash function used to create the
227  * signature.
228  *
229  * The signature size should always the size of the key.
230  *
231  * @return
232  * LE_OK if successful.
233  * LE_BAD_PARAMETER if the key reference is invalid
234  * or if the key type is invalid
235  * or if either digestPtr or signaturePtr are NULL.
236  * LE_OUT_OF_RANGE if either the saltSize or the digestSize is too big.
237  * LE_FORMAT_ERROR if signatureSize does not match the key size.
238  * LE_FAULT if the signature is not valid.
239  */
240 //--------------------------------------------------------------------------------------------------
241 LE_SHARED le_result_t ifgen_le_iks_rsa_Pss_VerifySig
242 (
243  le_msg_SessionRef_t _ifgen_sessionRef,
244  uint64_t keyRef,
245  ///< [IN] Key reference.
246  uint32_t saltSize,
247  ///< [IN] Salt size.
248  const uint8_t* digestPtr,
249  ///< [IN] Digest to sign.
250  size_t digestSize,
251  ///< [IN]
252  const uint8_t* signaturePtr,
253  ///< [IN] Signature of the message.
254  size_t signatureSize
255  ///< [IN]
256 );
257 /** @} **/
258 #endif // LE_IKS_RSA_COMMON_H_INCLUDE_GUARD
#define LE_SHARED
Definition: le_basics.h:287
le_result_t
Definition: le_basics.h:46
struct le_msg_Session * le_msg_SessionRef_t
Definition: le_messaging.h:860