2 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
17 * @file ckmc-manager.h
19 * @brief Provides management functions(storing, retrieving, and removing) for keys, certificates and data of a user and additional crypto functions.
23 #ifndef __TIZEN_CORE_CKMC_MANAGER_H
24 #define __TIZEN_CORE_CKMC_MANAGER_H
27 #include <sys/types.h>
29 #include <ckmc/ckmc-type.h>
30 #include <ckmc/ckmc-error.h>
37 * @addtogroup CAPI_KEY_MANAGER_CLIENT_MODULE
43 * @brief Stores a key inside key manager based on the provided policy.
47 * @privilege %http://tizen.org/privilege/keymanager
49 * @remarks Currently only six types of keys are supported for this API. These are RSA public/private key, DSA public/private key and ECDSA public/private key.
50 * @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.
51 * @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.
52 * @remarks If password in policy is provided, the key is additionally encrypted with the password in 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
58 * @return @c 0 on success,
59 * otherwise a negative error value
61 * @retval #CKMC_ERROR_NONE Successful
62 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
63 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
64 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
65 * @retval #CKMC_ERROR_INVALID_FORMAT The format of raw_key is not valid
66 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
67 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
69 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
71 * @see ckmc_remove_key()
73 * @see ckmc_get_key_alias_list()
77 int ckmc_save_key(const char *alias, const ckmc_key_s key, const ckmc_policy_s policy);
80 * @brief Removes a key from key manager.
84 * @privilege %http://tizen.org/privilege/keymanager
86 * @remarks A client can remove only keys stored by the client.
88 * @param[in] alias The name of a key to be removed
90 * @return @c 0 on success,
91 * otherwise a negative error value
93 * @retval #CKMC_ERROR_NONE Successful
94 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
95 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
96 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
97 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
98 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
100 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
102 * @see ckmc_save_key()
103 * @see ckmc_get_key()
104 * @see ckmc_get_key_alias_list()
106 int ckmc_remove_key(const char *alias);
109 * @brief Gets a key from key manager.
113 * @privilege %http://tizen.org/privilege/keymanager
115 * @remarks A client can access only data stored by the client.
116 * @remarks You must destroy the newly created @a ppkey by calling ckmc_key_free() if it is no longer needed.
118 * @param[in] alias The name of a key to retrieve
119 * @param[in] password The password used in decrypting a key value \n
120 * If password of policy is provided in ckmc_save_key(), the same password should be provided.
121 * @param[out] ppkey The pointer to a newly created ckmc_key_s handle
123 * @return @c 0 on success,
124 * otherwise a negative error value
126 * @retval #CKMC_ERROR_NONE Successful
127 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
128 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
129 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
130 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
131 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
133 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
135 * @see ckmc_save_key()
136 * @see ckmc_remove_key()
137 * @see ckmc_get_key_alias_list()
139 int ckmc_get_key(const char *alias, const char *password, ckmc_key_s **ppkey);
142 * @brief Gets all the alias of keys that the client can access.
146 * @privilege %http://tizen.org/privilege/keymanager
148 * @remarks A client can access only data stored by the client.
149 * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free() if it is no longer needed.
151 * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys \n
152 * If there is no available key alias, *ppalias_list will be null.
154 * @return @c 0 on success,
155 * otherwise a negative error value
157 * @retval #CKMC_ERROR_NONE Successful
158 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
159 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
160 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
161 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
162 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
164 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
166 * @see ckmc_save_key()
167 * @see ckmc_remove_key()
168 * @see ckmc_get_key()
170 int ckmc_get_key_alias_list(ckmc_alias_list_s** ppalias_list);
176 * @brief Stores a certificate inside key manager based on the provided policy.
180 * @privilege %http://tizen.org/privilege/keymanager
182 * @remarks the certificate's binary value will be converted and saved as binary DER encoded certificates.
184 * @param[in] alias The name of a certificate to be stored
185 * @param[in] cert The certificate's binary value to be stored
186 * @param[in] policy The policy about how to store a certificate securely
188 * @return @c 0 on success,
189 * otherwise a negative error value
191 * @retval #CKMC_ERROR_NONE Successful
192 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
193 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
194 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
195 * @retval #CKMC_ERROR_INVALID_FORMAT The format of raw_cert is not valid
196 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
197 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
199 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
201 * @see ckmc_remove_cert()
202 * @see ckmc_get_cert()
203 * @see ckmc_get_cert_alias_list()
205 * @see #ckmc_policy_s
207 int ckmc_save_cert(const char *alias, const ckmc_cert_s cert, const ckmc_policy_s policy);
210 * @brief Removes a certificate from key manager.
214 * @privilege %http://tizen.org/privilege/keymanager
216 * @remarks A client can remove only certificates stored by the client.
218 * @param[in] alias The name of a certificate to be removed
220 * @return @c 0 on success,
221 * otherwise a negative error value
223 * @retval #CKMC_ERROR_NONE Successful
224 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
225 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
226 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
227 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
228 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
230 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
232 * @see ckmc_save_cert()
233 * @see ckmc_get_cert()
234 * @see ckmc_get_cert_alias_list()
236 int ckmc_remove_cert(const char *alias);
239 * @brief Gets a certificate from key manager.
243 * @privilege %http://tizen.org/privilege/keymanager
245 * @remarks A client can access only certificate stored by the client.
246 * @remarks A DER encoded certificate will be returned as a return value.
247 * @remarks You must destroy the newly created @a ppcert by calling ckmc_cert_free() if it is no longer needed.
249 * @param[in] alias The name of a certificate to retrieve
250 * @param[in] password The password used in decrypting a certificate value \n
251 * If password of policy is provided in ckmc_save_cert(), the same password should be provided.
252 * @param[out] ppcert The pointer to a newly created ckmc_cert_s handle
254 * @return @c 0 on success,
255 * otherwise a negative error value
257 * @retval #CKMC_ERROR_NONE Successful
258 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
259 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
260 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
261 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exists
262 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
264 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
266 * @see ckmc_save_cert()
267 * @see ckmc_remove_cert()
268 * @see ckmc_get_cert_alias_list()
270 int ckmc_get_cert(const char *alias, const char *password, ckmc_cert_s **ppcert);
273 * @brief Gets all alias of certificates which the client can access.
277 * @privilege %http://tizen.org/privilege/keymanager
279 * @remarks A client can access only data stored by the client.
280 * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free() if it is no longer needed.
282 * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys \n
283 * If there is no available key alias, *ppalias_list will be null.
285 * @return @c 0 on success,
286 * otherwise a negative error value
288 * @retval #CKMC_ERROR_NONE Successful
289 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
290 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
291 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
292 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
293 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
295 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
297 * @see ckmc_save_cert()
298 * @see ckmc_remove_cert()
299 * @see ckmc_get_cert()
301 int ckmc_get_cert_alias_list(ckmc_alias_list_s** ppalias_list);
307 * @brief Stores a data inside key manager based on the provided policy.
311 * @privilege %http://tizen.org/privilege/keymanager
313 * @param[in] alias The name of a data to be stored
314 * @param[in] data The binary value to be stored
315 * @param[in] policy The policy about how to store a data securely
317 * @return @c 0 on success,
318 * otherwise a negative error value
320 * @retval #CKMC_ERROR_NONE Successful
321 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
322 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
323 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
324 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
325 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
327 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
329 * @see ckmc_remove_data()
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);
338 * @brief Removes a data from key manager.
342 * @privilege %http://tizen.org/privilege/keymanager
344 * @remarks A client can remove only data stored by the client.
346 * @param[in] alias The name of a data to be removed
348 * @return @c 0 on success,
349 * otherwise a negative error value
351 * @retval #CKMC_ERROR_NONE Successful
352 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
353 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
354 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
355 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
356 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
358 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
360 * @see ckmc_save_data()
361 * @see ckmc_get_data()
362 * @see ckmc_get_data_alias_list()
364 int ckmc_remove_data(const char *alias);
367 * @brief Gets a data from key manager.
371 * @privilege %http://tizen.org/privilege/keymanager
373 * @remarks A client can access only data stored by the client.
374 * @remarks You must destroy the newly created @a ppdata by calling ckmc_buffer_free() if it is no longer needed.
376 * @param[in] alias The name of a data to retrieve
377 * @param[in] password The password used in decrypting a data value \n
378 * If password of policy is provided in ckmc_save_data(), the same password should be provided.
379 * @param[out] ppdata The pointer to a newly created ckmc_raw_buffer_s handle
381 * @return @c 0 on success,
382 * otherwise a negative error value
384 * @retval #CKMC_ERROR_NONE Successful
385 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
386 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
387 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
388 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
389 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
391 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
393 * @see ckmc_save_data()
394 * @see ckmc_remove_data()
395 * @see ckmc_get_data_alias_list()
397 int ckmc_get_data(const char *alias, const char *password, ckmc_raw_buffer_s **ppdata);
400 * @brief Gets all alias of data which the client can access.
404 * @privilege %http://tizen.org/privilege/keymanager
406 * @remarks A client can access only data stored by the client.
407 * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free() if it is no longer needed.
409 * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys \n
410 * If there is no available key alias, *ppalias_list will be null.
412 * @return @c 0 on success,
413 * otherwise a negative error value
415 * @retval #CKMC_ERROR_NONE Successful
416 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
417 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
418 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
419 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
420 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
422 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
424 * @see ckmc_save_data()
425 * @see ckmc_remove_data()
426 * @see ckmc_get_data()
428 int ckmc_get_data_alias_list(ckmc_alias_list_s** ppalias_list);
434 * @brief Creates RSA private/public key pair and stores them inside key manager based on each policy.
438 * @privilege %http://tizen.org/privilege/keymanager
440 * @remarks If password in policy is provided, the key is additionally encrypted with the password in policy.
442 * @param[in] size The size of key strength to be created \n
443 * @c 1024, @c 2048, and @c 4096 are supported.
444 * @param[in] private_key_alias The name of private key to be stored
445 * @param[in] public_key_alias The name of public key to be stored
446 * @param[in] policy_private_key The policy about how to store a private key securely
447 * @param[in] policy_public_key The policy about how to store a public key securely
449 * @return @c 0 on success,
450 * otherwise a negative error value
452 * @retval #CKMC_ERROR_NONE Successful
453 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
454 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
455 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
456 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
457 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
459 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
461 * @see ckmc_create_key_pair_dsa()
462 * @see ckmc_create_key_pair_ecdsa()
463 * @see ckmc_create_signature()
464 * @see ckmc_verify_signature()
466 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);
469 * @brief Creates DSA private/public key pair and stores them inside key manager based on each policy.
473 * @privilege %http://tizen.org/privilege/keymanager
475 * @remarks If password in policy is provided, the key is additionally encrypted with the password in policy.
477 * @param[in] size The size of key strength to be created \n
478 * @c 1024, @c 2048, @c 3072 and @c 4096 are supported.
479 * @param[in] private_key_alias The name of private key to be stored
480 * @param[in] public_key_alias The name of public key to be stored
481 * @param[in] policy_private_key The policy about how to store a private key securely
482 * @param[in] policy_public_key The policy about how to store a public key securely
484 * @return @c 0 on success,
485 * otherwise a negative error value
487 * @retval #CKMC_ERROR_NONE Successful
488 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
489 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
490 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
491 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
492 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
494 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
496 * @see ckmc_create_key_pair_rsa()
497 * @see ckmc_create_key_pair_ecdsa()
498 * @see ckmc_create_signature()
499 * @see ckmc_verify_signature()
501 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);
504 * @brief Creates ECDSA private/public key pair and stores them inside key manager based on each policy.
508 * @privilege %http://tizen.org/privilege/keymanager
510 * @remarks If password in policy is provided, the key is additionally encrypted with the password in policy.
512 * @param[in] type The type of elliptic curve of ECDSA
513 * @param[in] private_key_alias The name of private key to be stored
514 * @param[in] public_key_alias The name of public key to be stored
515 * @param[in] policy_private_key The policy about how to store a private key securely
516 * @param[in] policy_public_key The policy about how to store a public key securely
518 * @return @c 0 on success,
519 * otherwise a negative error value
521 * @retval #CKMC_ERROR_NONE Successful
522 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
523 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
524 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
525 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
526 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
528 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
530 * @see ckmc_create_key_pair_rsa()
531 * @see ckmc_create_key_pair_dsa()
532 * @see ckmc_create_signature()
533 * @see ckmc_verify_signature()
534 * @see #ckmc_ec_type_e
536 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);
539 * @brief Creates a signature on a given message using a private key and returns the signature.
543 * @privilege %http://tizen.org/privilege/keymanager
545 * @remarks If password of policy is provided during storing a key, the same password should be provided.
546 * @remarks You must destroy the newly created @a ppsignature by calling ckmc_buffer_free() if it is no longer needed.
548 * @param[in] private_key_alias The name of private key
549 * @param[in] password The password used in decrypting a private key value
550 * @param[in] message The message that is signed with a private key
551 * @param[in] hash The hash algorithm used in creating signature
552 * @param[in] padding The RSA padding algorithm used in creating signature \n
553 * It is used only when the signature algorithm is RSA.
554 * @param[out] ppsignature The pointer to a newly created signature \n
555 * If an error occurs, @a *ppsignature will be null.
557 * @return @c 0 on success,
558 * otherwise a negative error value
560 * @retval #CKMC_ERROR_NONE Successful
561 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
562 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
563 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
564 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
565 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
567 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
569 * @see ckmc_create_key_pair_rsa()
570 * @see ckmc_create_key_pair_ecdsa()
571 * @see ckmc_verify_signature()
572 * @see ckmc_buffer_free()
573 * @see #ckmc_hash_algo_e
574 * @see #ckmc_rsa_padding_algo_e
576 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);
579 * @brief Verifies a given signature on a given message using a public key and returns the signature status.
583 * @privilege %http://tizen.org/privilege/keymanager
585 * @remarks If password of policy is provided during storing a key, the same password should be provided.
587 * @param[in] public_key_alias The name of public key
588 * @param[in] password The password used in decrypting a public key value
589 * @param[in] message The input on which the signature is created
590 * @param[in] signature The signature that is verified with public key
591 * @param[in] hash The hash algorithm used in verifying signature
592 * @param[in] padding The RSA padding algorithm used in verifying signature \n
593 * It is used only when the signature algorithm is RSA.
595 * @return @c 0 on success and the signature is valid,
596 * otherwise a negative error value
598 * @retval #CKMC_ERROR_NONE Successful
599 * @retval #CKMC_ERROR_VERIFICATION_FAILED The signature is invalid
600 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
601 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
602 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
603 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
604 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
606 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
608 * @see ckmc_create_key_pair_rsa()
609 * @see ckmc_create_key_pair_ecdsa()
610 * @see ckmc_verify_signature()
611 * @see #ckmc_hash_algo_e
612 * @see #ckmc_rsa_padding_algo_e
614 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);
617 * @brief Verifies a certificate chain and returns that chain.
621 * @privilege %http://tizen.org/privilege/keymanager
623 * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
624 * @remarks You must destroy the newly created @a ppcert_chain_list by calling ckmc_cert_list_all_free() if it is no longer needed.
626 * @param[in] cert The certificate to be verified
627 * @param[in] untrustedcerts The untrusted CA certificates to be used in verifying a certificate chain
628 * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
629 * If an error occurs, @a *ppcert_chain_list will be null.
631 * @return @c 0 on success and the signature is valid,
632 * 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_INVALID_FORMAT The format of certificate is not valid
640 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
642 * @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_with_alias())
645 * @see ckmc_cert_list_all_free()
647 int ckmc_get_cert_chain(const ckmc_cert_s *cert, const ckmc_cert_list_s *untrustedcerts, ckmc_cert_list_s **ppcert_chain_list);
650 * @brief Verifies a certificate chain using an alias list of untrusted certificates and return that chain.
654 * @privilege %http://tizen.org/privilege/keymanager
656 * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
657 * @remarks You must destroy the newly created @a ppcert_chain_list by calling ckmc_cert_list_all_free() if it is no longer needed.
659 * @param[in] cert The certificate to be verified
660 * @param[in] untrustedcerts The alias list of untrusted CA certificates stored in key manager to be used in verifying a certificate chain
661 * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
662 * If an error occurs, @a *ppcert_chain_list will be null.
664 * @return @c 0 on success and the signature is valid,
665 * otherwise a negative error value
667 * @retval #CKMC_ERROR_NONE Successful
668 * @retval #CKMC_ERROR_VERIFICATION_FAILED The certificate chain is not valid
669 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
670 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
671 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
672 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
673 * @retval #CKMC_ERROR_INVALID_FORMAT The format of certificate is not valid
674 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
676 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
678 * @see ckmc_get_cert_chain())
679 * @see ckmc_cert_list_all_free()
681 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);
684 * @brief Allows another application to access client's application data
688 * @privilege %http://tizen.org/privilege/keymanager
690 * @remarks Data identified by @a alias should exist
692 * @param[in] alias Data alias for which access will be granted
693 * @param[in] accessor Package id of the application that will gain access rights
694 * @param[in] granted Rights granted for @a accessor application
696 * @return @c 0 on success, otherwise a negative error value
698 * @retval #CKMC_ERROR_NONE Successful
699 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
700 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
701 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
702 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
703 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
705 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
707 * @see ckmc_deny_access()
709 int ckmc_allow_access(const char *alias, const char *accessor, ckmc_access_right_e granted);
712 * @brief Revokes another application's access to client's application data
716 * @privilege %http://tizen.org/privilege/keymanager
718 * @remarks Data identified by @a alias should exist
719 * @remarks Only access previously granted with ckmc_allow_access can be revoked.
721 * @param[in] alias Data alias for which access will be revoked
722 * @param[in] accessor Package id of the application that will lose access rights
724 * @return @c 0 on success, otherwise a negative error value
726 * @retval #CKMC_ERROR_NONE Successful
727 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or the @a accessor doesn't
728 * have access to @a alias
729 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
730 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
731 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
732 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
734 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
736 * @see ckmc_allow_access()
738 int ckmc_deny_access(const char *alias, const char *accessor);
750 #endif /* __TIZEN_CORE_CKMC_MANAGER_H */