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 * @brief Separator between alias and label.
54 * @remarks Alias can be provided as an alias alone, or together with label - in this
55 * case, separator " " (space bar) is used to separate label and alias.
57 * @see key-manager_doc.h
59 KEY_MANAGER_CAPI extern char const * const ckmc_label_name_separator;
62 * This is deprecated: Tizen 3.0 does not use smack labels directly.
63 * You should use pkgId instead.
65 * @brief Shared owner label
67 * @remarks Shared database label - user may be given permission to access shared
68 * database items. In such case, the alias should contain shared database
71 * @see #ckmc_label_name_separator
72 * @see key-manager_doc.h
74 KEY_MANAGER_CAPI extern char const * const ckmc_label_shared_owner;
77 * alias can be provided as an alias alone, or together with owner id - in this
78 * case, separator " " (space bar) is used to separate id and alias.
79 * @see key-manager_doc.h
81 KEY_MANAGER_CAPI extern char const * const ckmc_owner_id_separator;
84 * ckmc_owner_id_system constains id connected with all SYSTEM applications that runs
85 * with uid less then 5000.
87 * Client should use ckmc_owner_id_system to access data owned by system application
88 * and stored in system database.
90 * Note: Client must have permission to access proper row.
92 KEY_MANAGER_CAPI extern char const * const ckmc_owner_id_system;
95 * @brief Enumeration for key types of key manager.
98 typedef enum __ckmc_key_type {
99 CKMC_KEY_NONE = 0, /**< Key type not specified */
100 CKMC_KEY_RSA_PUBLIC, /**< RSA public key */
101 CKMC_KEY_RSA_PRIVATE, /**< RSA private key */
102 CKMC_KEY_ECDSA_PUBLIC, /**< ECDSA public key */
103 CKMC_KEY_ECDSA_PRIVATE, /**< ECDSA private key */
104 CKMC_KEY_DSA_PUBLIC, /**< DSA public key */
105 CKMC_KEY_DSA_PRIVATE, /**< DSA private key */
106 CKMC_KEY_AES, /**< AES key */
110 * @brief Enumeration for data format.
113 typedef enum __ckmc_data_format {
114 CKMC_FORM_DER_BASE64 = 0, /**< DER format base64 encoded data */
115 CKMC_FORM_DER, /**< DER encoded data */
116 CKMC_FORM_PEM /**< PEM encoded data. It consists of the DER format base64 encoded
117 with additional header and footer lines. */
118 } ckmc_data_format_e;
121 * @brief Enumeration for elliptic curve.
124 typedef enum __ckmc_ec_type {
125 CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended
126 elliptic curve domain */
127 CKMC_EC_PRIME256V1, /**< "SEC 2" recommended elliptic curve domain - secp256r1 */
128 CKMC_EC_SECP384R1 /**< NIST curve P-384 (covers "secp384r1", the elliptic curve domain
129 listed in See SEC 2 */
133 * @brief Enumeration for hash algorithm.
136 typedef enum __ckmc_hash_algo {
137 CKMC_HASH_NONE = 0, /**< No Hash Algorithm */
138 CKMC_HASH_SHA1, /**< Hash Algorithm SHA1 */
139 CKMC_HASH_SHA256, /**< Hash Algorithm SHA256 */
140 CKMC_HASH_SHA384, /**< Hash Algorithm SHA384 */
141 CKMC_HASH_SHA512 /**< Hash Algorithm SHA512 */
145 * @brief Enumeration for RSA padding algorithm.
148 typedef enum __ckmc_rsa_padding_algo {
149 CKMC_NONE_PADDING = 0, /**< No Padding */
150 CKMC_PKCS1_PADDING, /**< PKCS#1 Padding */
151 CKMC_X931_PADDING /**< X9.31 padding */
152 } ckmc_rsa_padding_algo_e;
155 * @deprecated Deprecated since 2.4. [Use ckmc_permission_e() instead]
156 * @brief Enumeration for database access rights.
159 typedef enum __ckmc_access_right{
160 CKMC_AR_READ = 0, /**< Access right for read*/
161 CKMC_AR_READ_REMOVE /**< Access right for read and remove*/
162 } ckmc_access_right_e;
165 * @brief Enumeration for permissions to access/modify alias.
168 typedef enum __ckmc_permission{
169 CKMC_PERMISSION_NONE = 0x00, /**< Clear permissions */
170 CKMC_PERMISSION_READ = 0x01, /**< Eead allowed */
171 CKMC_PERMISSION_REMOVE = 0x02 /**< Remove allowed */
175 * @brief The structure for binary buffer used in key manager CAPI.
178 typedef struct __ckmc_raw_buff {
179 unsigned char* data; /**< Byte array containing binary data */
180 size_t size; /**< The size of the binary data */
184 * @brief The structure for a policy for storing key/certificate/binary data.
187 typedef struct __ckmc_policy {
188 char* password; /**< Byte array used to encrypt data inside CKM. If it is not null, the data
189 (or key, or certificate) is stored encrypted with this password inside
191 bool extractable; /**< If true key may be extracted from storage */
195 * @brief The structure for key used in key manager CAPI.
198 typedef struct __ckmc_key {
199 unsigned char* raw_key; /**< Byte array of key. raw_key may be encrypted with password */
200 size_t key_size; /**< The byte size of raw_key */
201 ckmc_key_type_e key_type; /**< The raw_key's type */
202 char* password; /**< Byte array used to decrypt data raw_key inside key manager. */
206 * @brief The structure for certificate used in key manager CAPI.
209 typedef struct __ckmc_cert {
210 unsigned char* raw_cert; /**< Byte array of certificate */
211 size_t cert_size; /**< Byte size of raw_cert */
212 ckmc_data_format_e data_format; /**< Raw_cert's encoding format */
216 * @brief The structure for linked list of alias.
219 typedef struct __ckmc_alias_list {
220 char *alias; /**< The name of key, certificate or data stored in key manager */
221 struct __ckmc_alias_list *next; /**< The pointer pointing to the next ckmc_alias_list_s */
225 * @brief The structure for linked list of ckmc_cert_s
228 typedef struct __ckmc_cert_list {
229 ckmc_cert_s *cert; /**< The pointer of ckmc_cert_s */
230 struct __ckmc_cert_list *next; /**< The pointer pointing to the next ckmc_cert_list_s */
234 * @brief Enumeration for OCSP status.
237 typedef enum __ckmc_ocsp_status {
238 CKMC_OCSP_STATUS_GOOD = 0, /**< OCSP status is good */
239 CKMC_OCSP_STATUS_REVOKED, /**< The certificate is revoked */
240 CKMC_OCSP_STATUS_UNKNOWN, /**< Unknown error */
241 CKMC_OCSP_ERROR_UNSUPPORTED, /**< The certificate does not provide OCSP extension */
242 CKMC_OCSP_ERROR_INVALID_URL, /**< The invalid URL in certificate OCSP extension */
243 CKMC_OCSP_ERROR_INVALID_RESPONSE, /**< The invalid response from OCSP server */
244 CKMC_OCSP_ERROR_REMOTE, /**< OCSP remote server error */
245 CKMC_OCSP_ERROR_NET, /**< Network connection error */
246 CKMC_OCSP_ERROR_INTERNAL /**< OpenSSL API error */
247 } ckmc_ocsp_status_e;
250 * @brief The structure for PKCS12 used in key manager CAPI.
253 typedef struct __ckmc_pkcs12 {
254 ckmc_key_s *priv_key; /**< The private key, may be null */
255 ckmc_cert_s *cert; /**< The certificate, may be null */
256 ckmc_cert_list_s *ca_chain; /**< The chain certificate list, may be null */
260 * @brief Enumeration for crypto algorithm parameters.
263 * @see #ckmc_algo_type_e
265 typedef enum __ckmc_param_name {
266 CKMC_PARAM_ALGO_TYPE = 1,
268 CKMC_PARAM_ED_IV = 101, /**< 16B buffer (up to 2^64-1 bytes long in case of AES GCM) */
269 CKMC_PARAM_ED_CTR_LEN, /**< integer - ctr length in bits*/
270 CKMC_PARAM_ED_AAD, /**< buffer */
271 CKMC_PARAM_ED_TAG_LEN, /**< integer - tag length in bits */
272 CKMC_PARAM_ED_LABEL, /**< buffer */
274 CKMC_PARAM_GEN_KEY_LEN = 201, /**< integer - key length in bits */
275 CKMC_PARAM_GEN_EC, /**< integer - elliptic curve (ckmc_ec_type_e) */
277 CKMC_PARAM_SV_HASH_ALGO = 301, /**< integer - hash algorithm (ckmc_hash_algo_e) */
278 CKMC_PARAM_SV_RSA_PADDING /**< integer - RSA padding (ckmc_rsa_padding_algo_e) */
282 * @brief Structure for algorithm parameter list.
285 typedef struct __ckmc_param_list ckmc_param_list_s;
288 * @brief Enumeration for crypto algorithm types.
291 * @see #ckmc_param_name_e
293 typedef enum __ckmc_algo_type {
294 CKMC_ALGO_AES_CTR = 1, /**< AES-CTR algorithm
295 Supported parameters:
296 - CKMC_PARAM_ALGO_TYPE,
298 - CKMC_PARAM_ED_CTR_LEN (128 only) */
300 CKMC_ALGO_AES_CBC, /**< AES-CBC algorithm
301 Supported parameters:
302 - CKMC_PARAM_ALGO_TYPE,
303 - CKMC_PARAM_ED_IV */
305 CKMC_ALGO_AES_GCM, /**< AES-GCM algorithm
306 Supported parameters:
307 - CKMC_PARAM_ALGO_TYPE,
309 - CKMC_PARAM_ED_TAG_LEN
310 - CKMC_PARAM_ED_AAD */
312 CKMC_ALGO_AES_CFB, /**< AES-CFB algorithm
313 Supported parameters:
314 - CKMC_PARAM_ALGO_TYPE,
315 - CKMC_PARAM_ED_IV */
317 CKMC_ALGO_RSA_OAEP, /**< RSA-OAEP algorithm
318 Supported parameters:
319 - CKMC_PARAM_ALGO_TYPE,
320 - CKMC_PARAM_ED_LABEL */
322 CKMC_ALGO_RSA_SV, /**< RSA algorithm used for signing/verification
323 Supported parameters:
324 - CKMC_PARAM_ALGO_TYPE,
325 - CKMC_PARAM_SV_HASH_ALGO
326 - CKMC_PARAM_SV_RSA_PADDING */
328 CKMC_ALGO_DSA_SV, /**< DSA algorithm used for signing/verification
329 Supported parameters:
330 - CKMC_PARAM_ALGO_TYPE,
331 - CKMC_PARAM_SV_HASH_ALGO */
333 CKMC_ALGO_ECDSA_SV, /**< ECDA algorithm used for signing/verification
334 Supported parameters:
335 - CKMC_PARAM_ALGO_TYPE,
336 - CKMC_PARAM_SV_HASH_ALGO */
338 CKMC_ALGO_RSA_GEN, /**< RSA algorithm used for key generation
339 Supported parameters:
340 - CKMC_PARAM_ALGO_TYPE,
341 - CKMC_PARAM_GEN_KEY_LEN */
343 CKMC_ALGO_DSA_GEN, /**< DSA algorithm used for key generation
344 Supported parameters:
345 - CKMC_PARAM_ALGO_TYPE,
346 - CKMC_PARAM_GEN_KEY_LEN */
348 CKMC_ALGO_ECDSA_GEN, /**< ECDSA algorithm used for key generation
349 Supported parameters:
350 - CKMC_PARAM_ALGO_TYPE,
351 - CKMC_PARAM_GEN_EC */
353 CKMC_ALGO_AES_GEN, /**< AES key generation
354 Supported parameters:
355 - CKMC_PARAM_ALGO_TYPE,
356 - CKMC_PARAM_GEN_KEY_LEN */
360 * @brief Creates a new @a ckmc_key_s handle and returns it.
364 * @remarks You must destroy the newly created @a ckmc_key_s by calling ckmc_key_free() if it is no
367 * @param[in] raw_key The byte array of key \n
368 * @a raw_key may be encrypted with password
369 * @param[in] key_size The byte size of @a raw_key
370 * @param[in] key_type The @a raw_key's type
371 * @param[in] password The byte array used to decrypt @a raw_key inside key manager \n
372 * If @a raw_key is not encrypted, @a password can be null
373 * @param[out] ppkey The pointer to a newly created @a ckmc_key_s handle
375 * @return #CKMC_ERROR_NONE on success,
376 * otherwise a negative error value
378 * @retval #CKMC_ERROR_NONE Successful
379 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
380 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
382 * @see ckmc_key_free()
385 int ckmc_key_new(unsigned char *raw_key,
387 ckmc_key_type_e key_type,
388 char *password, ckmc_key_s **ppkey);
391 * @brief Destroys the @a ckmc_key_s handle and releases all its resources.
395 * @param[in] key The @a ckmc_key_s handle to destroy
398 void ckmc_key_free(ckmc_key_s *key);
401 * @brief Creates a new @a ckmc_raw_buffer_s handle and returns it.
405 * @remarks You must destroy the newly created @a ckmc_raw_buffer_s by calling ckmc_buffer_free() if
406 * it is no longer needed.
408 * @param[in] data The byte array of buffer
409 * @param[in] size The byte size of buffer
410 * @param[out] ppbuffer The pointer to a newly created @a ckmc_buffer_s handle
412 * @return #CKMC_ERROR_NONE on success,
413 * otherwise a negative error value
415 * @retval #CKMC_ERROR_NONE Successful
416 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
417 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
419 * @see ckmc_buffer_free()
420 * @see #ckmc_raw_buffer_s
422 int ckmc_buffer_new(unsigned char *data, size_t size, ckmc_raw_buffer_s **ppbuffer);
425 * @brief Destroys the @a ckmc_raw_buffer_s handle and releases all its resources.
429 * @param[in] buffer The @a ckmc_raw_buffer_s structure to destroy
432 void ckmc_buffer_free(ckmc_raw_buffer_s *buffer);
435 * @brief Creates a new @a ckmc_cert_s handle and returns it.
439 * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
442 * @param[in] raw_cert The byte array of certificate
443 * @param[in] cert_size The byte size of raw_cert
444 * @param[in] data_format The encoding format of raw_cert
445 * @param[out] ppcert The pointer to a newly created @a ckmc_cert_s handle
447 * @return #CKMC_ERROR_NONE on success,
448 * otherwise a negative error value
450 * @retval #CKMC_ERROR_NONE Successful
451 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
452 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
454 * @see ckmc_cert_free()
455 * @see ckmc_load_cert_from_file()
458 int ckmc_cert_new(unsigned char *raw_cert,
460 ckmc_data_format_e data_format,
461 ckmc_cert_s **ppcert);
464 * @brief Destroys the @a ckmc_cert handle and releases all its resources.
468 * @param[in] cert The @a ckmc_cert_s handle to destroy
470 * @see ckmc_load_cert_from_file()
471 * @see ckmc_load_from_pkcs12_file
473 void ckmc_cert_free(ckmc_cert_s *cert);
476 * @brief Creates a new @a ckmc_cert_s handle from a given file and returns it.
480 * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
483 * @param[in] file_path The path of certificate file to be loaded \n
484 * The only DER or PEM encoded certificate file is supported
485 * @param[out] cert The pointer of newly created @a ckmc_cert_s handle
487 * @return #CKMC_ERROR_NONE on success,
488 * otherwise a negative error value
490 * @retval #CKMC_ERROR_NONE Successful
491 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
492 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid certificate file format
493 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
495 * @see ckmc_cert_free()
498 int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert);
501 * @brief Creates a new @a ckmc_pkcs12_s handle and returns it.
505 * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it
506 * is no longer needed.
507 * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly
508 * returned ckmc_pkcs12_s.
510 * @param[in] private_key @a ckmc_key_s handle to the private key (optional)
511 * @param[in] cert @a ckmc_cert_s handle to the certificate (optional)
512 * @param[in] ca_cert_list @a ckmc_cert_list_s list of chain certificate handles (optional)
513 * @param[out] pkcs12_bundle The pointer to a newly created @a ckmc_pkcs12_s handle
515 * @return #CKMC_ERROR_NONE on success,
516 * otherwise a negative error value
518 * @retval #CKMC_ERROR_NONE Successful
519 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or private_key, cert and
520 * ca_cert_list all are null
521 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
523 * @see ckmc_pkcs12_free()
524 * @see ckmc_load_from_pkcs12_file()
525 * @see ckmc_pkcs12_load()
528 * @see #ckmc_cert_list_s
529 * @see #ckmc_pkcs12_s
531 int ckmc_pkcs12_new(ckmc_key_s *private_key,
533 ckmc_cert_list_s *ca_cert_list,
534 ckmc_pkcs12_s **pkcs12_bundle);
537 * @deprecated Deprecated since 2.4. [Use ckmc_pkcs12_load() instead]
538 * @brief Creates a new @a ckmc_key_s(private key), @a ckmc_cert_s(certificate), and
539 * @a ckmc_cert_list_s(CA certificates) handle from a given PKCS#12 file and returns them.
543 * @remarks You must destroy the newly created @a ckmc_key_s, @a ckmc_cert_s, and
544 * @a ckmc_cert_list_s by calling ckmc_key_free(), ckmc_cert_free(), and
545 * ckmc_cert_list_all_free() if they are no longer needed.
547 * @param[in] file_path The path of PKCS12 file to be loaded
548 * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n
549 * If PKCS12 file is not encrypted, passphrase can be null
550 * @param[out] private_key The pointer of newly created @a ckmc_key_s handle for a private key
551 * @param[out] cert The pointer of newly created @a ckmc_cert_s handle for a certificate \n
552 * It is null if the PKCS12 file does not contain a certificate
553 * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
555 * It is null if the PKCS12 file does not contain CA certificates
557 * @return #CKMC_ERROR_NONE on success,
558 * otherwise a negative error value
560 * @retval #CKMC_ERROR_NONE Successful
561 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
562 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
563 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
565 * @see ckmc_pkcs12_new()
566 * @see ckmc_pkcs12_load()
567 * @see ckmc_key_free()
568 * @see ckmc_cert_free()
569 * @see ckmc_cert_list_all_free()
572 * @see #ckmc_cert_list_s
574 int ckmc_load_from_pkcs12_file(const char *file_path,
575 const char *passphrase,
576 ckmc_key_s **private_key, ckmc_cert_s **cert,
577 ckmc_cert_list_s **ca_cert_list);
580 * @brief Creates a new @a ckmc_pkcs12_s handle from a given PKCS#12 file and returns it.
584 * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if
585 * they are no longer needed.
587 * @param[in] file_path The path of PKCS12 file to be loaded
588 * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n
589 * If PKCS12 file is not encrypted, passphrase can be null
590 * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
592 * It is null if the PKCS12 file does not contain CA certificates
594 * @return #CKMC_ERROR_NONE on success,
595 * otherwise a negative error value
597 * @retval #CKMC_ERROR_NONE Successful
598 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
599 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
600 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
602 * @see ckmc_pkcs12_free()
603 * @see #ckmc_pkcs12_s
605 int ckmc_pkcs12_load(const char *file_path,
606 const char *passphrase,
607 ckmc_pkcs12_s **pkcs12_bundle);
610 * @brief Destroys the @a ckmc_pkcs12_s handle and releases all its resources.
614 * @param[in] pkcs12 The @a ckmc_pkcs12_s handle to destroy
616 * @see ckmc_pkcs12_new()
617 * @see ckmc_pkcs12_load()
619 void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12);
622 * @brief Creates a new @a ckmc_alias_list_s handle and returns it.
623 * The alias pointer in the returned @a ckmc_alias_list_s handle points to the provided
624 * characters and next is null.
628 * @remarks You must destroy the newly created @a ckmc_alias_list_s
629 * by calling ckmc_alias_list_free() or ckmc_alias_list_all_free() if it is no longer
632 * @param[in] alias The first item to be set in the newly created @a ckmc_alias_list_s
633 * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
635 * @return #CKMC_ERROR_NONE on success,
636 * otherwise a negative error value
638 * @retval #CKMC_ERROR_NONE Successful
639 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
640 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
642 * @see ckmc_alias_list_all_free()
643 * @see #ckmc_alias_list_s
645 int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list);
648 * @brief Creates a new @a ckmc_alias_list_s handle, adds it to a previous @a ckmc_alias_list_s and
649 * returns it. The alias pointer in the returned @a ckmc_alias_list_s handle points to the
650 * provided characters and next is null.
654 * @param[in] previous The last @a ckmc_alias_list_s handle to which a newly created
655 * @a ckmc_alias_list_s is added
656 * @param[in] alias The item to be set in the newly created @a ckmc_alias_list_s
657 * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle
659 * @return #CKMC_ERROR_NONE on success,
660 * otherwise a negative error value
662 * @retval #CKMC_ERROR_NONE Successful
663 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
664 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
666 * @see ckmc_alias_list_all_free()
667 * @see #ckmc_alias_list_s
669 int ckmc_alias_list_add(ckmc_alias_list_s *previous,
671 ckmc_alias_list_s **pplast);
674 * @brief Destroys the @a ckmc_alias_list_s handle and releases resources of @a ckmc_alias_list_s
675 * from the provided first handle cascadingly.
679 * @remarks It does not destroy an alias itself in @a ckmc_alias_list_s.
681 * @param[in] first The first @a ckmc_alias_list_s handle to destroy
683 * @see ckmc_alias_list_all_free()
684 * @see #ckmc_alias_list_s
686 void ckmc_alias_list_free(ckmc_alias_list_s *first);
689 * @brief Destroys the @a ckmc_alias_list_s handle and releases all its resources from the provided
690 * first handle cascadingly.
694 * @remarks It also destroys the alias in @a ckmc_alias_list_s.
696 * @param[in] first The first @a ckmc_alias_list_s handle to destroy
698 * @see #ckmc_alias_list_s
700 void ckmc_alias_list_all_free(ckmc_alias_list_s *first);
703 * @brief Creates a new @a ckmc_cert_list_s handle and returns it.
704 * The cert pointer in the returned @a ckmc_cert_list_s handle points to the provided
705 * @a ckmc_cert_s and next is null.
709 * @remarks You must destroy the newly created @a ckmc_cert_list_s by calling ckmc_cert_list_free()
710 * or ckmc_cert_list_all_free() if it is no longer needed.
712 * @param[in] cert The first item to be set in the newly created @a ckmc_cert_list_s
713 * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
715 * @return #CKMC_ERROR_NONE on success,
716 * otherwise a negative error value
718 * @retval #CKMC_ERROR_NONE Successful
719 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
720 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
722 * @see ckmc_cert_list_all_free()
723 * @see #ckmc_cert_list_s
725 int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list);
728 * @brief Creates a new @a ckmc_cert_list_s handle, adds it to a previous @a ckmc_cert_list_s and
729 * returns it. The cert pointer in the returned @a ckmc_alias_list_s handle points to the
730 * provided @a ckmc_cert_s and next is null.
734 * @param[in] previous The last @a ckmc_cert_list_s handle to which a newly created
735 * @a ckmc_cert_list_s is added
736 * @param[in] cert The item to be set in the newly created @a ckmc_cert_list_s
737 * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle
739 * @return #CKMC_ERROR_NONE on success,
740 * otherwise a negative error value
742 * @retval #CKMC_ERROR_NONE Successful
743 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
744 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
746 * @see ckmc_cert_list_all_free()
747 * @see #ckmc_cert_list_s
749 int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast);
752 * @brief Destroys the @a ckmc_cert_list_s handle and releases resources of @a ckmc_cert_list_s
753 * from the provided first handle cascadingly.
757 * @remarks It does not destroy @a ckmc_cert_s itself in @a ckmc_cert_list_s.
759 * @param[in] first The first @a ckmc_cert_list_s handle to destroy
761 * @see ckmc_cert_list_all_free()
762 * @see #ckmc_cert_list_s
764 void ckmc_cert_list_free(ckmc_cert_list_s *first);
767 * @brief Destroys the @a ckmc_cert_list_s handle and releases all its resources from the provided
768 * first handle cascadingly.
772 * @remarks It also destroys @a ckmc_cert_s in @a ckmc_cert_list_s.
774 * @param[in] first The first @a ckmc_cert_list_s handle to destroy
776 * @see #ckmc_cert_list_s
778 void ckmc_cert_list_all_free(ckmc_cert_list_s *first);
781 * @brief Creates new parameter list
785 * @remarks Caller is responsible for freeing it with ckmc_param_list_free()
787 * @param[in] ppparam_list Double pointer to the list variable to which the newly created list will
790 * @return #CKMC_ERROR_NONE on success,
791 * otherwise a negative error value
793 * @retval #CKMC_ERROR_NONE Successful
794 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
796 * @see ckmc_param_list_add_integer()
797 * @see ckmc_param_list_add_buffer()
798 * @see ckmc_param_list_free()
799 * @see ckmc_generate_params()
800 * @see #ckmc_param_list_s
801 * @see #ckmc_param_name_e
803 int ckmc_param_list_new(ckmc_param_list_s **ppparams);
806 * @brief Adds integer parameter to the list
810 * @remarks Caller is responsible for @a ckmc_param_list_s creation.
812 * @param[in] params List of params created with ckmc_param_list_new() or
813 * ckmc_generate_params()
814 * @param[in] name Name of parameter to add \n
815 * Existing parameter will be overwritten \n
816 * Passing invalid parameter name will result in an error
817 * @param[in] value Value of the parameter in form of a integer
819 * @return #CKMC_ERROR_NONE on success,
820 * otherwise a negative error value
822 * @retval #CKMC_ERROR_NONE Successful
823 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
825 * @see ckmc_param_list_new()
826 * @see ckmc_param_list_add_buffer()
827 * @see ckmc_param_list_get_integer()
828 * @see ckmc_param_list_get_buffer()
829 * @see ckmc_param_list_free()
830 * @see ckmc_generate_params()
831 * @see #ckmc_param_list_s
832 * @see #ckmc_param_name_e
834 int ckmc_param_list_add_integer(ckmc_param_list_s *params,
835 ckmc_param_name_e name,
839 * @brief Adds buffer parameter to the list
843 * @remarks Caller is responsible for @a ckmc_param_list_s creation.
845 * @param[in] params List of params created with ckmc_param_list_new()
846 * or ckmc_generate_params()
847 * @param[in] name Name of parameter to add \n
848 * Existing parameter will be overwritten \n
849 * Passing invalid parameter name will result in an error
850 * @param[in] buffer Value of the parameter in form of a buffer \n
851 * Caller is responsible for creating and freeing the buffer
853 * @return #CKMC_ERROR_NONE on success,
854 * otherwise a negative error value
856 * @retval #CKMC_ERROR_NONE Successful
857 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
859 * @see ckmc_param_list_new()
860 * @see ckmc_param_list_add_integer()
861 * @see ckmc_param_list_get_integer()
862 * @see ckmc_param_list_get_buffer()
863 * @see ckmc_param_list_free()
864 * @see ckmc_generate_params()
865 * @see #ckmc_param_list_s
866 * @see #ckmc_param_name_e
868 int ckmc_param_list_add_buffer(ckmc_param_list_s *params,
869 ckmc_param_name_e name,
870 const ckmc_raw_buffer_s *buffer);
873 * @brief Gets integer parameter from the list.
877 * @remarks Caller is responsible for @a ckmc_param_list_s creation.
879 * @param[in] params List of params created with ckmc_param_list_new()
880 * or ckmc_generate_params()
881 * @param[in] name Name of parameter to get
882 * @param[out] value Value of the parameter in form of a integer
884 * @return #CKMC_ERROR_NONE on success,
885 * otherwise a negative error value
887 * @retval #CKMC_ERROR_NONE Successful
888 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
890 * @see ckmc_param_list_new()
891 * @see ckmc_param_list_add_integer()
892 * @see ckmc_param_list_add_buffer()
893 * @see ckmc_param_list_get_buffer()
894 * @see ckmc_param_list_free()
895 * @see ckmc_generate_params()
896 * @see #ckmc_param_list_s
897 * @see #ckmc_param_name_e
900 int ckmc_param_list_get_integer(const ckmc_param_list_s *params,
901 ckmc_param_name_e name,
905 * @brief Gets buffer parameter from the list.
909 * @remarks Caller is responsible for @a ckmc_param_list_s creation.
911 * @param[in] params List of params created with ckmc_param_list_new()
912 * or ckmc_generate_params()
913 * @param[in] name Name of parameter to get
914 * @param[out] buffer Value of the parameter in form of a buffer \n
915 * Caller is responsible for creating and freeing the buffer
917 * @return #CKMC_ERROR_NONE on success,
918 * otherwise a negative error value
920 * @retval #CKMC_ERROR_NONE Successful
921 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
923 * @see ckmc_param_list_new()
924 * @see ckmc_param_list_add_integer()
925 * @see ckmc_param_list_add_buffer()
926 * @see ckmc_param_list_get_integer()
927 * @see ckmc_param_list_free()
928 * @see ckmc_generate_params()
929 * @see #ckmc_param_list_s
930 * @see #ckmc_param_name_e
932 int ckmc_param_list_get_buffer(const ckmc_param_list_s *params,
933 ckmc_param_name_e name,
934 ckmc_raw_buffer_s **buffer);
937 * @brief Frees previously allocated list of algorithm params
941 * @param[in] first First element of the list to be freed
943 * @see ckmc_param_list_new()
944 * @see ckmc_param_list_add_integer()
945 * @see ckmc_param_list_add_buffer()
946 * @see ckmc_param_list_get_integer()
947 * @see ckmc_param_list_get_buffer()
948 * @see ckmc_generate_params()
949 * @see #ckmc_param_list_s
950 * @see #ckmc_param_name_e
953 void ckmc_param_list_free(ckmc_param_list_s *params);
956 * @brief Generates algorithm parameters for a given algorithm type and adds them to the list.
960 * @remarks Caller is responsible for @a ckmc_param_list_s creation and destruction.
961 * @remarks Algorithm parameters are set to default values. Optional fields are left empty.
962 * Initialization vectors are left empty (they have to be added manually). Existing params
963 * will be overwritten with default values. Caller is responsible for freeing the list with
964 * ckmc_param_list_free().
965 * @remarks If the function returns error, provided param list may contain some of default parameters.
967 * @param[in] type Type of the algorithm
968 * @param[out] params List of params to be filled \n
969 * List should be empty, otherwise an error will be returned
971 * @return #CKMC_ERROR_NONE on success,
972 * otherwise a negative error value
974 * @retval #CKMC_ERROR_NONE Successful
975 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
977 * @see ckmc_param_list_new()
978 * @see ckmc_param_list_add_integer()
979 * @see ckmc_param_list_add_buffer()
980 * @see ckmc_param_list_get_integer()
981 * @see ckmc_param_list_get_buffer()
982 * @see ckmc_param_list_free()
983 * @see #ckmc_param_list_s
984 * @see #ckmc_param_name_e
986 int ckmc_generate_params(ckmc_algo_type_e type, ckmc_param_list_s *params);
996 #endif /* __TIZEN_CORE_CKMC_TYPE_H */