Add system database - managed by service (uid<5000) users, accessible by priviledged...
[platform/core/security/key-manager.git] / src / include / ckmc / ckmc-type.h
1 /*
2  *  Copyright (c) 2000 - 2014 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 #ifndef __TIZEN_CORE_CKMC_TYPE_H
23 #define __TIZEN_CORE_CKMC_TYPE_H
24
25 #include <stddef.h>
26 #include <ckmc/ckmc-error.h>
27
28 #define KEY_MANAGER_CAPI __attribute__((visibility("default")))
29
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  * @addtogroup CAPI_KEY_MANAGER_TYPES_MODULE
37  * @{
38  */
39
40 /**
41  * alias can be provided as an alias alone, or together with label - in this
42  * case, separator " " (space bar) is used to separate label and alias.
43  * @see key-manager_doc.h
44  */
45 KEY_MANAGER_CAPI extern char const * const ckmc_label_name_separator;
46
47 /**
48  * shared database label - user may be given permission to access shared
49  * database items. In such case, the alias should contain shared database
50  * label.
51  * @see ckmc_label_name_separator
52  * @see key-manager_doc.h
53  */
54 KEY_MANAGER_CAPI extern char const * const ckmc_label_shared_owner;
55
56 /**
57  * @brief Enumeration for key types of key manager.
58  * @since_tizen 2.3
59  */
60 typedef enum __ckmc_key_type {
61     CKMC_KEY_NONE = 0,       /**< key type not specified */
62     CKMC_KEY_RSA_PUBLIC,     /**< RSA public key */
63     CKMC_KEY_RSA_PRIVATE,    /**< RSA private key */
64     CKMC_KEY_ECDSA_PUBLIC,   /**< ECDSA public key */
65     CKMC_KEY_ECDSA_PRIVATE,  /**< ECDSA private key */
66     CKMC_KEY_DSA_PUBLIC,     /**< DSA public key */
67     CKMC_KEY_DSA_PRIVATE,    /**< DSA private key */
68     CKMC_KEY_AES,            /**< AES key */
69 } ckmc_key_type_e;
70
71 /**
72  * @brief Enumeration for data format.
73  * @since_tizen 2.3
74  */
75 typedef enum __ckmc_data_format {
76     CKMC_FORM_DER_BASE64 = 0,  /**< DER format base64 encoded data */
77     CKMC_FORM_DER,             /**< DER encoded data */
78     CKMC_FORM_PEM              /**< PEM encoded data. It consists of the DER format base64 encoded
79                                     with additional header and footer lines. */
80 } ckmc_data_format_e;
81
82 /**
83  * @brief Enumeration for elliptic curve.
84  * @since_tizen 2.3
85  */
86 typedef enum __ckmc_ec_type {
87     CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended
88                                  elliptic curve domain  */
89     CKMC_EC_PRIME256V1,     /**< "SEC 2" recommended elliptic curve domain - secp256r1 */
90     CKMC_EC_SECP384R1       /**< NIST curve P-384 (covers "secp384r1", the elliptic curve domain
91                                  listed in See SEC 2 */
92 } ckmc_ec_type_e;
93
94 /**
95  * @brief Enumeration for hash algorithm.
96  * @since_tizen 2.3
97  */
98 typedef enum __ckmc_hash_algo {
99     CKMC_HASH_NONE = 0, /**< No Hash Algorithm  */
100     CKMC_HASH_SHA1,     /**< Hash Algorithm SHA1  */
101     CKMC_HASH_SHA256,   /**< Hash Algorithm SHA256  */
102     CKMC_HASH_SHA384,   /**< Hash Algorithm SHA384  */
103     CKMC_HASH_SHA512    /**< Hash Algorithm SHA512  */
104 } ckmc_hash_algo_e;
105
106 /**
107  * @brief Enumeration for RSA padding algorithm.
108  * @since_tizen 2.3
109  */
110 typedef enum __ckmc_rsa_padding_algo {
111     CKMC_NONE_PADDING = 0,  /**< No Padding */
112     CKMC_PKCS1_PADDING,     /**< PKCS#1 Padding */
113     CKMC_X931_PADDING       /**< X9.31 padding */
114 } ckmc_rsa_padding_algo_e;
115
116 /**
117  * @deprecated Deprecated since 2.4. [Use ckmc_permission_e() instead]
118  * @brief Enumeration for database access rights.
119  * @since_tizen 2.3
120  */
121 typedef enum __ckmc_access_right{
122     CKMC_AR_READ = 0,       /**< access right for read*/
123     CKMC_AR_READ_REMOVE     /**< access right for read and remove*/
124 } ckmc_access_right_e;
125
126 /**
127  * @brief Enumeration for permissions to access/modify alias.
128  * @since_tizen 2.4
129  */
130 typedef enum __ckmc_permission{
131     CKMC_PERMISSION_NONE        = 0x00, /**< clear permissions */
132     CKMC_PERMISSION_READ        = 0x01, /**< read allowed */
133     CKMC_PERMISSION_REMOVE      = 0x02  /**< remove allowed */
134 } ckmc_permission_e;
135
136 /**
137  * @brief the structure for binary buffer used in key manager CAPI.
138  * @since_tizen 2.3
139  */
140 typedef struct __ckmc_raw_buff {
141     unsigned char* data; /**< Byte array containing binary data */
142     size_t size;         /**< The size of the binary data */
143 } ckmc_raw_buffer_s;
144
145 /**
146  * @brief The structure for a policy for storing key/certificate/binary data.
147  * @since_tizen 2.3
148  */
149 typedef struct __ckmc_policy {
150     char* password;   /**< Byte array used to encrypt data inside CKM. If it is not null, the data
151                            (or key, or certificate) is stored encrypted with this password inside
152                            key manager */
153     bool extractable; /**< If true key may be extracted from storage */
154 } ckmc_policy_s;
155
156 /**
157  * @brief The structure for key used in key manager CAPI.
158  * @since_tizen 2.3
159  */
160 typedef struct __ckmc_key {
161     unsigned char* raw_key;   /**< Byte array of key. raw_key may be encrypted with password */
162     size_t key_size;          /**< The byte size of raw_key */
163     ckmc_key_type_e key_type; /**< The raw_key's type */
164     char* password;           /**< Byte array used to decrypt data raw_key inside key manager. */
165 } ckmc_key_s;
166
167 /**
168  * @brief The structure for certificate used in key manager CAPI.
169  * @since_tizen 2.3
170  */
171 typedef struct __ckmc_cert {
172     unsigned char* raw_cert;  /**< Byte array of certificate */
173     size_t cert_size;         /**< Byte size of raw_cert */
174     ckmc_data_format_e data_format; /**< Raw_cert's encoding format */
175 } ckmc_cert_s;
176
177 /**
178  * @brief The structure for linked list of alias.
179  * @since_tizen 2.3
180  */
181 typedef struct __ckmc_alias_list {
182     char *alias;  /**< The name of key, certificate or data stored in key manager */
183     struct __ckmc_alias_list *next; /**< The pointer pointing to the next ckmc_alias_list_s */
184 } ckmc_alias_list_s;
185
186 /**
187  * @brief The structure for linked list of ckmc_cert_s
188  * @since_tizen 2.3
189  */
190 typedef struct __ckmc_cert_list {
191     ckmc_cert_s *cert; /**< The pointer of ckmc_cert_s */
192     struct __ckmc_cert_list *next; /**< The pointer pointing to the next ckmc_cert_list_s */
193 } ckmc_cert_list_s;
194
195 /**
196  * @brief Enumeration for OCSP status.
197  * @since_tizen 2.4
198  */
199 typedef enum __ckmc_ocsp_status {
200     CKMC_OCSP_STATUS_GOOD = 0,          /**< OCSP status is good */
201     CKMC_OCSP_STATUS_REVOKED,           /**< certificate is revoked */
202     CKMC_OCSP_STATUS_UNKNOWN,           /**< unknown error */
203     CKMC_OCSP_ERROR_UNSUPPORTED,        /**< certificate does not provide OCSP extension */
204     CKMC_OCSP_ERROR_INVALID_URL,        /**< invalid URL in certificate OCSP extension */
205     CKMC_OCSP_ERROR_INVALID_RESPONSE,   /**< invalid response from OCSP server */
206     CKMC_OCSP_ERROR_REMOTE,             /**< OCSP remote server error */
207     CKMC_OCSP_ERROR_NET,                /**< network connection error */
208     CKMC_OCSP_ERROR_INTERNAL            /**< OpenSSL API error */
209 } ckmc_ocsp_status_e;
210
211 /**
212  * @brief The structure for PKCS12 used in key manager CAPI.
213  * @since_tizen 2.4
214  */
215 typedef struct __ckmc_pkcs12 {
216     ckmc_key_s  *priv_key;      /**< private key, may be null */
217     ckmc_cert_s *cert;          /**< certificate, may be null */
218     ckmc_cert_list_s *ca_chain; /**< chain certificates list, may be null */
219 } ckmc_pkcs12_s;
220
221
222 /**
223  * @internal
224  * @brief Creates a new @a ckmc_key_s handle and returns it.
225  *
226  * @since_tizen 2.3
227  *
228  * @remarks You must destroy the newly created @a ckmc_key_s by calling ckmc_key_free() if it is no
229  *          longer needed.
230  *
231  * @param[in] raw_key  The byte array of key \n
232  *                     @a raw_key may be encrypted with password.
233  * @param[in] key_size The byte size of @a raw_key
234  * @param[in] key_type The @a raw_key's type
235  * @param[in] password The byte array used to decrypt @a raw_key inside key manager \n
236  *                     If @a raw_key is not encrypted, @a password can be null.
237  * @param[out] ppkey   The pointer to a newly created @a ckmc_key_s handle
238  *
239  * @return @c 0 on success,
240  *         otherwise a negative error value
241  *
242  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
243  * @retval #CKMC_ERROR_OUT_OF_MEMORY     Not enough memory
244  *
245  * @see ckmc_key_free()
246  * @see #ckmc_key_s
247  */
248 int ckmc_key_new(unsigned char *raw_key,
249                  size_t key_size,
250                  ckmc_key_type_e key_type,
251                  char *password, ckmc_key_s **ppkey);
252
253 /**
254  * @brief Destroys the @a ckmc_key_s handle and releases all its resources.
255  *
256  * @since_tizen 2.3
257  *
258  * @param[in] key The @a ckmc_key_s handle to destroy
259  *
260  */
261 void ckmc_key_free(ckmc_key_s *key);
262
263 /**
264  * @internal
265  * @brief Creates a new @a ckmc_raw_buffer_s handle and returns it.
266  *
267  * @since_tizen 2.3
268  *
269  * @remarks You must destroy the newly created @a ckmc_raw_buffer_s by calling ckmc_buffer_free() if
270  *          it is no longer needed.
271  *
272  * @param[in]  data      The byte array of buffer
273  * @param[in]  size      The byte size of buffer
274  * @param[out] ppbuffer  The pointer to a newly created @a ckmc_buffer_s handle
275  *
276  * @return @c 0 on success,
277  *         otherwise a negative error value
278  *
279  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
280  * @retval #CKMC_ERROR_OUT_OF_MEMORY      Not enough memory
281  *
282  * @see ckmc_buffer_free()
283  * @see #ckmc_raw_buffer_s
284  */
285 int ckmc_buffer_new(unsigned char *data, size_t size,ckmc_raw_buffer_s **ppbuffer);
286
287 /**
288  * @brief Destroys the @a ckmc_raw_buffer_s handle and releases all its resources.
289  *
290  * @since_tizen 2.3
291  *
292  * @param[in] buffer The @a ckmc_raw_buffer_s handle to destroy
293  *
294  */
295 void ckmc_buffer_free(ckmc_raw_buffer_s *buffer);
296
297 /**
298  * @internal
299  * @brief Creates a new @a ckmc_cert_s handle and returns it.
300  *
301  * @since_tizen 2.3
302  *
303  * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
304  *          no longer needed.
305  *
306  * @param[in]  raw_cert     The byte array of certificate
307  * @param[in]  cert_size    The byte size of raw_cert
308  * @param[in]  data_format  The encoding format of raw_cert
309  * @param[out] ppcert       The pointer to a newly created @a ckmc_cert_s handle
310  *
311  * @return @c 0 on success,
312  *         otherwise a negative error value
313  *
314  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
315  * @retval #CKMC_ERROR_OUT_OF_MEMORY      Not enough memory
316  *
317  * @see ckmc_cert_free()
318  * @see ckmc_load_cert_from_file()
319  * @see #ckmc_cert_s
320  */
321 int ckmc_cert_new(unsigned char *raw_cert,
322                   size_t cert_size,
323                   ckmc_data_format_e data_format,
324                   ckmc_cert_s **ppcert);
325
326 /**
327  * @brief Destroys the @a ckmc_cert handle and releases all its resources.
328  *
329  * @since_tizen 2.3
330  *
331  * @param[in] cert The @a ckmc_cert_s handle to destroy
332  *
333  * @see ckmc_load_cert_from_file()
334  * @see ckmc_load_from_pkcs12_file
335  */
336 void ckmc_cert_free(ckmc_cert_s *cert);
337
338 /**
339  * @brief Creates a new @a ckmc_cert_s handle from a given file and returns it.
340  *
341  * @since_tizen 2.3
342  *
343  * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
344  *          no longer needed.
345  *
346  * @param[in]  file_path  The path of certificate file to be loaded \n
347  *                        The only DER or PEM encoded certificate file is supported.
348  * @param[out] cert       The pointer of newly created @a ckmc_cert_s handle
349  *
350  * @return #CKMC_ERROR_NONE on success,
351  *         otherwise a negative error value
352  *
353  * @retval #CKMC_ERROR_NONE                Successful
354  * @retval #CKMC_ERROR_OUT_OF_MEMORY       Not enough memory space
355  * @retval #CKMC_ERROR_INVALID_FORMAT      Invalid certificate file format
356  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED  Provided file does not exist or cannot be accessed
357  *
358  * @see ckmc_cert_free()
359  * @see #ckmc_cert_s
360  */
361 int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert);
362
363 /**
364  * @internal
365  * @brief Creates a new @a ckmc_pkcs12_s handle and returns it.
366  *
367  * @since_tizen 2.4
368  *
369  * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it
370  *          is no longer needed.
371  * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly
372  *          returned ckmc_pkcs12_s.
373  *
374  * @param[in]  private_key      @a ckmc_key_s handle to the private key (optional)
375  * @param[in]  cert             @a ckmc_cert_s handle to the certificate (optional)
376  * @param[in]  ca_cert_list     @a ckmc_cert_list_s list of chain certificate handles (optional)
377  * @param[out] pkcs12_bundle    The pointer to a newly created @a ckmc_pkcs12_s handle
378  *
379  * @return @c 0 on success,
380  *         otherwise a negative error value
381  *
382  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid or private_key, cert and
383  *                                        ca_cert_list all are null.
384  * @retval #CKMC_ERROR_OUT_OF_MEMORY      Not enough memory
385  *
386  * @see ckmc_pkcs12_free()
387  * @see ckmc_load_from_pkcs12_file()
388  * @see ckmc_pkcs12_load()
389  * @see #ckmc_key_s
390  * @see #ckmc_cert_s
391  * @see #ckmc_cert_list_s
392  * @see #ckmc_pkcs12_s
393  */
394 int ckmc_pkcs12_new(ckmc_key_s *private_key,
395                     ckmc_cert_s *cert,
396                     ckmc_cert_list_s *ca_cert_list,
397                     ckmc_pkcs12_s **pkcs12_bundle);
398
399 /**
400  * @deprecated Deprecated since 2.4. [Use ckmc_pkcs12_load() instead]
401  * @brief Creates a new @a ckmc_key_s(private key), @a ckmc_cert_s(certificate), and
402  *        @a ckmc_cert_list_s(CA certificates) handle from a given PKCS#12 file and returns them.
403  *
404  * @since_tizen 2.3
405  *
406  * @remarks You must destroy the newly created @a ckmc_key_s, @a ckmc_cert_s, and
407  *          @a ckmc_cert_list_s by calling ckmc_key_free(), ckmc_cert_free(), and
408  *          ckmc_cert_list_all_free() if they are no longer needed.
409  *
410  * @param[in]  file_path    The path of PKCS12 file to be loaded
411  * @param[in]  passphrase   The passphrase used to decrypt the PCKS12 file \n
412  *                          If PKCS12 file is not encrypted, passphrase can be null.
413  * @param[out] private_key  The pointer of newly created @a ckmc_key_s handle for a private key
414  * @param[out] cert         The pointer of newly created @a ckmc_cert_s handle for a certificate \n
415  *                          It is null if the PKCS12 file does not contain a certificate.
416  * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
417  *                          certificates \n
418  *                          It is null if the PKCS12 file does not contain CA certificates.
419  *
420  * @return #CKMC_ERROR_NONE on success,
421  *         otherwise a negative error value
422  *
423  * @retval #CKMC_ERROR_NONE                Successful
424  * @retval #CKMC_ERROR_OUT_OF_MEMORY       Not enough memory space
425  * @retval #CKMC_ERROR_INVALID_FORMAT      Invalid PKCS12 file format
426  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED  Provided file does not exist or cannot be accessed
427  *
428  * @see ckmc_pkcs12_new()
429  * @see ckmc_pkcs12_load()
430  * @see ckmc_key_free()
431  * @see ckmc_cert_free()
432  * @see ckmc_cert_list_all_free()
433  * @see #ckmc_key_s
434  * @see #ckmc_cert_s
435  * @see #ckmc_cert_list_s
436  */
437 int ckmc_load_from_pkcs12_file(const char *file_path,
438                                const char *passphrase,
439                                ckmc_key_s **private_key, ckmc_cert_s **cert,
440                                ckmc_cert_list_s **ca_cert_list);
441
442 /**
443  * @brief Creates a new @a ckmc_pkcs12_s handle from a given PKCS#12 file and returns it.
444  *
445  * @since_tizen 2.4
446  *
447  * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if
448  *          they are no longer needed.
449  *
450  * @param[in]  file_path    The path of PKCS12 file to be loaded
451  * @param[in]  passphrase   The passphrase used to decrypt the PCKS12 file \n
452  *                          If PKCS12 file is not encrypted, passphrase can be null.
453  * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
454  *                          certificates \n
455  *                          It is null if the PKCS12 file does not contain CA certificates.
456  *
457  * @return #CKMC_ERROR_NONE on success,
458  *         otherwise a negative error value
459  *
460  * @retval #CKMC_ERROR_NONE                Successful
461  * @retval #CKMC_ERROR_OUT_OF_MEMORY       Not enough memory space
462  * @retval #CKMC_ERROR_INVALID_FORMAT      Invalid PKCS12 file format
463  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED  Provided file does not exist or cannot be accessed
464  *
465  * @see ckmc_pkcs12_free()
466  * @see #ckmc_pkcs12_s
467  */
468 int ckmc_pkcs12_load(const char *file_path,
469                                 const char *passphrase,
470                                 ckmc_pkcs12_s **pkcs12_bundle);
471
472 /**
473  * @brief Destroys the @a ckmc_pkcs12_s handle and releases all its resources.
474  *
475  * @since_tizen 2.4
476  *
477  * @param[in] pkcs12 The @a ckmc_pkcs12_s handle to destroy
478  *
479  * @see ckmc_pkcs12_new()
480  * @see ckmc_pkcs12_load()
481  */
482 void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12);
483
484 /**
485  * @internal
486  * @brief Creates a new @a ckmc_alias_list_s handle and returns it.
487  *        The alias pointer in the returned @a ckmc_alias_list_s handle points to the provided
488  *        characters and next is null.
489  *
490  * @since_tizen 2.3
491  *
492  * @remarks You must destroy the newly created @a ckmc_alias_list_s
493  *          by calling ckmc_alias_list_free() or ckmc_alias_list_all_free() if it is no longer
494  *          needed.
495  *
496  * @param[in]  alias        The first item to be set in the newly created @a ckmc_alias_list_s
497  * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
498  *
499  * @return @c 0 on success,
500  *         otherwise a negative error value
501  *
502  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
503  * @retval #CKMC_ERROR_OUT_OF_MEMORY     Not enough memory
504  *
505  * @see ckmc_alias_list_all_free()
506  * @see #ckmc_alias_list_s
507  */
508 int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list);
509
510 /**
511  * @internal
512  * @brief Creates a new @a ckmc_alias_list_s handle, adds it to a previous @a ckmc_alias_list_s and
513  *        returns it. The alias pointer in the returned @a ckmc_alias_list_s handle points to the
514  *        provided characters and next is null.
515  *
516  * @since_tizen 2.3
517  *
518  * @param[in]  previous  The last @a ckmc_alias_list_s handle to which a newly created
519  *                       @a ckmc_alias_list_s is added
520  * @param[in]  alias     The item to be set in the newly created @a ckmc_alias_list_s
521  * @param[out] pplast    The pointer to a newly created and added @a ckmc_alias_list_s handle
522  *
523  * @return @c 0 on success,
524  *         otherwise a negative error value
525  *
526  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
527  * @retval #CKMC_ERROR_OUT_OF_MEMORY      Not enough memory
528  *
529  * @see ckmc_alias_list_all_free()
530  * @see #ckmc_alias_list_s
531  */
532 int ckmc_alias_list_add(ckmc_alias_list_s *previous,
533                         char *alias,
534                         ckmc_alias_list_s **pplast);
535
536 /**
537  * @internal
538  * @brief Destroys the @a ckmc_alias_list_s handle and releases resources of @a ckmc_alias_list_s
539  *        from the provided first handle cascadingly.
540  *
541  * @since_tizen 2.3
542  *
543  * @remarks It does not destroy an alias itself in @a ckmc_alias_list_s.
544  *
545  * @param[in] first The first @a ckmc_alias_list_s handle to destroy
546  *
547  * @see ckmc_alias_list_all_free()
548  * @see #ckmc_alias_list_s
549  */
550 void ckmc_alias_list_free(ckmc_alias_list_s *first);
551
552 /**
553  * @brief Destroys the @a ckmc_alias_list_s handle and releases all its resources from the provided
554  *        first handle cascadingly.
555  *
556  * @since_tizen 2.3
557  *
558  * @remarks It also destroys the alias in @a ckmc_alias_list_s.
559  *
560  * @param[in] first The first @a ckmc_alias_list_s handle to destroy
561  *
562  * @see #ckmc_alias_list_s
563  */
564 void ckmc_alias_list_all_free(ckmc_alias_list_s *first);
565
566 /**
567  * @internal
568  * @brief Creates a new @a ckmc_cert_list_s handle and returns it.
569  *        The cert pointer in the returned @a ckmc_cert_list_s handle points to the provided
570  *        @a ckmc_cert_s and next is null.
571  *
572  * @since_tizen 2.3
573  *
574  * @remarks You must destroy the newly created @a ckmc_cert_list_s by calling ckmc_cert_list_free()
575  *          or ckmc_cert_list_all_free() if it is no longer needed.
576  *
577  * @param[in]  cert          The first item to be set in the newly created @a ckmc_cert_list_s
578  * @param[out] ppalias_list  The pointer to a newly created @a ckmc_alias_list_s handle
579  *
580  * @return @c 0 on success,
581  *         otherwise a negative error value
582  *
583  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
584  * @retval #CKMC_ERROR_OUT_OF_MEMORY      Not enough memory
585  *
586  * @see ckmc_cert_list_all_free()
587  * @see #ckmc_cert_list_s
588  */
589 int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list);
590
591 /**
592  * @internal
593  * @brief Creates a new @a ckmc_cert_list_s handle, adds it to a previous @a ckmc_cert_list_s and
594  *        returns it. The cert pointer in the returned @a ckmc_alias_list_s handle points to the
595  *        provided @a ckmc_cert_s and next is null.
596  *
597  * @since_tizen 2.3
598  *
599  * @param[in]  previous  The last @a ckmc_cert_list_s handle to which a newly created
600  *                       @a ckmc_cert_list_s is added
601  * @param[in]  cert      The item to be set in the newly created @a ckmc_cert_list_s
602  * @param[out] pplast    The pointer to a newly created and added @a ckmc_alias_list_s handle
603  *
604  * @return @c 0 on success,
605  *         otherwise a negative error value
606  *
607  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
608  * @retval #CKMC_ERROR_OUT_OF_MEMORY      Not enough memory
609  *
610  * @see ckmc_cert_list_all_free()
611  * @see #ckmc_cert_list_s
612  */
613 int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast);
614
615 /**
616  * @internal
617  * @brief Destroys the @a ckmc_cert_list_s handle and releases resources of @a ckmc_cert_list_s
618  *        from the provided first handle cascadingly.
619  *
620  * @since_tizen 2.3
621  *
622  * @remarks It does not destroy @a ckmc_cert_s itself in @a ckmc_cert_list_s.
623  *
624  * @param[in] first The first @a ckmc_cert_list_s handle to destroy
625  *
626  * @see ckmc_cert_list_all_free()
627  * @see #ckmc_cert_list_s
628  */
629 void ckmc_cert_list_free(ckmc_cert_list_s *first);
630
631 /**
632  * @brief Destroys the @a ckmc_cert_list_s handle and releases all its resources from the provided
633  *        first handle cascadingly.
634  *
635  * @since_tizen 2.3
636  *
637  * @remarks It also destroys @a ckmc_cert_s in ckmc_cert_list_s.
638  *
639  * @param[in] first The first @a ckmc_cert_list_s handle to destroy
640  *
641  * @see #ckmc_cert_list_s
642  */
643 void ckmc_cert_list_all_free(ckmc_cert_list_s *first);
644
645 /**
646  * @}
647  */
648
649 #ifdef __cplusplus
650 }
651 #endif
652
653 #endif /* __TIZEN_CORE_CKMC_TYPE_H */