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