c3240e8826adf2417ab43999699e7e6bde3ac151
[platform/core/security/key-manager.git] / src / include / ckmc / ckmc-type.h
1 /*
2  * Copyright (c) 2000 - 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  *
16  *
17  * @file ckmc-type.h
18  * @version 1.0
19  * @brief Definitions of struct for the Key Manager's CAPI and their utility functions.
20  */
21
22
23 #ifndef __TIZEN_CORE_CKMC_TYPE_H__
24 #define __TIZEN_CORE_CKMC_TYPE_H__
25
26
27 #include <stddef.h>
28 #include <stdint.h>
29 #include <ckmc/ckmc-error.h>
30
31
32 #define KEY_MANAGER_CAPI __attribute__((visibility("default")))
33
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39
40 /**
41  * @addtogroup CAPI_KEY_MANAGER_TYPES_MODULE
42  * @{
43  */
44
45
46 /*
47  * Note: on tizen 3.0 owner id is equal to pkgId.
48  *       Preinstalled system(uid < 5000) and user (uid >= 5000) applications
49  *       does not have any pkgId. That's why ckm uses special "virtual"
50  *       pkgid for them. The virtual strings are defined under:
51  *                       ckmc_owner_id_system
52  */
53
54
55 /**
56  * @deprecated Deprecated since 3.0. [Use ckmc_owner_id_separator instead]
57  * @brief Separator between alias and label.
58  * @since_tizen 2.3
59  * @remarks Alias can be provided as an alias alone, or together with label - in this
60  *          case, separator " " (space bar) is used to separate label and alias.
61  * @see #ckmc_owner_id_separator
62  */
63 KEY_MANAGER_CAPI extern char const *const ckmc_label_name_separator;
64
65
66 /**
67  * @brief Separator between alias and owner id.
68  * @since_tizen 3.0
69  * @remarks Alias can be provided as an alias alone, or together with owner id.
70  *          In this case, separator " " (space bar) is used to separate id and alias.
71  * @see ckmc_alias_new()
72  */
73 KEY_MANAGER_CAPI extern char const *const ckmc_owner_id_separator;
74
75
76 /**
77  * @brief The owner of system database.
78  * @since_tizen 3.0
79  * @remarks #ckmc_owner_id_system contains id connected with all system applications that run with
80  *          uid less than 5000. Client should use #ckmc_owner_id_system to access data owned by
81  *          system application and stored in system database. Client must have permission to access
82  *          proper row.
83  * @see ckmc_alias_new()
84  */
85 KEY_MANAGER_CAPI extern char const *const ckmc_owner_id_system;
86
87
88 /**
89  * @brief Enumeration for key types of key manager.
90  * @since_tizen 2.3
91  */
92 typedef enum __ckmc_key_type {
93         CKMC_KEY_NONE = 0, /**< Key type not specified */
94         CKMC_KEY_RSA_PUBLIC, /**< RSA public key */
95         CKMC_KEY_RSA_PRIVATE, /**< RSA private key */
96         CKMC_KEY_ECDSA_PUBLIC, /**< ECDSA public key */
97         CKMC_KEY_ECDSA_PRIVATE, /**< ECDSA private key */
98         CKMC_KEY_DSA_PUBLIC, /**< DSA public key */
99         CKMC_KEY_DSA_PRIVATE, /**< DSA private key */
100         CKMC_KEY_AES, /**< AES key */
101 } ckmc_key_type_e;
102
103
104 /**
105  * @brief Enumeration for data format.
106  * @since_tizen 2.3
107  */
108 typedef enum __ckmc_data_format {
109         CKMC_FORM_DER_BASE64 = 0, /**< DER format base64 encoded data */
110         CKMC_FORM_DER, /**< DER encoded data */
111         CKMC_FORM_PEM /**< PEM encoded data. It consists of the DER format base64 encoded
112                   with additional header and footer lines. */
113 } ckmc_data_format_e;
114
115
116 /**
117  * @brief Enumeration for elliptic curve.
118  * @since_tizen 2.3
119  */
120 typedef enum __ckmc_ec_type {
121         CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended
122                             elliptic curve domain */
123         CKMC_EC_PRIME256V1, /**< "SEC 2" recommended elliptic curve domain - secp256r1 */
124         CKMC_EC_SECP384R1 /**< NIST curve P-384 (covers "secp384r1"), the elliptic curve domain
125                       listed in See SEC 2 */
126 } ckmc_ec_type_e;
127
128
129 /**
130  * @brief Enumeration for hash algorithm.
131  * @since_tizen 2.3
132  */
133 typedef enum __ckmc_hash_algo {
134         CKMC_HASH_NONE = 0, /**< No Hash Algorithm */
135         CKMC_HASH_SHA1, /**< Hash Algorithm SHA1 */
136         CKMC_HASH_SHA256, /**< Hash Algorithm SHA256 */
137         CKMC_HASH_SHA384, /**< Hash Algorithm SHA384 */
138         CKMC_HASH_SHA512 /**< Hash Algorithm SHA512 */
139 } ckmc_hash_algo_e;
140
141
142 /**
143  * @brief Enumeration for RSA padding algorithm.
144  * @since_tizen 2.3
145  */
146 typedef enum __ckmc_rsa_padding_algo {
147         CKMC_NONE_PADDING = 0, /**< No Padding */
148         CKMC_PKCS1_PADDING, /**< PKCS#1 Padding */
149         CKMC_X931_PADDING /**< X9.31 padding */
150 } ckmc_rsa_padding_algo_e;
151
152
153 /**
154  * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif
155  *             [Use #ckmc_permission_e instead]
156  * @brief Enumeration for database access rights.
157  * @since_tizen 2.3
158  */
159 typedef enum __ckmc_access_right {
160         CKMC_AR_READ = 0, /**< Access right for read*/
161         CKMC_AR_READ_REMOVE /**< Access right for read and remove*/
162 } ckmc_access_right_e;
163
164
165 /**
166  * @brief Enumeration for permissions to access/modify alias.
167  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
168  */
169 typedef enum __ckmc_permission {
170         CKMC_PERMISSION_NONE = 0x00, /**< Clear permissions */
171         CKMC_PERMISSION_READ = 0x01, /**< Read allowed */
172         CKMC_PERMISSION_REMOVE = 0x02 /**< Remove allowed */
173 } ckmc_permission_e;
174
175 /**
176  * @brief The structure for binary buffer used in key manager CAPI.
177  * @since_tizen 2.3
178  */
179 typedef struct __ckmc_raw_buff {
180         unsigned char *data; /**< Byte array containing binary data */
181         size_t size; /**< The size of the binary data */
182 } ckmc_raw_buffer_s;
183
184
185 /**
186  * @brief The structure for a policy for storing key/certificate/binary data.
187  * @since_tizen 2.3
188  */
189 typedef struct __ckmc_policy {
190         char *password; /**< Byte array used to encrypt data inside CKM. If it is not NULL, the data
191                         (or key, or certificate) is stored encrypted with this password inside
192                         key manager */
193         bool extractable; /**< If true key may be extracted from storage */
194 } ckmc_policy_s;
195
196
197 /**
198  * @brief The structure for key used in key manager CAPI.
199  * @since_tizen 2.3
200  */
201 typedef struct __ckmc_key {
202         unsigned char
203         *raw_key; /**< Byte array of key. raw_key may be encrypted with password */
204         size_t key_size; /**< The byte size of raw_key */
205         ckmc_key_type_e key_type; /**< The raw_key's type */
206         char *password; /**< Byte array used to decrypt data raw_key inside key manager. */
207 } ckmc_key_s;
208
209
210 /**
211  * @brief The structure for certificate used in key manager CAPI.
212  * @since_tizen 2.3
213  */
214 typedef struct __ckmc_cert {
215         unsigned char *raw_cert; /**< Byte array of certificate */
216         size_t cert_size; /**< Byte size of raw_cert */
217         ckmc_data_format_e data_format; /**< Raw_cert's encoding format */
218 } ckmc_cert_s;
219
220
221 /**
222  * @brief The structure for linked list of alias.
223  * @since_tizen 2.3
224  */
225 typedef struct __ckmc_alias_list {
226         char *alias; /**< The name of key, certificate or data stored in key manager */
227         struct __ckmc_alias_list *next; /**< The pointer pointing to the next #ckmc_alias_list_s */
228 } ckmc_alias_list_s;
229
230 struct ckmc_alias_info_s;
231
232 /**
233  * @brief The structure of alias and additional information about it.
234  * @since_tizen 5.5
235  */
236 typedef struct ckmc_alias_info_s ckmc_alias_info_s;
237
238 /**
239  * @brief The structure for linked list of alias with additional information.
240  * @since_tizen 5.5
241  */
242 typedef struct __ckmc_alias_info_list_s {
243         struct ckmc_alias_info_s* info; /**< The pointer pointing to the alias structure with additional
244                                         information */
245         struct __ckmc_alias_info_list_s* next; /**< The pointer pointing to the next
246                                                #ckmc_alias_info_list_s */
247 } ckmc_alias_info_list_s;
248
249
250 /**
251  * @brief The structure for linked list of #ckmc_cert_s.
252  * @since_tizen 2.3
253  */
254 typedef struct __ckmc_cert_list {
255         ckmc_cert_s *cert; /**< The pointer of #ckmc_cert_s */
256         struct __ckmc_cert_list *next; /**< The pointer pointing to the next #ckmc_cert_list_s */
257 } ckmc_cert_list_s;
258
259
260 /**
261  * @brief Enumeration for OCSP status.
262  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
263  */
264 typedef enum __ckmc_ocsp_status {
265         CKMC_OCSP_STATUS_GOOD = 0, /**< OCSP status is good */
266         CKMC_OCSP_STATUS_REVOKED, /**< The certificate is revoked */
267         CKMC_OCSP_STATUS_UNKNOWN, /**< Unknown error */
268         CKMC_OCSP_ERROR_UNSUPPORTED, /**< The certificate does not provide OCSP extension */
269         CKMC_OCSP_ERROR_INVALID_URL, /**< The invalid URL in certificate OCSP extension */
270         CKMC_OCSP_ERROR_INVALID_RESPONSE, /**< The invalid response from OCSP server */
271         CKMC_OCSP_ERROR_REMOTE, /**< OCSP remote server error */
272         CKMC_OCSP_ERROR_NET, /**< Network connection error */
273         CKMC_OCSP_ERROR_INTERNAL /**< OpenSSL API error */
274 } ckmc_ocsp_status_e;
275
276
277 /**
278  * @brief The structure for PKCS12 used in key manager CAPI.
279  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
280  */
281 typedef struct __ckmc_pkcs12 {
282         ckmc_key_s *priv_key; /**< The private key, may be NULL */
283         ckmc_cert_s *cert; /**< The certificate, may be NULL */
284         ckmc_cert_list_s *ca_chain; /**< The chain certificate list, may be NULL */
285 } ckmc_pkcs12_s;
286
287
288 /**
289  * @brief Enumeration for crypto algorithm parameters.
290  * @since_tizen 3.0
291  * @see #ckmc_algo_type_e
292  */
293 typedef enum __ckmc_param_name {
294         CKMC_PARAM_ALGO_TYPE = 1, /**< integer - type of algorithm (see #ckmc_algo_type_e) */
295
296         CKMC_PARAM_ED_IV = 101, /**< buffer - initialization vector */
297         CKMC_PARAM_ED_CTR_LEN, /**< integer - ctr length in bits*/
298         CKMC_PARAM_ED_AAD, /**< buffer - Additional Authentication Data for AES GCM */
299         CKMC_PARAM_ED_TAG_LEN, /**< integer - tag length in bits */
300         CKMC_PARAM_ED_LABEL, /**< buffer - RSA OAEP label (not supported at the moment) */
301
302         CKMC_PARAM_KDF_PRF = 401, /**< integer - pseudo-random function number (see #ckmc_kdf_prf_e)
303                                   (Since 6.0) */
304         CKMC_PARAM_KDF_LEN, /**< integer - length of the derived key in bytes. The value must be one of
305                             {16, 24, 32} (Since 6.0) */
306
307         CKMC_PARAM_KBKDF_MODE, /**< integer - KDF mode number (see #ckmc_kbkdf_mode_e) (Since 6.0) */
308         CKMC_PARAM_KBKDF_LABEL, /**< buffer - the purpose for the derived key. Conflicts with
309                                 #CKMC_PARAM_KBKDF_FIXED_INPUT (Since 6.0) */
310
311         CKMC_PARAM_KBKDF_CONTEXT, /**< buffer - information related to the derived key. Conflicts with
312                                   #CKMC_PARAM_KBKDF_FIXED_INPUT (Since 6.0) */
313
314         CKMC_PARAM_KBKDF_FIXED_INPUT, /**< buffer - KBKDF fixed input replacing context and label
315                                        (Since 6.0). Conflicts with:
316                                       - #CKMC_PARAM_KBKDF_LABEL,
317                                       - #CKMC_PARAM_KBKDF_CONTEXT,
318                                       - #CKMC_PARAM_KBKDF_LLEN,
319                                       - #CKMC_PARAM_KBKDF_NO_SEPARATOR */
320         CKMC_PARAM_KBKDF_COUNTER_LOCATION, /**< integer - specifies location of the counter in KBKDF
321                                            (see #ckmc_kbkdf_counter_location_e) (Since 6.0) */
322         CKMC_PARAM_KBKDF_RLEN, /**< integer - specifies the length of the counter representation in bits
323                                in KBKDF. The value must be one of {8, 16, 24, 32}. If not set, the
324                                default value = 32 will be used. (Since 6.0) */
325         CKMC_PARAM_KBKDF_LLEN, /**< integer - specifies the length of the length suffix representation
326                                in bits in KBKDF. The value must be one of {0, 8, 16, 24, 32}. If set to
327                                0 the length suffix will be skipped. If not set, the default value = 32
328                                will be used. The length suffix is skipped if
329                                #CKMC_PARAM_KBKDF_FIXED_INPUT is passed and this parameter conflicts
330                                with it. (Since 6.0) */
331         CKMC_PARAM_KBKDF_NO_SEPARATOR, /**< integer - presence of this parameter will skip the zero
332                                        octet separator between label and context in KBKDF.
333                                        All values are allowed. This parameter conflicts with
334                                        #CKMC_PARAM_KBKDF_FIXED_INPUT. (Since 6.0) */
335
336         CKMC_PARAM_ECDH_PUBKEY, /**< buffer - EC public key in DER form (see #ckmc_key_s) (Since 6.0) */
337 } ckmc_param_name_e;
338
339 /**
340  * @brief Enumeration for key derivation function pseudo-random function parameter.
341  * @since_tizen 6.0
342  *
343  * @see ckmc_key_derive()
344  * @see #ckmc_param_name_e
345  */
346 typedef enum __ckmc_kdf_prf {
347         CKMC_KDF_PRF_HMAC_SHA256 = 1, /**< HMAC SHA256 */
348         CKMC_KDF_PRF_HMAC_SHA384, /**< HMAC SHA384 */
349         CKMC_KDF_PRF_HMAC_SHA512, /**< HMAC SHA512 */
350 } ckmc_kdf_prf_e;
351
352 /**
353  * @brief Enumeration for key based key derivation function mode.
354  * @since_tizen 6.0
355  *
356  * @see ckmc_key_derive()
357  * @see #ckmc_param_name_e
358  */
359 typedef enum __ckmc_kbkdf_mode {
360         CKMC_KBKDF_MODE_COUNTER = 1, /**< KBKDF counter mode */
361 } ckmc_kbkdf_mode_e;
362
363 /**
364  * @brief Enumeration for KBKDF counter location relative to fixed input.
365  * @since_tizen 6.0
366  *
367  * @see ckmc_key_derive()
368  * @see #ckmc_param_name_e
369  */
370 typedef enum __ckmc_kbkdf_counter_location {
371         CKMC_KBKDF_COUNTER_BEFORE_FIXED = 1, /**< Counter is located before fixed input */
372         CKMC_KBKDF_COUNTER_AFTER_FIXED, /**< Counter is located after fixed input */
373         CKMC_KBKDF_COUNTER_MIDDLE_FIXED, /**< Counter is located in the middle of the fixed input
374                                          (between context and label). This setting requires setting
375                                          #CKMC_PARAM_KBKDF_LABEL and #CKMC_PARAM_KBKDF_CONTEXT and
376                                          conflicts with #CKMC_PARAM_KBKDF_FIXED_INPUT. If this location
377                                          is used the separator will be skipped regardless of the
378                                          #CKMC_PARAM_KBKDF_NO_SEPARATOR parameter */
379 } ckmc_kbkdf_counter_location_e;
380
381 /**
382  * @brief Algorithm parameter list handle.
383  * @since_tizen 3.0
384  * @remarks Each parameter list must have at least one #CKMC_PARAM_ALGO_TYPE parameter that
385  *          identifies the algorithm. See #ckmc_algo_type_e for available algorithms and additional
386  *          parameters they support.
387  * @see ckmc_generate_new_params()
388  * @see ckmc_param_list_new()
389  * @see ckmc_param_list_set_integer()
390  * @see ckmc_param_list_set_buffer()
391  * @see ckmc_param_list_get_integer()
392  * @see ckmc_param_list_get_buffer()
393  * @see ckmc_param_list_free()
394  * @see #ckmc_algo_type_e
395  * @see #ckmc_param_name_e
396  */
397 typedef struct __ckmc_param_list *ckmc_param_list_h;
398
399
400 /**
401  * @brief Enumeration for crypto algorithm types.
402  * @since_tizen 3.0
403  * @see #ckmc_param_name_e
404  */
405 typedef enum __ckmc_algo_type {
406         CKMC_ALGO_AES_CTR = 1, /**< AES-CTR algorithm
407                            Supported parameters:
408                            - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_AES_CTR (mandatory),
409                            - #CKMC_PARAM_ED_IV = 16-byte initialization vector (mandatory)
410                            - #CKMC_PARAM_ED_CTR_LEN = length of counter block in bits
411                            (optional, only 128b is supported at the moment) */
412
413         CKMC_ALGO_AES_CBC, /**< AES-CBC algorithm
414                        Supported parameters:
415                        - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_AES_CBC (mandatory),
416                        - #CKMC_PARAM_ED_IV = 16-byte initialization vector (mandatory) */
417
418         CKMC_ALGO_AES_GCM, /**< AES-GCM algorithm
419                        Supported parameters:
420                        - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_AES_GCM (mandatory),
421                        - #CKMC_PARAM_ED_IV = 1 to (2^64-1) bytes long initialization vector.
422                        Note that the backend may impose additional limit on the maximum size
423                        (ckmc_backend_get_max_chunk_size()). Recommended length is 12B (mandatory)
424                        - #CKMC_PARAM_ED_TAG_LEN = GCM tag length in bits. One of
425                        {32, 64, 96, 104, 112, 120, 128} (optional, if not present, the
426                        length 128 is used; since Tizen 5.0, if TrustZone backend is used,
427                        32 and 64 lengths are not supported)
428                        - #CKMC_PARAM_ED_AAD = additional authentication data. Note that the backend
429                        may impose limit on the maximum size (ckmc_backend_get_max_chunk_size())
430                        (optional) */
431
432         CKMC_ALGO_AES_CFB, /**< AES-CFB algorithm
433                        Supported parameters:
434                        - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_AES_CFB (mandatory),
435                        - #CKMC_PARAM_ED_IV = 16-byte initialization vector (mandatory) */
436
437         CKMC_ALGO_RSA_OAEP, /**< RSA-OAEP algorithm
438                         Supported parameters:
439                         - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_RSA_OAEP (mandatory),
440                         - #CKMC_PARAM_ED_LABEL = label to be associated with the message
441                         (optional, not supported at the moment) */
442
443         CKMC_ALGO_KBKDF, /**< Key based key derivation algorithm
444                      Supported parameters:
445                      - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_KBKDF (mandatory),
446                      - #CKMC_PARAM_KDF_PRF = pseudo-random function (see #ckmc_kdf_prf_e)
447                      (mandatory),
448                      - #CKMC_PARAM_KBKDF_MODE = KDF mode (see #ckmc_kbkdf_mode_e) (mandatory),
449                      - #CKMC_PARAM_KBKDF_LABEL = the purpose for the derived key (optional),
450                      - #CKMC_PARAM_KBKDF_CONTEXT = information related to the derived key
451                      (optional),
452                      - #CKMC_PARAM_KDF_LEN = length of the derived key (mandatory)
453                      - #CKMC_PARAM_KBKDF_FIXED_INPUT = replacement for context and label (optional),
454                      - #CKMC_PARAM_KBKDF_COUNTER_LOCATION = counter location
455                      (see #ckmc_kbkdf_counter_location_e) (mandatory),
456                      - #CKMC_PARAM_KBKDF_RLEN = length of the counter representation (optional),
457                      - #CKMC_PARAM_KBKDF_LLEN = length of the length suffix representation
458                      (optional),
459                      - #CKMC_PARAM_KBKDF_NO_SEPARATOR = existence of zero separator (optional) */
460
461         CKMC_ALGO_ECDH, /**< ECDH shared secret key agreement protocol
462                      Supported parameters (all are required):
463                      - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_ECDH,
464                      - #CKMC_PARAM_ECDH_PUBKEY = peer's public key (see #ckmc_key_s) */
465 } ckmc_algo_type_e;
466
467 /**
468  * @brief Enumeration for backend identifiers.
469  * @since_tizen 6.0
470  * @see ckmc_get_backend_info()
471  * @see ckmc_alias_info_get_backend()
472  */
473 typedef enum __ckmc_backend_id {
474         CKMC_BACKEND_SW = 0, /**< Software backend */
475         CKMC_BACKEND_TZ      /**< TrustZone backend */
476 } ckmc_backend_id_e;
477
478 /**
479  * @brief Backend information handle.
480  * @since_tizen 6.0
481  * @see ckmc_alias_info_get_backend()
482  * @see ckmc_get_backend_info()
483  * @see ckmc_backend_get_max_chunk_size()
484  * @see ckmc_backend_info_free()
485  */
486 typedef struct __ckmc_backend_info_s *ckmc_backend_info_h;
487
488 /**
489  * @brief Encryption/decryption context handle.
490  * @since_tizen 6.0
491  * @see ckmc_cipher_initialize()
492  * @see ckmc_cipher_update()
493  * @see ckmc_cipher_finalize()
494  * @see ckmc_cipher_free()
495  */
496 typedef struct __ckmc_cipher_ctx *ckmc_cipher_ctx_h;
497
498 /**
499  * @brief Gets the alias from #ckmc_alias_info_s structure.
500  * @since_tizen 5.5
501  * @remarks The @a alias should not be released.
502  *          The @a alias can be used until #ckmc_alias_info_s is released.
503  * @param[in] info The pointer to the #ckmc_alias_info_s structure
504  * @param[out] alias The pointer to the alias
505  * @return #CKMC_ERROR_NONE on success,
506  *         otherwise a negative error value
507  * @retval #CKMC_ERROR_NONE Successful
508  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
509  * @see #ckmc_alias_info_s
510  */
511 int ckmc_alias_info_get_alias(const ckmc_alias_info_s* info, char** alias);
512
513 /**
514  * @brief Gets the password protection status from #ckmc_alias_info_s structure.
515  * @since_tizen 5.5
516  * @param[in] info The pointer to the #ckmc_alias_info_s structure
517  * @param[out] is_password_protected The pointer to the password protection flag
518  * @return #CKMC_ERROR_NONE on success,
519  *         otherwise a negative error value
520  * @retval #CKMC_ERROR_NONE Successful
521  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
522  * @see #ckmc_alias_info_s
523  */
524 int ckmc_alias_info_is_password_protected(const ckmc_alias_info_s* info,
525                                           bool* is_password_protected);
526
527 /**
528  * @brief Gets the backend identifier from #ckmc_alias_info_s structure.
529  * @since_tizen 6.0
530  * @param[in] info The pointer to the #ckmc_alias_info_s structure
531  * @param[out] backend The pointer to the backend identifier
532  * @return #CKMC_ERROR_NONE on success, otherwise a negative error value
533  * @retval #CKMC_ERROR_NONE Successful
534  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
535  * @see #ckmc_backend_id_e
536  * @see #ckmc_alias_info_s
537  * @see ckmc_get_backend_info()
538  * @see ckmc_backend_info_free()
539  * @see ckmc_backend_get_max_chunk_size()
540  */
541 int ckmc_alias_info_get_backend(const ckmc_alias_info_s* info, ckmc_backend_id_e* backend);
542
543 /**
544  * @brief Destroys the #ckmc_alias_info_list_s handle and releases resources of
545  *                 #ckmc_alias_info_list_s from the provided first handle cascadingly.
546  * @since_tizen 5.5
547  * @param[in] first The first #ckmc_alias_info_list_s handle to destroy
548  * @see #ckmc_alias_info_list_s
549  */
550 void ckmc_alias_info_list_all_free(ckmc_alias_info_list_s *first);
551
552 /**
553  * @brief Creates a new full alias which is a concatenation of @a owner_id and @a alias.
554  * @since_tizen 3.0
555  * @remarks @a full_alias should be freed with free() after use.
556  * @remarks Returns #CKMC_ERROR_INVALID_PARAMETER if any of parameter is NULL.
557  * @remarks Returns #CKMC_ERROR_INVALID_PARAMETER if @a owner_id is empty.
558  * @param[in] owner_id Data owner's id. This should be package id if data owner is
559  *                     application. If you want to access data stored by system
560  *                     services, it should be #ckmc_owner_id_system
561  * @param[in] alias Data alias
562  * @param[out] full_alias The newly created alias which is a concatenation of
563  *                        @a owner_id, #ckmc_owner_id_separator and @a alias.
564  *                        Destroy by free() after use
565  * @return #CKMC_ERROR_NONE on success,
566  *         otherwise a negative error value
567  * @retval #CKMC_ERROR_NONE Successful
568  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
569  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
570  * @see #ckmc_owner_id_separator
571  * @see #ckmc_owner_id_system
572  */
573 int ckmc_alias_new(const char *owner_id, const char *alias, char **full_alias);
574
575
576 /**
577  * @brief Creates a new #ckmc_key_s handle and returns it.
578  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
579  * @remarks You must destroy the newly created #ckmc_key_s by calling ckmc_key_free() if it is no
580  *          longer needed.
581  * @param[in] raw_key The byte array of key. The @a raw_key may be encrypted with password.
582  * @param[in] key_size The byte size of @a raw_key
583  * @param[in] key_type The type of @a raw_key
584  * @param[in] password The byte array used to decrypt @a raw_key inside key manager. If @a raw_key
585  *                     is not encrypted, @a password can be NULL
586  * @param[out] ppkey The pointer to a newly created #ckmc_key_s handle
587  * @return #CKMC_ERROR_NONE on success,
588  *         otherwise a negative error value
589  * @retval #CKMC_ERROR_NONE Successful
590  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
591  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
592  * @see ckmc_key_free()
593  * @see #ckmc_key_s
594  */
595 int ckmc_key_new(unsigned char *raw_key,
596                  size_t key_size,
597                  ckmc_key_type_e key_type,
598                  char *password,
599                  ckmc_key_s **ppkey);
600
601
602 /**
603  * @brief Destroys the #ckmc_key_s handle and releases all its resources.
604  * @since_tizen 2.3
605  * @param[in] key The #ckmc_key_s handle to destroy
606  */
607 void ckmc_key_free(ckmc_key_s *key);
608
609
610 /**
611  * @brief Creates a new #ckmc_raw_buffer_s handle and returns it.
612  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
613  * @remarks You must destroy the newly created #ckmc_raw_buffer_s by calling ckmc_buffer_free() if
614  *          it is no longer needed.
615  * @param[in] data The byte array of buffer
616  * @param[in] size The byte size of buffer
617  * @param[out] ppbuffer The pointer to a newly created #ckmc_raw_buffer_s handle
618  * @return #CKMC_ERROR_NONE on success,
619  *         otherwise a negative error value
620  * @retval #CKMC_ERROR_NONE Successful
621  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
622  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
623  * @see ckmc_buffer_free()
624  * @see #ckmc_raw_buffer_s
625  */
626 int ckmc_buffer_new(unsigned char *data, size_t size, ckmc_raw_buffer_s **ppbuffer);
627
628
629 /**
630  * @brief Destroys the #ckmc_raw_buffer_s handle and releases all its resources.
631  * @since_tizen 2.3
632  * @param[in] buffer The #ckmc_raw_buffer_s structure to destroy
633  */
634 void ckmc_buffer_free(ckmc_raw_buffer_s *buffer);
635
636
637 /**
638  * @brief Creates a new #ckmc_cert_s handle and returns it.
639  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
640  * @remarks You must destroy the newly created #ckmc_cert_s by calling ckmc_cert_free() if it is no
641  *          longer needed.
642  * @param[in] raw_cert The byte array of certificate
643  * @param[in] cert_size The byte size of raw_cert
644  * @param[in] data_format The encoding format of raw_cert
645  * @param[out] ppcert The pointer to a newly created #ckmc_cert_s handle
646  * @return #CKMC_ERROR_NONE on success,
647  *         otherwise a negative error value
648  * @retval #CKMC_ERROR_NONE Successful
649  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
650  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
651  * @see ckmc_cert_free()
652  * @see ckmc_load_cert_from_file()
653  * @see #ckmc_cert_s
654  */
655 int ckmc_cert_new(unsigned char *raw_cert,
656                   size_t cert_size,
657                   ckmc_data_format_e data_format,
658                   ckmc_cert_s **ppcert);
659
660
661 /**
662  * @brief Destroys the #ckmc_cert_s handle and releases all its resources.
663  * @since_tizen 2.3
664  * @param[in] cert The #ckmc_cert_s handle to destroy
665  * @see ckmc_load_cert_from_file()
666  */
667 void ckmc_cert_free(ckmc_cert_s *cert);
668
669
670 /**
671  * @brief Creates a new #ckmc_cert_s handle from a given file and returns it.
672  * @since_tizen 2.3
673  * @remarks You must destroy the newly created #ckmc_cert_s by calling ckmc_cert_free() if it is no
674  *          longer needed.
675  * @param[in] file_path The path of certificate file to be loaded. Only DER or PEM encoded
676  *                      certificate file is supported
677  * @param[out] cert The pointer of newly created #ckmc_cert_s handle
678  * @return #CKMC_ERROR_NONE on success,
679  *         otherwise a negative error value
680  * @retval #CKMC_ERROR_NONE Successful
681  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
682  * @retval #CKMC_ERROR_INVALID_FORMAT Invalid certificate file format
683  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
684  * @see ckmc_cert_free()
685  * @see #ckmc_cert_s
686  */
687 int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert);
688
689
690 /**
691  * @brief Creates a new #ckmc_pkcs12_s handle and returns it.
692  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
693  * @remarks You must destroy the newly created #ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it is
694  *          no longer needed.
695  * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly
696  *          returned @a pkcs12_bundle.
697  * @param[in] private_key #ckmc_key_s handle to the private key (optional)
698  * @param[in] cert #ckmc_cert_s handle to the certificate (optional)
699  * @param[in] ca_cert_list #ckmc_cert_list_s list of chain certificate handles (optional)
700  * @param[out] pkcs12_bundle The pointer to a newly created #ckmc_pkcs12_s handle
701  * @return #CKMC_ERROR_NONE on success,
702  *         otherwise a negative error value
703  * @retval #CKMC_ERROR_NONE Successful
704  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or @a private_key, @a cert and
705  *                                       @a ca_cert_list all are NULL
706  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
707  * @see ckmc_pkcs12_free()
708  * @see ckmc_pkcs12_load()
709  * @see #ckmc_key_s
710  * @see #ckmc_cert_s
711  * @see #ckmc_cert_list_s
712  * @see #ckmc_pkcs12_s
713  */
714 int ckmc_pkcs12_new(ckmc_key_s *private_key,
715                     ckmc_cert_s *cert,
716                     ckmc_cert_list_s *ca_cert_list,
717                     ckmc_pkcs12_s **pkcs12_bundle);
718
719
720 /**
721  * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif
722  *             [Use ckmc_pkcs12_load() instead]
723  * @brief Creates a new #ckmc_key_s (@a private_key), #ckmc_cert_s (@a cert),
724  *        and #ckmc_cert_list_s (@a ca_cert_list) handle from a given PKCS#12 file and returns them.
725  * @since_tizen 2.3
726  * @remarks You must destroy the newly created @a private_key, @a cert and @a ca_cert_list
727             by calling ckmc_key_free(), ckmc_cert_free(), and ckmc_cert_list_all_free() if they are
728             no longer needed.
729  * @param[in] file_path The path of PKCS12 file to be loaded
730  * @param[in] passphrase The passphrase used to decrypt the PCKS12 file. If PKCS12 file is not
731  *                       encrypted, passphrase can be NULL
732  * @param[out] private_key The pointer of newly created #ckmc_key_s handle for a private key
733  * @param[out] cert The pointer of newly created #ckmc_cert_s handle for a certificate. It is NULL
734  *                  if the PKCS12 file does not contain a certificate
735  * @param[out] ca_cert_list The pointer of newly created #ckmc_cert_list_s handle for CA
736  *                          certificates. It is NULL if the PKCS12 file does not contain
737  *                          CA certificates
738  * @return #CKMC_ERROR_NONE on success,
739  *         otherwise a negative error value
740  * @retval #CKMC_ERROR_NONE Successful
741  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
742  * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
743  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
744  * @see ckmc_pkcs12_new()
745  * @see ckmc_pkcs12_load()
746  * @see ckmc_key_free()
747  * @see ckmc_cert_free()
748  * @see ckmc_cert_list_all_free()
749  * @see #ckmc_key_s
750  * @see #ckmc_cert_s
751  * @see #ckmc_cert_list_s
752  */
753 int ckmc_load_from_pkcs12_file(const char *file_path,
754                                const char *passphrase,
755                                ckmc_key_s **private_key,
756                                ckmc_cert_s **cert,
757                                ckmc_cert_list_s **ca_cert_list) TIZEN_DEPRECATED_API;
758
759
760 /**
761  * @brief Creates a new #ckmc_pkcs12_s handle from a given PKCS#12 file and returns it.
762  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
763  * @remarks You must destroy the newly created #ckmc_pkcs12_s by calling ckmc_pkcs12_free() if they
764  *          are no longer needed.
765  * @param[in] file_path The path of PKCS12 file to be loaded
766  * @param[in] passphrase The passphrase used to decrypt the PCKS12 file. If PKCS12 file is not
767  *                       encrypted, passphrase can be NULL
768  * @param[out] pkcs12_bundle The pointer of newly created #ckmc_cert_list_s handle for
769  *                           CA certificates. It is NULL if the PKCS12 file does not contain
770  *                           CA certificates
771  * @return #CKMC_ERROR_NONE on success,
772  *         otherwise a negative error value
773  * @retval #CKMC_ERROR_NONE Successful
774  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
775  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
776  * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
777  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
778  * @see ckmc_pkcs12_free()
779  * @see #ckmc_pkcs12_s
780  */
781 int ckmc_pkcs12_load(const char *file_path, const char *passphrase, ckmc_pkcs12_s **pkcs12_bundle);
782
783
784 /**
785  * @brief Destroys the #ckmc_pkcs12_s handle and releases all its resources.
786  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
787  * @param[in] pkcs12 The #ckmc_pkcs12_s handle to destroy
788  * @see ckmc_pkcs12_new()
789  * @see ckmc_pkcs12_load()
790  */
791 void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12);
792
793
794 /**
795  * @brief Creates a new #ckmc_alias_list_s handle and returns it. The alias pointer in the returned
796  *        #ckmc_alias_list_s handle points to the provided characters and next is NULL.
797  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
798  * @remarks You must destroy the newly created #ckmc_alias_list_s by calling ckmc_alias_list_free()
799  *          or ckmc_alias_list_all_free() if it is no longer needed.
800  * @param[in] alias The first item to be set in the newly created #ckmc_alias_list_s
801  * @param[out] ppalias_list The pointer to a newly created #ckmc_alias_list_s handle
802  * @return #CKMC_ERROR_NONE on success,
803  *         otherwise a negative error value
804  * @retval #CKMC_ERROR_NONE Successful
805  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
806  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
807  * @see ckmc_alias_list_all_free()
808  * @see #ckmc_alias_list_s
809  */
810 int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list);
811
812
813 /**
814  * @brief Creates a new #ckmc_alias_list_s handle, adds it to a previous #ckmc_alias_list_s and
815  *        returns it. The alias pointer in the returned #ckmc_alias_list_s handle points to the
816  *        provided characters and next is NULL.
817  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
818  * @remarks You must destroy the newly created @a pplast using ckmc_alias_list_free()
819  * @param[in] previous The last #ckmc_alias_list_s handle to which a newly created
820  *                     #ckmc_alias_list_s is added
821  * @param[in] alias The item to be set in the newly created #ckmc_alias_list_s
822  * @param[out] pplast The pointer to a newly created and added #ckmc_alias_list_s handle
823  * @return #CKMC_ERROR_NONE on success,
824  *         otherwise a negative error value
825  * @retval #CKMC_ERROR_NONE Successful
826  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
827  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
828  * @see ckmc_alias_list_all_free()
829  * @see #ckmc_alias_list_s
830  */
831 int ckmc_alias_list_add(ckmc_alias_list_s *previous, char *alias, ckmc_alias_list_s **pplast);
832
833
834 /**
835  * @brief Destroys the #ckmc_alias_list_s handle and releases resources of #ckmc_alias_list_s from
836  *        the provided first handle cascadingly.
837  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
838  * @remarks It does not destroy an alias itself in #ckmc_alias_list_s.
839  * @param[in] first The first #ckmc_alias_list_s handle to destroy
840  * @see ckmc_alias_list_all_free()
841  * @see #ckmc_alias_list_s
842  */
843 void ckmc_alias_list_free(ckmc_alias_list_s *first);
844
845
846 /**
847  * @brief Destroys the #ckmc_alias_list_s handle and releases all its resources from the provided
848  *        first handle cascadingly.
849  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
850  * @remarks It also destroys the alias in #ckmc_alias_list_s.
851  * @param[in] first The first #ckmc_alias_list_s handle to destroy
852  * @see #ckmc_alias_list_s
853  */
854 void ckmc_alias_list_all_free(ckmc_alias_list_s *first);
855
856
857 /**
858  * @brief Creates a new #ckmc_cert_list_s handle and returns it. The cert pointer in the returned
859  *        #ckmc_cert_list_s handle points to the provided #ckmc_cert_s and next is NULL.
860  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
861  * @remarks You must destroy the newly created #ckmc_cert_list_s by calling ckmc_cert_list_free() or
862  *          ckmc_cert_list_all_free() if it is no longer needed.
863  * @param[in] cert The first item to be set in the newly created #ckmc_cert_list_s
864  * @param[out] ppalias_list The pointer to a newly created #ckmc_alias_list_s handle
865  * @return #CKMC_ERROR_NONE on success,
866  *         otherwise a negative error value
867  * @retval #CKMC_ERROR_NONE Successful
868  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
869  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
870  * @see ckmc_cert_list_all_free()
871  * @see #ckmc_cert_list_s
872  */
873 int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list);
874
875
876 /**
877  * @brief Creates a new #ckmc_cert_list_s handle, adds it to a previous #ckmc_cert_list_s and
878  *        returns it. The cert pointer in the returned #ckmc_alias_list_s handle points to the
879  *        provided #ckmc_cert_s and next is NULL.
880  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
881  * @remarks You must destroy the newly created @a pplast using ckmc_cert_list_free()
882  * @param[in] previous The last #ckmc_cert_list_s handle to which a newly created #ckmc_cert_list_s
883  *                     is added
884  * @param[in] cert The item to be set in the newly created #ckmc_cert_list_s
885  * @param[out] pplast The pointer to a newly created and added #ckmc_alias_list_s handle
886  * @return #CKMC_ERROR_NONE on success,
887  *         otherwise a negative error value
888  * @retval #CKMC_ERROR_NONE Successful
889  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
890  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
891  * @see ckmc_cert_list_all_free()
892  * @see #ckmc_cert_list_s
893  */
894 int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast);
895
896
897 /**
898  * @brief Destroys the #ckmc_cert_list_s handle and releases resources of #ckmc_cert_list_s from the
899  *        provided first handle cascadingly.
900  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
901  * @remarks It does not destroy #ckmc_cert_s itself in #ckmc_cert_list_s.
902  * @param[in] first The first #ckmc_cert_list_s handle to destroy
903  * @see ckmc_cert_list_all_free()
904  * @see #ckmc_cert_list_s
905  */
906 void ckmc_cert_list_free(ckmc_cert_list_s *first);
907
908
909 /**
910  * @brief Destroys the #ckmc_cert_list_s handle and releases all its resources from the provided
911  *        first handle cascadingly.
912  * @since_tizen 2.3
913  * @remarks It also destroys #ckmc_cert_s in #ckmc_cert_list_s.
914  * @param[in] first The first #ckmc_cert_list_s handle to destroy
915  * @see #ckmc_cert_list_s
916  */
917 void ckmc_cert_list_all_free(ckmc_cert_list_s *first);
918
919
920 /**
921  * @brief Creates new parameter list.
922  * @since_tizen 3.0
923  * @remarks Caller is responsible for freeing it with ckmc_param_list_free().
924  * @param[in] pparams Double pointer to the handle of param list to which the newly created
925  *                    algorithm param list will be assigned
926  * @return #CKMC_ERROR_NONE on success,
927  *         otherwise a negative error value
928  * @retval #CKMC_ERROR_NONE Successful
929  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
930  * @see ckmc_param_list_set_integer()
931  * @see ckmc_param_list_set_buffer()
932  * @see ckmc_param_list_free()
933  * @see ckmc_generate_new_params()
934  * @see #ckmc_param_list_h
935  * @see #ckmc_param_name_e
936  * @see #ckmc_algo_type_e
937  */
938 int ckmc_param_list_new(ckmc_param_list_h *pparams);
939
940
941 /**
942  * @brief Sets integer parameter to the list.
943  * @since_tizen 3.0
944  * @remarks Caller is responsible for #ckmc_param_list_h creation.
945  * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or
946  *                   ckmc_generate_new_params(). New param with @a name and @a value will be set
947  *                   here
948  * @param[in] name Name of parameter to set. Existing parameter will be overwritten. Passing invalid
949  *                 parameter name will result in an error
950  * @param[in] value Value of the parameter in form of a integer
951  * @return #CKMC_ERROR_NONE on success,
952  *         otherwise a negative error value
953  * @retval #CKMC_ERROR_NONE Successful
954  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
955  * @see ckmc_param_list_new()
956  * @see ckmc_param_list_set_buffer()
957  * @see ckmc_param_list_get_integer()
958  * @see ckmc_param_list_get_buffer()
959  * @see ckmc_param_list_free()
960  * @see ckmc_generate_new_params()
961  * @see #ckmc_param_list_h
962  * @see #ckmc_param_name_e
963  * @see #ckmc_algo_type_e
964  */
965 int ckmc_param_list_set_integer(ckmc_param_list_h params, ckmc_param_name_e name, uint64_t value);
966
967
968 /**
969  * @brief Sets buffer parameter to the list.
970  * @since_tizen 3.0
971  * @remarks Caller is responsible for #ckmc_param_list_h creation.
972  * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or
973  *                   ckmc_generate_new_params(). New param with @a name and @a buffer will be set
974  *                   here
975  * @param[in] name Name of parameter to set. Existing parameter will be overwritten. Passing invalid
976  *                 parameter name will result in an error
977  * @param[in] buffer Value of the parameter in form of a buffer. Caller is responsible for creating
978  *                   and freeing the buffer
979  * @return #CKMC_ERROR_NONE on success,
980  *         otherwise a negative error value
981  * @retval #CKMC_ERROR_NONE Successful
982  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
983  * @see ckmc_param_list_new()
984  * @see ckmc_param_list_set_integer()
985  * @see ckmc_param_list_get_integer()
986  * @see ckmc_param_list_get_buffer()
987  * @see ckmc_param_list_free()
988  * @see ckmc_generate_new_params()
989  * @see #ckmc_param_list_h
990  * @see #ckmc_param_name_e
991  * @see #ckmc_algo_type_e
992  */
993 int ckmc_param_list_set_buffer(ckmc_param_list_h params,
994                                ckmc_param_name_e name,
995                                const ckmc_raw_buffer_s *buffer);
996
997
998 /**
999  * @brief Gets integer parameter from the list.
1000  * @since_tizen 3.0
1001  * @remarks Caller is responsible for #ckmc_param_list_h creation.
1002  * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or
1003  *                   ckmc_generate_new_params() which contains param with @a name
1004  * @param[in] name Name of parameter to get
1005  * @param[out] pvalue Value of the parameter in form of a integer
1006  * @return #CKMC_ERROR_NONE on success,
1007  *         otherwise a negative error value
1008  * @retval #CKMC_ERROR_NONE Successful
1009  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
1010  * @see ckmc_param_list_new()
1011  * @see ckmc_param_list_set_integer()
1012  * @see ckmc_param_list_set_buffer()
1013  * @see ckmc_param_list_get_buffer()
1014  * @see ckmc_param_list_free()
1015  * @see ckmc_generate_new_params()
1016  * @see #ckmc_param_list_h
1017  * @see #ckmc_param_name_e
1018  * @see #ckmc_algo_type_e
1019  */
1020 int ckmc_param_list_get_integer(ckmc_param_list_h params, ckmc_param_name_e name, uint64_t *pvalue);
1021
1022
1023 /**
1024  * @brief Gets buffer parameter from the list.
1025  * @since_tizen 3.0
1026  * @remarks Caller is responsible for #ckmc_param_list_h creation.
1027  * @remarks You must destroy the @a ppbuffer using ckmc_buffer_free()
1028  * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or
1029  *                   ckmc_generate_new_params() which contains param with @a name
1030  * @param[in] name Name of parameter to get
1031  * @param[out] ppbuffer Value of the parameter in form of a buffer
1032  * @return #CKMC_ERROR_NONE on success,
1033  *         otherwise a negative error value
1034  * @retval #CKMC_ERROR_NONE Successful
1035  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
1036  * @see ckmc_param_list_new()
1037  * @see ckmc_param_list_set_integer()
1038  * @see ckmc_param_list_set_buffer()
1039  * @see ckmc_param_list_get_integer()
1040  * @see ckmc_param_list_free()
1041  * @see ckmc_generate_new_params()
1042  * @see ckmc_buffer_free()
1043  * @see #ckmc_param_list_h
1044  * @see #ckmc_param_name_e
1045  * @see #ckmc_algo_type_e
1046  */
1047 int ckmc_param_list_get_buffer(ckmc_param_list_h params,
1048                                ckmc_param_name_e name,
1049                                ckmc_raw_buffer_s **ppbuffer);
1050
1051
1052 /**
1053  * @brief Frees previously allocated list of algorithm params.
1054  * @since_tizen 3.0
1055  * @param[in] params First element of the list to be freed
1056  * @see ckmc_param_list_new()
1057  * @see ckmc_param_list_set_integer()
1058  * @see ckmc_param_list_set_buffer()
1059  * @see ckmc_param_list_get_integer()
1060  * @see ckmc_param_list_get_buffer()
1061  * @see ckmc_generate_new_params()
1062  * @see #ckmc_param_list_h
1063  * @see #ckmc_param_name_e
1064  * @see #ckmc_algo_type_e
1065  */
1066 void ckmc_param_list_free(ckmc_param_list_h params);
1067
1068
1069 /**
1070  * @brief Generates algorithm parameters for a given algorithm type and set them to the list.
1071  * @since_tizen 3.0
1072  * @remarks Caller is responsible for #ckmc_param_list_h destruction.
1073  * @remarks Algorithm parameters are set to default values. Optional fields are left empty.
1074  *          Initialization vectors are left empty (they have to be set manually).
1075  *          Caller is responsible for freeing the list with ckmc_param_list_free().
1076  * @remarks If the function returns error, provided param list may contain some of default
1077  *          parameters.
1078  * @param[in] type Type of the algorithm
1079  * @param[out] pparams Newly generated handle of param list which should be freed by caller after
1080  *                     use
1081  * @return #CKMC_ERROR_NONE on success,
1082  *         otherwise a negative error value
1083  * @retval #CKMC_ERROR_NONE Successful
1084  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
1085  * @see ckmc_param_list_new()
1086  * @see ckmc_param_list_set_integer()
1087  * @see ckmc_param_list_set_buffer()
1088  * @see ckmc_param_list_get_integer()
1089  * @see ckmc_param_list_get_buffer()
1090  * @see ckmc_param_list_free()
1091  * @see #ckmc_param_list_h
1092  * @see #ckmc_param_name_e
1093  * @see #ckmc_algo_type_e
1094  */
1095 int ckmc_generate_new_params(ckmc_algo_type_e type, ckmc_param_list_h *pparams);
1096
1097 /**
1098  * @brief Retrieves maximum data chunk size in bytes that can be passed to given backend. This is
1099  *        the maximum size of data passed as encryption/decryption input, AAD or IV.
1100  *
1101  * @since_tizen 6.0
1102  *
1103  * @param[in] info Backend info handle
1104  * @param[out] size Maximum chunk size. Equal to 0 if there's no backend specific limitation beside
1105  *             available memory
1106  *
1107  * @return @c 0 on success, otherwise a negative error value
1108  * @retval #CKMC_ERROR_NONE Successful
1109  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid (@a info is invalid,
1110  *                                       @a size = NULL)
1111  *
1112  * @see #ckmc_backend_info_h
1113  * @see ckmc_get_backend_info()
1114  */
1115 int ckmc_backend_get_max_chunk_size(const ckmc_backend_info_h info, size_t* size);
1116
1117 /**
1118  * @brief Destroys the backend information handle and releases all its resources.
1119  *
1120  * @since_tizen 6.0
1121  *
1122  * @param[in] info Backend information handle created with ckmc_get_backend_info()
1123  *
1124  * @see #ckmc_backend_info_h
1125  * @see ckmc_get_backend_info()
1126  * @see ckmc_backend_get_max_chunk_size()
1127  */
1128 void ckmc_backend_info_free(ckmc_backend_info_h info);
1129
1130
1131 /**
1132  * @}
1133  */
1134
1135
1136 #ifdef __cplusplus
1137 }
1138 #endif
1139
1140
1141 #endif /* __TIZEN_CORE_CKMC_TYPE_H__ */