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 * @param[in] alias The name of a certificate to be stored
183 * @param[in] cert The certificate's binary value to be stored
184 * @param[in] policy The policy about how to store a certificate securely
186 * @return @c 0 on success,
187 * otherwise a negative error value
189 * @retval #CKMC_ERROR_NONE Successful
190 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
191 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
192 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
193 * @retval #CKMC_ERROR_INVALID_FORMAT The format of raw_cert is not valid
194 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
195 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
197 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
199 * @see ckmc_remove_cert()
200 * @see ckmc_get_cert()
201 * @see ckmc_get_cert_alias_list()
203 * @see #ckmc_policy_s
205 int ckmc_save_cert(const char *alias, const ckmc_cert_s cert, const ckmc_policy_s policy);
208 * @brief Removes a certificate from key manager.
212 * @privilege %http://tizen.org/privilege/keymanager
214 * @remarks A client can remove only certificates stored by the client.
216 * @param[in] alias The name of a certificate to be removed
218 * @return @c 0 on success,
219 * 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 the error with unknown reason
225 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
226 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
228 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
230 * @see ckmc_save_cert()
231 * @see ckmc_get_cert()
232 * @see ckmc_get_cert_alias_list()
234 int ckmc_remove_cert(const char *alias);
237 * @brief Gets a certificate from key manager.
241 * @privilege %http://tizen.org/privilege/keymanager
243 * @remarks A client can access only certificate stored by the client.
244 * @remarks You must destroy the newly created @a ppcert by calling ckmc_cert_free() if it is no longer needed.
246 * @param[in] alias The name of a certificate to retrieve
247 * @param[in] password The password used in decrypting a certificate value \n
248 * If password of policy is provided in ckmc_save_cert(), the same password should be provided.
249 * @param[out] ppcert The pointer to a newly created ckmc_cert_s handle
251 * @return @c 0 on success,
252 * otherwise a negative error value
254 * @retval #CKMC_ERROR_NONE Successful
255 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
256 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
257 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
258 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exists
259 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
261 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
263 * @see ckmc_save_cert()
264 * @see ckmc_remove_cert()
265 * @see ckmc_get_cert_alias_list()
267 int ckmc_get_cert(const char *alias, const char *password, ckmc_cert_s **ppcert);
270 * @brief Gets all alias of certificates which the client can access.
274 * @privilege %http://tizen.org/privilege/keymanager
276 * @remarks A client can access only data stored by the client.
277 * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free() if it is no longer needed.
279 * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys \n
280 * If there is no available key alias, *ppalias_list will be null.
282 * @return @c 0 on success,
283 * otherwise a negative error value
285 * @retval #CKMC_ERROR_NONE Successful
286 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
287 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
288 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
289 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
290 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
292 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
294 * @see ckmc_save_cert()
295 * @see ckmc_remove_cert()
296 * @see ckmc_get_cert()
298 int ckmc_get_cert_alias_list(ckmc_alias_list_s** ppalias_list);
304 * @brief Stores a data inside key manager based on the provided policy.
308 * @privilege %http://tizen.org/privilege/keymanager
310 * @param[in] alias The name of a data to be stored
311 * @param[in] data The binary value to be stored
312 * @param[in] policy The policy about how to store a data securely
314 * @return @c 0 on success,
315 * otherwise a negative error value
317 * @retval #CKMC_ERROR_NONE Successful
318 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
319 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
320 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
321 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
322 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
324 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
326 * @see ckmc_remove_data()
327 * @see ckmc_get_data()
328 * @see ckmc_get_data_alias_list()
329 * @see #ckmc_raw_buffer_s
330 * @see #ckmc_policy_s
332 int ckmc_save_data(const char *alias, ckmc_raw_buffer_s data, const ckmc_policy_s policy);
335 * @brief Removes a data from key manager.
339 * @privilege %http://tizen.org/privilege/keymanager
341 * @remarks A client can remove only data stored by the client.
343 * @param[in] alias The name of a data to be removed
345 * @return @c 0 on success,
346 * 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
355 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
357 * @see ckmc_save_data()
358 * @see ckmc_get_data()
359 * @see ckmc_get_data_alias_list()
361 int ckmc_remove_data(const char *alias);
364 * @brief Gets a data from key manager.
368 * @privilege %http://tizen.org/privilege/keymanager
370 * @remarks A client can access only data stored by the client.
371 * @remarks You must destroy the newly created @a ppdata by calling ckmc_buffer_free() if it is no longer needed.
373 * @param[in] alias The name of a data to retrieve
374 * @param[in] password The password used in decrypting a data value \n
375 * If password of policy is provided in ckmc_save_data(), the same password should be provided.
376 * @param[out] ppdata The pointer to a newly created ckmc_raw_buffer_s handle
378 * @return @c 0 on success,
379 * otherwise a negative error value
381 * @retval #CKMC_ERROR_NONE Successful
382 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
383 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
384 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
385 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
386 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
388 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
390 * @see ckmc_save_data()
391 * @see ckmc_remove_data()
392 * @see ckmc_get_data_alias_list()
394 int ckmc_get_data(const char *alias, const char *password, ckmc_raw_buffer_s **ppdata);
397 * @brief Gets all alias of data which the client can access.
401 * @privilege %http://tizen.org/privilege/keymanager
403 * @remarks A client can access only data stored by the client.
404 * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free() if it is no longer needed.
406 * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys \n
407 * If there is no available key alias, *ppalias_list will be null.
409 * @return @c 0 on success,
410 * otherwise a negative error value
412 * @retval #CKMC_ERROR_NONE Successful
413 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
414 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
415 * @retval #CKMC_ERROR_DB_ERROR Failed due to the error with unknown reason
416 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
417 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
419 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
421 * @see ckmc_save_data()
422 * @see ckmc_remove_data()
423 * @see ckmc_get_data()
425 int ckmc_get_data_alias_list(ckmc_alias_list_s** ppalias_list);
431 * @brief Creates RSA private/public key pair and stores them inside key manager based on each policy.
435 * @privilege %http://tizen.org/privilege/keymanager
437 * @remarks If password in policy is provided, the key is additionally encrypted with the password in policy.
439 * @param[in] size The size of key strength to be created \n
440 * @c 1024, @c 2048, and @c 4096 are supported.
441 * @param[in] private_key_alias The name of private key to be stored
442 * @param[in] public_key_alias The name of public key to be stored
443 * @param[in] policy_private_key The policy about how to store a private key securely
444 * @param[in] policy_public_key The policy about how to store a public key securely
446 * @return @c 0 on success,
447 * otherwise a negative error value
449 * @retval #CKMC_ERROR_NONE Successful
450 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
451 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
452 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
453 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
454 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
456 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
458 * @see ckmc_create_key_pair_dsa()
459 * @see ckmc_create_key_pair_ecdsa()
460 * @see ckmc_create_signature()
461 * @see ckmc_verify_signature()
463 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);
466 * @brief Creates DSA private/public key pair and stores them inside key manager based on each policy.
470 * @privilege %http://tizen.org/privilege/keymanager
472 * @remarks If password in policy is provided, the key is additionally encrypted with the password in policy.
474 * @param[in] size The size of key strength to be created \n
475 * @c 1024, @c 2048, @c 3072 and @c 4096 are supported.
476 * @param[in] private_key_alias The name of private key to be stored
477 * @param[in] public_key_alias The name of public key to be stored
478 * @param[in] policy_private_key The policy about how to store a private key securely
479 * @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
484 * @retval #CKMC_ERROR_NONE Successful
485 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
486 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
487 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
488 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
489 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
491 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
493 * @see ckmc_create_key_pair_rsa()
494 * @see ckmc_create_key_pair_ecdsa()
495 * @see ckmc_create_signature()
496 * @see ckmc_verify_signature()
498 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);
501 * @brief Creates ECDSA private/public key pair and stores them inside key manager based on each policy.
505 * @privilege %http://tizen.org/privilege/keymanager
507 * @remarks If password in policy is provided, the key is additionally encrypted with the password in policy.
509 * @param[in] type The type of elliptic curve of ECDSA
510 * @param[in] private_key_alias The name of private key to be stored
511 * @param[in] public_key_alias The name of public key to be stored
512 * @param[in] policy_private_key The policy about how to store a private key securely
513 * @param[in] policy_public_key The policy about how to store a public key securely
515 * @return @c 0 on success,
516 * otherwise a negative error value
518 * @retval #CKMC_ERROR_NONE Successful
519 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
520 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
521 * @retval #CKMC_ERROR_DB_ALIAS_EXISTS Alias already exists
522 * @retval #CKMC_ERROR_DB_ERROR Failed due to other DB transaction unexpectedly
523 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
525 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
527 * @see ckmc_create_key_pair_rsa()
528 * @see ckmc_create_key_pair_dsa()
529 * @see ckmc_create_signature()
530 * @see ckmc_verify_signature()
531 * @see #ckmc_ec_type_e
533 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);
536 * @brief Creates a signature on a given message using a private key and returns the signature.
540 * @privilege %http://tizen.org/privilege/keymanager
542 * @remarks If password of policy is provided during storing a key, the same password should be provided.
543 * @remarks You must destroy the newly created @a ppsignature by calling ckmc_buffer_free() if it is no longer needed.
545 * @param[in] private_key_alias The name of private key
546 * @param[in] password The password used in decrypting a private key value
547 * @param[in] message The message that is signed with a private key
548 * @param[in] hash The hash algorithm used in creating signature
549 * @param[in] padding The RSA padding algorithm used in creating signature \n
550 * It is used only when the signature algorithm is RSA.
551 * @param[out] ppsignature The pointer to a newly created signature \n
552 * If an error occurs, @a *ppsignature will be null.
554 * @return @c 0 on success,
555 * otherwise a negative error value
557 * @retval #CKMC_ERROR_NONE Successful
558 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
559 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
560 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
561 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
563 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
565 * @see ckmc_create_key_pair_rsa()
566 * @see ckmc_create_key_pair_ecdsa()
567 * @see ckmc_verify_signature()
568 * @see ckmc_buffer_free()
569 * @see #ckmc_hash_algo_e
570 * @see #ckmc_rsa_padding_algo_e
572 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);
575 * @brief Verifies a given signature on a given message using a public key and returns the signature status.
579 * @privilege %http://tizen.org/privilege/keymanager
581 * @remarks If password of policy is provided during storing a key, the same password should be provided.
583 * @param[in] public_key_alias The name of public key
584 * @param[in] password The password used in decrypting a public key value
585 * @param[in] message The input on which the signature is created
586 * @param[in] signature The signature that is verified with public key
587 * @param[in] hash The hash algorithm used in verifying signature
588 * @param[in] padding The RSA padding algorithm used in verifying signature \n
589 * It is used only when the signature algorithm is RSA.
591 * @return @c 0 on success and the signature is valid,
592 * otherwise a negative error value
594 * @retval #CKMC_ERROR_NONE Successful
595 * @retval #CKMC_ERROR_VERIFICATION_FAILED The signature is invalid
596 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
597 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
598 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
599 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
601 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
603 * @see ckmc_create_key_pair_rsa()
604 * @see ckmc_create_key_pair_ecdsa()
605 * @see ckmc_verify_signature()
606 * @see #ckmc_hash_algo_e
607 * @see #ckmc_rsa_padding_algo_e
609 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);
612 * @brief Verifies a certificate chain and returns that chain.
616 * @privilege %http://tizen.org/privilege/keymanager
618 * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
619 * @remarks You must destroy the newly created @a ppcert_chain_list by calling ckmc_cert_list_all_free() if it is no longer needed.
621 * @param[in] cert The certificate to be verified
622 * @param[in] untrustedcerts The untrusted CA certificates to be used in verifying a certificate chain
623 * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
624 * If an error occurs, @a *ppcert_chain_list will be null.
626 * @return @c 0 on success and the signature is valid,
627 * otherwise a negative error value
629 * @retval #CKMC_ERROR_NONE Successful
630 * @retval #CKMC_ERROR_VERIFICATION_FAILED The certificate chain is not valid
631 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
632 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
633 * @retval #CKMC_ERROR_INVALID_FORMAT The format of certificate is not valid
634 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
636 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
638 * @see ckmc_get_cert_chain_with_alias())
639 * @see ckmc_cert_list_all_free()
641 int ckmc_get_cert_chain(const ckmc_cert_s *cert, const ckmc_cert_list_s *untrustedcerts, ckmc_cert_list_s **ppcert_chain_list);
644 * @brief Verifies a certificate chain using an alias list of untrusted certificates and return that chain.
648 * @privilege %http://tizen.org/privilege/keymanager
650 * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
651 * @remarks You must destroy the newly created @a ppcert_chain_list by calling ckmc_cert_list_all_free() if it is no longer needed.
653 * @param[in] cert The certificate to be verified
654 * @param[in] untrustedcerts The alias list of untrusted CA certificates stored in key manager to be used in verifying a certificate chain
655 * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
656 * If an error occurs, @a *ppcert_chain_list will be null.
658 * @return @c 0 on success and the signature is valid,
659 * otherwise a negative error value
661 * @retval #CKMC_ERROR_NONE Successful
662 * @retval #CKMC_ERROR_VERIFICATION_FAILED The certificate chain is not valid
663 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
664 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
665 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
666 * @retval #CKMC_ERROR_INVALID_FORMAT The format of certificate is not valid
667 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
669 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
671 * @see ckmc_get_cert_chain())
672 * @see ckmc_cert_list_all_free()
674 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);
677 * @brief Allows another application to access client's application data
681 * @privilege %http://tizen.org/privilege/keymanager
683 * @remarks Data identified by @a alias should exist
685 * @param[in] alias Data alias for which access will be granted
686 * @param[in] accessor Package id (smack label) of the application that will gain access rights
687 * @param[in] granted Rights granted for @a accessor application
689 * @return @c 0 on success, otherwise a negative error value
691 * @retval #CKMC_ERROR_NONE Successful
692 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
693 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
694 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
695 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
697 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
699 * @see ckmc_deny_access()
701 int ckmc_allow_access(const char *alias, const char *accessor, ckmc_access_right_e granted);
704 * @brief Revokes another application's access to client's application data
708 * @privilege %http://tizen.org/privilege/keymanager
710 * @remarks Data identified by @a alias should exist
711 * @remarks Only access previously granted with ckmc_allow_access can be revoked.
713 * @param[in] alias Data alias for which access will be revoked
714 * @param[in] accessor Package id (smack label) of the application that will lose access rights
716 * @return @c 0 on success, otherwise a negative error value
718 * @retval #CKMC_ERROR_NONE Successful
719 * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid or the @a accessor doesn't
720 * have access to @a alias
721 * @retval #CKMC_ERROR_DB_LOCKED A user key is not loaded in memory (a user is not logged in)
722 * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN Alias does not exist
723 * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
725 * @pre User is already logged in and the user key is already loaded into memory in plain text form.
727 * @see ckmc_allow_access()
729 int ckmc_deny_access(const char *alias, const char *accessor);
741 #endif /* __TIZEN_CORE_CKMC_MANAGER_H */