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.
23 #ifndef __TIZEN_CORE_CKMC_TYPE_H
24 #define __TIZEN_CORE_CKMC_TYPE_H
29 #include <ckmc/ckmc-error.h>
32 #define KEY_MANAGER_CAPI __attribute__((visibility("default")))
41 * @addtogroup CAPI_KEY_MANAGER_TYPES_MODULE
47 * Note: on tizen 3.0 owner id is equal to pkgId.
48 * Preinstalled system(uid < 5000) and user (uid >= 5000) applications
49 * does not have any pkgId. That's why ckm uses special "virtual"
50 * pkgid for them. The virtual strings are defined under:
51 * ckmc_owner_id_system
56 * @deprecated Deprecated since 3.0. [Use ckmc_owner_id_separator instead]
57 * @brief Separator between alias and label.
59 * @remarks Alias can be provided as an alias alone, or together with label - in this
60 * case, separator " " (space bar) is used to separate label and alias.
61 * @see #ckmc_owner_id_separator
63 KEY_MANAGER_CAPI extern char const *const ckmc_label_name_separator;
67 * @brief Separator between alias and owner id.
69 * @remarks Alias can be provided as an alias alone, or together with owner id.
70 * In this case, separator " " (space bar) is used to separate id and alias.
71 * @see ckmc_alias_new()
73 KEY_MANAGER_CAPI extern char const *const ckmc_owner_id_separator;
77 * @brief The owner of system database.
79 * @remarks #ckmc_owner_id_system contains id connected with all system applications that run with uid less than 5000.
80 * Client should use #ckmc_owner_id_system to access data owned by system application and stored in system database.
81 * Client must have permission to access proper row.
82 * @see ckmc_alias_new()
84 KEY_MANAGER_CAPI extern char const *const ckmc_owner_id_system;
88 * @brief Enumeration for key types of key manager.
91 typedef enum __ckmc_key_type {
92 CKMC_KEY_NONE = 0, /**< Key type not specified */
93 CKMC_KEY_RSA_PUBLIC, /**< RSA public key */
94 CKMC_KEY_RSA_PRIVATE, /**< RSA private key */
95 CKMC_KEY_ECDSA_PUBLIC, /**< ECDSA public key */
96 CKMC_KEY_ECDSA_PRIVATE, /**< ECDSA private key */
97 CKMC_KEY_DSA_PUBLIC, /**< DSA public key */
98 CKMC_KEY_DSA_PRIVATE, /**< DSA private key */
99 CKMC_KEY_AES, /**< AES key */
104 * @brief Enumeration for data format.
107 typedef enum __ckmc_data_format {
108 CKMC_FORM_DER_BASE64 = 0, /**< DER format base64 encoded data */
109 CKMC_FORM_DER, /**< DER encoded data */
110 CKMC_FORM_PEM /**< PEM encoded data. It consists of the DER format base64 encoded
111 with additional header and footer lines. */
112 } ckmc_data_format_e;
116 * @brief Enumeration for elliptic curve.
119 typedef enum __ckmc_ec_type {
120 CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended
121 elliptic curve domain */
122 CKMC_EC_PRIME256V1, /**< "SEC 2" recommended elliptic curve domain - secp256r1 */
123 CKMC_EC_SECP384R1 /**< NIST curve P-384(covers "secp384r1", the elliptic curve domain
124 listed in See SEC 2 */
129 * @brief Enumeration for hash algorithm.
132 typedef enum __ckmc_hash_algo {
133 CKMC_HASH_NONE = 0, /**< No Hash Algorithm */
134 CKMC_HASH_SHA1, /**< Hash Algorithm SHA1 */
135 CKMC_HASH_SHA256, /**< Hash Algorithm SHA256 */
136 CKMC_HASH_SHA384, /**< Hash Algorithm SHA384 */
137 CKMC_HASH_SHA512 /**< Hash Algorithm SHA512 */
142 * @brief Enumeration for RSA padding algorithm.
145 typedef enum __ckmc_rsa_padding_algo {
146 CKMC_NONE_PADDING = 0, /**< No Padding */
147 CKMC_PKCS1_PADDING, /**< PKCS#1 Padding */
148 CKMC_X931_PADDING /**< X9.31 padding */
149 } ckmc_rsa_padding_algo_e;
153 * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif [Use ckmc_permission_e() instead]
154 * @brief Enumeration for database access rights.
157 typedef enum __ckmc_access_right {
158 CKMC_AR_READ = 0, /**< Access right for read*/
159 CKMC_AR_READ_REMOVE /**< Access right for read and remove*/
160 } ckmc_access_right_e;
164 * @brief Enumeration for permissions to access/modify alias.
165 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
167 typedef enum __ckmc_permission {
168 CKMC_PERMISSION_NONE = 0x00, /**< Clear permissions */
169 CKMC_PERMISSION_READ = 0x01, /**< Read allowed */
170 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 */
185 * @brief The structure for a policy for storing key/certificate/binary data.
188 typedef struct __ckmc_policy {
189 char *password; /**< Byte array used to encrypt data inside CKM. If it is not null, the data
190 (or key, or certificate) is stored encrypted with this password inside
192 bool extractable; /**< If true key may be extracted from storage */
197 * @brief The structure for key used in key manager CAPI.
200 typedef struct __ckmc_key {
202 *raw_key; /**< Byte array of key. raw_key may be encrypted with password */
203 size_t key_size; /**< The byte size of raw_key */
204 ckmc_key_type_e key_type; /**< The raw_key's type */
205 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 */
221 * @brief The structure for linked list of alias.
224 typedef struct __ckmc_alias_list {
225 char *alias; /**< The name of key, certificate or data stored in key manager */
226 struct __ckmc_alias_list
227 *next; /**< The pointer pointing to the next ckmc_alias_list_s */
232 * @brief The structure for linked list of ckmc_cert_s
235 typedef struct __ckmc_cert_list {
236 ckmc_cert_s *cert; /**< The pointer of ckmc_cert_s */
237 struct __ckmc_cert_list
238 *next; /**< The pointer pointing to the next ckmc_cert_list_s */
243 * @brief Enumeration for OCSP status.
244 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
246 typedef enum __ckmc_ocsp_status {
247 CKMC_OCSP_STATUS_GOOD = 0, /**< OCSP status is good */
248 CKMC_OCSP_STATUS_REVOKED, /**< The certificate is revoked */
249 CKMC_OCSP_STATUS_UNKNOWN, /**< Unknown error */
250 CKMC_OCSP_ERROR_UNSUPPORTED, /**< The certificate does not provide OCSP extension */
251 CKMC_OCSP_ERROR_INVALID_URL, /**< The invalid URL in certificate OCSP extension */
252 CKMC_OCSP_ERROR_INVALID_RESPONSE, /**< The invalid response from OCSP server */
253 CKMC_OCSP_ERROR_REMOTE, /**< OCSP remote server error */
254 CKMC_OCSP_ERROR_NET, /**< Network connection error */
255 CKMC_OCSP_ERROR_INTERNAL /**< OpenSSL API error */
256 } ckmc_ocsp_status_e;
260 * @brief The structure for PKCS12 used in key manager CAPI.
261 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
263 typedef struct __ckmc_pkcs12 {
264 ckmc_key_s *priv_key; /**< The private key, may be null */
265 ckmc_cert_s *cert; /**< The certificate, may be null */
266 ckmc_cert_list_s *ca_chain; /**< The chain certificate list, may be null */
271 * @brief Enumeration for crypto algorithm parameters.
273 * @see #ckmc_algo_type_e
275 typedef enum __ckmc_param_name {
276 CKMC_PARAM_ALGO_TYPE = 1,
278 CKMC_PARAM_ED_IV = 101, /**< 16B buffer (up to 2^64-1 bytes long in case of AES GCM) */
279 CKMC_PARAM_ED_CTR_LEN, /**< integer - ctr length in bits*/
280 CKMC_PARAM_ED_AAD, /**< buffer */
281 CKMC_PARAM_ED_TAG_LEN, /**< integer - tag length in bits */
282 CKMC_PARAM_ED_LABEL /**< buffer */
287 * @brief Algorithm parameter list handle.
289 * @remarks Each parameter list must have at least one CKMC_PARAM_ALGO_TYPE parameter that identifies the algorithm.
290 * See #ckmc_algo_type_e for available algorithms and additional parameters they support.
291 * @see ckmc_generate_new_params()
292 * @see ckmc_param_list_new()
293 * @see ckmc_param_list_set_integer()
294 * @see ckmc_param_list_set_buffer()
295 * @see ckmc_param_list_get_integer()
296 * @see ckmc_param_list_get_buffer()
297 * @see ckmc_param_list_free()
298 * @see #ckmc_algo_type_e
299 * @see #ckmc_param_name_e
301 typedef struct __ckmc_param_list *ckmc_param_list_h;
305 * @brief Enumeration for crypto algorithm types.
307 * @see #ckmc_param_name_e
309 typedef enum __ckmc_algo_type {
310 CKMC_ALGO_AES_CTR = 1, /**< AES-CTR algorithm
311 Supported parameters:
312 - CKMC_PARAM_ALGO_TYPE = CKMC_ALGO_AES_CTR(mandatory),
313 - CKMC_PARAM_ED_IV = 16-byte initialization vector(mandatory)
314 - CKMC_PARAM_ED_CTR_LEN = length of counter block in bits
315 (optional, only 128b is supported at the moment) */
317 CKMC_ALGO_AES_CBC, /**< AES-CBC algorithm
318 Supported parameters:
319 - CKMC_PARAM_ALGO_TYPE = CKMC_ALGO_AES_CBC(mandatory),
320 - CKMC_PARAM_ED_IV = 16-byte initialization vector(mandatory) */
322 CKMC_ALGO_AES_GCM, /**< AES-GCM algorithm
323 Supported parameters:
324 - CKMC_PARAM_ALGO_TYPE = CKMC_ALGO_AES_GCM(mandatory),
325 - CKMC_PARAM_ED_IV = initialization vector(mandatory)
326 - CKMC_PARAM_ED_TAG_LEN = GCM tag length in bits. One of
327 {32, 64, 96, 104, 112, 120, 128} (optional, if not present, the
328 length 128 is used; since Tizen 5.0, if TrustZone backend is used,
329 32 and 64 lengths are not supported)
330 - CKMC_PARAM_ED_AAD = additional authentication data(optional) */
332 CKMC_ALGO_AES_CFB, /**< AES-CFB algorithm
333 Supported parameters:
334 - CKMC_PARAM_ALGO_TYPE = CKMC_ALGO_AES_CFB(mandatory),
335 - CKMC_PARAM_ED_IV = 16-byte initialization vector(mandatory) */
337 CKMC_ALGO_RSA_OAEP /**< RSA-OAEP algorithm
338 Supported parameters:
339 - CKMC_PARAM_ALGO_TYPE = CKMC_ALGO_RSA_OAEP(required),
340 - CKMC_PARAM_ED_LABEL = label to be associated with the message
341 (optional, not supported at the moment) */
346 * @brief Creates a new full alias which is a concatenation of @a owner_id and @a alias.
348 * @remarks @a full_alias should be freed with free() after use.
349 * @remarks Returns #CKMC_ERROR_INVALID_PARAMETER if any of parameter is NULL.
350 * @remarks Returns #CKMC_ERROR_INVALID_PARAMETER if @a owner_id is empty.
351 * @param[in] owner_id Data owner's id. This should be package id if data owner is
352 * application. If you want to access data stored by system
353 * services, it should be #ckmc_owner_id_system
354 * @param[in] alias Data alias
355 * @param[out] full_alias The newly created alias which is a concatenation of
356 * @a owner_id, #ckmc_owner_id_separator and @a alias.
357 * Destroy by free() after use
358 * @return #CKMC_ERROR_NONE on success,
359 * otherwise a negative error value
360 * @retval #CKMC_ERROR_NONE Successful
361 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
362 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
363 * @see #ckmc_owner_id_separator
364 * @see #ckmc_owner_id_system
366 int ckmc_alias_new(const char *owner_id, const char *alias, char **full_alias);
370 * @brief Creates a new #ckmc_key_s handle and returns it.
371 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
372 * @remarks You must destroy the newly created #ckmc_key_s by calling ckmc_key_free() if it is no longer needed.
373 * @param[in] raw_key The byte array of key \n
374 * @a raw_key may be encrypted with password
375 * @param[in] key_size The byte size of @a raw_key
376 * @param[in] key_type The @a raw_key's type
377 * @param[in] password The byte array used to decrypt @a raw_key inside key manager \n
378 * If @a raw_key is not encrypted, @a password can be null
379 * @param[out] ppkey The pointer to a newly created #ckmc_key_s handle
380 * @return #CKMC_ERROR_NONE on success,
381 * otherwise a negative error value
382 * @retval #CKMC_ERROR_NONE Successful
383 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
384 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
385 * @see ckmc_key_free()
388 int ckmc_key_new(unsigned char *raw_key, size_t key_size, ckmc_key_type_e key_type, char *password, ckmc_key_s **ppkey);
392 * @brief Destroys the #ckmc_key_s handle and releases all its resources.
394 * @param[in] key The #ckmc_key_s handle to destroy
396 void ckmc_key_free(ckmc_key_s *key);
400 * @brief Creates a new #ckmc_raw_buffer_s handle and returns it.
401 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
402 * @remarks You must destroy the newly created #ckmc_raw_buffer_s by calling ckmc_buffer_free() if it is no longer needed.
403 * @param[in] data The byte array of buffer
404 * @param[in] size The byte size of buffer
405 * @param[out] ppbuffer The pointer to a newly created #ckmc_raw_buffer_s handle
406 * @return #CKMC_ERROR_NONE on success,
407 * otherwise a negative error value
408 * @retval #CKMC_ERROR_NONE Successful
409 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
410 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
411 * @see ckmc_buffer_free()
412 * @see #ckmc_raw_buffer_s
414 int ckmc_buffer_new(unsigned char *data, size_t size, ckmc_raw_buffer_s **ppbuffer);
418 * @brief Destroys the #ckmc_raw_buffer_s handle and releases all its resources.
420 * @param[in] buffer The #ckmc_raw_buffer_s structure to destroy
422 void ckmc_buffer_free(ckmc_raw_buffer_s *buffer);
426 * @brief Creates a new #ckmc_cert_s handle and returns it.
427 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
428 * @remarks You must destroy the newly created #ckmc_cert_s by calling ckmc_cert_free() if it is no longer needed.
429 * @param[in] raw_cert The byte array of certificate
430 * @param[in] cert_size The byte size of raw_cert
431 * @param[in] data_format The encoding format of raw_cert
432 * @param[out] ppcert The pointer to a newly created #ckmc_cert_s handle
433 * @return #CKMC_ERROR_NONE on success,
434 * otherwise a negative error value
435 * @retval #CKMC_ERROR_NONE Successful
436 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
437 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
438 * @see ckmc_cert_free()
439 * @see ckmc_load_cert_from_file()
442 int ckmc_cert_new(unsigned char *raw_cert, size_t cert_size, ckmc_data_format_e data_format, ckmc_cert_s **ppcert);
446 * @brief Destroys the #ckmc_cert_s handle and releases all its resources.
448 * @param[in] cert The #ckmc_cert_s handle to destroy
449 * @see ckmc_load_cert_from_file()
451 void ckmc_cert_free(ckmc_cert_s *cert);
455 * @brief Creates a new #ckmc_cert_s handle from a given file and returns it.
457 * @remarks You must destroy the newly created #ckmc_cert_s by calling ckmc_cert_free() if it is no longer needed.
458 * @param[in] file_path The path of certificate file to be loaded \n
459 * The only DER or PEM encoded certificate file is supported
460 * @param[out] cert The pointer of newly created #ckmc_cert_s handle
461 * @return #CKMC_ERROR_NONE on success,
462 * otherwise a negative error value
463 * @retval #CKMC_ERROR_NONE Successful
464 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
465 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid certificate file format
466 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
467 * @see ckmc_cert_free()
470 int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert);
474 * @brief Creates a new #ckmc_pkcs12_s handle and returns it.
475 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
476 * @remarks You must destroy the newly created #ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it is no longer needed.
477 * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly returned ckmc_pkcs12_s.
478 * @param[in] private_key #ckmc_key_s handle to the private key (optional)
479 * @param[in] cert #ckmc_cert_s handle to the certificate (optional)
480 * @param[in] ca_cert_list #ckmc_cert_list_s list of chain certificate handles (optional)
481 * @param[out] pkcs12_bundle The pointer to a newly created #ckmc_pkcs12_s handle
482 * @return #CKMC_ERROR_NONE on success,
483 * otherwise a negative error value
484 * @retval #CKMC_ERROR_NONE Successful
485 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or private_key, cert and ca_cert_list all are null
486 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
487 * @see ckmc_pkcs12_free()
488 * @see ckmc_pkcs12_load()
491 * @see #ckmc_cert_list_s
492 * @see #ckmc_pkcs12_s
494 int ckmc_pkcs12_new(ckmc_key_s *private_key, ckmc_cert_s *cert, ckmc_cert_list_s *ca_cert_list, ckmc_pkcs12_s **pkcs12_bundle);
498 * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif [Use ckmc_pkcs12_load() instead]
499 * @brief Creates a new #ckmc_key_s (@a private_key), #ckmc_cert_s (@a cert), and #ckmc_cert_list_s (@a ca_cert_list) handle from a given PKCS#12 file and returns them.
501 * @remarks You must destroy the newly created #ckmc_key_s, #ckmc_cert_s, and
502 * #ckmc_cert_list_s by calling ckmc_key_free(), ckmc_cert_free(), and
503 * 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 #ckmc_key_s handle for a private key
508 * @param[out] cert The pointer of newly created #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 #ckmc_cert_list_s handle for CA certificates \n
511 * It is null if the PKCS12 file does not contain CA certificates
512 * @return #CKMC_ERROR_NONE on success,
513 * otherwise a negative error value
514 * @retval #CKMC_ERROR_NONE Successful
515 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
516 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
517 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
518 * @see ckmc_pkcs12_new()
519 * @see ckmc_pkcs12_load()
520 * @see ckmc_key_free()
521 * @see ckmc_cert_free()
522 * @see ckmc_cert_list_all_free()
525 * @see #ckmc_cert_list_s
527 int ckmc_load_from_pkcs12_file(const char *file_path, const char *passphrase, ckmc_key_s **private_key, ckmc_cert_s **cert, ckmc_cert_list_s **ca_cert_list) TIZEN_DEPRECATED_API;
531 * @brief Creates a new #ckmc_pkcs12_s handle from a given PKCS#12 file and returns it.
532 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
533 * @remarks You must destroy the newly created #ckmc_pkcs12_s by calling ckmc_pkcs12_free() if 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] pkcs12_bundle The pointer of newly created #ckmc_cert_list_s handle for CA certificates \n
538 * It is null if the PKCS12 file does not contain CA certificates
539 * @return #CKMC_ERROR_NONE on success,
540 * otherwise a negative error value
541 * @retval #CKMC_ERROR_NONE Successful
542 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory space
543 * @retval #CKMC_ERROR_INVALID_FORMAT Invalid PKCS12 file format
544 * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed
545 * @see ckmc_pkcs12_free()
546 * @see #ckmc_pkcs12_s
548 int ckmc_pkcs12_load(const char *file_path, const char *passphrase, ckmc_pkcs12_s **pkcs12_bundle);
552 * @brief Destroys the #ckmc_pkcs12_s handle and releases all its resources.
553 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
554 * @param[in] pkcs12 The #ckmc_pkcs12_s handle to destroy
555 * @see ckmc_pkcs12_new()
556 * @see ckmc_pkcs12_load()
558 void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12);
562 * @brief Creates a new #ckmc_alias_list_s handle and returns it.
563 * The alias pointer in the returned #ckmc_alias_list_s handle points to the provided characters and next is null.
564 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
565 * @remarks You must destroy the newly created #ckmc_alias_list_s
566 * by calling ckmc_alias_list_free() or ckmc_alias_list_all_free() if it is no longer needed.
567 * @param[in] alias The first item to be set in the newly created #ckmc_alias_list_s
568 * @param[out] ppalias_list The pointer to a newly created #ckmc_alias_list_s handle
569 * @return #CKMC_ERROR_NONE on success,
570 * otherwise a negative error value
571 * @retval #CKMC_ERROR_NONE Successful
572 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
573 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
574 * @see ckmc_alias_list_all_free()
575 * @see #ckmc_alias_list_s
577 int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list);
581 * @brief Creates a new #ckmc_alias_list_s handle, adds it to a previous #ckmc_alias_list_s and returns it.
582 * The alias pointer in the returned #ckmc_alias_list_s handle points to the provided characters and next is null.
583 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
584 * @param[in] previous The last #ckmc_alias_list_s handle to which a newly created #ckmc_alias_list_s is added
585 * @param[in] alias The item to be set in the newly created #ckmc_alias_list_s
586 * @param[out] pplast The pointer to a newly created and added #ckmc_alias_list_s handle
587 * @return #CKMC_ERROR_NONE on success,
588 * otherwise a negative error value
589 * @retval #CKMC_ERROR_NONE Successful
590 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
591 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
592 * @see ckmc_alias_list_all_free()
593 * @see #ckmc_alias_list_s
595 int ckmc_alias_list_add(ckmc_alias_list_s *previous, char *alias, ckmc_alias_list_s **pplast);
599 * @brief Destroys the #ckmc_alias_list_s handle and releases resources of #ckmc_alias_list_s from the provided first handle cascadingly.
600 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
601 * @remarks It does not destroy an alias itself in #ckmc_alias_list_s.
602 * @param[in] first The first #ckmc_alias_list_s handle to destroy
603 * @see ckmc_alias_list_all_free()
604 * @see #ckmc_alias_list_s
606 void ckmc_alias_list_free(ckmc_alias_list_s *first);
610 * @brief Destroys the #ckmc_alias_list_s handle and releases all its resources from the provided first handle cascadingly.
611 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
612 * @remarks It also destroys the alias in #ckmc_alias_list_s.
613 * @param[in] first The first #ckmc_alias_list_s handle to destroy
614 * @see #ckmc_alias_list_s
616 void ckmc_alias_list_all_free(ckmc_alias_list_s *first);
620 * @brief Creates a new #ckmc_cert_list_s handle and returns it.
621 * The cert pointer in the returned #ckmc_cert_list_s handle points to the provided #ckmc_cert_s and next is null.
622 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
623 * @remarks You must destroy the newly created #ckmc_cert_list_s by calling ckmc_cert_list_free() or ckmc_cert_list_all_free() if it is no longer needed.
624 * @param[in] cert The first item to be set in the newly created #ckmc_cert_list_s
625 * @param[out] ppalias_list The pointer to a newly created #ckmc_alias_list_s handle
626 * @return #CKMC_ERROR_NONE on success,
627 * otherwise a negative error value
628 * @retval #CKMC_ERROR_NONE Successful
629 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
630 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
631 * @see ckmc_cert_list_all_free()
632 * @see #ckmc_cert_list_s
634 int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list);
638 * @brief Creates a new #ckmc_cert_list_s handle, adds it to a previous #ckmc_cert_list_s and returns it.
639 * The cert pointer in the returned #ckmc_alias_list_s handle points to the provided #ckmc_cert_s and next is null.
640 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
641 * @param[in] previous The last #ckmc_cert_list_s handle to which a newly created #ckmc_cert_list_s is added
642 * @param[in] cert The item to be set in the newly created #ckmc_cert_list_s
643 * @param[out] pplast The pointer to a newly created and added #ckmc_alias_list_s handle
644 * @return #CKMC_ERROR_NONE on success,
645 * otherwise a negative error value
646 * @retval #CKMC_ERROR_NONE Successful
647 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
648 * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory
649 * @see ckmc_cert_list_all_free()
650 * @see #ckmc_cert_list_s
652 int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast);
656 * @brief Destroys the #ckmc_cert_list_s handle and releases resources of #ckmc_cert_list_s from the provided first handle cascadingly.
657 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
658 * @remarks It does not destroy #ckmc_cert_s itself in #ckmc_cert_list_s.
659 * @param[in] first The first #ckmc_cert_list_s handle to destroy
660 * @see ckmc_cert_list_all_free()
661 * @see #ckmc_cert_list_s
663 void ckmc_cert_list_free(ckmc_cert_list_s *first);
667 * @brief Destroys the #ckmc_cert_list_s handle and releases all its resources from the provided first handle cascadingly.
669 * @remarks It also destroys #ckmc_cert_s in #ckmc_cert_list_s.
670 * @param[in] first The first #ckmc_cert_list_s handle to destroy
671 * @see #ckmc_cert_list_s
673 void ckmc_cert_list_all_free(ckmc_cert_list_s *first);
677 * @brief Creates new parameter list.
679 * @remarks Caller is responsible for freeing it with ckmc_param_list_free().
680 * @param[in] pparams Double pointer to the handle of param list to which the newly created algorithm param list will be assigned
681 * @return #CKMC_ERROR_NONE on success,
682 * otherwise a negative error value
683 * @retval #CKMC_ERROR_NONE Successful
684 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
685 * @see ckmc_param_list_set_integer()
686 * @see ckmc_param_list_set_buffer()
687 * @see ckmc_param_list_free()
688 * @see ckmc_generate_new_params()
689 * @see #ckmc_param_list_h
690 * @see #ckmc_param_name_e
691 * @see #ckmc_algo_type_e
693 int ckmc_param_list_new(ckmc_param_list_h *pparams);
697 * @brief Sets integer parameter to the list.
699 * @remarks Caller is responsible for #ckmc_param_list_h creation.
700 * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or ckmc_generate_new_params() \n
701 * New param with @a name and @a value will be set here
702 * @param[in] name Name of parameter to set \n
703 * Existing parameter will be overwritten \n
704 * Passing invalid parameter name will result in an error
705 * @param[in] value Value of the parameter in form of a integer
706 * @return #CKMC_ERROR_NONE on success,
707 * otherwise a negative error value
708 * @retval #CKMC_ERROR_NONE Successful
709 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
710 * @see ckmc_param_list_new()
711 * @see ckmc_param_list_set_buffer()
712 * @see ckmc_param_list_get_integer()
713 * @see ckmc_param_list_get_buffer()
714 * @see ckmc_param_list_free()
715 * @see ckmc_generate_new_params()
716 * @see #ckmc_param_list_h
717 * @see #ckmc_param_name_e
718 * @see #ckmc_algo_type_e
720 int ckmc_param_list_set_integer(ckmc_param_list_h params, ckmc_param_name_e name, uint64_t value);
724 * @brief Sets buffer parameter to the list.
726 * @remarks Caller is responsible for #ckmc_param_list_h creation.
727 * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or ckmc_generate_new_params()
728 * New param with @a name and @a buffer will be set here
729 * @param[in] name Name of parameter to set \n
730 * Existing parameter will be overwritten \n
731 * Passing invalid parameter name will result in an error
732 * @param[in] buffer Value of the parameter in form of a buffer \n
733 * Caller is responsible for creating and freeing the buffer
734 * @return #CKMC_ERROR_NONE on success,
735 * otherwise a negative error value
736 * @retval #CKMC_ERROR_NONE Successful
737 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
738 * @see ckmc_param_list_new()
739 * @see ckmc_param_list_set_integer()
740 * @see ckmc_param_list_get_integer()
741 * @see ckmc_param_list_get_buffer()
742 * @see ckmc_param_list_free()
743 * @see ckmc_generate_new_params()
744 * @see #ckmc_param_list_h
745 * @see #ckmc_param_name_e
746 * @see #ckmc_algo_type_e
748 int ckmc_param_list_set_buffer(ckmc_param_list_h params, ckmc_param_name_e name, const ckmc_raw_buffer_s *buffer);
752 * @brief Gets integer parameter from the list.
754 * @remarks Caller is responsible for #ckmc_param_list_h creation.
755 * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or ckmc_generate_new_params()
756 * which contains param with @a name
757 * @param[in] name Name of parameter to get
758 * @param[out] pvalue Value of the parameter in form of a integer
759 * @return #CKMC_ERROR_NONE on success,
760 * otherwise a negative error value
761 * @retval #CKMC_ERROR_NONE Successful
762 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
763 * @see ckmc_param_list_new()
764 * @see ckmc_param_list_set_integer()
765 * @see ckmc_param_list_set_buffer()
766 * @see ckmc_param_list_get_buffer()
767 * @see ckmc_param_list_free()
768 * @see ckmc_generate_new_params()
769 * @see #ckmc_param_list_h
770 * @see #ckmc_param_name_e
771 * @see #ckmc_algo_type_e
773 int ckmc_param_list_get_integer(ckmc_param_list_h params, ckmc_param_name_e name, uint64_t *pvalue);
777 * @brief Gets buffer parameter from the list.
779 * @remarks Caller is responsible for #ckmc_param_list_h creation.
780 * @param[in] params Algorithm param list handle created with ckmc_param_list_new() or ckmc_generate_new_params()
781 * which contains param with @a name
782 * @param[in] name Name of parameter to get
783 * @param[out] ppbuffer Value of the parameter in form of a buffer \n
784 * Caller is responsible for creating and freeing the buffer
785 * @return #CKMC_ERROR_NONE on success,
786 * otherwise a negative error value
787 * @retval #CKMC_ERROR_NONE Successful
788 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
789 * @see ckmc_param_list_new()
790 * @see ckmc_param_list_set_integer()
791 * @see ckmc_param_list_set_buffer()
792 * @see ckmc_param_list_get_integer()
793 * @see ckmc_param_list_free()
794 * @see ckmc_generate_new_params()
795 * @see ckmc_buffer_free()
796 * @see #ckmc_param_list_h
797 * @see #ckmc_param_name_e
798 * @see #ckmc_algo_type_e
800 int ckmc_param_list_get_buffer(ckmc_param_list_h params, ckmc_param_name_e name, ckmc_raw_buffer_s **ppbuffer);
804 * @brief Frees previously allocated list of algorithm params.
806 * @param[in] params First element of the list to be freed
807 * @see ckmc_param_list_new()
808 * @see ckmc_param_list_set_integer()
809 * @see ckmc_param_list_set_buffer()
810 * @see ckmc_param_list_get_integer()
811 * @see ckmc_param_list_get_buffer()
812 * @see ckmc_generate_new_params()
813 * @see #ckmc_param_list_h
814 * @see #ckmc_param_name_e
815 * @see #ckmc_algo_type_e
817 void ckmc_param_list_free(ckmc_param_list_h params);
821 * @brief Generates algorithm parameters for a given algorithm type and set them to the list.
823 * @remarks Caller is responsible for #ckmc_param_list_h destruction.
824 * @remarks Algorithm parameters are set to default values. Optional fields are left empty.
825 * Initialization vectors are left empty (they have to be set manually).
826 * Caller is responsible for freeing the list with ckmc_param_list_free().
827 * @remarks If the function returns error, provided param list may contain some of default parameters.
828 * @param[in] type Type of the algorithm
829 * @param[out] pparams Newly generated handle of param list which should be freed by caller after use
830 * @return #CKMC_ERROR_NONE on success,
831 * otherwise a negative error value
832 * @retval #CKMC_ERROR_NONE Successful
833 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
834 * @see ckmc_param_list_new()
835 * @see ckmc_param_list_set_integer()
836 * @see ckmc_param_list_set_buffer()
837 * @see ckmc_param_list_get_integer()
838 * @see ckmc_param_list_get_buffer()
839 * @see ckmc_param_list_free()
840 * @see #ckmc_param_list_h
841 * @see #ckmc_param_name_e
842 * @see #ckmc_algo_type_e
844 int ckmc_generate_new_params(ckmc_algo_type_e type, ckmc_param_list_h *pparams);
857 #endif /* __TIZEN_CORE_CKMC_TYPE_H */