X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Finclude%2Fckmc%2Fckmc-type.h;h=a450b86a3b9914bcc6eba082a7f25defa8df7630;hb=b5d73601f8a1a7a70797934e139617d5356c7f48;hp=b392137cc9b2a57fc8da2522183e1847ff8b1a62;hpb=cd65cc9a73c2f964cc5bcd7d6335c0d7be5613c5;p=platform%2Fcore%2Fsecurity%2Fkey-manager.git diff --git a/src/include/ckmc/ckmc-type.h b/src/include/ckmc/ckmc-type.h index b392137..a450b86 100644 --- a/src/include/ckmc/ckmc-type.h +++ b/src/include/ckmc/ckmc-type.h @@ -23,6 +23,7 @@ #define __TIZEN_CORE_CKMC_TYPE_H #include +#include #include #define KEY_MANAGER_CAPI __attribute__((visibility("default"))) @@ -42,7 +43,16 @@ extern "C" { * case, separator " " (space bar) is used to separate label and alias. * @see key-manager_doc.h */ -extern char const * const ckmc_label_name_separator; +KEY_MANAGER_CAPI extern char const * const ckmc_label_name_separator; + +/** + * shared database label - user may be given permission to access shared + * database items. In such case, the alias should contain shared database + * label. + * @see ckmc_label_name_separator + * @see key-manager_doc.h + */ +KEY_MANAGER_CAPI extern char const * const ckmc_label_shared_owner; /** * @brief Enumeration for key types of key manager. @@ -66,7 +76,8 @@ typedef enum __ckmc_key_type { typedef enum __ckmc_data_format { CKMC_FORM_DER_BASE64 = 0, /**< DER format base64 encoded data */ CKMC_FORM_DER, /**< DER encoded data */ - CKMC_FORM_PEM /**< PEM encoded data. It consists of the DER format base64 encoded with additional header and footer lines. */ + CKMC_FORM_PEM /**< PEM encoded data. It consists of the DER format base64 encoded + with additional header and footer lines. */ } ckmc_data_format_e; /** @@ -74,9 +85,11 @@ typedef enum __ckmc_data_format { * @since_tizen 2.3 */ typedef enum __ckmc_ec_type { - CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended elliptic curve domain */ + CKMC_EC_PRIME192V1 = 0, /**< Elliptic curve domain "secp192r1" listed in "SEC 2" recommended + elliptic curve domain */ CKMC_EC_PRIME256V1, /**< "SEC 2" recommended elliptic curve domain - secp256r1 */ - CKMC_EC_SECP384R1 /**< NIST curve P-384 (covers "secp384r1", the elliptic curve domain listed in See SEC 2 */ + CKMC_EC_SECP384R1 /**< NIST curve P-384 (covers "secp384r1", the elliptic curve domain + listed in See SEC 2 */ } ckmc_ec_type_e; /** @@ -102,7 +115,7 @@ typedef enum __ckmc_rsa_padding_algo { } ckmc_rsa_padding_algo_e; /** - * @deprecated, use ckmc_permission_e instead + * @deprecated Deprecated since 2.4. [Use ckmc_permission_e() instead] * @brief Enumeration for database access rights. * @since_tizen 2.3 */ @@ -113,7 +126,7 @@ typedef enum __ckmc_access_right{ /** * @brief Enumeration for permissions to access/modify alias. - * @since_tizen 3.0 + * @since_tizen 2.4 */ typedef enum __ckmc_permission{ CKMC_PERMISSION_NONE = 0x00, /**< clear permissions */ @@ -135,7 +148,9 @@ typedef struct __ckmc_raw_buff { * @since_tizen 2.3 */ typedef struct __ckmc_policy { - char* password; /**< Byte array used to encrypt data inside CKM. If it is not null, the data(or key, or certificate) is stored encrypted with this password inside key manager */ + char* password; /**< Byte array used to encrypt data inside CKM. If it is not null, the data + (or key, or certificate) is stored encrypted with this password inside + key manager */ bool extractable; /**< If true key may be extracted from storage */ } ckmc_policy_s; @@ -179,8 +194,24 @@ typedef struct __ckmc_cert_list { } ckmc_cert_list_s; /** + * @brief Enumeration for OCSP status. + * @since_tizen 2.4 + */ +typedef enum __ckmc_ocsp_status { + CKMC_OCSP_STATUS_GOOD = 0, /**< OCSP status is good */ + CKMC_OCSP_STATUS_REVOKED, /**< certificate is revoked */ + CKMC_OCSP_STATUS_UNKNOWN, /**< unknown error */ + CKMC_OCSP_ERROR_UNSUPPORTED, /**< certificate does not provide OCSP extension */ + CKMC_OCSP_ERROR_INVALID_URL, /**< invalid URL in certificate OCSP extension */ + CKMC_OCSP_ERROR_INVALID_RESPONSE, /**< invalid response from OCSP server */ + CKMC_OCSP_ERROR_REMOTE, /**< OCSP remote server error */ + CKMC_OCSP_ERROR_NET, /**< network connection error */ + CKMC_OCSP_ERROR_INTERNAL /**< OpenSSL API error */ +} ckmc_ocsp_status_e; + +/** * @brief The structure for PKCS12 used in key manager CAPI. - * @since_tizen 2.3 + * @since_tizen 2.4 */ typedef struct __ckmc_pkcs12 { ckmc_key_s *priv_key; /**< private key, may be null */ @@ -188,6 +219,104 @@ typedef struct __ckmc_pkcs12 { ckmc_cert_list_s *ca_chain; /**< chain certificates list, may be null */ } ckmc_pkcs12_s; +/** + * @brief Enumeration for crypto algorithm parameters. + * @since_tizen 3.0 + */ +typedef enum __ckmc_param_name { + CKMC_PARAM_ALGO_TYPE = 1, + + // encryption & decryption + CKMC_PARAM_ED_IV = 101, /**< 16B buffer (up to 2^64-1 bytes long in case of AES GCM) */ + CKMC_PARAM_ED_CTR_LEN, /**< integer - ctr length in bits*/ + CKMC_PARAM_ED_AAD, /**< buffer */ + CKMC_PARAM_ED_TAG_LEN, /**< integer - tag length in bits */ + CKMC_PARAM_ED_LABEL, /**< buffer */ + + // key generation + CKMC_PARAM_GEN_KEY_LEN = 201, /**< integer - key length in bits */ + CKMC_PARAM_GEN_EC, /**< integer - elliptic curve (ckmc_ec_type_e) */ + + // sign & verify + CKMC_PARAM_SV_HASH_ALGO = 301, /**< integer - hash algorithm (ckmc_hash_algo_e) */ + CKMC_PARAM_SV_RSA_PADDING, /**< integer - RSA padding (ckmc_rsa_padding_algo_e) */ +}ckmc_param_name_e; + +/** + * @brief Structure for algorithm parameter list. + * @since_tizen 3.0 + */ +typedef struct __ckmc_param_list ckmc_param_list_s; + +/** + * @brief Enumeration for crypto algorithm types. + * @since_tizen 3.0 + */ +typedef enum __ckmc_algo_type { + CKMC_ALGO_AES_CTR = 1, /**< AES-CTR algorithm + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_ED_IV + - CKMC_PARAM_ED_CTR_LEN (128 only) */ + + CKMC_ALGO_AES_CBC, /**< AES-CBC algorithm + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_ED_IV */ + + CKMC_ALGO_AES_GCM, /**< AES-GCM algorithm + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_ED_IV + - CKMC_PARAM_ED_TAG_LEN + - CKMC_PARAM_ED_AAD */ + + CKMC_ALGO_AES_CFB, /**< AES-CFB algorithm + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_ED_IV */ + + CKMC_ALGO_RSA_OAEP, /**< RSA-OAEP algorithm + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_ED_LABEL */ + + CKMC_ALGO_RSA_SV, /**< RSA algorithm used for signing/verification + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_SV_HASH_ALGO + - CKMC_PARAM_SV_RSA_PADDING */ + + CKMC_ALGO_DSA_SV, /**< DSA algorithm used for signing/verification + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_SV_HASH_ALGO */ + + CKMC_ALGO_ECDSA_SV, /**< ECDA algorithm used for signing/verification + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_SV_HASH_ALGO */ + + CKMC_ALGO_RSA_GEN, /**< RSA algorithm used for key generation + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_GEN_KEY_LEN */ + + CKMC_ALGO_DSA_GEN, /**< DSA algorithm used for key generation + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_GEN_KEY_LEN */ + + CKMC_ALGO_ECDSA_GEN, /**< ECDSA algorithm used for key generation + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_GEN_EC */ + + CKMC_ALGO_AES_GEN, /**< AES key generation + Supported parameters: + - CKMC_PARAM_ALGO_TYPE, + - CKMC_PARAM_GEN_KEY_LEN */ +} ckmc_algo_type_e; /** * @internal @@ -195,7 +324,8 @@ typedef struct __ckmc_pkcs12 { * * @since_tizen 2.3 * - * @remarks You must destroy the newly created @a ckmc_key_s by calling ckmc_key_free() if it is no longer needed. + * @remarks You must destroy the newly created @a ckmc_key_s by calling ckmc_key_free() if it is no + * longer needed. * * @param[in] raw_key The byte array of key \n * @a raw_key may be encrypted with password. @@ -214,8 +344,10 @@ typedef struct __ckmc_pkcs12 { * @see ckmc_key_free() * @see #ckmc_key_s */ -int ckmc_key_new(unsigned char *raw_key, size_t key_size, - ckmc_key_type_e key_type, char *password, ckmc_key_s **ppkey); +int ckmc_key_new(unsigned char *raw_key, + size_t key_size, + ckmc_key_type_e key_type, + char *password, ckmc_key_s **ppkey); /** * @brief Destroys the @a ckmc_key_s handle and releases all its resources. @@ -233,7 +365,8 @@ void ckmc_key_free(ckmc_key_s *key); * * @since_tizen 2.3 * - * @remarks You must destroy the newly created @a ckmc_raw_buffer_s by calling ckmc_buffer_free() if it is no longer needed. + * @remarks You must destroy the newly created @a ckmc_raw_buffer_s by calling ckmc_buffer_free() if + * it is no longer needed. * * @param[in] data The byte array of buffer * @param[in] size The byte size of buffer @@ -266,7 +399,8 @@ void ckmc_buffer_free(ckmc_raw_buffer_s *buffer); * * @since_tizen 2.3 * - * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is no longer needed. + * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is + * no longer needed. * * @param[in] raw_cert The byte array of certificate * @param[in] cert_size The byte size of raw_cert @@ -283,8 +417,10 @@ void ckmc_buffer_free(ckmc_raw_buffer_s *buffer); * @see ckmc_load_cert_from_file() * @see #ckmc_cert_s */ -int ckmc_cert_new(unsigned char *raw_cert, size_t cert_size, - ckmc_data_format_e data_format, ckmc_cert_s **ppcert); +int ckmc_cert_new(unsigned char *raw_cert, + size_t cert_size, + ckmc_data_format_e data_format, + ckmc_cert_s **ppcert); /** * @brief Destroys the @a ckmc_cert handle and releases all its resources. @@ -303,7 +439,8 @@ void ckmc_cert_free(ckmc_cert_s *cert); * * @since_tizen 2.3 * - * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is no longer needed. + * @remarks You must destroy the newly created @a ckmc_cert_s by calling ckmc_cert_free() if it is + * no longer needed. * * @param[in] file_path The path of certificate file to be loaded \n * The only DER or PEM encoded certificate file is supported. @@ -323,12 +460,15 @@ void ckmc_cert_free(ckmc_cert_s *cert); int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert); /** + * @internal * @brief Creates a new @a ckmc_pkcs12_s handle and returns it. * - * @since_tizen 2.3 + * @since_tizen 2.4 * - * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it is no longer needed. - * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly returned ckmc_pkcs12_s. + * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if it + * is no longer needed. + * @remarks On success, private_key, cert && ca_cert_list ownership is transferred into newly + * returned ckmc_pkcs12_s. * * @param[in] private_key @a ckmc_key_s handle to the private key (optional) * @param[in] cert @a ckmc_cert_s handle to the certificate (optional) @@ -338,27 +478,33 @@ int ckmc_load_cert_from_file(const char *file_path, ckmc_cert_s **cert); * @return @c 0 on success, * otherwise a negative error value * - * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or private_key, cert and ca_cert_list all are null. + * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or private_key, cert and + * ca_cert_list all are null. * @retval #CKMC_ERROR_OUT_OF_MEMORY Not enough memory * * @see ckmc_pkcs12_free() * @see ckmc_load_from_pkcs12_file() - * @see ckmc_load_from_pkcs12_file2() + * @see ckmc_pkcs12_load() * @see #ckmc_key_s * @see #ckmc_cert_s * @see #ckmc_cert_list_s * @see #ckmc_pkcs12_s */ -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); +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); /** - * @deprecated, use @a ckmc_load_from_pkcs12_file2() instead - * @brief Creates a new @a ckmc_key_s(private key), @a ckmc_cert_s(certificate), and @a ckmc_cert_list_s(CA certificates) handle from a given PKCS#12 file and returns them. + * @deprecated Deprecated since 2.4. [Use ckmc_pkcs12_load() instead] + * @brief Creates a new @a ckmc_key_s(private key), @a ckmc_cert_s(certificate), and + * @a ckmc_cert_list_s(CA certificates) handle from a given PKCS#12 file and returns them. * * @since_tizen 2.3 * - * @remarks You must destroy the newly created @a ckmc_key_s, @a ckmc_cert_s, and @a ckmc_cert_list_s by calling ckmc_key_free(), ckmc_cert_free(), and ckmc_cert_list_all_free() if they are no longer needed. + * @remarks You must destroy the newly created @a ckmc_key_s, @a ckmc_cert_s, and + * @a ckmc_cert_list_s by calling ckmc_key_free(), ckmc_cert_free(), and + * ckmc_cert_list_all_free() if they are no longer needed. * * @param[in] file_path The path of PKCS12 file to be loaded * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n @@ -366,7 +512,8 @@ int ckmc_pkcs12_new(ckmc_key_s *private_key, ckmc_cert_s *cert, * @param[out] private_key The pointer of newly created @a ckmc_key_s handle for a private key * @param[out] cert The pointer of newly created @a ckmc_cert_s handle for a certificate \n * It is null if the PKCS12 file does not contain a certificate. - * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA certificates \n + * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA + * certificates \n * It is null if the PKCS12 file does not contain CA certificates. * * @return #CKMC_ERROR_NONE on success, @@ -378,7 +525,7 @@ int ckmc_pkcs12_new(ckmc_key_s *private_key, ckmc_cert_s *cert, * @retval #CKMC_ERROR_FILE_ACCESS_DENIED Provided file does not exist or cannot be accessed * * @see ckmc_pkcs12_new() - * @see ckmc_load_from_pkcs12_file2() + * @see ckmc_pkcs12_load() * @see ckmc_key_free() * @see ckmc_cert_free() * @see ckmc_cert_list_all_free() @@ -386,21 +533,24 @@ int ckmc_pkcs12_new(ckmc_key_s *private_key, ckmc_cert_s *cert, * @see #ckmc_cert_s * @see #ckmc_cert_list_s */ -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); +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); /** * @brief Creates a new @a ckmc_pkcs12_s handle from a given PKCS#12 file and returns it. * - * @since_tizen 2.3 + * @since_tizen 2.4 * - * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if they are no longer needed. + * @remarks You must destroy the newly created @a ckmc_pkcs12_s by calling ckmc_pkcs12_free() if + * they are no longer needed. * * @param[in] file_path The path of PKCS12 file to be loaded * @param[in] passphrase The passphrase used to decrypt the PCKS12 file \n * If PKCS12 file is not encrypted, passphrase can be null. - * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA certificates \n + * @param[out] ca_cert_list The pointer of newly created @a ckmc_cert_list_s handle for CA + * certificates \n * It is null if the PKCS12 file does not contain CA certificates. * * @return #CKMC_ERROR_NONE on success, @@ -414,28 +564,33 @@ int ckmc_load_from_pkcs12_file(const char *file_path, const char *passphrase, * @see ckmc_pkcs12_free() * @see #ckmc_pkcs12_s */ -int ckmc_load_from_pkcs12_file2(const char *file_path, const char *passphrase, ckmc_pkcs12_s **pkcs12_bundle); +int ckmc_pkcs12_load(const char *file_path, + const char *passphrase, + ckmc_pkcs12_s **pkcs12_bundle); /** * @brief Destroys the @a ckmc_pkcs12_s handle and releases all its resources. * - * @since_tizen 2.3 + * @since_tizen 2.4 * * @param[in] pkcs12 The @a ckmc_pkcs12_s handle to destroy * * @see ckmc_pkcs12_new() - * @see ckmc_load_from_pkcs12_file2() + * @see ckmc_pkcs12_load() */ void ckmc_pkcs12_free(ckmc_pkcs12_s *pkcs12); /** * @internal * @brief Creates a new @a ckmc_alias_list_s handle and returns it. - * The alias pointer in the returned @a ckmc_alias_list_s handle points to the provided characters and next is null. + * The alias pointer in the returned @a ckmc_alias_list_s handle points to the provided + * characters and next is null. * * @since_tizen 2.3 * - * @remarks You must destroy the newly created @a ckmc_alias_list_s by calling ckmc_alias_list_free() or ckmc_alias_list_all_free() if it is no longer needed. + * @remarks You must destroy the newly created @a ckmc_alias_list_s + * by calling ckmc_alias_list_free() or ckmc_alias_list_all_free() if it is no longer + * needed. * * @param[in] alias The first item to be set in the newly created @a ckmc_alias_list_s * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle @@ -453,12 +608,14 @@ int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list); /** * @internal - * @brief Creates a new @a ckmc_alias_list_s handle, adds it to a previous @a ckmc_alias_list_s and returns it. - * The alias pointer in the returned @a ckmc_alias_list_s handle points to the provided characters and next is null. + * @brief Creates a new @a ckmc_alias_list_s handle, adds it to a previous @a ckmc_alias_list_s and + * returns it. The alias pointer in the returned @a ckmc_alias_list_s handle points to the + * provided characters and next is null. * * @since_tizen 2.3 * - * @param[in] previous The last @a ckmc_alias_list_s handle to which a newly created @a ckmc_alias_list_s is added + * @param[in] previous The last @a ckmc_alias_list_s handle to which a newly created + * @a ckmc_alias_list_s is added * @param[in] alias The item to be set in the newly created @a ckmc_alias_list_s * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle * @@ -472,11 +629,13 @@ int ckmc_alias_list_new(char *alias, ckmc_alias_list_s **ppalias_list); * @see #ckmc_alias_list_s */ int ckmc_alias_list_add(ckmc_alias_list_s *previous, - char *alias, ckmc_alias_list_s **pplast); + char *alias, + ckmc_alias_list_s **pplast); /** * @internal - * @brief Destroys the @a ckmc_alias_list_s handle and releases resources of @a ckmc_alias_list_s from the provided first handle cascadingly. + * @brief Destroys the @a ckmc_alias_list_s handle and releases resources of @a ckmc_alias_list_s + * from the provided first handle cascadingly. * * @since_tizen 2.3 * @@ -490,7 +649,8 @@ int ckmc_alias_list_add(ckmc_alias_list_s *previous, void ckmc_alias_list_free(ckmc_alias_list_s *first); /** - * @brief Destroys the @a ckmc_alias_list_s handle and releases all its resources from the provided first handle cascadingly. + * @brief Destroys the @a ckmc_alias_list_s handle and releases all its resources from the provided + * first handle cascadingly. * * @since_tizen 2.3 * @@ -505,11 +665,13 @@ void ckmc_alias_list_all_free(ckmc_alias_list_s *first); /** * @internal * @brief Creates a new @a ckmc_cert_list_s handle and returns it. - * The cert pointer in the returned @a ckmc_cert_list_s handle points to the provided @a ckmc_cert_s and next is null. + * The cert pointer in the returned @a ckmc_cert_list_s handle points to the provided + * @a ckmc_cert_s and next is null. * * @since_tizen 2.3 * - * @remarks You must destroy the newly created @a ckmc_cert_list_s by calling ckmc_cert_list_free() or ckmc_cert_list_all_free() if it is no longer needed. + * @remarks You must destroy the newly created @a ckmc_cert_list_s by calling ckmc_cert_list_free() + * or ckmc_cert_list_all_free() if it is no longer needed. * * @param[in] cert The first item to be set in the newly created @a ckmc_cert_list_s * @param[out] ppalias_list The pointer to a newly created @a ckmc_alias_list_s handle @@ -527,12 +689,14 @@ int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list); /** * @internal - * @brief Creates a new @a ckmc_cert_list_s handle, adds it to a previous @a ckmc_cert_list_s and returns it. - * The cert pointer in the returned @a ckmc_alias_list_s handle points to the provided @a ckmc_cert_s and next is null. + * @brief Creates a new @a ckmc_cert_list_s handle, adds it to a previous @a ckmc_cert_list_s and + * returns it. The cert pointer in the returned @a ckmc_alias_list_s handle points to the + * provided @a ckmc_cert_s and next is null. * * @since_tizen 2.3 * - * @param[in] previous The last @a ckmc_cert_list_s handle to which a newly created @a ckmc_cert_list_s is added + * @param[in] previous The last @a ckmc_cert_list_s handle to which a newly created + * @a ckmc_cert_list_s is added * @param[in] cert The item to be set in the newly created @a ckmc_cert_list_s * @param[out] pplast The pointer to a newly created and added @a ckmc_alias_list_s handle * @@ -545,12 +709,12 @@ int ckmc_cert_list_new(ckmc_cert_s *cert, ckmc_cert_list_s **ppalias_list); * @see ckmc_cert_list_all_free() * @see #ckmc_cert_list_s */ -int ckmc_cert_list_add(ckmc_cert_list_s *previous, - ckmc_cert_s *cert, ckmc_cert_list_s **pplast); +int ckmc_cert_list_add(ckmc_cert_list_s *previous, ckmc_cert_s *cert, ckmc_cert_list_s **pplast); /** * @internal - * @brief Destroys the @a ckmc_cert_list_s handle and releases resources of @a ckmc_cert_list_s from the provided first handle cascadingly. + * @brief Destroys the @a ckmc_cert_list_s handle and releases resources of @a ckmc_cert_list_s + * from the provided first handle cascadingly. * * @since_tizen 2.3 * @@ -564,7 +728,8 @@ int ckmc_cert_list_add(ckmc_cert_list_s *previous, void ckmc_cert_list_free(ckmc_cert_list_s *first); /** - * @brief Destroys the @a ckmc_cert_list_s handle and releases all its resources from the provided first handle cascadingly. + * @brief Destroys the @a ckmc_cert_list_s handle and releases all its resources from the provided + * first handle cascadingly. * * @since_tizen 2.3 * @@ -577,6 +742,202 @@ void ckmc_cert_list_free(ckmc_cert_list_s *first); void ckmc_cert_list_all_free(ckmc_cert_list_s *first); /** + * @brief Creates new parameter list + * + * @since_tizen 3.0 + * + * @remarks Caller is responsible for freeing it with ckmc_param_list_free + * + * @param[in] ppparam_list Double pointer to the list variable to which the newly created list will + * be assigned. + * + * @return @c 0 on success, otherwise a negative error value + * + * @retval #CKMC_ERROR_NONE Successful + * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid + * + * @see ckmc_param_list_add_integer + * @see ckmc_param_list_add_buffer + * @see ckmc_param_list_free + * @see ckmc_generate_params + * @see #ckmc_param_list_s + * @see #ckmc_param_name_e + */ +int ckmc_param_list_new(ckmc_param_list_s **ppparams); + +/** + * @brief Adds integer parameter to the list + * + * @since_tizen 3.0 + * + * @remarks Caller is responsible for ckmc_param_list_s creation. + * + * @param[in] params List of params created with ckcm_param_list_new. + * @param[in] name Name of parameter to add. Existing parameter will be overwritten. Passing + * invalid parameter name will result in an error. + * @param[in] value Value of the parameter in form of a integer. + * + * @return @c 0 on success, otherwise a negative error value + * + * @retval #CKMC_ERROR_NONE Successful + * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid + * + * @see ckmc_param_list_new + * @see ckmc_param_list_add_buffer + * @see ckmc_param_list_get_integer + * @see ckmc_param_list_get_buffer + * @see ckmc_param_list_free + * @see ckmc_generate_params + * @see #ckmc_param_list_s + * @see #ckmc_param_name_e + */ +int ckmc_param_list_add_integer(ckmc_param_list_s *params, + ckmc_param_name_e name, + uint64_t value); + +/** + * @brief Adds buffer parameter to the list + * + * @since_tizen 3.0 + * + * @remarks Caller is responsible for ckmc_param_list_s creation. + * + * @param[in] params List of params created with ckcm_param_list_new. + * @param[in] name Name of parameter to add. Existing parameter will be overwritten. Passing + * invalid parameter name will result in an error + * @param[in] buffer Value of the parameter in form of a buffer. Caller is responsible for + * creating and freeing the buffer. + * + * @return @c 0 on success, otherwise a negative error value + * + * @retval #CKMC_ERROR_NONE Successful + * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid + * + * @see ckmc_param_list_new + * @see ckmc_param_list_add_integer + * @see ckmc_param_list_get_integer + * @see ckmc_param_list_get_buffer + * @see ckmc_param_list_free + * @see ckmc_generate_params + * @see #ckmc_param_list_s + * @see #ckmc_param_name_e + */ +int ckmc_param_list_add_buffer(ckmc_param_list_s *params, + ckmc_param_name_e name, + const ckmc_raw_buffer_s *buffer); + +/** + * @brief Gets integer parameter from the list. + * + * @since_tizen 3.0 + * + * @remarks Caller is responsible for ckmc_param_list_s creation. + * + * @param[in] params List of params created with ckcm_param_list_new. + * @param[in] name Name of parameter to get. + * @param[out] value Value of the parameter in form of a integer. + * + * @return @c 0 on success, otherwise a negative error value + * + * @retval #CKMC_ERROR_NONE Successful + * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid + * + * @see ckmc_param_list_new + * @see ckmc_param_list_add_integer + * @see ckmc_param_list_add_buffer + * @see ckmc_param_list_get_buffer + * @see ckmc_param_list_free + * @see ckmc_generate_params + * @see #ckmc_param_list_s + * @see #ckmc_param_name_e + */ + +int ckmc_param_list_get_integer(const ckmc_param_list_s *params, + ckmc_param_name_e name, + uint64_t* value); + +/** + * @brief Gets buffer parameter from the list. + * + * @since_tizen 3.0 + * + * @remarks Caller is responsible for ckmc_param_list_s creation. + * + * @param[in] params List of params created with ckcm_param_list_new. + * @param[in] name Name of parameter to get. + * @param[out] buffer Value of the parameter in form of a buffer. Caller is responsible for + * creating and freeing the buffer. + * + * @return @c 0 on success, otherwise a negative error value + * + * @retval #CKMC_ERROR_NONE Successful + * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid + * + * @see ckmc_param_list_new + * @see ckmc_param_list_add_integer + * @see ckmc_param_list_add_buffer + * @see ckmc_param_list_get_integer + * @see ckmc_param_list_free + * @see ckmc_generate_params + * @see #ckmc_param_list_s + * @see #ckmc_param_name_e + */ +int ckmc_param_list_get_buffer(const ckmc_param_list_s *params, + ckmc_param_name_e name, + ckmc_raw_buffer_s **buffer); + +/** + * @brief Frees previously allocated list of algorithm params + * + * @since_tizen 3.0 + * + * @param[in] first First element of the list to be freed. + * + * @see ckmc_param_list_new + * @see ckmc_param_list_add_integer + * @see ckmc_param_list_add_buffer + * @see ckmc_param_list_get_integer + * @see ckmc_param_list_get_buffer + * @see ckmc_generate_params + * @see #ckmc_param_list_s + * @see #ckmc_param_name_e + */ + +void ckmc_param_list_free(ckmc_param_list_s *params); + +/** + * @brief Generates algorithm parameters for a given algorithm type and adds them to the list. + * + * @since_tizen 3.0 + * + * @remarks Caller is responsible for ckmc_param_list_s creation and destruction. + * @remarks Algorithm parameters are set to default values. Optional fields are left empty. + * Initialization vectors are left empty (they have to be added manually). Existing params + * will be overwritten with default values. Caller is responsible for freeing the list with + * ckmc_param_list_free. + * @remarks If the function returns error provided param list may contain some of default parameters + * + * @param[in] type Type of the algorithm + * @param[out] params List of params to be filled. List should be empty. Otherwise an error will + * be returned. + * + * @return @c 0 on success, otherwise a negative error value + * + * @retval #CKMC_ERROR_NONE Successful + * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid + * + * @see ckmc_param_list_new + * @see ckmc_param_list_add_integer + * @see ckmc_param_list_add_buffer + * @see ckmc_param_list_get_integer + * @see ckmc_param_list_get_buffer + * @see ckmc_param_list_free + * @see #ckmc_param_list_s + * @see #ckmc_param_name_e + */ +int ckmc_generate_params(ckmc_algo_type_e type, ckmc_param_list_s *params); + +/** * @} */