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 * @brief Separator between alias and owner id.
66 * @remarks Alias can be provided as an alias alone, or together with owner id.
67 * In this case, separator " " (space bar) is used to separate id and alias.
68 * @see key-manager_doc.h
70 KEY_MANAGER_CAPI extern char const * const ckmc_owner_id_separator;
73 * @brief The owner of system database.
75 * @remarks ckmc_owner_id_system constains id connected with all SYSTEM applications that run
76 * with uid less than 5000.
77 * Client should use ckmc_owner_id_system to access data owned by system application
78 * and stored in system database.
79 * Note: Client must have permission to access proper row.
81 KEY_MANAGER_CAPI extern char const * const ckmc_owner_id_system;
84 * @brief Enumeration for key types of key manager.
87 typedef enum __ckmc_key_type {
88 CKMC_KEY_NONE = 0, /**< Key type not specified */
89 CKMC_KEY_RSA_PUBLIC, /**< RSA public key */
90 CKMC_KEY_RSA_PRIVATE, /**< RSA private key */
91 CKMC_KEY_ECDSA_PUBLIC, /**< ECDSA public key */
92 CKMC_KEY_ECDSA_PRIVATE, /**< ECDSA private key */
93 CKMC_KEY_DSA_PUBLIC, /**< DSA public key */
94 CKMC_KEY_DSA_PRIVATE, /**< DSA private key */
95 CKMC_KEY_AES, /**< AES key */
99 * @brief Enumeration for data format.
102 typedef enum __ckmc_data_format {
103 CKMC_FORM_DER_BASE64 = 0, /**< DER format base64 encoded data */
104 CKMC_FORM_DER, /**< DER encoded data */
105 CKMC_FORM_PEM /**< PEM encoded data. It consists of the DER format base64 encoded
106 with additional header and footer lines. */
107 } ckmc_data_format_e;
110 * @brief Enumeration for elliptic curve.
113 typedef enum __ckmc_ec_type {
114 CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended
115 elliptic curve domain */
116 CKMC_EC_PRIME256V1, /**< "SEC 2" recommended elliptic curve domain - secp256r1 */
117 CKMC_EC_SECP384R1 /**< NIST curve P-384 (covers "secp384r1", the elliptic curve domain
118 listed in See SEC 2 */
122 * @brief Enumeration for hash algorithm.
125 typedef enum __ckmc_hash_algo {
126 CKMC_HASH_NONE = 0, /**< No Hash Algorithm */
127 CKMC_HASH_SHA1, /**< Hash Algorithm SHA1 */
128 CKMC_HASH_SHA256, /**< Hash Algorithm SHA256 */
129 CKMC_HASH_SHA384, /**< Hash Algorithm SHA384 */
130 CKMC_HASH_SHA512 /**< Hash Algorithm SHA512 */
134 * @brief Enumeration for RSA padding algorithm.
137 typedef enum __ckmc_rsa_padding_algo {
138 CKMC_NONE_PADDING = 0, /**< No Padding */
139 CKMC_PKCS1_PADDING, /**< PKCS#1 Padding */
140 CKMC_X931_PADDING /**< X9.31 padding */
141 } ckmc_rsa_padding_algo_e;
144 * @deprecated Deprecated since 2.4. [Use ckmc_permission_e() instead]
145 * @brief Enumeration for database access rights.
148 typedef enum __ckmc_access_right{
149 CKMC_AR_READ = 0, /**< Access right for read*/
150 CKMC_AR_READ_REMOVE /**< Access right for read and remove*/
151 } ckmc_access_right_e;
154 * @brief Enumeration for permissions to access/modify alias.
157 typedef enum __ckmc_permission{
158 CKMC_PERMISSION_NONE = 0x00, /**< Clear permissions */
159 CKMC_PERMISSION_READ = 0x01, /**< Eead allowed */
160 CKMC_PERMISSION_REMOVE = 0x02 /**< Remove allowed */
164 * @brief The structure for binary buffer used in key manager CAPI.
167 typedef struct __ckmc_raw_buff {
168 unsigned char* data; /**< Byte array containing binary data */
169 size_t size; /**< The size of the binary data */
173 * @brief The structure for a policy for storing key/certificate/binary data.
176 typedef struct __ckmc_policy {
177 char* password; /**< Byte array used to encrypt data inside CKM. If it is not null, the data
178 (or key, or certificate) is stored encrypted with this password inside
180 bool extractable; /**< If true key may be extracted from storage */
184 * @brief The structure for key used in key manager CAPI.
187 typedef struct __ckmc_key {
188 unsigned char* raw_key; /**< Byte array of key. raw_key may be encrypted with password */
189 size_t key_size; /**< The byte size of raw_key */
190 ckmc_key_type_e key_type; /**< The raw_key's type */
191 char* password; /**< Byte array used to decrypt data raw_key inside key manager. */
195 * @brief The structure for certificate used in key manager CAPI.
198 typedef struct __ckmc_cert {
199 unsigned char* raw_cert; /**< Byte array of certificate */
200 size_t cert_size; /**< Byte size of raw_cert */
201 ckmc_data_format_e data_format; /**< Raw_cert's encoding format */
205 * @brief The structure for linked list of alias.
208 typedef struct __ckmc_alias_list {
209 char *alias; /**< The name of key, certificate or data stored in key manager */
210 struct __ckmc_alias_list *next; /**< The pointer pointing to the next ckmc_alias_list_s */
214 * @brief The structure for linked list of ckmc_cert_s
217 typedef struct __ckmc_cert_list {
218 ckmc_cert_s *cert; /**< The pointer of ckmc_cert_s */
219 struct __ckmc_cert_list *next; /**< The pointer pointing to the next ckmc_cert_list_s */
223 * @brief Enumeration for OCSP status.
226 typedef enum __ckmc_ocsp_status {
227 CKMC_OCSP_STATUS_GOOD = 0, /**< OCSP status is good */
228 CKMC_OCSP_STATUS_REVOKED, /**< The certificate is revoked */
229 CKMC_OCSP_STATUS_UNKNOWN, /**< Unknown error */
230 CKMC_OCSP_ERROR_UNSUPPORTED, /**< The certificate does not provide OCSP extension */
231 CKMC_OCSP_ERROR_INVALID_URL, /**< The invalid URL in certificate OCSP extension */
232 CKMC_OCSP_ERROR_INVALID_RESPONSE, /**< The invalid response from OCSP server */
233 CKMC_OCSP_ERROR_REMOTE, /**< OCSP remote server error */
234 CKMC_OCSP_ERROR_NET, /**< Network connection error */
235 CKMC_OCSP_ERROR_INTERNAL /**< OpenSSL API error */
236 } ckmc_ocsp_status_e;
239 * @brief The structure for PKCS12 used in key manager CAPI.
242 typedef struct __ckmc_pkcs12 {
243 ckmc_key_s *priv_key; /**< The private key, may be null */
244 ckmc_cert_s *cert; /**< The certificate, may be null */
245 ckmc_cert_list_s *ca_chain; /**< The chain certificate list, may be null */
249 * @brief Enumeration for crypto algorithm parameters.
252 * @see #ckmc_algo_type_e
254 typedef enum __ckmc_param_name {
255 CKMC_PARAM_ALGO_TYPE = 1,
257 CKMC_PARAM_ED_IV = 101, /**< 16B buffer (up to 2^64-1 bytes long in case of AES GCM) */
258 CKMC_PARAM_ED_CTR_LEN, /**< integer - ctr length in bits*/
259 CKMC_PARAM_ED_AAD, /**< buffer */
260 CKMC_PARAM_ED_TAG_LEN, /**< integer - tag length in bits */
261 CKMC_PARAM_ED_LABEL /**< buffer */
265 * @brief Handle for algorithm parameter list.
268 typedef struct __ckmc_param_list *ckmc_param_list_h;
271 * @brief Enumeration for crypto algorithm types.
274 * @see #ckmc_param_name_e
276 typedef enum __ckmc_algo_type {
277 CKMC_ALGO_AES_CTR = 1, /**< AES-CTR algorithm
278 Supported parameters:
279 - CKMC_PARAM_ALGO_TYPE,
281 - CKMC_PARAM_ED_CTR_LEN (128 only) */
283 CKMC_ALGO_AES_CBC, /**< AES-CBC algorithm
284 Supported parameters:
285 - CKMC_PARAM_ALGO_TYPE,
286 - CKMC_PARAM_ED_IV */
288 CKMC_ALGO_AES_GCM, /**< AES-GCM algorithm
289 Supported parameters:
290 - CKMC_PARAM_ALGO_TYPE,
292 - CKMC_PARAM_ED_TAG_LEN
293 - CKMC_PARAM_ED_AAD */
295 CKMC_ALGO_AES_CFB, /**< AES-CFB algorithm
296 Supported parameters:
297 - CKMC_PARAM_ALGO_TYPE,
298 - CKMC_PARAM_ED_IV */
300 CKMC_ALGO_RSA_OAEP /**< RSA-OAEP algorithm
301 Supported parameters:
302 - CKMC_PARAM_ALGO_TYPE,
303 - CKMC_PARAM_ED_LABEL */
307 * @brief Creates a new @a ckmc_key_s handle and returns it.
311 * @remarks You must destroy the newly created @a ckmc_key_s by calling ckmc_key_free() if it is no
314 * @param[in] raw_key The byte array of key \n
315 * @a raw_key may be encrypted with password
316 * @param[in] key_size The byte size of @a raw_key
317 * @param[in] key_type The @a raw_key's type
318 * @param[in] password The byte array used to decrypt @a raw_key inside key manager \n
319 * If @a raw_key is not encrypted, @a password can be null
320 * @param[out] ppkey The pointer to a newly created @a ckmc_key_s handle
322 * @return #CKMC_ERROR_NONE on success,
323 * otherwise a negative error value
325 * @retval #CKMC_ERROR_NONE Successful
326 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
327 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
329 * @see ckmc_key_free()
332 int ckmc_key_new(unsigned char *raw_key,
334 ckmc_key_type_e key_type,
335 char *password, ckmc_key_s **ppkey);
338 * @brief Destroys the @a ckmc_key_s handle and releases all its resources.
342 * @param[in] key The @a ckmc_key_s handle to destroy
345 void ckmc_key_free(ckmc_key_s *key);
348 * @brief Creates a new @a ckmc_raw_buffer_s handle and returns it.
352 * @remarks You must destroy the newly created @a ckmc_raw_buffer_s by calling ckmc_buffer_free() if
353 * it is no longer needed.
355 * @param[in] data The byte array of buffer
356 * @param[in] size The byte size of buffer
357 * @param[out] ppbuffer The pointer to a newly created @a ckmc_buffer_s handle
359 * @return #CKMC_ERROR_NONE on success,
360 * otherwise a negative error value
362 * @retval #CKMC_ERROR_NONE Successful
363 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
364 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
366 * @see ckmc_buffer_free()
367 * @see #ckmc_raw_buffer_s
369 int ckmc_buffer_new(unsigned char *data, size_t size, ckmc_raw_buffer_s **ppbuffer);
372 * @brief Destroys the @a ckmc_raw_buffer_s handle and releases all its resources.
376 * @param[in] buffer The @a ckmc_raw_buffer_s structure to destroy
379 void ckmc_buffer_free(ckmc_raw_buffer_s *buffer);
382 * @brief Creates a new @a ckmc_cert_s handle and returns it.
386 * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
389 * @param[in] raw_cert The byte array of certificate
390 * @param[in] cert_size The byte size of raw_cert
391 * @param[in] data_format The encoding format of raw_cert
392 * @param[out] ppcert The pointer to a newly created @a ckmc_cert_s handle
394 * @return #CKMC_ERROR_NONE on success,
395 * otherwise a negative error value
397 * @retval #CKMC_ERROR_NONE Successful
398 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
399 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
401 * @see ckmc_cert_free()
402 * @see ckmc_load_cert_from_file()
405 int ckmc_cert_new(unsigned char *raw_cert,
407 ckmc_data_format_e data_format,
408 ckmc_cert_s **ppcert);
411 * @brief Destroys the @a ckmc_cert handle and releases all its resources.
415 * @param[in] cert The @a ckmc_cert_s handle to destroy
417 * @see ckmc_load_cert_from_file()
418 * @see ckmc_load_from_pkcs12_file
420 void ckmc_cert_free(ckmc_cert_s *cert);
423 * @brief Creates a new @a ckmc_cert_s handle from a given file and returns it.
427 * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
430 * @param[in] file_path The path of certificate file to be loaded \n
431 * The only DER or PEM encoded certificate file is supported
432 * @param[out] cert The pointer of newly created @a ckmc_cert_s handle
434 * @return #CKMC_ERROR_NONE on success,
435 * otherwise a negative error value
437 * @retval #CKMC_ERROR_NONE Successful
438 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
439 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid certificate file format
440 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
442 * @see ckmc_cert_free()
445 int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert);
448 * @brief Creates a new @a ckmc_pkcs12_s handle and returns it.
452 * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it
453 * is no longer needed.
454 * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly
455 * returned ckmc_pkcs12_s.
457 * @param[in] private_key @a ckmc_key_s handle to the private key (optional)
458 * @param[in] cert @a ckmc_cert_s handle to the certificate (optional)
459 * @param[in] ca_cert_list @a ckmc_cert_list_s list of chain certificate handles (optional)
460 * @param[out] pkcs12_bundle The pointer to a newly created @a ckmc_pkcs12_s handle
462 * @return #CKMC_ERROR_NONE on success,
463 * otherwise a negative error value
465 * @retval #CKMC_ERROR_NONE Successful
466 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or private_key, cert and
467 * ca_cert_list all are null
468 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
470 * @see ckmc_pkcs12_free()
471 * @see ckmc_load_from_pkcs12_file()
472 * @see ckmc_pkcs12_load()
475 * @see #ckmc_cert_list_s
476 * @see #ckmc_pkcs12_s
478 int ckmc_pkcs12_new(ckmc_key_s *private_key,
480 ckmc_cert_list_s *ca_cert_list,
481 ckmc_pkcs12_s **pkcs12_bundle);
484 * @deprecated Deprecated since 2.4. [Use ckmc_pkcs12_load() instead]
485 * @brief Creates a new @a ckmc_key_s(private key), @a ckmc_cert_s(certificate), and
486 * @a ckmc_cert_list_s(CA certificates) handle from a given PKCS#12 file and returns them.
490 * @remarks You must destroy the newly created @a ckmc_key_s, @a ckmc_cert_s, and
491 * @a ckmc_cert_list_s by calling ckmc_key_free(), ckmc_cert_free(), and
492 * ckmc_cert_list_all_free() if they are no longer needed.
494 * @param[in] file_path The path of PKCS12 file to be loaded
495 * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n
496 * If PKCS12 file is not encrypted, passphrase can be null
497 * @param[out] private_key The pointer of newly created @a ckmc_key_s handle for a private key
498 * @param[out] cert The pointer of newly created @a ckmc_cert_s handle for a certificate \n
499 * It is null if the PKCS12 file does not contain a certificate
500 * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
502 * It is null if the PKCS12 file does not contain CA certificates
504 * @return #CKMC_ERROR_NONE on success,
505 * otherwise a negative error value
507 * @retval #CKMC_ERROR_NONE Successful
508 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
509 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
510 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
512 * @see ckmc_pkcs12_new()
513 * @see ckmc_pkcs12_load()
514 * @see ckmc_key_free()
515 * @see ckmc_cert_free()
516 * @see ckmc_cert_list_all_free()
519 * @see #ckmc_cert_list_s
521 int ckmc_load_from_pkcs12_file(const char *file_path,
522 const char *passphrase,
523 ckmc_key_s **private_key, ckmc_cert_s **cert,
524 ckmc_cert_list_s **ca_cert_list);
527 * @brief Creates a new @a ckmc_pkcs12_s handle from a given PKCS#12 file and returns it.
531 * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if
532 * they are no longer needed.
534 * @param[in] file_path The path of PKCS12 file to be loaded
535 * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n
536 * If PKCS12 file is not encrypted, passphrase can be null
537 * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
539 * It is null if the PKCS12 file does not contain CA certificates
541 * @return #CKMC_ERROR_NONE on success,
542 * otherwise a negative error value
544 * @retval #CKMC_ERROR_NONE Successful
545 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
546 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
547 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
549 * @see ckmc_pkcs12_free()
550 * @see #ckmc_pkcs12_s
552 int ckmc_pkcs12_load(const char *file_path,
553 const char *passphrase,
554 ckmc_pkcs12_s **pkcs12_bundle);
557 * @brief Destroys the @a ckmc_pkcs12_s handle and releases all its resources.
561 * @param[in] pkcs12 The @a ckmc_pkcs12_s handle to destroy
563 * @see ckmc_pkcs12_new()
564 * @see ckmc_pkcs12_load()
566 void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12);
569 * @brief Creates a new @a ckmc_alias_list_s handle and returns it.
570 * The alias pointer in the returned @a ckmc_alias_list_s handle points to the provided
571 * characters and next is null.
575 * @remarks You must destroy the newly created @a ckmc_alias_list_s
576 * by calling ckmc_alias_list_free() or ckmc_alias_list_all_free() if it is no longer
579 * @param[in] alias The first item to be set in the newly created @a ckmc_alias_list_s
580 * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
582 * @return #CKMC_ERROR_NONE on success,
583 * otherwise a negative error value
585 * @retval #CKMC_ERROR_NONE Successful
586 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
587 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
589 * @see ckmc_alias_list_all_free()
590 * @see #ckmc_alias_list_s
592 int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list);
595 * @brief Creates a new @a ckmc_alias_list_s handle, adds it to a previous @a ckmc_alias_list_s and
596 * returns it. The alias pointer in the returned @a ckmc_alias_list_s handle points to the
597 * provided characters and next is null.
601 * @param[in] previous The last @a ckmc_alias_list_s handle to which a newly created
602 * @a ckmc_alias_list_s is added
603 * @param[in] alias The item to be set in the newly created @a ckmc_alias_list_s
604 * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle
606 * @return #CKMC_ERROR_NONE on success,
607 * otherwise a negative error value
609 * @retval #CKMC_ERROR_NONE Successful
610 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
611 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
613 * @see ckmc_alias_list_all_free()
614 * @see #ckmc_alias_list_s
616 int ckmc_alias_list_add(ckmc_alias_list_s *previous,
618 ckmc_alias_list_s **pplast);
621 * @brief Destroys the @a ckmc_alias_list_s handle and releases resources of @a ckmc_alias_list_s
622 * from the provided first handle cascadingly.
626 * @remarks It does not destroy an alias itself in @a ckmc_alias_list_s.
628 * @param[in] first The first @a ckmc_alias_list_s handle to destroy
630 * @see ckmc_alias_list_all_free()
631 * @see #ckmc_alias_list_s
633 void ckmc_alias_list_free(ckmc_alias_list_s *first);
636 * @brief Destroys the @a ckmc_alias_list_s handle and releases all its resources from the provided
637 * first handle cascadingly.
641 * @remarks It also destroys the alias 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_s
647 void ckmc_alias_list_all_free(ckmc_alias_list_s *first);
650 * @brief Creates a new @a ckmc_cert_list_s handle and returns it.
651 * The cert pointer in the returned @a ckmc_cert_list_s handle points to the provided
652 * @a ckmc_cert_s and next is null.
656 * @remarks You must destroy the newly created @a ckmc_cert_list_s by calling ckmc_cert_list_free()
657 * or ckmc_cert_list_all_free() if it is no longer needed.
659 * @param[in] cert The first item to be set in the newly created @a ckmc_cert_list_s
660 * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
662 * @return #CKMC_ERROR_NONE on success,
663 * otherwise a negative error value
665 * @retval #CKMC_ERROR_NONE Successful
666 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
667 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
669 * @see ckmc_cert_list_all_free()
670 * @see #ckmc_cert_list_s
672 int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list);
675 * @brief Creates a new @a ckmc_cert_list_s handle, adds it to a previous @a ckmc_cert_list_s and
676 * returns it. The cert pointer in the returned @a ckmc_alias_list_s handle points to the
677 * provided @a ckmc_cert_s and next is null.
681 * @param[in] previous The last @a ckmc_cert_list_s handle to which a newly created
682 * @a ckmc_cert_list_s is added
683 * @param[in] cert The item to be set in the newly created @a ckmc_cert_list_s
684 * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle
686 * @return #CKMC_ERROR_NONE on success,
687 * otherwise a negative error value
689 * @retval #CKMC_ERROR_NONE Successful
690 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
691 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
693 * @see ckmc_cert_list_all_free()
694 * @see #ckmc_cert_list_s
696 int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast);
699 * @brief Destroys the @a ckmc_cert_list_s handle and releases resources of @a ckmc_cert_list_s
700 * from the provided first handle cascadingly.
704 * @remarks It does not destroy @a ckmc_cert_s itself in @a ckmc_cert_list_s.
706 * @param[in] first The first @a ckmc_cert_list_s handle to destroy
708 * @see ckmc_cert_list_all_free()
709 * @see #ckmc_cert_list_s
711 void ckmc_cert_list_free(ckmc_cert_list_s *first);
714 * @brief Destroys the @a ckmc_cert_list_s handle and releases all its resources from the provided
715 * first handle cascadingly.
719 * @remarks It also destroys @a ckmc_cert_s 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_s
725 void ckmc_cert_list_all_free(ckmc_cert_list_s *first);
728 * @brief Creates new parameter list.
732 * @remarks Caller is responsible for freeing it with ckmc_param_list_free().
734 * @param[in] pparams Double pointer to the handle of param list to which the
735 * newly created algorithm param list will be assigned
737 * @return #CKMC_ERROR_NONE on success,
738 * otherwise a negative error value
740 * @retval #CKMC_ERROR_NONE Successful
741 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
743 * @see ckmc_param_list_set_integer()
744 * @see ckmc_param_list_set_buffer()
745 * @see ckmc_param_list_free()
746 * @see ckmc_generate_new_params()
747 * @see #ckmc_param_list_h
748 * @see #ckmc_param_name_e
750 int ckmc_param_list_new(ckmc_param_list_h *pparams);
753 * @brief Sets integer parameter to the list.
757 * @remarks Caller is responsible for @a ckmc_param_list_h creation.
759 * @param[in] params Algorithm param list handle created with
760 * ckmc_param_list_new() or ckmc_generate_new_params() \n
761 * New param with @a name and @a value will be set` here
762 * @param[in] name Name of parameter to set \n
763 * Existing parameter will be overwritten \n
764 * Passing invalid parameter name will result in an error
765 * @param[in] value Value of the parameter in form of a integer
767 * @return #CKMC_ERROR_NONE on success,
768 * otherwise a negative error value
770 * @retval #CKMC_ERROR_NONE Successful
771 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
773 * @see ckmc_param_list_new()
774 * @see ckmc_param_list_set_buffer()
775 * @see ckmc_param_list_get_integer()
776 * @see ckmc_param_list_get_buffer()
777 * @see ckmc_param_list_free()
778 * @see ckmc_generate_new_params()
779 * @see #ckmc_param_list_h
780 * @see #ckmc_param_name_e
782 int ckmc_param_list_set_integer(ckmc_param_list_h params,
783 ckmc_param_name_e name,
787 * @brief Sets buffer parameter to the list.
791 * @remarks Caller is responsible for @a ckmc_param_list_h creation.
793 * @param[in] params Algorithm param list handle created with
794 * ckmc_param_list_new() or ckmc_generate_new_params()
795 * New param with @a name and @a buffer will be set here
796 * @param[in] name Name of parameter to set \n
797 * Existing parameter will be overwritten \n
798 * Passing invalid parameter name will result in an error
799 * @param[in] buffer Value of the parameter in form of a buffer \n
800 * Caller is responsible for creating and freeing the buffer
802 * @return #CKMC_ERROR_NONE on success,
803 * otherwise a negative error value
805 * @retval #CKMC_ERROR_NONE Successful
806 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
808 * @see ckmc_param_list_new()
809 * @see ckmc_param_list_set_integer()
810 * @see ckmc_param_list_get_integer()
811 * @see ckmc_param_list_get_buffer()
812 * @see ckmc_param_list_free()
813 * @see ckmc_generate_new_params()
814 * @see #ckmc_param_list_h
815 * @see #ckmc_param_name_e
817 int ckmc_param_list_set_buffer(ckmc_param_list_h params,
818 ckmc_param_name_e name,
819 const ckmc_raw_buffer_s *buffer);
822 * @brief Gets integer parameter from the list.
826 * @remarks Caller is responsible for @a ckmc_param_list_h creation.
828 * @param[in] params Algorithm param list handle created with
829 * ckmc_param_list_new() or ckmc_generate_new_params()
830 * which contains param with @a name
831 * @param[in] name Name of parameter to get
832 * @param[out] pvalue Value of the parameter in form of a integer
834 * @return #CKMC_ERROR_NONE on success,
835 * otherwise a negative error value
837 * @retval #CKMC_ERROR_NONE Successful
838 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
840 * @see ckmc_param_list_new()
841 * @see ckmc_param_list_set_integer()
842 * @see ckmc_param_list_set_buffer()
843 * @see ckmc_param_list_get_buffer()
844 * @see ckmc_param_list_free()
845 * @see ckmc_generate_new_params()
846 * @see #ckmc_param_list_h
847 * @see #ckmc_param_name_e
850 int ckmc_param_list_get_integer(ckmc_param_list_h params,
851 ckmc_param_name_e name,
855 * @brief Gets buffer parameter from the list.
859 * @remarks Caller is responsible for @a ckmc_param_list_h creation.
861 * @param[in] params Algorithm param list handle created with
862 * ckmc_param_list_new() or ckmc_generate_new_params()
863 * which contains param with @a name
864 * @param[in] name Name of parameter to get
865 * @param[out] ppbuffer Value of the parameter in form of a buffer \n
866 * Caller is responsible for creating and freeing the buffer
868 * @return #CKMC_ERROR_NONE on success,
869 * otherwise a negative error value
871 * @retval #CKMC_ERROR_NONE Successful
872 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
874 * @see ckmc_param_list_new()
875 * @see ckmc_param_list_set_integer()
876 * @see ckmc_param_list_set_buffer()
877 * @see ckmc_param_list_get_integer()
878 * @see ckmc_param_list_free()
879 * @see ckmc_generate_new_params()
880 * @see ckmc_buffer_free()
881 * @see #ckmc_param_list_h
882 * @see #ckmc_param_name_e
884 int ckmc_param_list_get_buffer(ckmc_param_list_h params,
885 ckmc_param_name_e name,
886 ckmc_raw_buffer_s **ppbuffer);
889 * @brief Frees previously allocated list of algorithm params.
893 * @param[in] first First element of the list to be freed
895 * @see ckmc_param_list_new()
896 * @see ckmc_param_list_set_integer()
897 * @see ckmc_param_list_set_buffer()
898 * @see ckmc_param_list_get_integer()
899 * @see ckmc_param_list_get_buffer()
900 * @see ckmc_generate_new_params()
901 * @see #ckmc_param_list_h
902 * @see #ckmc_param_name_e
904 void ckmc_param_list_free(ckmc_param_list_h params);
907 * @brief Generates algorithm parameters for a given algorithm type and set them to the list.
911 * @remarks Caller is responsible for @a ckmc_param_list_h destruction.
912 * @remarks Algorithm parameters are set to default values. Optional fields are left empty.
913 * Initialization vectors are left empty (they have to be set manually). Caller is
914 * responsible for freeing the list with ckmc_param_list_free().
915 * @remarks If the function returns error, provided param list may contain some of default parameters.
917 * @param[in] type Type of the algorithm
918 * @param[out] pparams Newly generated handle of param list which should be freed by caller after used
920 * @return #CKMC_ERROR_NONE on success,
921 * otherwise a negative error value
923 * @retval #CKMC_ERROR_NONE Successful
924 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
926 * @see ckmc_param_list_new()
927 * @see ckmc_param_list_set_integer()
928 * @see ckmc_param_list_set_buffer()
929 * @see ckmc_param_list_get_integer()
930 * @see ckmc_param_list_get_buffer()
931 * @see ckmc_param_list_free()
932 * @see #ckmc_param_list_h
933 * @see #ckmc_param_name_e
935 int ckmc_generate_new_params(ckmc_algo_type_e type, ckmc_param_list_h *pparams);
945 #endif /* __TIZEN_CORE_CKMC_TYPE_H */