72757761e4185c061d8a1a958bf2fdc68997fa4b
[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                        (@see ckmc_backend_get_max_chunk_size()). Recommended length is 12B
424                        (mandatory)
425                        - #CKMC_PARAM_ED_TAG_LEN = GCM tag length in bits. One of
426                        {32, 64, 96, 104, 112, 120, 128} (optional, if not present, the
427                        length 128 is used; since Tizen 5.0, if TrustZone backend is used,
428                        32 and 64 lengths are not supported)
429                        - #CKMC_PARAM_ED_AAD = additional authentication data. Note that the backend
430                        may impose limit on the maximum size (@see ckmc_backend_get_max_chunk_size())
431                        (optional) */
432
433         CKMC_ALGO_AES_CFB, /**< AES-CFB algorithm
434                        Supported parameters:
435                        - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_AES_CFB (mandatory),
436                        - #CKMC_PARAM_ED_IV = 16-byte initialization vector (mandatory) */
437
438         CKMC_ALGO_RSA_OAEP, /**< RSA-OAEP algorithm
439                         Supported parameters:
440                         - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_RSA_OAEP (mandatory),
441                         - #CKMC_PARAM_ED_LABEL = label to be associated with the message
442                         (optional, not supported at the moment) */
443
444         CKMC_ALGO_KBKDF, /**< Key based key derivation algorithm
445                      Supported parameters:
446                      - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_KBKDF (mandatory),
447                      - #CKMC_PARAM_KDF_PRF = pseudo-random function (see #ckmc_kdf_prf_e)
448                      (mandatory),
449                      - #CKMC_PARAM_KBKDF_MODE = KDF mode (see #ckmc_kbkdf_mode_e) (mandatory),
450                      - #CKMC_PARAM_KBKDF_LABEL = the purpose for the derived key (optional),
451                      - #CKMC_PARAM_KBKDF_CONTEXT = information related to the derived key
452                      (optional),
453                      - #CKMC_PARAM_KDF_LEN = length of the derived key (mandatory)
454                      - #CKMC_PARAM_KBKDF_FIXED_INPUT = replacement for context and label (optional),
455                      - #CKMC_PARAM_KBKDF_COUNTER_LOCATION = counter location
456                      (see #ckmc_kbkdf_counter_location_e) (mandatory),
457                      - #CKMC_PARAM_KBKDF_RLEN = length of the counter representation (optional),
458                      - #CKMC_PARAM_KBKDF_LLEN = length of the length suffix representation
459                      (optional),
460                      - #CKMC_PARAM_KBKDF_NO_SEPARATOR = existence of zero separator (optional) */
461
462         CKMC_ALGO_ECDH, /**< ECDH shared secret key agreement protocol
463                      Supported parameters (all are required):
464                      - #CKMC_PARAM_ALGO_TYPE = #CKMC_ALGO_ECDH,
465                      - #CKMC_PARAM_ECDH_PUBKEY = peer's public key (see #ckmc_key_s) */
466 } ckmc_algo_type_e;
467
468 /**
469  * @brief Enumeration for backend identifiers.
470  * @since_tizen 6.0
471  * @see ckmc_get_backend_info()
472  * @see ckmc_alias_info_get_backend()
473  */
474 typedef enum __ckmc_backend_id {
475         CKMC_BACKEND_SW = 0, /**< Software backend */
476         CKMC_BACKEND_TZ      /**< TrustZone backend */
477 } ckmc_backend_id_e;
478
479 /**
480  * @brief Backend information handle.
481  * @since_tizen 6.0
482  * @see ckmc_alias_info_get_backend()
483  * @see ckmc_get_backend_info()
484  * @see ckmc_backend_get_max_chunk_size()
485  * @see ckmc_backend_info_free()
486  */
487 typedef struct __ckmc_backend_info_s *ckmc_backend_info_h;
488
489 /**
490  * @brief Encryption/decryption context handle.
491  * @since_tizen 6.0
492  * @see ckmc_cipher_initialize()
493  * @see ckmc_cipher_update()
494  * @see ckmc_cipher_finalize()
495  * @see ckmc_cipher_free()
496  */
497 typedef struct __ckmc_cipher_ctx *ckmc_cipher_ctx_h;
498
499 /**
500  * @brief Gets the alias from #ckmc_alias_info_s structure.
501  * @since_tizen 5.5
502  * @remarks The @a alias should not be released.
503  *          The @a alias can be used until #ckmc_alias_info_s is released.
504  * @param[in] info The pointer to the #ckmc_alias_info_s structure
505  * @param[out] alias The pointer to the alias
506  * @return #CKMC_ERROR_NONE on success,
507  *         otherwise a negative error value
508  * @retval #CKMC_ERROR_NONE Successful
509  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
510  * @see #ckmc_alias_info_s
511  */
512 int ckmc_alias_info_get_alias(const ckmc_alias_info_s* info, char** alias);
513
514 /**
515  * @brief Gets the password protection status from #ckmc_alias_info_s structure.
516  * @since_tizen 5.5
517  * @param[in] info The pointer to the #ckmc_alias_info_s structure
518  * @param[out] is_password_protected The pointer to the password protection flag
519  * @return #CKMC_ERROR_NONE on success,
520  *         otherwise a negative error value
521  * @retval #CKMC_ERROR_NONE Successful
522  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
523  * @see #ckmc_alias_info_s
524  */
525 int ckmc_alias_info_is_password_protected(const ckmc_alias_info_s* info,
526                                           bool* is_password_protected);
527
528 /**
529  * @brief Gets the backend identifier from #ckmc_alias_info_s structure.
530  * @since_tizen 6.0
531  * @param[in] info The pointer to the #ckmc_alias_info_s structure
532  * @param[out] backend The pointer to the backend identifier
533  * @return #CKMC_ERROR_NONE on success, otherwise a negative error value
534  * @retval #CKMC_ERROR_NONE Successful
535  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
536  * @see #ckmc_backend_id_e
537  * @see #ckmc_alias_info_s
538  * @see ckmc_get_backend_info()
539  * @see ckmc_backend_info_free()
540  * @see ckmc_backend_get_max_chunk_size()
541  */
542 int ckmc_alias_info_get_backend(const ckmc_alias_info_s* info, ckmc_backend_id_e* backend);
543
544 /**
545  * @brief Destroys the #ckmc_alias_info_list_s handle and releases resources of
546  *                 #ckmc_alias_info_list_s from the provided first handle cascadingly.
547  * @since_tizen 5.5
548  * @param[in] first The first #ckmc_alias_info_list_s handle to destroy
549  * @see #ckmc_alias_info_list_s
550  */
551 void ckmc_alias_info_list_all_free(ckmc_alias_info_list_s *first);
552
553 /**
554  * @brief Creates a new full alias which is a concatenation of @a owner_id and @a alias.
555  * @since_tizen 3.0
556  * @remarks @a full_alias should be freed with free() after use.
557  * @remarks Returns #CKMC_ERROR_INVALID_PARAMETER if any of parameter is NULL.
558  * @remarks Returns #CKMC_ERROR_INVALID_PARAMETER if @a owner_id is empty.
559  * @param[in] owner_id Data owner's id. This should be package id if data owner is
560  *                     application. If you want to access data stored by system
561  *                     services, it should be #ckmc_owner_id_system
562  * @param[in] alias Data alias
563  * @param[out] full_alias The newly created alias which is a concatenation of
564  *                        @a owner_id, #ckmc_owner_id_separator and @a alias.
565  *                        Destroy by free() after use
566  * @return #CKMC_ERROR_NONE on success,
567  *         otherwise a negative error value
568  * @retval #CKMC_ERROR_NONE Successful
569  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
570  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
571  * @see #ckmc_owner_id_separator
572  * @see #ckmc_owner_id_system
573  */
574 int ckmc_alias_new(const char *owner_id, const char *alias, char **full_alias);
575
576
577 /**
578  * @brief Creates a new #ckmc_key_s handle and returns it.
579  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
580  * @remarks You must destroy the newly created #ckmc_key_s by calling ckmc_key_free() if it is no
581  *          longer needed.
582  * @param[in] raw_key The byte array of key. The @a raw_key may be encrypted with password.
583  * @param[in] key_size The byte size of @a raw_key
584  * @param[in] key_type The type of @a raw_key
585  * @param[in] password The byte array used to decrypt @a raw_key inside key manager. If @a raw_key
586  *                     is not encrypted, @a password can be NULL
587  * @param[out] ppkey The pointer to a newly created #ckmc_key_s handle
588  * @return #CKMC_ERROR_NONE on success,
589  *         otherwise a negative error value
590  * @retval #CKMC_ERROR_NONE Successful
591  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
592  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
593  * @see ckmc_key_free()
594  * @see #ckmc_key_s
595  */
596 int ckmc_key_new(unsigned char *raw_key,
597                  size_t key_size,
598                  ckmc_key_type_e key_type,
599                  char *password,
600                  ckmc_key_s **ppkey);
601
602
603 /**
604  * @brief Destroys the #ckmc_key_s handle and releases all its resources.
605  * @since_tizen 2.3
606  * @param[in] key The #ckmc_key_s handle to destroy
607  */
608 void ckmc_key_free(ckmc_key_s *key);
609
610
611 /**
612  * @brief Creates a new #ckmc_raw_buffer_s handle and returns it.
613  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
614  * @remarks You must destroy the newly created #ckmc_raw_buffer_s by calling ckmc_buffer_free() if
615  *          it is no longer needed.
616  * @param[in] data The byte array of buffer
617  * @param[in] size The byte size of buffer
618  * @param[out] ppbuffer The pointer to a newly created #ckmc_raw_buffer_s handle
619  * @return #CKMC_ERROR_NONE on success,
620  *         otherwise a negative error value
621  * @retval #CKMC_ERROR_NONE Successful
622  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
623  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
624  * @see ckmc_buffer_free()
625  * @see #ckmc_raw_buffer_s
626  */
627 int ckmc_buffer_new(unsigned char *data, size_t size, ckmc_raw_buffer_s **ppbuffer);
628
629
630 /**
631  * @brief Destroys the #ckmc_raw_buffer_s handle and releases all its resources.
632  * @since_tizen 2.3
633  * @param[in] buffer The #ckmc_raw_buffer_s structure to destroy
634  */
635 void ckmc_buffer_free(ckmc_raw_buffer_s *buffer);
636
637
638 /**
639  * @brief Creates a new #ckmc_cert_s handle and returns it.
640  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
641  * @remarks You must destroy the newly created #ckmc_cert_s by calling ckmc_cert_free() if it is no
642  *          longer needed.
643  * @param[in] raw_cert The byte array of certificate
644  * @param[in] cert_size The byte size of raw_cert
645  * @param[in] data_format The encoding format of raw_cert
646  * @param[out] ppcert The pointer to a newly created #ckmc_cert_s handle
647  * @return #CKMC_ERROR_NONE on success,
648  *         otherwise a negative error value
649  * @retval #CKMC_ERROR_NONE Successful
650  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
651  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
652  * @see ckmc_cert_free()
653  * @see ckmc_load_cert_from_file()
654  * @see #ckmc_cert_s
655  */
656 int ckmc_cert_new(unsigned char *raw_cert,
657                   size_t cert_size,
658                   ckmc_data_format_e data_format,
659                   ckmc_cert_s **ppcert);
660
661
662 /**
663  * @brief Destroys the #ckmc_cert_s handle and releases all its resources.
664  * @since_tizen 2.3
665  * @param[in] cert The #ckmc_cert_s handle to destroy
666  * @see ckmc_load_cert_from_file()
667  */
668 void ckmc_cert_free(ckmc_cert_s *cert);
669
670
671 /**
672  * @brief Creates a new #ckmc_cert_s handle from a given file and returns it.
673  * @since_tizen 2.3
674  * @remarks You must destroy the newly created #ckmc_cert_s by calling ckmc_cert_free() if it is no
675  *          longer needed.
676  * @param[in] file_path The path of certificate file to be loaded. Only DER or PEM encoded
677  *                      certificate file is supported
678  * @param[out] cert The pointer of newly created #ckmc_cert_s handle
679  * @return #CKMC_ERROR_NONE on success,
680  *         otherwise a negative error value
681  * @retval #CKMC_ERROR_NONE Successful
682  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
683  * @retval #CKMC_ERROR_INVALID_FORMAT Invalid certificate file format
684  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
685  * @see ckmc_cert_free()
686  * @see #ckmc_cert_s
687  */
688 int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert);
689
690
691 /**
692  * @brief Creates a new #ckmc_pkcs12_s handle and returns it.
693  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
694  * @remarks You must destroy the newly created #ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it is
695  *          no longer needed.
696  * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly
697  *          returned @a pkcs12_bundle.
698  * @param[in] private_key #ckmc_key_s handle to the private key (optional)
699  * @param[in] cert #ckmc_cert_s handle to the certificate (optional)
700  * @param[in] ca_cert_list #ckmc_cert_list_s list of chain certificate handles (optional)
701  * @param[out] pkcs12_bundle The pointer to a newly created #ckmc_pkcs12_s handle
702  * @return #CKMC_ERROR_NONE on success,
703  *         otherwise a negative error value
704  * @retval #CKMC_ERROR_NONE Successful
705  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or @a private_key, @a cert and
706  *                                       @a ca_cert_list all are NULL
707  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
708  * @see ckmc_pkcs12_free()
709  * @see ckmc_pkcs12_load()
710  * @see #ckmc_key_s
711  * @see #ckmc_cert_s
712  * @see #ckmc_cert_list_s
713  * @see #ckmc_pkcs12_s
714  */
715 int ckmc_pkcs12_new(ckmc_key_s *private_key,
716                     ckmc_cert_s *cert,
717                     ckmc_cert_list_s *ca_cert_list,
718                     ckmc_pkcs12_s **pkcs12_bundle);
719
720
721 /**
722  * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif
723  *             [Use ckmc_pkcs12_load() instead]
724  * @brief Creates a new #ckmc_key_s (@a private_key), #ckmc_cert_s (@a cert),
725  *        and #ckmc_cert_list_s (@a ca_cert_list) handle from a given PKCS#12 file and returns them.
726  * @since_tizen 2.3
727  * @remarks You must destroy the newly created @a private_key, @a cert and @a ca_cert_list
728             by calling ckmc_key_free(), ckmc_cert_free(), and ckmc_cert_list_all_free() if they are
729             no longer needed.
730  * @param[in] file_path The path of PKCS12 file to be loaded
731  * @param[in] passphrase The passphrase used to decrypt the PCKS12 file. If PKCS12 file is not
732  *                       encrypted, passphrase can be NULL
733  * @param[out] private_key The pointer of newly created #ckmc_key_s handle for a private key
734  * @param[out] cert The pointer of newly created #ckmc_cert_s handle for a certificate. It is NULL
735  *                  if the PKCS12 file does not contain a certificate
736  * @param[out] ca_cert_list The pointer of newly created #ckmc_cert_list_s handle for CA
737  *                          certificates. It is NULL if the PKCS12 file does not contain
738  *                          CA certificates
739  * @return #CKMC_ERROR_NONE on success,
740  *         otherwise a negative error value
741  * @retval #CKMC_ERROR_NONE Successful
742  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
743  * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
744  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
745  * @see ckmc_pkcs12_new()
746  * @see ckmc_pkcs12_load()
747  * @see ckmc_key_free()
748  * @see ckmc_cert_free()
749  * @see ckmc_cert_list_all_free()
750  * @see #ckmc_key_s
751  * @see #ckmc_cert_s
752  * @see #ckmc_cert_list_s
753  */
754 int ckmc_load_from_pkcs12_file(const char *file_path,
755                                const char *passphrase,
756                                ckmc_key_s **private_key,
757                                ckmc_cert_s **cert,
758                                ckmc_cert_list_s **ca_cert_list) TIZEN_DEPRECATED_API;
759
760
761 /**
762  * @brief Creates a new #ckmc_pkcs12_s handle from a given PKCS#12 file and returns it.
763  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
764  * @remarks You must destroy the newly created #ckmc_pkcs12_s by calling ckmc_pkcs12_free() if they
765  *          are no longer needed.
766  * @param[in] file_path The path of PKCS12 file to be loaded
767  * @param[in] passphrase The passphrase used to decrypt the PCKS12 file. If PKCS12 file is not
768  *                       encrypted, passphrase can be NULL
769  * @param[out] pkcs12_bundle The pointer of newly created #ckmc_cert_list_s handle for
770  *                           CA certificates. It is NULL if the PKCS12 file does not contain
771  *                           CA certificates
772  * @return #CKMC_ERROR_NONE on success,
773  *         otherwise a negative error value
774  * @retval #CKMC_ERROR_NONE Successful
775  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
776  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
777  * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
778  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
779  * @see ckmc_pkcs12_free()
780  * @see #ckmc_pkcs12_s
781  */
782 int ckmc_pkcs12_load(const char *file_path, const char *passphrase, ckmc_pkcs12_s **pkcs12_bundle);
783
784
785 /**
786  * @brief Destroys the #ckmc_pkcs12_s handle and releases all its resources.
787  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
788  * @param[in] pkcs12 The #ckmc_pkcs12_s handle to destroy
789  * @see ckmc_pkcs12_new()
790  * @see ckmc_pkcs12_load()
791  */
792 void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12);
793
794
795 /**
796  * @brief Creates a new #ckmc_alias_list_s handle and returns it. The alias pointer in the returned
797  *        #ckmc_alias_list_s handle points to the provided characters and next is NULL.
798  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
799  * @remarks You must destroy the newly created #ckmc_alias_list_s by calling ckmc_alias_list_free()
800  *          or ckmc_alias_list_all_free() if it is no longer needed.
801  * @param[in] alias The first item to be set in the newly created #ckmc_alias_list_s
802  * @param[out] ppalias_list The pointer to a newly created #ckmc_alias_list_s handle
803  * @return #CKMC_ERROR_NONE on success,
804  *         otherwise a negative error value
805  * @retval #CKMC_ERROR_NONE Successful
806  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
807  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
808  * @see ckmc_alias_list_all_free()
809  * @see #ckmc_alias_list_s
810  */
811 int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list);
812
813
814 /**
815  * @brief Creates a new #ckmc_alias_list_s handle, adds it to a previous #ckmc_alias_list_s and
816  *        returns it. The alias pointer in the returned #ckmc_alias_list_s handle points to the
817  *        provided characters and next is NULL.
818  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
819  * @remarks You must destroy the newly created @a pplast using ckmc_alias_list_free()
820  * @param[in] previous The last #ckmc_alias_list_s handle to which a newly created
821  *                     #ckmc_alias_list_s is added
822  * @param[in] alias The item to be set in the newly created #ckmc_alias_list_s
823  * @param[out] pplast The pointer to a newly created and added #ckmc_alias_list_s handle
824  * @return #CKMC_ERROR_NONE on success,
825  *         otherwise a negative error value
826  * @retval #CKMC_ERROR_NONE Successful
827  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
828  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
829  * @see ckmc_alias_list_all_free()
830  * @see #ckmc_alias_list_s
831  */
832 int ckmc_alias_list_add(ckmc_alias_list_s *previous, char *alias, ckmc_alias_list_s **pplast);
833
834
835 /**
836  * @brief Destroys the #ckmc_alias_list_s handle and releases resources of #ckmc_alias_list_s from
837  *        the provided first handle cascadingly.
838  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
839  * @remarks It does not destroy an alias itself in #ckmc_alias_list_s.
840  * @param[in] first The first #ckmc_alias_list_s handle to destroy
841  * @see ckmc_alias_list_all_free()
842  * @see #ckmc_alias_list_s
843  */
844 void ckmc_alias_list_free(ckmc_alias_list_s *first);
845
846
847 /**
848  * @brief Destroys the #ckmc_alias_list_s handle and releases all its resources from the provided
849  *        first handle cascadingly.
850  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
851  * @remarks It also destroys the alias in #ckmc_alias_list_s.
852  * @param[in] first The first #ckmc_alias_list_s handle to destroy
853  * @see #ckmc_alias_list_s
854  */
855 void ckmc_alias_list_all_free(ckmc_alias_list_s *first);
856
857
858 /**
859  * @brief Creates a new #ckmc_cert_list_s handle and returns it. The cert pointer in the returned
860  *        #ckmc_cert_list_s handle points to the provided #ckmc_cert_s and next is NULL.
861  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
862  * @remarks You must destroy the newly created #ckmc_cert_list_s by calling ckmc_cert_list_free() or
863  *          ckmc_cert_list_all_free() if it is no longer needed.
864  * @param[in] cert The first item to be set in the newly created #ckmc_cert_list_s
865  * @param[out] ppalias_list The pointer to a newly created #ckmc_alias_list_s handle
866  * @return #CKMC_ERROR_NONE on success,
867  *         otherwise a negative error value
868  * @retval #CKMC_ERROR_NONE Successful
869  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
870  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
871  * @see ckmc_cert_list_all_free()
872  * @see #ckmc_cert_list_s
873  */
874 int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list);
875
876
877 /**
878  * @brief Creates a new #ckmc_cert_list_s handle, adds it to a previous #ckmc_cert_list_s and
879  *        returns it. The cert pointer in the returned #ckmc_alias_list_s handle points to the
880  *        provided #ckmc_cert_s and next is NULL.
881  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
882  * @remarks You must destroy the newly created @a pplast using ckmc_cert_list_free()
883  * @param[in] previous The last #ckmc_cert_list_s handle to which a newly created #ckmc_cert_list_s
884  *                     is added
885  * @param[in] cert The item to be set in the newly created #ckmc_cert_list_s
886  * @param[out] pplast The pointer to a newly created and added #ckmc_alias_list_s handle
887  * @return #CKMC_ERROR_NONE on success,
888  *         otherwise a negative error value
889  * @retval #CKMC_ERROR_NONE Successful
890  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
891  * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
892  * @see ckmc_cert_list_all_free()
893  * @see #ckmc_cert_list_s
894  */
895 int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast);
896
897
898 /**
899  * @brief Destroys the #ckmc_cert_list_s handle and releases resources of #ckmc_cert_list_s from the
900  *        provided first handle cascadingly.
901  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
902  * @remarks It does not destroy #ckmc_cert_s itself in #ckmc_cert_list_s.
903  * @param[in] first The first #ckmc_cert_list_s handle to destroy
904  * @see ckmc_cert_list_all_free()
905  * @see #ckmc_cert_list_s
906  */
907 void ckmc_cert_list_free(ckmc_cert_list_s *first);
908
909
910 /**
911  * @brief Destroys the #ckmc_cert_list_s handle and releases all its resources from the provided
912  *        first handle cascadingly.
913  * @since_tizen 2.3
914  * @remarks It also destroys #ckmc_cert_s in #ckmc_cert_list_s.
915  * @param[in] first The first #ckmc_cert_list_s handle to destroy
916  * @see #ckmc_cert_list_s
917  */
918 void ckmc_cert_list_all_free(ckmc_cert_list_s *first);
919
920
921 /**
922  * @brief Creates new parameter list.
923  * @since_tizen 3.0
924  * @remarks Caller is responsible for freeing it with ckmc_param_list_free().
925  * @param[in] pparams Double pointer to the handle of param list to which the newly created
926  *                    algorithm param list will be assigned
927  * @return #CKMC_ERROR_NONE on success,
928  *         otherwise a negative error value
929  * @retval #CKMC_ERROR_NONE Successful
930  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
931  * @see ckmc_param_list_set_integer()
932  * @see ckmc_param_list_set_buffer()
933  * @see ckmc_param_list_free()
934  * @see ckmc_generate_new_params()
935  * @see #ckmc_param_list_h
936  * @see #ckmc_param_name_e
937  * @see #ckmc_algo_type_e
938  */
939 int ckmc_param_list_new(ckmc_param_list_h *pparams);
940
941
942 /**
943  * @brief Sets integer parameter to the list.
944  * @since_tizen 3.0
945  * @remarks Caller is responsible for #ckmc_param_list_h creation.
946  * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or
947  *                   ckmc_generate_new_params(). New param with @a name and @a value will be set
948  *                   here
949  * @param[in] name Name of parameter to set. Existing parameter will be overwritten. Passing invalid
950  *                 parameter name will result in an error
951  * @param[in] value Value of the parameter in form of a integer
952  * @return #CKMC_ERROR_NONE on success,
953  *         otherwise a negative error value
954  * @retval #CKMC_ERROR_NONE Successful
955  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
956  * @see ckmc_param_list_new()
957  * @see ckmc_param_list_set_buffer()
958  * @see ckmc_param_list_get_integer()
959  * @see ckmc_param_list_get_buffer()
960  * @see ckmc_param_list_free()
961  * @see ckmc_generate_new_params()
962  * @see #ckmc_param_list_h
963  * @see #ckmc_param_name_e
964  * @see #ckmc_algo_type_e
965  */
966 int ckmc_param_list_set_integer(ckmc_param_list_h params, ckmc_param_name_e name, uint64_t value);
967
968
969 /**
970  * @brief Sets buffer parameter to the list.
971  * @since_tizen 3.0
972  * @remarks Caller is responsible for #ckmc_param_list_h creation.
973  * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or
974  *                   ckmc_generate_new_params(). New param with @a name and @a buffer will be set
975  *                   here
976  * @param[in] name Name of parameter to set. Existing parameter will be overwritten. Passing invalid
977  *                 parameter name will result in an error
978  * @param[in] buffer Value of the parameter in form of a buffer. Caller is responsible for creating
979  *                   and freeing the buffer
980  * @return #CKMC_ERROR_NONE on success,
981  *         otherwise a negative error value
982  * @retval #CKMC_ERROR_NONE Successful
983  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
984  * @see ckmc_param_list_new()
985  * @see ckmc_param_list_set_integer()
986  * @see ckmc_param_list_get_integer()
987  * @see ckmc_param_list_get_buffer()
988  * @see ckmc_param_list_free()
989  * @see ckmc_generate_new_params()
990  * @see #ckmc_param_list_h
991  * @see #ckmc_param_name_e
992  * @see #ckmc_algo_type_e
993  */
994 int ckmc_param_list_set_buffer(ckmc_param_list_h params,
995                                ckmc_param_name_e name,
996                                const ckmc_raw_buffer_s *buffer);
997
998
999 /**
1000  * @brief Gets integer parameter from the list.
1001  * @since_tizen 3.0
1002  * @remarks Caller is responsible for #ckmc_param_list_h creation.
1003  * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or
1004  *                   ckmc_generate_new_params() which contains param with @a name
1005  * @param[in] name Name of parameter to get
1006  * @param[out] pvalue Value of the parameter in form of a integer
1007  * @return #CKMC_ERROR_NONE on success,
1008  *         otherwise a negative error value
1009  * @retval #CKMC_ERROR_NONE Successful
1010  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
1011  * @see ckmc_param_list_new()
1012  * @see ckmc_param_list_set_integer()
1013  * @see ckmc_param_list_set_buffer()
1014  * @see ckmc_param_list_get_buffer()
1015  * @see ckmc_param_list_free()
1016  * @see ckmc_generate_new_params()
1017  * @see #ckmc_param_list_h
1018  * @see #ckmc_param_name_e
1019  * @see #ckmc_algo_type_e
1020  */
1021 int ckmc_param_list_get_integer(ckmc_param_list_h params, ckmc_param_name_e name, uint64_t *pvalue);
1022
1023
1024 /**
1025  * @brief Gets buffer parameter from the list.
1026  * @since_tizen 3.0
1027  * @remarks Caller is responsible for #ckmc_param_list_h creation.
1028  * @remarks You must destroy the @a ppbuffer using ckmc_buffer_free()
1029  * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or
1030  *                   ckmc_generate_new_params() which contains param with @a name
1031  * @param[in] name Name of parameter to get
1032  * @param[out] ppbuffer Value of the parameter in form of a buffer
1033  * @return #CKMC_ERROR_NONE on success,
1034  *         otherwise a negative error value
1035  * @retval #CKMC_ERROR_NONE Successful
1036  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
1037  * @see ckmc_param_list_new()
1038  * @see ckmc_param_list_set_integer()
1039  * @see ckmc_param_list_set_buffer()
1040  * @see ckmc_param_list_get_integer()
1041  * @see ckmc_param_list_free()
1042  * @see ckmc_generate_new_params()
1043  * @see ckmc_buffer_free()
1044  * @see #ckmc_param_list_h
1045  * @see #ckmc_param_name_e
1046  * @see #ckmc_algo_type_e
1047  */
1048 int ckmc_param_list_get_buffer(ckmc_param_list_h params,
1049                                ckmc_param_name_e name,
1050                                ckmc_raw_buffer_s **ppbuffer);
1051
1052
1053 /**
1054  * @brief Frees previously allocated list of algorithm params.
1055  * @since_tizen 3.0
1056  * @param[in] params First element of the list to be freed
1057  * @see ckmc_param_list_new()
1058  * @see ckmc_param_list_set_integer()
1059  * @see ckmc_param_list_set_buffer()
1060  * @see ckmc_param_list_get_integer()
1061  * @see ckmc_param_list_get_buffer()
1062  * @see ckmc_generate_new_params()
1063  * @see #ckmc_param_list_h
1064  * @see #ckmc_param_name_e
1065  * @see #ckmc_algo_type_e
1066  */
1067 void ckmc_param_list_free(ckmc_param_list_h params);
1068
1069
1070 /**
1071  * @brief Generates algorithm parameters for a given algorithm type and set them to the list.
1072  * @since_tizen 3.0
1073  * @remarks Caller is responsible for #ckmc_param_list_h destruction.
1074  * @remarks Algorithm parameters are set to default values. Optional fields are left empty.
1075  *          Initialization vectors are left empty (they have to be set manually).
1076  *          Caller is responsible for freeing the list with ckmc_param_list_free().
1077  * @remarks If the function returns error, provided param list may contain some of default
1078  *          parameters.
1079  * @param[in] type Type of the algorithm
1080  * @param[out] pparams Newly generated handle of param list which should be freed by caller after
1081  *                     use
1082  * @return #CKMC_ERROR_NONE on success,
1083  *         otherwise a negative error value
1084  * @retval #CKMC_ERROR_NONE Successful
1085  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
1086  * @see ckmc_param_list_new()
1087  * @see ckmc_param_list_set_integer()
1088  * @see ckmc_param_list_set_buffer()
1089  * @see ckmc_param_list_get_integer()
1090  * @see ckmc_param_list_get_buffer()
1091  * @see ckmc_param_list_free()
1092  * @see #ckmc_param_list_h
1093  * @see #ckmc_param_name_e
1094  * @see #ckmc_algo_type_e
1095  */
1096 int ckmc_generate_new_params(ckmc_algo_type_e type, ckmc_param_list_h *pparams);
1097
1098 /**
1099  * @brief Retrieves maximum data chunk size in bytes that can be passed to given backend. This is
1100  *        the maximum size of data passed as encryption/decryption input, AAD or IV.
1101  *
1102  * @since_tizen 6.0
1103  *
1104  * @param[in] info Backend info handle
1105  * @param[out] size Maximum chunk size. Equal to 0 if there's no backend specific limitation beside
1106  *             available memory
1107  *
1108  * @return @c 0 on success, otherwise a negative error value
1109  * @retval #CKMC_ERROR_NONE Successful
1110  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid (@a info is invalid,
1111  *                                       @a size = NULL)
1112  *
1113  * @see #ckmc_backend_info_h
1114  * @see ckmc_get_backend_info()
1115  */
1116 int ckmc_backend_get_max_chunk_size(const ckmc_backend_info_h info, size_t* size);
1117
1118 /**
1119  * @brief Destroys the backend information handle and releases all its resources.
1120  *
1121  * @since_tizen 6.0
1122  *
1123  * @param[in] info Backend information handle created with ckmc_get_backend_info()
1124  *
1125  * @see #ckmc_backend_info_h
1126  * @see ckmc_get_backend_info()
1127  * @see ckmc_backend_get_max_chunk_size()
1128  */
1129 void ckmc_backend_info_free(ckmc_backend_info_h info);
1130
1131
1132 /**
1133  * @}
1134  */
1135
1136
1137 #ifdef __cplusplus
1138 }
1139 #endif
1140
1141
1142 #endif /* __TIZEN_CORE_CKMC_TYPE_H__ */