2 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
19 * @brief Definitions of struct for the Key Manager's CAPI and their utility functions.
22 #ifndef __TIZEN_CORE_CKMC_TYPE_H
23 #define __TIZEN_CORE_CKMC_TYPE_H
27 #include <ckmc/ckmc-error.h>
29 #define KEY_MANAGER_CAPI __attribute__((visibility("default")))
37 * @addtogroup CAPI_KEY_MANAGER_TYPES_MODULE
42 * Note: on tizen 3.0 owner id is equal to pkgId.
43 * Preinstalled system(uid < 5000) and user (uid >= 5000) applications
44 * does not have any pkgId. Thats why ckm uses special "virtual"
45 * pkgid for them. The virtual strings are defined under:
52 * @deprecated Deprecated since 3.0. [Use ckmc_owner_id_separator instead]
53 * @brief Separator between alias and label.
55 * @remarks Alias can be provided as an alias alone, or together with label - in this
56 * case, separator " " (space bar) is used to separate label and alias.
58 * @see #ckmc_owner_id_separator
59 * @see key-manager_doc.h
61 KEY_MANAGER_CAPI extern char const * const ckmc_label_name_separator;
64 * This is deprecated: Tizen 3.0 does not use smack labels directly.
65 * You should use pkgId instead.
67 * @brief Shared owner label
69 * @remarks Shared database label - user may be given permission to access shared
70 * database items. In such case, the alias should contain shared database
73 * @see #ckmc_label_name_separator
74 * @see key-manager_doc.h
76 KEY_MANAGER_CAPI extern char const * const ckmc_label_shared_owner;
79 * @brief Separator between alias and owner id.
81 * @remarks Alias can be provided as an alias alone, or together with owner id.
82 * In this case, separator " " (space bar) is used to separate id and alias.
83 * @see key-manager_doc.h
85 KEY_MANAGER_CAPI extern char const * const ckmc_owner_id_separator;
88 * @brief The owner of system database.
90 * @remarks ckmc_owner_id_system constains id connected with all SYSTEM applications that run
91 * with uid less than 5000.
92 * Client should use ckmc_owner_id_system to access data owned by system application
93 * and stored in system database.
94 * Note: Client must have permission to access proper row.
96 KEY_MANAGER_CAPI extern char const * const ckmc_owner_id_system;
99 * @brief Enumeration for key types of key manager.
102 typedef enum __ckmc_key_type {
103 CKMC_KEY_NONE = 0, /**< Key type not specified */
104 CKMC_KEY_RSA_PUBLIC, /**< RSA public key */
105 CKMC_KEY_RSA_PRIVATE, /**< RSA private key */
106 CKMC_KEY_ECDSA_PUBLIC, /**< ECDSA public key */
107 CKMC_KEY_ECDSA_PRIVATE, /**< ECDSA private key */
108 CKMC_KEY_DSA_PUBLIC, /**< DSA public key */
109 CKMC_KEY_DSA_PRIVATE, /**< DSA private key */
110 CKMC_KEY_AES, /**< AES key */
114 * @brief Enumeration for data format.
117 typedef enum __ckmc_data_format {
118 CKMC_FORM_DER_BASE64 = 0, /**< DER format base64 encoded data */
119 CKMC_FORM_DER, /**< DER encoded data */
120 CKMC_FORM_PEM /**< PEM encoded data. It consists of the DER format base64 encoded
121 with additional header and footer lines. */
122 } ckmc_data_format_e;
125 * @brief Enumeration for elliptic curve.
128 typedef enum __ckmc_ec_type {
129 CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended
130 elliptic curve domain */
131 CKMC_EC_PRIME256V1, /**< "SEC 2" recommended elliptic curve domain - secp256r1 */
132 CKMC_EC_SECP384R1 /**< NIST curve P-384 (covers "secp384r1", the elliptic curve domain
133 listed in See SEC 2 */
137 * @brief Enumeration for hash algorithm.
140 typedef enum __ckmc_hash_algo {
141 CKMC_HASH_NONE = 0, /**< No Hash Algorithm */
142 CKMC_HASH_SHA1, /**< Hash Algorithm SHA1 */
143 CKMC_HASH_SHA256, /**< Hash Algorithm SHA256 */
144 CKMC_HASH_SHA384, /**< Hash Algorithm SHA384 */
145 CKMC_HASH_SHA512 /**< Hash Algorithm SHA512 */
149 * @brief Enumeration for RSA padding algorithm.
152 typedef enum __ckmc_rsa_padding_algo {
153 CKMC_NONE_PADDING = 0, /**< No Padding */
154 CKMC_PKCS1_PADDING, /**< PKCS#1 Padding */
155 CKMC_X931_PADDING /**< X9.31 padding */
156 } ckmc_rsa_padding_algo_e;
159 * @deprecated Deprecated since 2.4. [Use ckmc_permission_e() instead]
160 * @brief Enumeration for database access rights.
163 typedef enum __ckmc_access_right{
164 CKMC_AR_READ = 0, /**< Access right for read*/
165 CKMC_AR_READ_REMOVE /**< Access right for read and remove*/
166 } ckmc_access_right_e;
169 * @brief Enumeration for permissions to access/modify alias.
172 typedef enum __ckmc_permission{
173 CKMC_PERMISSION_NONE = 0x00, /**< Clear permissions */
174 CKMC_PERMISSION_READ = 0x01, /**< Eead allowed */
175 CKMC_PERMISSION_REMOVE = 0x02 /**< Remove allowed */
179 * @brief The structure for binary buffer used in key manager CAPI.
182 typedef struct __ckmc_raw_buff {
183 unsigned char* data; /**< Byte array containing binary data */
184 size_t size; /**< The size of the binary data */
188 * @brief The structure for a policy for storing key/certificate/binary data.
191 typedef struct __ckmc_policy {
192 char* password; /**< Byte array used to encrypt data inside CKM. If it is not null, the data
193 (or key, or certificate) is stored encrypted with this password inside
195 bool extractable; /**< If true key may be extracted from storage */
199 * @brief The structure for key used in key manager CAPI.
202 typedef struct __ckmc_key {
203 unsigned char* 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. */
210 * @brief The structure for certificate used in key manager CAPI.
213 typedef struct __ckmc_cert {
214 unsigned char* raw_cert; /**< Byte array of certificate */
215 size_t cert_size; /**< Byte size of raw_cert */
216 ckmc_data_format_e data_format; /**< Raw_cert's encoding format */
220 * @brief The structure for linked list of alias.
223 typedef struct __ckmc_alias_list {
224 char *alias; /**< The name of key, certificate or data stored in key manager */
225 struct __ckmc_alias_list *next; /**< The pointer pointing to the next ckmc_alias_list_s */
229 * @brief The structure for linked list of ckmc_cert_s
232 typedef struct __ckmc_cert_list {
233 ckmc_cert_s *cert; /**< The pointer of ckmc_cert_s */
234 struct __ckmc_cert_list *next; /**< The pointer pointing to the next ckmc_cert_list_s */
238 * @brief Enumeration for OCSP status.
241 typedef enum __ckmc_ocsp_status {
242 CKMC_OCSP_STATUS_GOOD = 0, /**< OCSP status is good */
243 CKMC_OCSP_STATUS_REVOKED, /**< The certificate is revoked */
244 CKMC_OCSP_STATUS_UNKNOWN, /**< Unknown error */
245 CKMC_OCSP_ERROR_UNSUPPORTED, /**< The certificate does not provide OCSP extension */
246 CKMC_OCSP_ERROR_INVALID_URL, /**< The invalid URL in certificate OCSP extension */
247 CKMC_OCSP_ERROR_INVALID_RESPONSE, /**< The invalid response from OCSP server */
248 CKMC_OCSP_ERROR_REMOTE, /**< OCSP remote server error */
249 CKMC_OCSP_ERROR_NET, /**< Network connection error */
250 CKMC_OCSP_ERROR_INTERNAL /**< OpenSSL API error */
251 } ckmc_ocsp_status_e;
254 * @brief The structure for PKCS12 used in key manager CAPI.
257 typedef struct __ckmc_pkcs12 {
258 ckmc_key_s *priv_key; /**< The private key, may be null */
259 ckmc_cert_s *cert; /**< The certificate, may be null */
260 ckmc_cert_list_s *ca_chain; /**< The chain certificate list, may be null */
264 * @brief Enumeration for crypto algorithm parameters.
267 * @see #ckmc_algo_type_e
269 typedef enum __ckmc_param_name {
270 CKMC_PARAM_ALGO_TYPE = 1,
272 CKMC_PARAM_ED_IV = 101, /**< 16B buffer (up to 2^64-1 bytes long in case of AES GCM) */
273 CKMC_PARAM_ED_CTR_LEN, /**< integer - ctr length in bits*/
274 CKMC_PARAM_ED_AAD, /**< buffer */
275 CKMC_PARAM_ED_TAG_LEN, /**< integer - tag length in bits */
276 CKMC_PARAM_ED_LABEL /**< buffer */
280 * @brief Handle for algorithm parameter list.
283 typedef struct __ckmc_param_list *ckmc_param_list_h;
286 * @brief Enumeration for crypto algorithm types.
289 * @see #ckmc_param_name_e
291 typedef enum __ckmc_algo_type {
292 CKMC_ALGO_AES_CTR = 1, /**< AES-CTR algorithm
293 Supported parameters:
294 - CKMC_PARAM_ALGO_TYPE,
296 - CKMC_PARAM_ED_CTR_LEN (128 only) */
298 CKMC_ALGO_AES_CBC, /**< AES-CBC algorithm
299 Supported parameters:
300 - CKMC_PARAM_ALGO_TYPE,
301 - CKMC_PARAM_ED_IV */
303 CKMC_ALGO_AES_GCM, /**< AES-GCM algorithm
304 Supported parameters:
305 - CKMC_PARAM_ALGO_TYPE,
307 - CKMC_PARAM_ED_TAG_LEN
308 - CKMC_PARAM_ED_AAD */
310 CKMC_ALGO_AES_CFB, /**< AES-CFB algorithm
311 Supported parameters:
312 - CKMC_PARAM_ALGO_TYPE,
313 - CKMC_PARAM_ED_IV */
315 CKMC_ALGO_RSA_OAEP /**< RSA-OAEP algorithm
316 Supported parameters:
317 - CKMC_PARAM_ALGO_TYPE,
318 - CKMC_PARAM_ED_LABEL */
322 * @brief Creates a new @a ckmc_key_s handle and returns it.
326 * @remarks You must destroy the newly created @a ckmc_key_s by calling ckmc_key_free() if it is no
329 * @param[in] raw_key The byte array of key \n
330 * @a raw_key may be encrypted with password
331 * @param[in] key_size The byte size of @a raw_key
332 * @param[in] key_type The @a raw_key's type
333 * @param[in] password The byte array used to decrypt @a raw_key inside key manager \n
334 * If @a raw_key is not encrypted, @a password can be null
335 * @param[out] ppkey The pointer to a newly created @a ckmc_key_s handle
337 * @return #CKMC_ERROR_NONE on success,
338 * otherwise a negative error value
340 * @retval #CKMC_ERROR_NONE Successful
341 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
342 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
344 * @see ckmc_key_free()
347 int ckmc_key_new(unsigned char *raw_key,
349 ckmc_key_type_e key_type,
350 char *password, ckmc_key_s **ppkey);
353 * @brief Destroys the @a ckmc_key_s handle and releases all its resources.
357 * @param[in] key The @a ckmc_key_s handle to destroy
360 void ckmc_key_free(ckmc_key_s *key);
363 * @brief Creates a new @a ckmc_raw_buffer_s handle and returns it.
367 * @remarks You must destroy the newly created @a ckmc_raw_buffer_s by calling ckmc_buffer_free() if
368 * it is no longer needed.
370 * @param[in] data The byte array of buffer
371 * @param[in] size The byte size of buffer
372 * @param[out] ppbuffer The pointer to a newly created @a ckmc_buffer_s handle
374 * @return #CKMC_ERROR_NONE on success,
375 * otherwise a negative error value
377 * @retval #CKMC_ERROR_NONE Successful
378 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
379 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
381 * @see ckmc_buffer_free()
382 * @see #ckmc_raw_buffer_s
384 int ckmc_buffer_new(unsigned char *data, size_t size, ckmc_raw_buffer_s **ppbuffer);
387 * @brief Destroys the @a ckmc_raw_buffer_s handle and releases all its resources.
391 * @param[in] buffer The @a ckmc_raw_buffer_s structure to destroy
394 void ckmc_buffer_free(ckmc_raw_buffer_s *buffer);
397 * @brief Creates a new @a ckmc_cert_s handle and returns it.
401 * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
404 * @param[in] raw_cert The byte array of certificate
405 * @param[in] cert_size The byte size of raw_cert
406 * @param[in] data_format The encoding format of raw_cert
407 * @param[out] ppcert The pointer to a newly created @a ckmc_cert_s handle
409 * @return #CKMC_ERROR_NONE on success,
410 * otherwise a negative error value
412 * @retval #CKMC_ERROR_NONE Successful
413 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
414 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
416 * @see ckmc_cert_free()
417 * @see ckmc_load_cert_from_file()
420 int ckmc_cert_new(unsigned char *raw_cert,
422 ckmc_data_format_e data_format,
423 ckmc_cert_s **ppcert);
426 * @brief Destroys the @a ckmc_cert handle and releases all its resources.
430 * @param[in] cert The @a ckmc_cert_s handle to destroy
432 * @see ckmc_load_cert_from_file()
433 * @see ckmc_load_from_pkcs12_file
435 void ckmc_cert_free(ckmc_cert_s *cert);
438 * @brief Creates a new @a ckmc_cert_s handle from a given file and returns it.
442 * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
445 * @param[in] file_path The path of certificate file to be loaded \n
446 * The only DER or PEM encoded certificate file is supported
447 * @param[out] cert The pointer of newly created @a ckmc_cert_s handle
449 * @return #CKMC_ERROR_NONE on success,
450 * otherwise a negative error value
452 * @retval #CKMC_ERROR_NONE Successful
453 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
454 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid certificate file format
455 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
457 * @see ckmc_cert_free()
460 int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert);
463 * @brief Creates a new @a ckmc_pkcs12_s handle and returns it.
467 * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it
468 * is no longer needed.
469 * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly
470 * returned ckmc_pkcs12_s.
472 * @param[in] private_key @a ckmc_key_s handle to the private key (optional)
473 * @param[in] cert @a ckmc_cert_s handle to the certificate (optional)
474 * @param[in] ca_cert_list @a ckmc_cert_list_s list of chain certificate handles (optional)
475 * @param[out] pkcs12_bundle The pointer to a newly created @a ckmc_pkcs12_s handle
477 * @return #CKMC_ERROR_NONE on success,
478 * otherwise a negative error value
480 * @retval #CKMC_ERROR_NONE Successful
481 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or private_key, cert and
482 * ca_cert_list all are null
483 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
485 * @see ckmc_pkcs12_free()
486 * @see ckmc_load_from_pkcs12_file()
487 * @see ckmc_pkcs12_load()
490 * @see #ckmc_cert_list_s
491 * @see #ckmc_pkcs12_s
493 int ckmc_pkcs12_new(ckmc_key_s *private_key,
495 ckmc_cert_list_s *ca_cert_list,
496 ckmc_pkcs12_s **pkcs12_bundle);
499 * @deprecated Deprecated since 2.4. [Use ckmc_pkcs12_load() instead]
500 * @brief Creates a new @a ckmc_key_s(private key), @a ckmc_cert_s(certificate), and
501 * @a ckmc_cert_list_s(CA certificates) handle from a given PKCS#12 file and returns them.
505 * @remarks You must destroy the newly created @a ckmc_key_s, @a ckmc_cert_s, and
506 * @a ckmc_cert_list_s by calling ckmc_key_free(), ckmc_cert_free(), and
507 * ckmc_cert_list_all_free() if they are no longer needed.
509 * @param[in] file_path The path of PKCS12 file to be loaded
510 * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n
511 * If PKCS12 file is not encrypted, passphrase can be null
512 * @param[out] private_key The pointer of newly created @a ckmc_key_s handle for a private key
513 * @param[out] cert The pointer of newly created @a ckmc_cert_s handle for a certificate \n
514 * It is null if the PKCS12 file does not contain a certificate
515 * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
517 * It is null if the PKCS12 file does not contain CA certificates
519 * @return #CKMC_ERROR_NONE on success,
520 * otherwise a negative error value
522 * @retval #CKMC_ERROR_NONE Successful
523 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
524 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
525 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
527 * @see ckmc_pkcs12_new()
528 * @see ckmc_pkcs12_load()
529 * @see ckmc_key_free()
530 * @see ckmc_cert_free()
531 * @see ckmc_cert_list_all_free()
534 * @see #ckmc_cert_list_s
536 int ckmc_load_from_pkcs12_file(const char *file_path,
537 const char *passphrase,
538 ckmc_key_s **private_key, ckmc_cert_s **cert,
539 ckmc_cert_list_s **ca_cert_list);
542 * @brief Creates a new @a ckmc_pkcs12_s handle from a given PKCS#12 file and returns it.
546 * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if
547 * they are no longer needed.
549 * @param[in] file_path The path of PKCS12 file to be loaded
550 * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n
551 * If PKCS12 file is not encrypted, passphrase can be null
552 * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
554 * It is null if the PKCS12 file does not contain CA certificates
556 * @return #CKMC_ERROR_NONE on success,
557 * otherwise a negative error value
559 * @retval #CKMC_ERROR_NONE Successful
560 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
561 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
562 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
564 * @see ckmc_pkcs12_free()
565 * @see #ckmc_pkcs12_s
567 int ckmc_pkcs12_load(const char *file_path,
568 const char *passphrase,
569 ckmc_pkcs12_s **pkcs12_bundle);
572 * @brief Destroys the @a ckmc_pkcs12_s handle and releases all its resources.
576 * @param[in] pkcs12 The @a ckmc_pkcs12_s handle to destroy
578 * @see ckmc_pkcs12_new()
579 * @see ckmc_pkcs12_load()
581 void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12);
584 * @brief Creates a new @a ckmc_alias_list_s handle and returns it.
585 * The alias pointer in the returned @a ckmc_alias_list_s handle points to the provided
586 * characters and next is null.
590 * @remarks You must destroy the newly created @a ckmc_alias_list_s
591 * by calling ckmc_alias_list_free() or ckmc_alias_list_all_free() if it is no longer
594 * @param[in] alias The first item to be set in the newly created @a ckmc_alias_list_s
595 * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
597 * @return #CKMC_ERROR_NONE on success,
598 * otherwise a negative error value
600 * @retval #CKMC_ERROR_NONE Successful
601 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
602 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
604 * @see ckmc_alias_list_all_free()
605 * @see #ckmc_alias_list_s
607 int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list);
610 * @brief Creates a new @a ckmc_alias_list_s handle, adds it to a previous @a ckmc_alias_list_s and
611 * returns it. The alias pointer in the returned @a ckmc_alias_list_s handle points to the
612 * provided characters and next is null.
616 * @param[in] previous The last @a ckmc_alias_list_s handle to which a newly created
617 * @a ckmc_alias_list_s is added
618 * @param[in] alias The item to be set in the newly created @a ckmc_alias_list_s
619 * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle
621 * @return #CKMC_ERROR_NONE on success,
622 * otherwise a negative error value
624 * @retval #CKMC_ERROR_NONE Successful
625 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
626 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
628 * @see ckmc_alias_list_all_free()
629 * @see #ckmc_alias_list_s
631 int ckmc_alias_list_add(ckmc_alias_list_s *previous,
633 ckmc_alias_list_s **pplast);
636 * @brief Destroys the @a ckmc_alias_list_s handle and releases resources of @a ckmc_alias_list_s
637 * from the provided first handle cascadingly.
641 * @remarks It does not destroy an alias itself in @a ckmc_alias_list_s.
643 * @param[in] first The first @a ckmc_alias_list_s handle to destroy
645 * @see ckmc_alias_list_all_free()
646 * @see #ckmc_alias_list_s
648 void ckmc_alias_list_free(ckmc_alias_list_s *first);
651 * @brief Destroys the @a ckmc_alias_list_s handle and releases all its resources from the provided
652 * first handle cascadingly.
656 * @remarks It also destroys the alias in @a ckmc_alias_list_s.
658 * @param[in] first The first @a ckmc_alias_list_s handle to destroy
660 * @see #ckmc_alias_list_s
662 void ckmc_alias_list_all_free(ckmc_alias_list_s *first);
665 * @brief Creates a new @a ckmc_cert_list_s handle and returns it.
666 * The cert pointer in the returned @a ckmc_cert_list_s handle points to the provided
667 * @a ckmc_cert_s and next is null.
671 * @remarks You must destroy the newly created @a ckmc_cert_list_s by calling ckmc_cert_list_free()
672 * or ckmc_cert_list_all_free() if it is no longer needed.
674 * @param[in] cert The first item to be set in the newly created @a ckmc_cert_list_s
675 * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
677 * @return #CKMC_ERROR_NONE on success,
678 * otherwise a negative error value
680 * @retval #CKMC_ERROR_NONE Successful
681 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
682 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
684 * @see ckmc_cert_list_all_free()
685 * @see #ckmc_cert_list_s
687 int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list);
690 * @brief Creates a new @a ckmc_cert_list_s handle, adds it to a previous @a ckmc_cert_list_s and
691 * returns it. The cert pointer in the returned @a ckmc_alias_list_s handle points to the
692 * provided @a ckmc_cert_s and next is null.
696 * @param[in] previous The last @a ckmc_cert_list_s handle to which a newly created
697 * @a ckmc_cert_list_s is added
698 * @param[in] cert The item to be set in the newly created @a ckmc_cert_list_s
699 * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle
701 * @return #CKMC_ERROR_NONE on success,
702 * otherwise a negative error value
704 * @retval #CKMC_ERROR_NONE Successful
705 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
706 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
708 * @see ckmc_cert_list_all_free()
709 * @see #ckmc_cert_list_s
711 int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast);
714 * @brief Destroys the @a ckmc_cert_list_s handle and releases resources of @a ckmc_cert_list_s
715 * from the provided first handle cascadingly.
719 * @remarks It does not destroy @a ckmc_cert_s itself in @a ckmc_cert_list_s.
721 * @param[in] first The first @a ckmc_cert_list_s handle to destroy
723 * @see ckmc_cert_list_all_free()
724 * @see #ckmc_cert_list_s
726 void ckmc_cert_list_free(ckmc_cert_list_s *first);
729 * @brief Destroys the @a ckmc_cert_list_s handle and releases all its resources from the provided
730 * first handle cascadingly.
734 * @remarks It also destroys @a ckmc_cert_s in @a ckmc_cert_list_s.
736 * @param[in] first The first @a ckmc_cert_list_s handle to destroy
738 * @see #ckmc_cert_list_s
740 void ckmc_cert_list_all_free(ckmc_cert_list_s *first);
743 * @brief Creates new parameter list.
747 * @remarks Caller is responsible for freeing it with ckmc_param_list_free().
749 * @param[in] pparams Double pointer to the handle of param list to which the
750 * newly created algorithm param list will be assigned
752 * @return #CKMC_ERROR_NONE on success,
753 * otherwise a negative error value
755 * @retval #CKMC_ERROR_NONE Successful
756 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
758 * @see ckmc_param_list_set_integer()
759 * @see ckmc_param_list_set_buffer()
760 * @see ckmc_param_list_free()
761 * @see ckmc_generate_new_params()
762 * @see #ckmc_param_list_h
763 * @see #ckmc_param_name_e
765 int ckmc_param_list_new(ckmc_param_list_h *pparams);
768 * @brief Set integer parameter to the list.
772 * @remarks Caller is responsible for @a ckmc_param_list_h creation.
774 * @param[in] params Algorithm param list handle created with
775 * ckmc_param_list_new() or ckmc_generate_new_params() \n
776 * New param with @a name and @a value will be set` here
777 * @param[in] name Name of parameter to set \n
778 * Existing parameter will be overwritten \n
779 * Passing invalid parameter name will result in an error
780 * @param[in] value Value of the parameter in form of a integer
782 * @return #CKMC_ERROR_NONE on success,
783 * otherwise a negative error value
785 * @retval #CKMC_ERROR_NONE Successful
786 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
788 * @see ckmc_param_list_new()
789 * @see ckmc_param_list_set_buffer()
790 * @see ckmc_param_list_get_integer()
791 * @see ckmc_param_list_get_buffer()
792 * @see ckmc_param_list_free()
793 * @see ckmc_generate_new_params()
794 * @see #ckmc_param_list_h
795 * @see #ckmc_param_name_e
797 int ckmc_param_list_set_integer(ckmc_param_list_h params,
798 ckmc_param_name_e name,
802 * @brief Set buffer parameter to the list.
806 * @remarks Caller is responsible for @a ckmc_param_list_h creation.
808 * @param[in] params Algorithm param list handle created with
809 * ckmc_param_list_new() or ckmc_generate_new_params()
810 * New param with @a name and @a buffer will be set here
811 * @param[in] name Name of parameter to set \n
812 * Existing parameter will be overwritten \n
813 * Passing invalid parameter name will result in an error
814 * @param[in] buffer Value of the parameter in form of a buffer \n
815 * Caller is responsible for creating and freeing the buffer
817 * @return #CKMC_ERROR_NONE on success,
818 * otherwise a negative error value
820 * @retval #CKMC_ERROR_NONE Successful
821 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
823 * @see ckmc_param_list_new()
824 * @see ckmc_param_list_set_integer()
825 * @see ckmc_param_list_get_integer()
826 * @see ckmc_param_list_get_buffer()
827 * @see ckmc_param_list_free()
828 * @see ckmc_generate_new_params()
829 * @see #ckmc_param_list_h
830 * @see #ckmc_param_name_e
832 int ckmc_param_list_set_buffer(ckmc_param_list_h params,
833 ckmc_param_name_e name,
834 const ckmc_raw_buffer_s *buffer);
837 * @brief Gets integer parameter from the list.
841 * @remarks Caller is responsible for @a ckmc_param_list_h creation.
843 * @param[in] params Algorithm param list handle created with
844 * ckmc_param_list_new() or ckmc_generate_new_params()
845 * which contains param with @a name
846 * @param[in] name Name of parameter to get
847 * @param[out] pvalue Value of the parameter in form of a integer
849 * @return #CKMC_ERROR_NONE on success,
850 * otherwise a negative error value
852 * @retval #CKMC_ERROR_NONE Successful
853 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
855 * @see ckmc_param_list_new()
856 * @see ckmc_param_list_set_integer()
857 * @see ckmc_param_list_set_buffer()
858 * @see ckmc_param_list_get_buffer()
859 * @see ckmc_param_list_free()
860 * @see ckmc_generate_new_params()
861 * @see #ckmc_param_list_h
862 * @see #ckmc_param_name_e
865 int ckmc_param_list_get_integer(ckmc_param_list_h params,
866 ckmc_param_name_e name,
870 * @brief Gets buffer parameter from the list.
874 * @remarks Caller is responsible for @a ckmc_param_list_h creation.
876 * @param[in] params Algorithm param list handle created with
877 * ckmc_param_list_new() or ckmc_generate_new_params()
878 * which contains param with @a name
879 * @param[in] name Name of parameter to get
880 * @param[out] ppbuffer Value of the parameter in form of a buffer \n
881 * Caller is responsible for creating and freeing the buffer
883 * @return #CKMC_ERROR_NONE on success,
884 * otherwise a negative error value
886 * @retval #CKMC_ERROR_NONE Successful
887 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
889 * @see ckmc_param_list_new()
890 * @see ckmc_param_list_set_integer()
891 * @see ckmc_param_list_set_buffer()
892 * @see ckmc_param_list_get_integer()
893 * @see ckmc_param_list_free()
894 * @see ckmc_generate_new_params()
895 * @see ckmc_buffer_free()
896 * @see #ckmc_param_list_h
897 * @see #ckmc_param_name_e
899 int ckmc_param_list_get_buffer(ckmc_param_list_h params,
900 ckmc_param_name_e name,
901 ckmc_raw_buffer_s **ppbuffer);
904 * @brief Frees previously allocated list of algorithm params.
908 * @param[in] first First element of the list to be freed
910 * @see ckmc_param_list_new()
911 * @see ckmc_param_list_set_integer()
912 * @see ckmc_param_list_set_buffer()
913 * @see ckmc_param_list_get_integer()
914 * @see ckmc_param_list_get_buffer()
915 * @see ckmc_generate_new_params()
916 * @see #ckmc_param_list_h
917 * @see #ckmc_param_name_e
919 void ckmc_param_list_free(ckmc_param_list_h params);
922 * @brief Generates algorithm parameters for a given algorithm type and set them to the list.
926 * @remarks Caller is responsible for @a ckmc_param_list_h destruction.
927 * @remarks Algorithm parameters are set to default values. Optional fields are left empty.
928 * Initialization vectors are left empty (they have to be set manually). Caller is
929 * responsible for freeing the list with ckmc_param_list_free().
930 * @remarks If the function returns error, provided param list may contain some of default parameters.
932 * @param[in] type Type of the algorithm
933 * @param[out] pparams Newly generated handle of param list which should be freed by caller after used
935 * @return #CKMC_ERROR_NONE on success,
936 * otherwise a negative error value
938 * @retval #CKMC_ERROR_NONE Successful
939 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
941 * @see ckmc_param_list_new()
942 * @see ckmc_param_list_set_integer()
943 * @see ckmc_param_list_set_buffer()
944 * @see ckmc_param_list_get_integer()
945 * @see ckmc_param_list_get_buffer()
946 * @see ckmc_param_list_free()
947 * @see #ckmc_param_list_h
948 * @see #ckmc_param_name_e
950 int ckmc_generate_new_params(ckmc_algo_type_e type, ckmc_param_list_h *pparams);
960 #endif /* __TIZEN_CORE_CKMC_TYPE_H */