2 * Copyright (c) 2000 - 2014 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 * alias can be provided as an alias alone, or together with label - in this
43 * case, separator " " (space bar) is used to separate label and alias.
44 * @see key-manager_doc.h
46 KEY_MANAGER_CAPI extern char const * const ckmc_label_name_separator;
49 * shared database label - user may be given permission to access shared
50 * database items. In such case, the alias should contain shared database
52 * @see ckmc_label_name_separator
53 * @see key-manager_doc.h
55 KEY_MANAGER_CAPI extern char const * const ckmc_label_shared_owner;
58 * @brief Enumeration for key types of key manager.
61 typedef enum __ckmc_key_type {
62 CKMC_KEY_NONE = 0, /**< key type not specified */
63 CKMC_KEY_RSA_PUBLIC, /**< RSA public key */
64 CKMC_KEY_RSA_PRIVATE, /**< RSA private key */
65 CKMC_KEY_ECDSA_PUBLIC, /**< ECDSA public key */
66 CKMC_KEY_ECDSA_PRIVATE, /**< ECDSA private key */
67 CKMC_KEY_DSA_PUBLIC, /**< DSA public key */
68 CKMC_KEY_DSA_PRIVATE, /**< DSA private key */
69 CKMC_KEY_AES, /**< AES key */
73 * @brief Enumeration for data format.
76 typedef enum __ckmc_data_format {
77 CKMC_FORM_DER_BASE64 = 0, /**< DER format base64 encoded data */
78 CKMC_FORM_DER, /**< DER encoded data */
79 CKMC_FORM_PEM /**< PEM encoded data. It consists of the DER format base64 encoded
80 with additional header and footer lines. */
84 * @brief Enumeration for elliptic curve.
87 typedef enum __ckmc_ec_type {
88 CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended
89 elliptic curve domain */
90 CKMC_EC_PRIME256V1, /**< "SEC 2" recommended elliptic curve domain - secp256r1 */
91 CKMC_EC_SECP384R1 /**< NIST curve P-384 (covers "secp384r1", the elliptic curve domain
92 listed in See SEC 2 */
96 * @brief Enumeration for hash algorithm.
99 typedef enum __ckmc_hash_algo {
100 CKMC_HASH_NONE = 0, /**< No Hash Algorithm */
101 CKMC_HASH_SHA1, /**< Hash Algorithm SHA1 */
102 CKMC_HASH_SHA256, /**< Hash Algorithm SHA256 */
103 CKMC_HASH_SHA384, /**< Hash Algorithm SHA384 */
104 CKMC_HASH_SHA512 /**< Hash Algorithm SHA512 */
108 * @brief Enumeration for RSA padding algorithm.
111 typedef enum __ckmc_rsa_padding_algo {
112 CKMC_NONE_PADDING = 0, /**< No Padding */
113 CKMC_PKCS1_PADDING, /**< PKCS#1 Padding */
114 CKMC_X931_PADDING /**< X9.31 padding */
115 } ckmc_rsa_padding_algo_e;
118 * @deprecated Deprecated since 2.4. [Use ckmc_permission_e() instead]
119 * @brief Enumeration for database access rights.
122 typedef enum __ckmc_access_right{
123 CKMC_AR_READ = 0, /**< access right for read*/
124 CKMC_AR_READ_REMOVE /**< access right for read and remove*/
125 } ckmc_access_right_e;
128 * @brief Enumeration for permissions to access/modify alias.
131 typedef enum __ckmc_permission{
132 CKMC_PERMISSION_NONE = 0x00, /**< clear permissions */
133 CKMC_PERMISSION_READ = 0x01, /**< read allowed */
134 CKMC_PERMISSION_REMOVE = 0x02 /**< remove allowed */
138 * @brief the structure for binary buffer used in key manager CAPI.
141 typedef struct __ckmc_raw_buff {
142 unsigned char* data; /**< Byte array containing binary data */
143 size_t size; /**< The size of the binary data */
147 * @brief The structure for a policy for storing key/certificate/binary data.
150 typedef struct __ckmc_policy {
151 char* password; /**< Byte array used to encrypt data inside CKM. If it is not null, the data
152 (or key, or certificate) is stored encrypted with this password inside
154 bool extractable; /**< If true key may be extracted from storage */
158 * @brief The structure for key used in key manager CAPI.
161 typedef struct __ckmc_key {
162 unsigned char* raw_key; /**< Byte array of key. raw_key may be encrypted with password */
163 size_t key_size; /**< The byte size of raw_key */
164 ckmc_key_type_e key_type; /**< The raw_key's type */
165 char* password; /**< Byte array used to decrypt data raw_key inside key manager. */
169 * @brief The structure for certificate used in key manager CAPI.
172 typedef struct __ckmc_cert {
173 unsigned char* raw_cert; /**< Byte array of certificate */
174 size_t cert_size; /**< Byte size of raw_cert */
175 ckmc_data_format_e data_format; /**< Raw_cert's encoding format */
179 * @brief The structure for linked list of alias.
182 typedef struct __ckmc_alias_list {
183 char *alias; /**< The name of key, certificate or data stored in key manager */
184 struct __ckmc_alias_list *next; /**< The pointer pointing to the next ckmc_alias_list_s */
188 * @brief The structure for linked list of ckmc_cert_s
191 typedef struct __ckmc_cert_list {
192 ckmc_cert_s *cert; /**< The pointer of ckmc_cert_s */
193 struct __ckmc_cert_list *next; /**< The pointer pointing to the next ckmc_cert_list_s */
197 * @brief Enumeration for OCSP status.
200 typedef enum __ckmc_ocsp_status {
201 CKMC_OCSP_STATUS_GOOD = 0, /**< OCSP status is good */
202 CKMC_OCSP_STATUS_REVOKED, /**< certificate is revoked */
203 CKMC_OCSP_STATUS_UNKNOWN, /**< unknown error */
204 CKMC_OCSP_ERROR_UNSUPPORTED, /**< certificate does not provide OCSP extension */
205 CKMC_OCSP_ERROR_INVALID_URL, /**< invalid URL in certificate OCSP extension */
206 CKMC_OCSP_ERROR_INVALID_RESPONSE, /**< invalid response from OCSP server */
207 CKMC_OCSP_ERROR_REMOTE, /**< OCSP remote server error */
208 CKMC_OCSP_ERROR_NET, /**< network connection error */
209 CKMC_OCSP_ERROR_INTERNAL /**< OpenSSL API error */
210 } ckmc_ocsp_status_e;
213 * @brief The structure for PKCS12 used in key manager CAPI.
216 typedef struct __ckmc_pkcs12 {
217 ckmc_key_s *priv_key; /**< private key, may be null */
218 ckmc_cert_s *cert; /**< certificate, may be null */
219 ckmc_cert_list_s *ca_chain; /**< chain certificates list, may be null */
223 * @brief Enumeration for crypto algorithm parameters.
226 typedef enum __ckmc_param_name {
227 CKMC_PARAM_ALGO_TYPE = 1,
229 // encryption & decryption
230 CKMC_PARAM_ED_IV = 101, /**< 16B buffer (up to 2^64-1 bytes long in case of AES GCM) */
231 CKMC_PARAM_ED_CTR_LEN, /**< integer */
232 CKMC_PARAM_ED_AAD, /**< buffer */
233 CKMC_PARAM_ED_TAG_LEN, /**< integer */
234 CKMC_PARAM_ED_LABEL, /**< buffer */
237 CKMC_PARAM_GEN_KEY_LEN = 201, /**< integer */
238 CKMC_PARAM_GEN_EC, /**< integer - elliptic curve (ckmc_ec_type_e) */
241 CKMC_PARAM_SV_HASH_ALGO = 301, /**< integer - hash algorithm (ckmc_hash_algo_e) */
242 CKMC_PARAM_SV_RSA_PADDING, /**< integer - RSA padding (ckmc_rsa_padding_algo_e) */
246 * @brief Structure for algorithm parameter list.
249 typedef struct __ckmc_param_list ckmc_param_list_s;
252 * @brief Enumeration for crypto algorithm types.
255 typedef enum __ckmc_algo_type {
256 CKMC_ALGO_AES_CTR = 1, /**< AES-CTR algorithm
257 Supported parameters:
258 - CKMC_PARAM_ALGO_TYPE,
260 - CKMC_PARAM_ED_CTR_LEN (128 only) */
262 CKMC_ALGO_AES_CBC, /**< AES-CBC algorithm
263 Supported parameters:
264 - CKMC_PARAM_ALGO_TYPE,
265 - CKMC_PARAM_ED_IV */
267 CKMC_ALGO_AES_GCM, /**< AES-GCM algorithm
268 Supported parameters:
269 - CKMC_PARAM_ALGO_TYPE,
271 - CKMC_PARAM_ED_TAG_LEN
272 - CKMC_PARAM_ED_AAD */
274 CKMC_ALGO_AES_CFB, /**< AES-CFB algorithm
275 Supported parameters:
276 - CKMC_PARAM_ALGO_TYPE,
277 - CKMC_PARAM_ED_IV */
279 CKMC_ALGO_RSA_OAEP, /**< RSA-OAEP algorithm
280 Supported parameters:
281 - CKMC_PARAM_ALGO_TYPE,
282 - CKMC_PARAM_ED_LABEL */
284 CKMC_ALGO_RSA_SV, /**< RSA algorithm used for signing/verification
285 Supported parameters:
286 - CKMC_PARAM_ALGO_TYPE,
287 - CKMC_PARAM_SV_HASH_ALGO
288 - CKMC_PARAM_SV_RSA_PADDING */
290 CKMC_ALGO_DSA_SV, /**< DSA algorithm used for signing/verification
291 Supported parameters:
292 - CKMC_PARAM_ALGO_TYPE,
293 - CKMC_PARAM_SV_HASH_ALGO */
295 CKMC_ALGO_ECDSA_SV, /**< ECDA algorithm used for signing/verification
296 Supported parameters:
297 - CKMC_PARAM_ALGO_TYPE,
298 - CKMC_PARAM_SV_HASH_ALGO */
300 CKMC_ALGO_RSA_GEN, /**< RSA algorithm used for key generation
301 Supported parameters:
302 - CKMC_PARAM_ALGO_TYPE,
303 - CKMC_PARAM_GEN_KEY_LEN */
305 CKMC_ALGO_DSA_GEN, /**< DSA algorithm used for key generation
306 Supported parameters:
307 - CKMC_PARAM_ALGO_TYPE,
308 - CKMC_PARAM_GEN_KEY_LEN */
310 CKMC_ALGO_ECDSA_GEN, /**< ECDA algorithm used for key generation
311 Supported parameters:
312 - CKMC_PARAM_ALGO_TYPE,
313 - CKMC_PARAM_GEN_EC */
318 * @brief Creates a new @a ckmc_key_s handle and returns it.
322 * @remarks You must destroy the newly created @a ckmc_key_s by calling ckmc_key_free() if it is no
325 * @param[in] raw_key The byte array of key \n
326 * @a raw_key may be encrypted with password.
327 * @param[in] key_size The byte size of @a raw_key
328 * @param[in] key_type The @a raw_key's type
329 * @param[in] password The byte array used to decrypt @a raw_key inside key manager \n
330 * If @a raw_key is not encrypted, @a password can be null.
331 * @param[out] ppkey The pointer to a newly created @a ckmc_key_s handle
333 * @return @c 0 on success,
334 * otherwise a negative error value
336 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
337 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
339 * @see ckmc_key_free()
342 int ckmc_key_new(unsigned char *raw_key,
344 ckmc_key_type_e key_type,
345 char *password, ckmc_key_s **ppkey);
348 * @brief Destroys the @a ckmc_key_s handle and releases all its resources.
352 * @param[in] key The @a ckmc_key_s handle to destroy
355 void ckmc_key_free(ckmc_key_s *key);
359 * @brief Creates a new @a ckmc_raw_buffer_s handle and returns it.
363 * @remarks You must destroy the newly created @a ckmc_raw_buffer_s by calling ckmc_buffer_free() if
364 * it is no longer needed.
366 * @param[in] data The byte array of buffer
367 * @param[in] size The byte size of buffer
368 * @param[out] ppbuffer The pointer to a newly created @a ckmc_buffer_s handle
370 * @return @c 0 on success,
371 * otherwise a negative error value
373 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
374 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
376 * @see ckmc_buffer_free()
377 * @see #ckmc_raw_buffer_s
379 int ckmc_buffer_new(unsigned char *data, size_t size,ckmc_raw_buffer_s **ppbuffer);
382 * @brief Destroys the @a ckmc_raw_buffer_s handle and releases all its resources.
386 * @param[in] buffer The @a ckmc_raw_buffer_s handle to destroy
389 void ckmc_buffer_free(ckmc_raw_buffer_s *buffer);
393 * @brief Creates a new @a ckmc_cert_s handle and returns it.
397 * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
400 * @param[in] raw_cert The byte array of certificate
401 * @param[in] cert_size The byte size of raw_cert
402 * @param[in] data_format The encoding format of raw_cert
403 * @param[out] ppcert The pointer to a newly created @a ckmc_cert_s handle
405 * @return @c 0 on success,
406 * otherwise a negative error value
408 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
409 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
411 * @see ckmc_cert_free()
412 * @see ckmc_load_cert_from_file()
415 int ckmc_cert_new(unsigned char *raw_cert,
417 ckmc_data_format_e data_format,
418 ckmc_cert_s **ppcert);
421 * @brief Destroys the @a ckmc_cert handle and releases all its resources.
425 * @param[in] cert The @a ckmc_cert_s handle to destroy
427 * @see ckmc_load_cert_from_file()
428 * @see ckmc_load_from_pkcs12_file
430 void ckmc_cert_free(ckmc_cert_s *cert);
433 * @brief Creates a new @a ckmc_cert_s handle from a given file and returns it.
437 * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is
440 * @param[in] file_path The path of certificate file to be loaded \n
441 * The only DER or PEM encoded certificate file is supported.
442 * @param[out] cert The pointer of newly created @a ckmc_cert_s handle
444 * @return #CKMC_ERROR_NONE on success,
445 * otherwise a negative error value
447 * @retval #CKMC_ERROR_NONE Successful
448 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
449 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid certificate file format
450 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
452 * @see ckmc_cert_free()
455 int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert);
459 * @brief Creates a new @a ckmc_pkcs12_s handle and returns it.
463 * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it
464 * is no longer needed.
465 * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly
466 * returned ckmc_pkcs12_s.
468 * @param[in] private_key @a ckmc_key_s handle to the private key (optional)
469 * @param[in] cert @a ckmc_cert_s handle to the certificate (optional)
470 * @param[in] ca_cert_list @a ckmc_cert_list_s list of chain certificate handles (optional)
471 * @param[out] pkcs12_bundle The pointer to a newly created @a ckmc_pkcs12_s handle
473 * @return @c 0 on success,
474 * otherwise a negative error value
476 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or private_key, cert and
477 * ca_cert_list all are null.
478 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
480 * @see ckmc_pkcs12_free()
481 * @see ckmc_load_from_pkcs12_file()
482 * @see ckmc_pkcs12_load()
485 * @see #ckmc_cert_list_s
486 * @see #ckmc_pkcs12_s
488 int ckmc_pkcs12_new(ckmc_key_s *private_key,
490 ckmc_cert_list_s *ca_cert_list,
491 ckmc_pkcs12_s **pkcs12_bundle);
494 * @deprecated Deprecated since 2.4. [Use ckmc_pkcs12_load() instead]
495 * @brief Creates a new @a ckmc_key_s(private key), @a ckmc_cert_s(certificate), and
496 * @a ckmc_cert_list_s(CA certificates) handle from a given PKCS#12 file and returns them.
500 * @remarks You must destroy the newly created @a ckmc_key_s, @a ckmc_cert_s, and
501 * @a ckmc_cert_list_s by calling ckmc_key_free(), ckmc_cert_free(), and
502 * ckmc_cert_list_all_free() if they are no longer needed.
504 * @param[in] file_path The path of PKCS12 file to be loaded
505 * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n
506 * If PKCS12 file is not encrypted, passphrase can be null.
507 * @param[out] private_key The pointer of newly created @a ckmc_key_s handle for a private key
508 * @param[out] cert The pointer of newly created @a ckmc_cert_s handle for a certificate \n
509 * It is null if the PKCS12 file does not contain a certificate.
510 * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
512 * It is null if the PKCS12 file does not contain CA certificates.
514 * @return #CKMC_ERROR_NONE on success,
515 * otherwise a negative error value
517 * @retval #CKMC_ERROR_NONE Successful
518 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
519 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
520 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
522 * @see ckmc_pkcs12_new()
523 * @see ckmc_pkcs12_load()
524 * @see ckmc_key_free()
525 * @see ckmc_cert_free()
526 * @see ckmc_cert_list_all_free()
529 * @see #ckmc_cert_list_s
531 int ckmc_load_from_pkcs12_file(const char *file_path,
532 const char *passphrase,
533 ckmc_key_s **private_key, ckmc_cert_s **cert,
534 ckmc_cert_list_s **ca_cert_list);
537 * @brief Creates a new @a ckmc_pkcs12_s handle from a given PKCS#12 file and returns it.
541 * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if
542 * they are no longer needed.
544 * @param[in] file_path The path of PKCS12 file to be loaded
545 * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n
546 * If PKCS12 file is not encrypted, passphrase can be null.
547 * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA
549 * It is null if the PKCS12 file does not contain CA certificates.
551 * @return #CKMC_ERROR_NONE on success,
552 * otherwise a negative error value
554 * @retval #CKMC_ERROR_NONE Successful
555 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
556 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
557 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
559 * @see ckmc_pkcs12_free()
560 * @see #ckmc_pkcs12_s
562 int ckmc_pkcs12_load(const char *file_path,
563 const char *passphrase,
564 ckmc_pkcs12_s **pkcs12_bundle);
567 * @brief Destroys the @a ckmc_pkcs12_s handle and releases all its resources.
571 * @param[in] pkcs12 The @a ckmc_pkcs12_s handle to destroy
573 * @see ckmc_pkcs12_new()
574 * @see ckmc_pkcs12_load()
576 void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12);
580 * @brief Creates a new @a ckmc_alias_list_s handle and returns it.
581 * The alias pointer in the returned @a ckmc_alias_list_s handle points to the provided
582 * characters and next is null.
586 * @remarks You must destroy the newly created @a ckmc_alias_list_s
587 * by calling ckmc_alias_list_free() or ckmc_alias_list_all_free() if it is no longer
590 * @param[in] alias The first item to be set in the newly created @a ckmc_alias_list_s
591 * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
593 * @return @c 0 on success,
594 * otherwise a negative error value
596 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
597 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
599 * @see ckmc_alias_list_all_free()
600 * @see #ckmc_alias_list_s
602 int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list);
606 * @brief Creates a new @a ckmc_alias_list_s handle, adds it to a previous @a ckmc_alias_list_s and
607 * returns it. The alias pointer in the returned @a ckmc_alias_list_s handle points to the
608 * provided characters and next is null.
612 * @param[in] previous The last @a ckmc_alias_list_s handle to which a newly created
613 * @a ckmc_alias_list_s is added
614 * @param[in] alias The item to be set in the newly created @a ckmc_alias_list_s
615 * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle
617 * @return @c 0 on success,
618 * otherwise a negative error value
620 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
621 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
623 * @see ckmc_alias_list_all_free()
624 * @see #ckmc_alias_list_s
626 int ckmc_alias_list_add(ckmc_alias_list_s *previous,
628 ckmc_alias_list_s **pplast);
632 * @brief Destroys the @a ckmc_alias_list_s handle and releases resources of @a ckmc_alias_list_s
633 * from the provided first handle cascadingly.
637 * @remarks It does not destroy an alias itself in @a ckmc_alias_list_s.
639 * @param[in] first The first @a ckmc_alias_list_s handle to destroy
641 * @see ckmc_alias_list_all_free()
642 * @see #ckmc_alias_list_s
644 void ckmc_alias_list_free(ckmc_alias_list_s *first);
647 * @brief Destroys the @a ckmc_alias_list_s handle and releases all its resources from the provided
648 * first handle cascadingly.
652 * @remarks It also destroys the alias in @a ckmc_alias_list_s.
654 * @param[in] first The first @a ckmc_alias_list_s handle to destroy
656 * @see #ckmc_alias_list_s
658 void ckmc_alias_list_all_free(ckmc_alias_list_s *first);
662 * @brief Creates a new @a ckmc_cert_list_s handle and returns it.
663 * The cert pointer in the returned @a ckmc_cert_list_s handle points to the provided
664 * @a ckmc_cert_s and next is null.
668 * @remarks You must destroy the newly created @a ckmc_cert_list_s by calling ckmc_cert_list_free()
669 * or ckmc_cert_list_all_free() if it is no longer needed.
671 * @param[in] cert The first item to be set in the newly created @a ckmc_cert_list_s
672 * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle
674 * @return @c 0 on success,
675 * otherwise a negative error value
677 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
678 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
680 * @see ckmc_cert_list_all_free()
681 * @see #ckmc_cert_list_s
683 int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list);
687 * @brief Creates a new @a ckmc_cert_list_s handle, adds it to a previous @a ckmc_cert_list_s and
688 * returns it. The cert pointer in the returned @a ckmc_alias_list_s handle points to the
689 * provided @a ckmc_cert_s and next is null.
693 * @param[in] previous The last @a ckmc_cert_list_s handle to which a newly created
694 * @a ckmc_cert_list_s is added
695 * @param[in] cert The item to be set in the newly created @a ckmc_cert_list_s
696 * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle
698 * @return @c 0 on success,
699 * otherwise a negative error value
701 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
702 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
704 * @see ckmc_cert_list_all_free()
705 * @see #ckmc_cert_list_s
707 int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast);
711 * @brief Destroys the @a ckmc_cert_list_s handle and releases resources of @a ckmc_cert_list_s
712 * from the provided first handle cascadingly.
716 * @remarks It does not destroy @a ckmc_cert_s itself in @a ckmc_cert_list_s.
718 * @param[in] first The first @a ckmc_cert_list_s handle to destroy
720 * @see ckmc_cert_list_all_free()
721 * @see #ckmc_cert_list_s
723 void ckmc_cert_list_free(ckmc_cert_list_s *first);
726 * @brief Destroys the @a ckmc_cert_list_s handle and releases all its resources from the provided
727 * first handle cascadingly.
731 * @remarks It also destroys @a ckmc_cert_s in ckmc_cert_list_s.
733 * @param[in] first The first @a ckmc_cert_list_s handle to destroy
735 * @see #ckmc_cert_list_s
737 void ckmc_cert_list_all_free(ckmc_cert_list_s *first);
740 * @brief Creates new parameter list
744 * @remarks Caller is responsible for freeing it with ckmc_param_list_free
746 * @param[in] ppparam_list Double pointer to the list variable to which the newly created list will
749 * @return @c 0 on success, otherwise a negative error value
751 * @retval #CKMC_ERROR_NONE Successful
752 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
754 * @see ckmc_param_list_add_integer
755 * @see ckmc_param_list_add_buffer
756 * @see ckmc_param_list_free
757 * @see ckmc_generate_params
758 * @see #ckmc_param_list_s
759 * @see #ckmc_param_name_e
761 int ckmc_param_list_new(ckmc_param_list_s **ppparams);
764 * @brief Adds integer parameter to the list
768 * @remarks Caller is responsible for ckmc_param_list_s creation.
770 * @param[in] params List of params created with ckcm_param_list_new.
771 * @param[in] name Name of parameter to add. Existing parameter will be overwritten. Passing
772 * invalid parameter name will result in an error.
773 * @param[in] value Value of the parameter in form of a integer.
775 * @return @c 0 on success, otherwise a negative error value
777 * @retval #CKMC_ERROR_NONE Successful
778 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
780 * @see ckmc_param_list_new
781 * @see ckmc_param_list_add_buffer
782 * @see ckmc_param_list_get_integer
783 * @see ckmc_param_list_get_buffer
784 * @see ckmc_param_list_free
785 * @see ckmc_generate_params
786 * @see #ckmc_param_list_s
787 * @see #ckmc_param_name_e
789 int ckmc_param_list_add_integer(ckmc_param_list_s *params,
790 ckmc_param_name_e name,
794 * @brief Adds buffer parameter to the list
798 * @remarks Caller is responsible for ckmc_param_list_s creation.
800 * @param[in] params List of params created with ckcm_param_list_new.
801 * @param[in] name Name of parameter to add. Existing parameter will be overwritten. Passing
802 * invalid parameter name will result in an error
803 * @param[in] buffer Value of the parameter in form of a buffer. Caller is responsible for
804 * creating and freeing the buffer.
806 * @return @c 0 on success, otherwise a negative error value
808 * @retval #CKMC_ERROR_NONE Successful
809 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
811 * @see ckmc_param_list_new
812 * @see ckmc_param_list_add_integer
813 * @see ckmc_param_list_get_integer
814 * @see ckmc_param_list_get_buffer
815 * @see ckmc_param_list_free
816 * @see ckmc_generate_params
817 * @see #ckmc_param_list_s
818 * @see #ckmc_param_name_e
820 int ckmc_param_list_add_buffer(ckmc_param_list_s *params,
821 ckmc_param_name_e name,
822 const ckmc_raw_buffer_s *buffer);
825 * @brief Gets integer parameter from the list.
829 * @remarks Caller is responsible for ckmc_param_list_s creation.
831 * @param[in] params List of params created with ckcm_param_list_new.
832 * @param[in] name Name of parameter to get.
833 * @param[out] value Value of the parameter in form of a integer.
835 * @return @c 0 on success, 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_add_integer
842 * @see ckmc_param_list_add_buffer
843 * @see ckmc_param_list_get_buffer
844 * @see ckmc_param_list_free
845 * @see ckmc_generate_params
846 * @see #ckmc_param_list_s
847 * @see #ckmc_param_name_e
850 int ckmc_param_list_get_integer(const ckmc_param_list_s *params,
851 ckmc_param_name_e name,
855 * @brief Gets buffer parameter from the list.
859 * @remarks Caller is responsible for ckmc_param_list_s creation.
861 * @param[in] params List of params created with ckcm_param_list_new.
862 * @param[in] name Name of parameter to get.
863 * @param[out] buffer Value of the parameter in form of a buffer. Caller is responsible for
864 * creating and freeing the buffer.
866 * @return @c 0 on success, otherwise a negative error value
868 * @retval #CKMC_ERROR_NONE Successful
869 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
871 * @see ckmc_param_list_new
872 * @see ckmc_param_list_add_integer
873 * @see ckmc_param_list_add_buffer
874 * @see ckmc_param_list_get_integer
875 * @see ckmc_param_list_free
876 * @see ckmc_generate_params
877 * @see #ckmc_param_list_s
878 * @see #ckmc_param_name_e
880 int ckmc_param_list_get_buffer(const ckmc_param_list_s *params,
881 ckmc_param_name_e name,
882 ckmc_raw_buffer_s **buffer);
885 * @brief Frees previously allocated list of algorithm params
889 * @param[in] first First element of the list to be freed.
891 * @see ckmc_param_list_new
892 * @see ckmc_param_list_add_integer
893 * @see ckmc_param_list_add_buffer
894 * @see ckmc_param_list_get_integer
895 * @see ckmc_param_list_get_buffer
896 * @see ckmc_generate_params
897 * @see #ckmc_param_list_s
898 * @see #ckmc_param_name_e
901 void ckmc_param_list_free(ckmc_param_list_s *params);
904 * @brief Generates algorithm parameters for a given algorithm type and adds them to the list.
908 * @remarks Caller is responsible for ckmc_param_list_s creation and destruction.
909 * @remarks Algorithm parameters are set to default values. Optional fields are left empty.
910 * Initialization vectors are left empty (they have to be added manually). Existing params
911 * will be overwritten with default values. Caller is responsible for freeing the list with
912 * ckmc_param_list_free.
913 * @remarks If the function returns error provided param list may contain some of default parameters
915 * @param[in] type Type of the algorithm
916 * @param[out] params List of params to be filled. List should be empty. Otherwise an error will
919 * @return @c 0 on success, otherwise a negative error value
921 * @retval #CKMC_ERROR_NONE Successful
922 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
924 * @see ckmc_param_list_new
925 * @see ckmc_param_list_add_integer
926 * @see ckmc_param_list_add_buffer
927 * @see ckmc_param_list_get_integer
928 * @see ckmc_param_list_get_buffer
929 * @see ckmc_param_list_free
930 * @see #ckmc_param_list_s
931 * @see #ckmc_param_name_e
933 int ckmc_generate_params(ckmc_algo_type_e type, ckmc_param_list_s *params);
943 #endif /* __TIZEN_CORE_CKMC_TYPE_H */