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
17 * @file ckmc-manager.h
19 * @brief Provides management functions(storing, retrieving, and removing) for keys,
20 * certificates and data of a user and additional crypto functions.
24 #ifndef __TIZEN_CORE_CKMC_MANAGER_H
25 #define __TIZEN_CORE_CKMC_MANAGER_H
29 #include <sys/types.h>
31 #include <ckmc/ckmc-type.h>
32 #include <ckmc/ckmc-error.h>
41 * @addtogroup CAPI_KEY_MANAGER_CLIENT_MODULE
47 * @brief Stores a key inside key manager based on the provided policy.
49 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
50 * @remarks Currently API supports seven types of keys. These are RSA public/private key, DSA public/private key, ECDSA public/private key, and AES symmetric key.
51 * @remarks key_type in key may be set to #CKMC_KEY_NONE as an input. key_type is determined inside key manager during storing keys.
52 * @remarks Some private key files are protected by a password. If raw_key in key read from those encrypted files is encrypted with a password, the password should be provided in the #ckmc_key_s structure.
53 * @remarks If password in policy is provided, the key is additionally encrypted with the password in the policy.
54 * @param[in] alias The name of a key to be stored
55 * @param[in] key The key's binary value to be stored
56 * @param[in] policy The policy about how to store a key securely
57 * @return @c 0 on success,
58 * otherwise a negative error value
59 * @retval #CKMC_ERROR_NONE Successful
60 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
61 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
62 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
63 * @retval #CKMC_ERROR_INVALID_FORMAT The format of raw_key is not valid
64 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
65 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
66 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
67 * @see ckmc_remove_alias()
69 * @see ckmc_get_key_alias_list()
73 int ckmc_save_key(const char *alias, const ckmc_key_s key, const ckmc_policy_s policy);
77 * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif [Use ckmc_remove_alias() instead]
78 * @brief Removes a key from key manager.
80 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
81 * @remarks To remove key, client must have remove permission to the specified key.
82 * @remarks The key owner can remove by default.
83 * @param[in] alias The name of a key to be removed
84 * @return @c 0 on success,
85 * otherwise a negative error value
86 * @retval #CKMC_ERROR_NONE Successful
87 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
88 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
89 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
90 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
91 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
92 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
93 * @see ckmc_save_key()
95 * @see ckmc_get_key_alias_list()
97 int ckmc_remove_key(const char *alias)
102 * @brief Gets a key from key manager.
104 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
105 * @remarks A client can access only data stored by the client.
106 * @remarks You must destroy the newly created @a ppkey by calling ckmc_key_free() if it is no longer needed.
107 * @param[in] alias The name of a key to retrieve
108 * @param[in] password The password used in decrypting a key value \n
109 * If password of policy is provided in ckmc_save_key(), the same password should be provided
110 * @param[out] ppkey The pointer to a newly created ckmc_key_s handle
111 * @return @c 0 on success,
112 * otherwise a negative error value
113 * @retval #CKMC_ERROR_NONE Successful
114 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
115 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
116 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
117 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
118 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
119 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Decryption failed because password is incorrect
120 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
121 * @see ckmc_save_key()
122 * @see ckmc_remove_alias()
123 * @see ckmc_get_key_alias_list()
125 int ckmc_get_key(const char *alias, const char *password, ckmc_key_s **ppkey);
129 * @brief Gets all the alias of keys that the client can access.
131 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
132 * @remarks A client can access only data stored by the client.
133 * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free()
134 * if it is no longer needed.
135 * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all
136 * available alias of keys \n
137 * If there is no available key alias, *ppalias_list will be null
138 * @return @c 0 on success,
139 * otherwise a negative error value
140 * @retval #CKMC_ERROR_NONE Successful
141 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
142 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
143 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
144 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
145 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
146 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
147 * @see ckmc_save_key()
148 * @see ckmc_remove_alias()
149 * @see ckmc_get_key()
151 int ckmc_get_key_alias_list(ckmc_alias_list_s **ppalias_list);
156 * @brief Stores a certificate inside key manager based on the provided policy.
158 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0
159 * @remarks The certificate's binary value will be converted and saved as binary DER encoded certificates.
160 * @param[in] alias The name of a certificate to be stored
161 * @param[in] cert The certificate's binary value to be stored
162 * @param[in] policy The policy about how to store a certificate securely
163 * @return @c 0 on success,
164 * otherwise a negative error value
165 * @retval #CKMC_ERROR_NONE Successful
166 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
167 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
168 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
169 * @retval #CKMC_ERROR_INVALID_FORMAT The format of raw_cert is not valid
170 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
171 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
172 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
173 * @see ckmc_remove_alias()
174 * @see ckmc_get_cert()
175 * @see ckmc_get_cert_alias_list()
177 * @see #ckmc_policy_s
179 int ckmc_save_cert(const char *alias, const ckmc_cert_s cert, const ckmc_policy_s policy);
183 * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif [Use ckmc_remove_alias() instead]
184 * @brief Removes a certificate from key manager.
186 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
187 * @remarks To remove certificate, client must have remove permission to the specified certificate.
188 * @remarks The key owner can remove by default.
189 * @param[in] alias The name of a certificate to be removed
190 * @return @c 0 on success,
191 * otherwise a negative error value
192 * @retval #CKMC_ERROR_NONE Successful
193 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
194 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
195 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
196 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
197 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
198 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
199 * @see ckmc_save_cert()
200 * @see ckmc_get_cert()
201 * @see ckmc_get_cert_alias_list()
203 int ckmc_remove_cert(const char *alias)
204 TIZEN_DEPRECATED_API;
208 * @brief Gets a certificate from key manager.
210 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
211 * @remarks A client can access only certificate stored by the client.
212 * @remarks A DER encoded certificate will be returned as a return value.
213 * @remarks You must destroy the newly created @a ppcert by calling ckmc_cert_free() if it is no longer needed.
214 * @param[in] alias The name of a certificate to retrieve
215 * @param[in] password The password used in decrypting a certificate value \n
216 * If password of policy is provided in ckmc_save_cert(), the same password
218 * @param[out] ppcert The pointer to a newly created ckmc_cert_s handle
219 * @return @c 0 on success,
220 * otherwise a negative error value
221 * @retval #CKMC_ERROR_NONE Successful
222 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
223 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
224 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
225 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exists
226 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
227 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Decryption failed because password is incorrect
228 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
229 * @see ckmc_save_cert()
230 * @see ckmc_remove_alias()
231 * @see ckmc_get_cert_alias_list()
233 int ckmc_get_cert(const char *alias, const char *password, ckmc_cert_s **ppcert);
237 * @brief Gets all alias of certificates which the client can access.
239 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
240 * @remarks A client can access only data stored by the client.
241 * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free() if it is no longer needed.
242 * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys \n
243 * If there is no available key alias, *ppalias_list will be null
244 * @return @c 0 on success,
245 * otherwise a negative error value
246 * @retval #CKMC_ERROR_NONE Successful
247 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
248 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
249 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
250 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
251 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
252 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
253 * @see ckmc_save_cert()
254 * @see ckmc_remove_alias()
255 * @see ckmc_get_cert()
257 int ckmc_get_cert_alias_list(ckmc_alias_list_s **ppalias_list);
261 * @brief Stores PKCS12's contents inside key manager based on the provided policies. All items from the PKCS12 will use the same alias.
262 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
263 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
264 * @param[in] alias The name of a data to be stored
265 * @param[in] pkcs Pointer to the pkcs12 structure to be saved
266 * @param[in] key_policy The policy about how to store pkcs's private key
267 * @param[in] cert_policy The policy about how to store pkcs's certificate
268 * @return @c 0 on success,
269 * otherwise a negative error value
270 * @retval #CKMC_ERROR_NONE Successful
271 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
272 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
273 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
274 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
275 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
276 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
277 * @see ckmc_remove_alias()
278 * @see ckmc_get_pkcs12()
279 * @see ckmc_get_data_alias_list()
280 * @see ckmc_pkcs12_load()
281 * @see #ckmc_pkcs12_s
282 * @see #ckmc_policy_s
284 int ckmc_save_pkcs12(const char *alias, const ckmc_pkcs12_s *pkcs, const ckmc_policy_s key_policy,const ckmc_policy_s cert_policy);
288 * @brief Gets a pkcs12 from key manager.
289 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
290 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
291 * @remarks A client can access only data stored by the client.
292 * @remarks You must destroy the newly created @a pkcs12 by calling ckmc_pkcs12_free() if it is no longer needed.
293 * @param[in] alias The name of a data to retrieve
294 * @param[in] key_password Password that was used to encrypt privateKey (may be NULL)
295 * @param[in] cert_password Password used to encrypt certificates (may be NULL)
296 * @param[out] pkcs12 The pointer to a newly created ckmc_pkcs12_s handle
297 * @return @c 0 on success,
298 * otherwise a negative error value
299 * @retval #CKMC_ERROR_NONE Successful
300 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
301 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
302 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
303 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
304 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
305 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED key_password or cert_password does not match with password used to encrypt data
306 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
307 * @see ckmc_save_pkcs12()
308 * @see ckmc_remove_alias()
310 int ckmc_get_pkcs12(const char *alias, const char *key_password, const char *cert_password, ckmc_pkcs12_s **pkcs12);
314 * @brief Stores a data inside key manager based on the provided policy.
316 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
317 * @param[in] alias The name of a data to be stored
318 * @param[in] data The binary value to be stored
319 * @param[in] policy The policy about how to store a data securely
320 * @return @c 0 on success,
321 * otherwise a negative error value
322 * @retval #CKMC_ERROR_NONE Successful
323 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
324 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
325 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
326 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
327 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
328 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
329 * @see ckmc_remove_alias()
330 * @see ckmc_get_data()
331 * @see ckmc_get_data_alias_list()
332 * @see #ckmc_raw_buffer_s
333 * @see #ckmc_policy_s
335 int ckmc_save_data(const char *alias, ckmc_raw_buffer_s data, const ckmc_policy_s policy);
339 * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif [Use ckmc_remove_alias() instead]
340 * @brief Removes a data from key manager.
342 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
343 * @remarks To remove data, client must have remove permission to the specified data object.
344 * @remarks The data owner can remove by default.
345 * @param[in] alias The name of a data to be removed
346 * @return @c 0 on success,
347 * otherwise a negative error value
348 * @retval #CKMC_ERROR_NONE Successful
349 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
350 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
351 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
352 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
353 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
354 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
355 * @see ckmc_save_data()
356 * @see ckmc_get_data()
357 * @see ckmc_get_data_alias_list()
359 int ckmc_remove_data(const char *alias)
360 TIZEN_DEPRECATED_API;
364 * @brief Gets a data from key manager.
366 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
367 * @remarks A client can access only data stored by the client.
368 * @remarks You must destroy the newly created @a ppdata by calling ckmc_buffer_free() if it is no longer needed.
369 * @param[in] alias The name of a data to retrieve
370 * @param[in] password The password used in decrypting a data value \n
371 * If password of policy is provided in ckmc_save_data(), the same password
373 * @param[out] ppdata The pointer to a newly created ckmc_raw_buffer_s handle
374 * @return @c 0 on success,
375 * otherwise a negative error value
376 * @retval #CKMC_ERROR_NONE Successful
377 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
378 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
379 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
380 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
381 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
382 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Decryption failed because password is incorrect
383 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
384 * @see ckmc_save_data()
385 * @see ckmc_remove_alias()
386 * @see ckmc_get_data_alias_list()
388 int ckmc_get_data(const char *alias, const char *password, ckmc_raw_buffer_s **ppdata);
392 * @brief Gets all alias of data which the client can access.
394 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
395 * @remarks A client can access only data stored by the client.
396 * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free() if it is no longer needed.
397 * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys \n
398 * If there is no available key alias, *ppalias_list will be null
399 * @return @c 0 on success,
400 * otherwise a negative error value
401 * @retval #CKMC_ERROR_NONE Successful
402 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
403 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
404 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
405 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
406 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
407 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
408 * @see ckmc_save_data()
409 * @see ckmc_remove_alias()
410 * @see ckmc_get_data()
412 int ckmc_get_data_alias_list(ckmc_alias_list_s **ppalias_list);
416 * @brief Creates RSA private/public key pair and stores them inside key manager based on each policy.
418 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
419 * @remarks If password in the policy is provided, the key is additionally encrypted with the password in the policy.
420 * @param[in] size The size of key strength to be created \n
421 * @c 1024, @c 2048, and @c 4096 are supported
422 * @param[in] private_key_alias The name of private key to be stored
423 * @param[in] public_key_alias The name of public key to be stored
424 * @param[in] policy_private_key The policy about how to store a private key securely
425 * @param[in] policy_public_key The policy about how to store a public key securely
426 * @return @c 0 on success,
427 * otherwise a negative error value
428 * @retval #CKMC_ERROR_NONE Successful
429 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
430 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
431 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
432 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
433 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
434 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
435 * @see ckmc_create_key_pair_dsa()
436 * @see ckmc_create_key_pair_ecdsa()
437 * @see ckmc_create_signature()
438 * @see ckmc_verify_signature()
440 int ckmc_create_key_pair_rsa(const size_t size, const char *private_key_alias, const char *public_key_alias, const ckmc_policy_s policy_private_key, const ckmc_policy_s policy_public_key);
444 * @brief Creates DSA private/public key pair and stores them inside key manager based on each policy.
446 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
447 * @remarks If password in the policy is provided, the key is additionally encrypted with the password in the policy.
448 * @param[in] size The size of key strength to be created \n
449 * @c 1024, @c 2048, @c 3072 and @c 4096 are supported
450 * @param[in] private_key_alias The name of private key to be stored
451 * @param[in] public_key_alias The name of public key to be stored
452 * @param[in] policy_private_key The policy about how to store a private key securely
453 * @param[in] policy_public_key The policy about how to store a public key securely
454 * @return @c 0 on success,
455 * otherwise a negative error value
456 * @retval #CKMC_ERROR_NONE Successful
457 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
458 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
459 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
460 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
461 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
462 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
463 * @see ckmc_create_key_pair_rsa()
464 * @see ckmc_create_key_pair_ecdsa()
465 * @see ckmc_create_signature()
466 * @see ckmc_verify_signature()
468 int ckmc_create_key_pair_dsa(const size_t size, const char *private_key_alias, const char *public_key_alias, const ckmc_policy_s policy_private_key, const ckmc_policy_s policy_public_key);
472 * @brief Creates ECDSA private/public key pair and stores them inside key manager based on each policy.
474 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
475 * @remarks If password in the policy is provided, the key is additionally encrypted with the password in the policy.
476 * @param[in] type The type of elliptic curve of ECDSA
477 * @param[in] private_key_alias The name of private key to be stored
478 * @param[in] public_key_alias The name of public key to be stored
479 * @param[in] policy_private_key The policy about how to store a private key securely
480 * @param[in] policy_public_key The policy about how to store a public key securely
481 * @return @c 0 on success,
482 * otherwise a negative error value
483 * @retval #CKMC_ERROR_NONE Successful
484 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
485 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
486 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
487 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
488 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
489 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
490 * @see ckmc_create_key_pair_rsa()
491 * @see ckmc_create_key_pair_dsa()
492 * @see ckmc_create_signature()
493 * @see ckmc_verify_signature()
494 * @see #ckmc_ec_type_e
496 int ckmc_create_key_pair_ecdsa(const ckmc_ec_type_e type, const char *private_key_alias, const char *public_key_alias, const ckmc_policy_s policy_private_key, const ckmc_policy_s policy_public_key);
500 * @brief Creates AES key and stores it inside key manager based on the policy.
502 * @remarks If password in the policy is provided, the key is additionally encrypted with the password in the policy.
503 * @param[in] size The size of key strength to be created \n
504 * @c 128, @c 192 and @c 256 are supported
505 * @param[in] key_alias The name of key to be stored
506 * @param[in] key_policy The policy about how to store the key securely
507 * @return @c 0 on success,
508 * otherwise a negative error value
509 * @retval #CKMC_ERROR_NONE Successful
510 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
511 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
512 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
513 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
514 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
515 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
516 * @see ckmc_create_key_pair_rsa()
517 * @see ckmc_create_key_pair_dsa()
518 * @see ckmc_create_key_pair_ecdsa()
519 * @see #ckmc_policy_s
521 int ckmc_create_key_aes(size_t size, const char *key_alias, ckmc_policy_s key_policy);
525 * @brief Creates a signature on a given message using a private key and returns the signature.
527 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
528 * @remarks If password of policy is provided during storing a key, the same password should be provided.
529 * @remarks You must destroy the newly created @a ppsignature by calling ckmc_buffer_free() if it is no longer needed.
530 * @param[in] private_key_alias The name of private key
531 * @param[in] password The password used in decrypting a private key value
532 * @param[in] message The message that is signed with a private key
533 * @param[in] hash The hash algorithm used in creating signature
534 * @param[in] padding The RSA padding algorithm used in creating signature \n
535 * It is used only when the signature algorithm is RSA. If
536 * @a padding is CKMC_NONE_PADDING you must use CKMC_HASH_NONE
537 * and the message must be equal to key length
538 * @param[out] ppsignature The pointer to a newly created signature \n
539 * If an error occurs, @a *ppsignature will be null
540 * @return @c 0 on success,
541 * otherwise a negative error value
542 * @retval #CKMC_ERROR_NONE Successful
543 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
544 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
545 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
546 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
547 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
548 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Decryption failed because password is incorrect
549 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
550 * @see ckmc_create_key_pair_rsa()
551 * @see ckmc_create_key_pair_ecdsa()
552 * @see ckmc_verify_signature()
553 * @see ckmc_buffer_free()
554 * @see #ckmc_hash_algo_e
555 * @see #ckmc_rsa_padding_algo_e
557 int ckmc_create_signature(const char *private_key_alias, const char *password, const ckmc_raw_buffer_s message, const ckmc_hash_algo_e hash, const ckmc_rsa_padding_algo_e padding, ckmc_raw_buffer_s **ppsignature);
561 * @brief Verifies a given signature on a given message using a public key and returns the signature status.
563 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
564 * @remarks If password of policy is provided during storing a key, the same password should be provided.
565 * @param[in] public_key_alias The name of public key
566 * @param[in] password The password used in decrypting a public key value
567 * @param[in] message The input on which the signature is created
568 * @param[in] signature The signature that is verified with public key
569 * @param[in] hash The hash algorithm used in verifying signature
570 * @param[in] padding The RSA padding algorithm used in verifying signature \n
571 * It is used only when the signature algorithm is RSA. If
572 * @a padding is CKMC_NONE_PADDING you must use CKMC_HASH_NONE
573 * and the message must be equal to key length
574 * @return @c 0 on success and the signature is valid,
575 * otherwise a negative error value
576 * @retval #CKMC_ERROR_NONE Successful
577 * @retval #CKMC_ERROR_VERIFICATION_FAILED The signature is invalid
578 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
579 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
580 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
581 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
582 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
583 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Decryption failed because password is incorrect
584 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
585 * @see ckmc_create_key_pair_rsa()
586 * @see ckmc_create_key_pair_ecdsa()
587 * @see ckmc_verify_signature()
588 * @see #ckmc_hash_algo_e
589 * @see #ckmc_rsa_padding_algo_e
591 int ckmc_verify_signature(const char *public_key_alias, const char *password, const ckmc_raw_buffer_s message, const ckmc_raw_buffer_s signature, const ckmc_hash_algo_e hash, const ckmc_rsa_padding_algo_e padding);
595 * @brief Verifies a certificate chain and returns that chain.
597 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
598 * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
599 * @remarks You must destroy the newly created @a ppcert_chain_list by calling ckmc_cert_list_all_free() if it is no longer needed.
600 * @param[in] cert The certificate to be verified
601 * @param[in] untrustedcerts The untrusted CA certificates to be used in verifying a certificate chain
602 * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
603 * If an error occurs, @a *ppcert_chain_list will be null
604 * @return @c 0 on success and the signature is valid,
605 * otherwise a negative error value
606 * @retval #CKMC_ERROR_NONE Successful
607 * @retval #CKMC_ERROR_VERIFICATION_FAILED The certificate chain is not valid
608 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
609 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
610 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
611 * @retval #CKMC_ERROR_INVALID_FORMAT The format of certificate is not valid
612 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
613 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Decryption failed because password is incorrect
614 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
615 * @see ckmc_cert_list_all_free()
617 int ckmc_get_cert_chain(const ckmc_cert_s *cert, const ckmc_cert_list_s *untrustedcerts, ckmc_cert_list_s **ppcert_chain_list);
621 * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif [Use ckmc_get_cert_chain() instead]
622 * @brief Verifies a certificate chain using an alias list of untrusted certificates and return that chain.
624 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
625 * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
626 * @remarks You must destroy the newly created @a ppcert_chain_list by calling ckmc_cert_list_all_free() if it is no longer needed.
627 * @remarks @a untrustedcerts shouldn't be protected with optional password.
628 * @param[in] cert The certificate to be verified
629 * @param[in] untrustedcerts The alias list of untrusted CA certificates stored in key manager to be used in verifying a certificate chain
630 * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
631 * If an error occurs, @a *ppcert_chain_list will be null
632 * @return @c 0 on success and the signature is valid,
633 * otherwise a negative error value
634 * @retval #CKMC_ERROR_NONE Successful
635 * @retval #CKMC_ERROR_VERIFICATION_FAILED The certificate chain is not valid
636 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
637 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
638 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
639 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
640 * @retval #CKMC_ERROR_INVALID_FORMAT The format of certificate is not valid
641 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
642 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Some certificates were encrypted with password and could not be used
643 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
644 * @see ckmc_get_cert_chain()
645 * @see ckmc_cert_list_all_free()
647 int ckmc_get_cert_chain_with_alias(const ckmc_cert_s *cert, const ckmc_alias_list_s *untrustedcerts, ckmc_cert_list_s **ppcert_chain_list) TIZEN_DEPRECATED_API;
651 * @brief Verifies a certificate chain and returns that chain using user-entered, trusted, and untrusted CA certificates.
652 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
653 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
654 * @remarks If the trusted root certificates are provided as a user input, these certificates do not need to exist in the system's certificate storage.
655 * @remarks You must destroy the newly created @a ppcert_chain_list by calling ckmc_cert_list_all_free() if it is no longer needed.
656 * @param[in] cert The certificate to be verified
657 * @param[in] untrustedcerts The untrusted CA certificates to be used in verifying a certificate chain
658 * @param[in] trustedcerts The trusted CA certificates to be used in verifying a certificate chain
659 * @param[in] use_trustedsystemcerts The flag indicating the use of the trusted root certificates in the system's certificate storage
660 * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
661 * If an error occurs, @a *ppcert_chain_list will be null
662 * @return @c 0 on success and the signature is valid,
663 * otherwise a negative error value
664 * @retval #CKMC_ERROR_NONE Successful
665 * @retval #CKMC_ERROR_VERIFICATION_FAILED The certificate chain is not valid
666 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
667 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
668 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
669 * @retval #CKMC_ERROR_INVALID_FORMAT The format of certificate is not valid
670 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
671 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
672 * @see ckmc_cert_list_all_free()
674 int ckmc_get_cert_chain_with_trustedcert(const ckmc_cert_s *cert, const ckmc_cert_list_s *untrustedcerts, const ckmc_cert_list_s *trustedcerts, const bool use_trustedsystemcerts, ckmc_cert_list_s **ppcert_chain_list);
678 * @brief Perform OCSP that checks certificate is whether revoked or not.
679 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
681 * @privilege %http://tizen.org/privilege/internet
682 * @remarks %http://tizen.org/privilege/internet (public level privilege) is required to use this API instead of %http://tizen.org/privilege/keymanager (public level privilege) since 3.0.
683 * @param[in] pcert_chain_list Valid certificate chain to perform OCSP check
684 * @param[out] ocsp_status The pointer to status result of OCSP check
685 * @return @c 0 on success,
686 * otherwise a negative error value
687 * @retval #CKMC_ERROR_NONE Successful
688 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
689 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
690 * @retval #CKMC_ERROR_NOT_SUPPORTED Device needed to run API is not supported
691 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
692 * @pre @a pcert_chain_list is created with ckmc_get_certificate_chain() or
693 * ckmc_get_certificate_chain_with_alias().
694 * @see ckmc_get_cert_chain())
695 * @see ckmc_cert_list_all_free()
697 int ckmc_ocsp_check(const ckmc_cert_list_s *pcert_chain_list, ckmc_ocsp_status_e *ocsp_status);
701 * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif [Use ckmc_set_permission() instead]
702 * @brief Allows another application to access client's application data.
704 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
705 * @remarks Data identified by @a alias should exist.
706 * @param[in] alias Data alias for which access will be granted
707 * @param[in] accessor Package id of the application that will gain access rights
708 * @param[in] granted Rights granted for @a accessor application
709 * @return @c 0 on success,
710 * otherwise a negative error value
711 * @retval #CKMC_ERROR_NONE Successful
712 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
713 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
714 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
715 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
716 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
717 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
718 * @see ckmc_deny_access()
720 int ckmc_allow_access(const char *alias, const char *accessor, ckmc_access_right_e granted) TIZEN_DEPRECATED_API;
724 * @brief Allows another application to access client's application data.
725 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
726 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
727 * @remarks Data identified by @a alias should exist.
728 * @param[in] alias Data alias for which access will be granted
729 * @param[in] accessor Package id of the application that will gain access rights
730 * @param[in] permissions Mask of permissions granted for @a accessor application
731 * (#ckmc_permission_e)
732 * (previous permission mask will be replaced with the new mask value)
733 * @return @c 0 on success,
734 * otherwise a negative error value
735 * @retval #CKMC_ERROR_NONE Successful
736 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
737 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
738 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
739 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
740 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
741 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
743 int ckmc_set_permission(const char *alias, const char *accessor, int permissions);
747 * @deprecated Deprecated since @if MOBILE 2.4. @elseif WEARABLE 3.0. @endif [Use ckmc_set_permission() instead]
748 * @brief Revokes another application's access to client's application data.
750 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
751 * @remarks Data identified by @a alias should exist.
752 * @remarks Only access previously granted with ckmc_allow_access can be revoked.
753 * @param[in] alias Data alias for which access will be revoked
754 * @param[in] accessor Package id of the application that will lose access rights
755 * @return @c 0 on success,
756 * otherwise a negative error value
757 * @retval #CKMC_ERROR_NONE Successful
758 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or the @a accessor doesn't have access to @a alias
759 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
760 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
761 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
762 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
763 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
764 * @see ckmc_allow_access()
765 * @see ckmc_set_permission()
767 int ckmc_deny_access(const char *alias, const char *accessor) TIZEN_DEPRECATED_API;
771 * @brief Removes an entry (no matter of type) from the key manager.
772 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
773 * @remarks %http://tizen.org/privilege/keymanager (public level privilege) is no longer required to use this API since 3.0.
774 * @remarks To remove item, client must have remove permission to the specified item.
775 * @remarks The item owner can remove by default.
776 * @param[in] alias Item alias to be removed
777 * @return @c 0 on success,
778 * otherwise a negative error value
779 * @retval #CKMC_ERROR_NONE Successful
780 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
781 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
782 * @retval #CKMC_ERROR_DB_ERROR Failed due to a database error
783 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
784 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
785 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
786 * @see ckmc_save_key()
787 * @see ckmc_save_cert()
788 * @see ckmc_save_data()
789 * @see ckmc_save_pkcs12()
790 * @see ckmc_create_key_pair_rsa()
791 * @see ckmc_create_key_pair_dsa()
792 * @see ckmc_create_key_pair_ecdsa()
794 int ckmc_remove_alias(const char *alias);
798 * @brief Encrypts data using selected key and algorithm.
800 * @remarks Key identified by @a key_alias should exist.
801 * @param[in] params Algorithm parameter list handle. See #ckmc_param_list_h and
802 * #ckmc_algo_type_e for details
803 * @param[in] key_alias Alias of the key to be used for encryption
804 * @param[in] password The password used in decrypting a key value \n
805 * If password of the policy is provided in ckmc_save_key(), the same
806 * password should be provided
807 * @param[in] decrypted Data to be encrypted. In case of AES algorithm there are no restrictions on the size of data.
808 * For RSA the size must be smaller or equal to key size in bytes - 42.
809 * Example: for 1024 RSA key the maximum data size is 1024/8 - 42 = 86
810 * @param[out] ppencrypted Encrypted data (some algorithms may return additional information embedded in encrypted data.
811 * AES GCM is an example) \n
812 * The caller is responsible for freeing @a encrypted with ckmc_buffer_free()
813 * @return @c 0 on success,
814 * otherwise a negative error value
815 * @retval #CKMC_ERROR_NONE Successful
816 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid (missing or invalid
817 * mandatory algorithm parameter, decrypted = NULL,
818 * ppencrypted = NULL)
819 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
820 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
821 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Key with given alias does not exist
822 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
823 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Key decryption failed because password is incorrect
824 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
825 * @see ckmc_buffer_free()
826 * @see ckmc_param_list_new()
827 * @see ckmc_param_list_free()
828 * @see ckmc_param_list_set_integer()
829 * @see ckmc_param_list_set_buffer()
830 * @see ckmc_generate_new_params()
831 * @see #ckmc_param_list_h
832 * @see #ckmc_param_name_e
833 * @see #ckmc_algo_type_e
835 int ckmc_encrypt_data(ckmc_param_list_h params, const char *key_alias, const char *password, const ckmc_raw_buffer_s decrypted, ckmc_raw_buffer_s **ppencrypted);
839 * @brief Decrypts data using selected key and algorithm.
841 * @remarks Key identified by @a key_alias should exist.
842 * @param[in] params Algorithm parameter list handle. You should use the same parameters that were used for encryption.
843 * See #ckmc_param_list_h and #ckmc_algo_type_e for details
844 * @param[in] key_alias Alias of the key to be used for encryption
845 * @param[in] password The password used in decrypting a key value \n
846 * If password of the policy is provided in ckmc_save_key(), the same password should be provided
847 * @param[in] encrypted Data to be decrypted (some algorithms may require additional information embedded in encrypted data. AES GCM is an example)
848 * @param[out] ppdecrypted Decrypted data \n
849 * The caller is responsible for freeing @a decrypted with ckmc_buffer_free()
850 * @return @c 0 on success,
851 * otherwise a negative error value
852 * @retval #CKMC_ERROR_NONE Successful
853 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid (missing or invalid
854 * mandatory algorithm parameter, encrypted = NULL,
855 * ppdecrypted = NULL)
856 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
857 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
858 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Key with given alias does not exist
859 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
860 * @retval #CKMC_ERROR_AUTHENTICATION_FAILED Key decryption failed because password is incorrect
861 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
862 * @see ckmc_buffer_free()
863 * @see ckmc_param_list_new()
864 * @see ckmc_param_list_free()
865 * @see ckmc_param_list_set_integer()
866 * @see ckmc_param_list_set_buffer()
867 * @see ckmc_generate_new_params()
868 * @see #ckmc_param_list_h
869 * @see #ckmc_param_name_e
870 * @see #ckmc_algo_type_e
872 int ckmc_decrypt_data(ckmc_param_list_h params, const char *key_alias, const char *password, const ckmc_raw_buffer_s encrypted, ckmc_raw_buffer_s **ppdecrypted);
885 #endif /* __TIZEN_CORE_CKMC_MANAGER_H */