Fix description in ckmc-manager.h
[platform/core/security/key-manager.git] / src / include / ckmc / ckmc-manager.h
1 /*
2  *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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
15  *
16  *
17  * @file        ckmc-manager.h
18  * @version     1.0
19  * @brief       Provides management functions(storing, retrieving, and removing) for keys,
20  *              certificates and data of a user and additional crypto functions.
21  */
22
23
24 #ifndef __TIZEN_CORE_CKMC_MANAGER_H
25 #define __TIZEN_CORE_CKMC_MANAGER_H
26
27 #include <stddef.h>
28 #include <sys/types.h>
29 #include <tizen.h>
30 #include <ckmc/ckmc-type.h>
31 #include <ckmc/ckmc-error.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 /**
38  * @addtogroup CAPI_KEY_MANAGER_CLIENT_MODULE
39  * @{
40  */
41
42
43 /**
44  * @brief Stores a key inside key manager based on the provided policy.
45  *
46  * @since_tizen 2.3
47  * @privlevel public
48  * @privilege %http://tizen.org/privilege/keymanager
49  *
50  * @remarks Currently only six types of keys are supported for this API. These are RSA
51  *          public/private key, DSA public/private key and ECDSA public/private key.
52  * @remarks key_type in key may be set to #CKMC_KEY_NONE as an input. key_type is determined inside
53  *          key manager during storing keys.
54  * @remarks Some private key files are protected by a password. If raw_key in key read from those
55  *          encrypted files is encrypted with a password, the password should be provided in the
56  *          #ckmc_key_s structure.
57  * @remarks If password in policy is provided, the key is additionally encrypted with the password
58  *          in policy.
59  *
60  * @param[in] alias   The name of a key to be stored
61  * @param[in] key     The key's binary value to be stored
62  * @param[in] policy  The policy about how to store a key securely
63  *
64  * @return @c 0 on success,
65  *         otherwise a negative error value
66  *
67  * @retval #CKMC_ERROR_NONE              Successful
68  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
69  * @retval #CKMC_ERROR_DB_LOCKED         A user key is not loaded in memory (a user is not logged
70  *                                       in)
71  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS   Alias already exists
72  * @retval #CKMC_ERROR_INVALID_FORMAT    The format of raw_key is not valid
73  * @retval #CKMC_ERROR_DB_ERROR          Failed due to a database error
74  * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
75  *
76  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
77  *
78  * @see ckmc_remove_key()
79  * @see ckmc_get_key()
80  * @see ckmc_get_key_alias_list()
81  * @see #ckmc_key_s
82  * @see #ckmc_policy_s
83  */
84 int ckmc_save_key(const char *alias, const ckmc_key_s key, const ckmc_policy_s policy);
85
86 /**
87  * @brief Removes a key from key manager.
88  *
89  * @since_tizen 2.3
90  * @privlevel public
91  * @privilege %http://tizen.org/privilege/keymanager
92  *
93  * @remarks To remove key, client must have remove permission to the specified key.
94  * @remarks The key owner can remove by default.
95  *
96  * @param[in] alias The name of a key to be removed
97  *
98  * @return @c 0 on success,
99  *         otherwise a negative error value
100  *
101  * @retval #CKMC_ERROR_NONE              Successful
102  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
103  * @retval #CKMC_ERROR_DB_LOCKED         A user key is not loaded in memory (a user is not logged
104  *                                       in)
105  * @retval #CKMC_ERROR_DB_ERROR          Failed due to a database error
106  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN  Alias does not exist
107  * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
108  *
109  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
110  *
111  * @see ckmc_save_key()
112  * @see ckmc_get_key()
113  * @see ckmc_get_key_alias_list()
114  */
115 int ckmc_remove_key(const char *alias);
116
117 /**
118  * @brief Gets a key from key manager.
119  *
120  * @since_tizen 2.3
121  * @privlevel public
122  * @privilege %http://tizen.org/privilege/keymanager
123  *
124  * @remarks A client can access only data stored by the client.
125  * @remarks You must destroy the newly created @a ppkey by calling ckmc_key_free() if it is no
126  *          longer needed.
127  *
128  * @param[in] alias     The name of a key to retrieve
129  * @param[in] password  The password used in decrypting a key value \n
130  *                      If password of policy is provided in ckmc_save_key(), the same password
131  *                      should be provided.
132  * @param[out] ppkey    The pointer to a newly created ckmc_key_s handle
133  *
134  * @return @c 0 on success,
135  *         otherwise a negative error value
136  *
137  * @retval #CKMC_ERROR_NONE              Successful
138  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
139  * @retval #CKMC_ERROR_DB_LOCKED         A user key is not loaded in memory (a user is not logged
140  *                                       in)
141  * @retval #CKMC_ERROR_DB_ERROR          Failed due to a database error
142  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN  Alias does not exist
143  * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
144  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
145  *                                       Decryption failed because password is incorrect.
146  *
147  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
148  *
149  * @see ckmc_save_key()
150  * @see ckmc_remove_key()
151  * @see ckmc_get_key_alias_list()
152  */
153 int ckmc_get_key(const char *alias, const char *password, ckmc_key_s **ppkey);
154
155 /**
156  * @brief Gets all the alias of keys that the client can access.
157  *
158  * @since_tizen 2.3
159  * @privlevel public
160  * @privilege %http://tizen.org/privilege/keymanager
161  *
162  * @remarks A client can access only data stored by the client.
163  * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free()
164  *          if it is no longer needed.
165  *
166  * @param[out] ppalias_list  The pointer to a newly created ckmc_alias_list_s handle containing all
167  *                           available alias of keys \n
168  *                           If there is no available key alias, *ppalias_list will be null.
169  *
170  * @return @c 0 on success,
171  *         otherwise a negative error value
172  *
173  * @retval #CKMC_ERROR_NONE              Successful
174  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
175  * @retval #CKMC_ERROR_DB_LOCKED         A user key is not loaded in memory (a user is not logged
176  *                                       in)
177  * @retval #CKMC_ERROR_DB_ERROR          Failed due to a database error
178  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN  Alias does not exist
179  * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
180  *
181  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
182  *
183  * @see ckmc_save_key()
184  * @see ckmc_remove_key()
185  * @see ckmc_get_key()
186  */
187 int ckmc_get_key_alias_list(ckmc_alias_list_s** ppalias_list);
188
189
190
191
192 /**
193  * @brief Stores a certificate inside key manager based on the provided policy.
194  *
195  * @since_tizen 2.3
196  * @privlevel public
197  * @privilege %http://tizen.org/privilege/keymanager
198  *
199  * @remarks the certificate's binary value will be converted and saved as binary DER encoded
200  *          certificates.
201  *
202  * @param[in] alias  The name of a certificate to be stored
203  * @param[in] cert   The certificate's binary value to be stored
204  * @param[in] policy The policy about how to store a certificate securely
205  *
206  * @return @c 0 on success,
207  *         otherwise a negative error value
208  *
209  * @retval #CKMC_ERROR_NONE               Successful
210  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
211  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
212  *                                        in)
213  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS    Alias already exists
214  * @retval #CKMC_ERROR_INVALID_FORMAT     The format of raw_cert is not valid
215  * @retval #CKMC_ERROR_DB_ERROR           Failed due to a database error
216  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
217  *
218  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
219  *
220  * @see ckmc_remove_cert()
221  * @see ckmc_get_cert()
222  * @see ckmc_get_cert_alias_list()
223  * @see #ckmc_cert_s
224  * @see #ckmc_policy_s
225  */
226 int ckmc_save_cert(const char *alias, const ckmc_cert_s cert, const ckmc_policy_s policy);
227
228 /**
229  * @brief Removes a certificate from key manager.
230  *
231  * @since_tizen 2.3
232  * @privlevel public
233  * @privilege %http://tizen.org/privilege/keymanager
234  *
235  * @remarks To remove certificate, client must have remove permission to the specified certificate.
236  * @remarks The key owner can remove by default.
237  *
238  * @param[in] alias The name of a certificate to be removed
239  *
240  * @return @c 0 on success,
241  *         otherwise a negative error value
242  *
243  * @retval #CKMC_ERROR_NONE               Successful
244  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
245  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
246  *                                        in)
247  * @retval #CKMC_ERROR_DB_ERROR           Failed due to a database error
248  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN   Alias does not exist
249  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
250  *
251  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
252  *
253  * @see ckmc_save_cert()
254  * @see ckmc_get_cert()
255  * @see ckmc_get_cert_alias_list()
256  */
257 int ckmc_remove_cert(const char *alias);
258
259 /**
260  * @brief Gets a certificate from key manager.
261  *
262  * @since_tizen 2.3
263  * @privlevel public
264  * @privilege %http://tizen.org/privilege/keymanager
265  *
266  * @remarks A client can access only certificate stored by the client.
267  * @remarks A DER encoded certificate will be returned as a return value.
268  * @remarks You must destroy the newly created @a ppcert by calling ckmc_cert_free() if it is no
269  *          longer needed.
270  *
271  * @param[in] alias    The name of a certificate to retrieve
272  * @param[in] password The password used in decrypting a certificate value \n
273  *                     If password of policy is provided in ckmc_save_cert(), the same password
274  *                     should be provided.
275  * @param[out] ppcert  The pointer to a newly created ckmc_cert_s handle
276  *
277  * @return @c 0 on success,
278  *         otherwise a negative error value
279  *
280  * @retval #CKMC_ERROR_NONE               Successful
281  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
282  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
283  *                                        in)
284  * @retval #CKMC_ERROR_DB_ERROR           Failed due to a database error
285  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN   Alias does not exists
286  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
287  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
288  *                                        Decryption failed because password is incorrect.
289  *
290  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
291  *
292  * @see ckmc_save_cert()
293  * @see ckmc_remove_cert()
294  * @see ckmc_get_cert_alias_list()
295  */
296 int ckmc_get_cert(const char *alias, const char *password, ckmc_cert_s **ppcert);
297
298 /**
299  * @brief Gets all alias of certificates which the client can access.
300  *
301  * @since_tizen 2.3
302  * @privlevel public
303  * @privilege %http://tizen.org/privilege/keymanager
304  *
305  * @remarks A client can access only data stored by the client.
306  * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free()
307  *          if it is no longer needed.
308  *
309  * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all
310  *                          available alias of keys \n
311  *                          If there is no available key alias, *ppalias_list will be null.
312  *
313  * @return @c 0 on success,
314  *         otherwise a negative error value
315  *
316  * @retval #CKMC_ERROR_NONE               Successful
317  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
318  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
319  *                                        in)
320  * @retval #CKMC_ERROR_DB_ERROR           Failed due to a database error
321  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN   Alias does not exist
322  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
323  *
324  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
325  *
326  * @see ckmc_save_cert()
327  * @see ckmc_remove_cert()
328  * @see ckmc_get_cert()
329  */
330 int ckmc_get_cert_alias_list(ckmc_alias_list_s** ppalias_list);
331
332
333
334
335 /**
336  * @brief Stores PKCS12's contents inside key manager based on the provided policies.
337  * All items from the PKCS12 will use the same alias.
338  *
339  * @since_tizen 2.3
340  * @privlevel public
341  * @privilege %http://tizen.org/privilege/keymanager
342  *
343  * @param[in] alias         The name of a data to be stored
344  * @param[in] pkcs          Pointer to the pkcs12 structure to be saved
345  * @param[in] key_policy    The policy about how to store pkcs's private key
346  * @param[in] cert_policy   The policy about how to store pkcs's certificate
347  *
348  * @return @c 0 on success,
349  *         otherwise a negative error value
350  *
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
354  *                                        in)
355  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS    Alias already exists
356  * @retval #CKMC_ERROR_DB_ERROR           Failed due to a database error
357  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
358  *
359  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
360  *
361  * @see ckmc_remove_pkcs12()
362  * @see ckmc_get_pkcs12()
363  * @see ckmc_get_data_alias_list()
364  * @see ckmc_load_from_pkcs12_file2()
365  * @see #ckmc_pkcs12_s
366  * @see #ckmc_policy_s
367  */
368 int ckmc_save_pkcs12(const char *alias,
369                      const ckmc_pkcs12_s *pkcs,
370                      const ckmc_policy_s key_policy,
371                      const ckmc_policy_s cert_policy);
372
373 /**
374  * @brief Removes all PKCS12 contents from key manager.
375  *
376  * @since_tizen 2.3
377  * @privlevel public
378  * @privilege %http://tizen.org/privilege/keymanager
379  *
380  * @remarks To remove PKCS12, client must have remove permission to the specified PKCS12 object.
381  * @remarks The key owner can remove by default.
382  *
383  * @param[in] alias The name of PKCS12 to be removed
384  *
385  * @return @c 0 on success,
386  *         otherwise a negative error value
387  *
388  * @retval #CKMC_ERROR_NONE               Successful
389  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
390  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
391  *                                        in)
392  * @retval #CKMC_ERROR_DB_ERROR           Failed due to a database error
393  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN   Alias does not exist
394  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
395  *
396  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
397  *
398  * @see ckmc_save_pkcs12()
399  * @see ckmc_get_pkcs12()
400  */
401 int ckmc_remove_pkcs12(const char *alias);
402
403 /**
404  * @brief Gets a pkcs12 from key manager.
405  *
406  * @since_tizen 2.3
407  * @privlevel public
408  * @privilege %http://tizen.org/privilege/keymanager
409  *
410  * @remarks A client can access only data stored by the client.
411  * @remarks You must destroy the newly created @a pkcs12 by calling ckmc_pkcs12_free() if it is no
412  *          longer needed.
413  *
414  * @param[in]  alias        The name of a data to retrieve
415  * @param[in]  keyPassword  Password that was used to encrypt privateKey (may be NULL)
416  * @param[in]  certPassword Password used to encrypt certificates (may be NULL)
417  * @param[out] pkcs12       The pointer to a newly created ckmc_pkcs12_s handle
418  *
419  * @return @c 0 on success,
420  *         otherwise a negative error value
421  *
422  * @retval #CKMC_ERROR_NONE               Successful
423  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
424  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
425  *                                        in)
426  * @retval #CKMC_ERROR_DB_ERROR           Failed due to a database error
427  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN   Alias does not exist
428  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
429  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
430  *                                        Decryption failed because password is incorrect.
431  *
432  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
433  *
434  * @see ckmc_save_pkcs12()
435  * @see ckmc_remove_pkcs12()
436  */
437 int ckmc_get_pkcs12(const char *alias, const char *keyPassword, const char *certPassword, ckmc_pkcs12_s **pkcs12);
438
439 /**
440  * @brief Stores a data inside key manager based on the provided policy.
441  *
442  * @since_tizen 2.3
443  * @privlevel public
444  * @privilege %http://tizen.org/privilege/keymanager
445  *
446  * @param[in] alias  The name of a data to be stored
447  * @param[in] data   The binary value to be stored
448  * @param[in] policy The policy about how to store a data securely
449  *
450  * @return @c 0 on success,
451  *         otherwise a negative error value
452  *
453  * @retval #CKMC_ERROR_NONE               Successful
454  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
455  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
456  *                                        in)
457  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS    Alias already exists
458  * @retval #CKMC_ERROR_DB_ERROR           Failed due to a database error
459  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
460  *
461  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
462  *
463  * @see ckmc_remove_data()
464  * @see ckmc_get_data()
465  * @see ckmc_get_data_alias_list()
466  * @see #ckmc_raw_buffer_s
467  * @see #ckmc_policy_s
468  */
469 int ckmc_save_data(const char *alias, ckmc_raw_buffer_s data, const ckmc_policy_s policy);
470
471 /**
472  * @brief Removes a data from key manager.
473  *
474  * @since_tizen 2.3
475  * @privlevel public
476  * @privilege %http://tizen.org/privilege/keymanager
477  *
478  * @remarks To remove data, client must have remove permission to the specified data object.
479  * @remarks The data owner can remove by default.
480  *
481  * @param[in] alias The name of a data to be removed
482  *
483  * @return @c 0 on success,
484  *         otherwise a negative error value
485  *
486  * @retval #CKMC_ERROR_NONE               Successful
487  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
488  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
489  *                                        in)
490  * @retval #CKMC_ERROR_DB_ERROR           Failed due to the error with unknown reason
491  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN   Alias does not exist
492  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
493  *
494  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
495  *
496  * @see ckmc_save_data()
497  * @see ckmc_get_data()
498  * @see ckmc_get_data_alias_list()
499  */
500 int ckmc_remove_data(const char *alias);
501
502 /**
503  * @brief Gets a data from key manager.
504  *
505  * @since_tizen 2.3
506  * @privlevel public
507  * @privilege %http://tizen.org/privilege/keymanager
508  *
509  * @remarks A client can access only data stored by the client.
510  * @remarks You must destroy the newly created @a ppdata by calling ckmc_buffer_free() if it is no
511  *          longer needed.
512  *
513  * @param[in]  alias     The name of a data to retrieve
514  * @param[in]  password  The password used in decrypting a data value \n
515  *                       If password of policy is provided in ckmc_save_data(), the same password
516  *                       should be provided.
517  * @param[out] ppdata    The pointer to a newly created ckmc_raw_buffer_s handle
518  *
519  * @return @c 0 on success,
520  *         otherwise a negative error value
521  *
522  * @retval #CKMC_ERROR_NONE               Successful
523  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
524  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
525  *                                        in)
526  * @retval #CKMC_ERROR_DB_ERROR           Failed due to the error with unknown reason
527  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN   Alias does not exist
528  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
529  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
530  *                                        Decryption failed because password is incorrect.
531  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
532  *
533  * @see ckmc_save_data()
534  * @see ckmc_remove_data()
535  * @see ckmc_get_data_alias_list()
536  */
537 int ckmc_get_data(const char *alias, const char *password, ckmc_raw_buffer_s **ppdata);
538
539 /**
540  * @brief Gets all alias of data which the client can access.
541  *
542  * @since_tizen 2.3
543  * @privlevel public
544  * @privilege %http://tizen.org/privilege/keymanager
545  *
546  * @remarks A client can access only data stored by the client.
547  * @remarks You must destroy the newly created @a ppalias_list by calling ckmc_alias_list_all_free()
548  *          if it is no longer needed.
549  *
550  * @param[out] ppalias_list The pointer to a newly created ckmc_alias_list_s handle containing all
551  *                          available alias of keys \n
552  *                          If there is no available key alias, *ppalias_list will be null.
553  *
554  * @return @c 0 on success,
555  *         otherwise a negative error value
556  *
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
560  *                                        in)
561  * @retval #CKMC_ERROR_DB_ERROR           Failed due to the error with unknown reason
562  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN   Alias does not exist
563  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
564  *
565  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
566  *
567  * @see ckmc_save_data()
568  * @see ckmc_remove_data()
569  * @see ckmc_get_data()
570  */
571 int ckmc_get_data_alias_list(ckmc_alias_list_s** ppalias_list);
572
573
574
575
576 /**
577  * @brief Creates RSA private/public key pair and stores them inside key manager based on each
578  *        policy.
579  *
580  * @since_tizen 2.3
581  * @privlevel public
582  * @privilege %http://tizen.org/privilege/keymanager
583  *
584  * @remarks If password in policy is provided, the key is additionally encrypted with the password
585  *          in policy.
586  *
587  * @param[in] size                The size of key strength to be created \n
588  *                                @c 1024, @c 2048, and @c 4096 are supported.
589  * @param[in] private_key_alias   The name of private key to be stored
590  * @param[in] public_key_alias    The name of public key to be stored
591  * @param[in] policy_private_key  The policy about how to store a private key securely
592  * @param[in] policy_public_key   The policy about how to store a public key securely
593  *
594  * @return @c 0 on success,
595  *         otherwise a negative error value
596  *
597  * @retval #CKMC_ERROR_NONE               Successful
598  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
599  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
600  *                                        in)
601  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS    Alias already exists
602  * @retval #CKMC_ERROR_DB_ERROR           Failed due to other DB transaction unexpectedly
603  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
604  *
605  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
606  *
607  * @see ckmc_create_key_pair_dsa()
608  * @see ckmc_create_key_pair_ecdsa()
609  * @see ckmc_create_signature()
610  * @see ckmc_verify_signature()
611  */
612 int ckmc_create_key_pair_rsa(const size_t size,
613                              const char *private_key_alias,
614                              const char *public_key_alias,
615                              const ckmc_policy_s policy_private_key,
616                              const ckmc_policy_s policy_public_key);
617
618 /**
619  * @brief Creates DSA private/public key pair and stores them inside key manager based on each
620  *        policy.
621  *
622  * @since_tizen 2.3
623  * @privlevel public
624  * @privilege %http://tizen.org/privilege/keymanager
625  *
626  * @remarks If password in policy is provided, the key is additionally encrypted with the password
627  *          in policy.
628  *
629  * @param[in] size                The size of key strength to be created \n
630  *                                @c 1024, @c 2048, @c 3072 and @c 4096 are supported.
631  * @param[in] private_key_alias   The name of private key to be stored
632  * @param[in] public_key_alias    The name of public key to be stored
633  * @param[in] policy_private_key  The policy about how to store a private key securely
634  * @param[in] policy_public_key   The policy about how to store a public key securely
635  *
636  * @return @c 0 on success,
637  *         otherwise a negative error value
638  *
639  * @retval #CKMC_ERROR_NONE               Successful
640  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
641  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
642  *                                        in)
643  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS    Alias already exists
644  * @retval #CKMC_ERROR_DB_ERROR           Failed due to other DB transaction unexpectedly
645  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
646  *
647  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
648  *
649  * @see ckmc_create_key_pair_rsa()
650  * @see ckmc_create_key_pair_ecdsa()
651  * @see ckmc_create_signature()
652  * @see ckmc_verify_signature()
653  */
654 int ckmc_create_key_pair_dsa(const size_t size,
655                              const char *private_key_alias,
656                              const char *public_key_alias,
657                              const ckmc_policy_s policy_private_key,
658                              const ckmc_policy_s policy_public_key);
659
660 /**
661  * @brief Creates ECDSA private/public key pair and stores them inside key manager based on each
662  *        policy.
663  *
664  * @since_tizen 2.3
665  * @privlevel public
666  * @privilege %http://tizen.org/privilege/keymanager
667  *
668  * @remarks If password in policy is provided, the key is additionally encrypted with the password
669  *          in policy.
670  *
671  * @param[in] type                The type of elliptic curve of ECDSA
672  * @param[in] private_key_alias   The name of private key to be stored
673  * @param[in] public_key_alias    The name of public key to be stored
674  * @param[in] policy_private_key  The policy about how to store a private key securely
675  * @param[in] policy_public_key   The policy about how to store a public key securely
676  *
677  * @return @c 0 on success,
678  *         otherwise a negative error value
679  *
680  * @retval #CKMC_ERROR_NONE               Successful
681  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
682  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
683  *                                        in)
684  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS    Alias already exists
685  * @retval #CKMC_ERROR_DB_ERROR           Failed due to other DB transaction unexpectedly
686  * @retval #CKMC_ERROR_PERMISSION_DENIED  Failed to access key manager
687  *
688  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
689  *
690  * @see ckmc_create_key_pair_rsa()
691  * @see ckmc_create_key_pair_dsa()
692  * @see ckmc_create_signature()
693  * @see ckmc_verify_signature()
694  * @see #ckmc_ec_type_e
695  */
696 int ckmc_create_key_pair_ecdsa(const ckmc_ec_type_e type,
697                                const char *private_key_alias,
698                                const char *public_key_alias,
699                                const ckmc_policy_s policy_private_key,
700                                const ckmc_policy_s policy_public_key);
701
702 /**
703  * @brief Creates a signature on a given message using a private key and returns the signature.
704  *
705  * @since_tizen 2.3
706  * @privlevel public
707  * @privilege %http://tizen.org/privilege/keymanager
708  *
709  * @remarks If password of policy is provided during storing a key, the same password should be
710  *          provided.
711  * @remarks You must destroy the newly created @a ppsignature by calling ckmc_buffer_free() if it is
712  *          no longer needed.
713  *
714  * @param[in]  private_key_alias  The name of private key
715  * @param[in]  password           The password used in decrypting a private key value
716  * @param[in]  message            The message that is signed with a private key
717  * @param[in]  hash               The hash algorithm used in creating signature
718  * @param[in]  padding            The RSA padding algorithm used in creating signature \n
719  *                                It is used only when the signature algorithm is RSA.
720  * @param[out] ppsignature        The pointer to a newly created signature \n
721  *                                If an error occurs, @a *ppsignature will be null.
722  *
723  * @return @c 0 on success,
724  *         otherwise a negative error value
725  *
726  * @retval #CKMC_ERROR_NONE               Successful
727  * @retval #CKMC_ERROR_INVALID_PARAMETER  Input parameter is invalid
728  * @retval #CKMC_ERROR_DB_LOCKED          A user key is not loaded in memory (a user is not logged
729  *                                        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
733  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
734  *                                        Decryption failed because password is incorrect.
735  *
736  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
737  *
738  * @see ckmc_create_key_pair_rsa()
739  * @see ckmc_create_key_pair_ecdsa()
740  * @see ckmc_verify_signature()
741  * @see ckmc_buffer_free()
742  * @see #ckmc_hash_algo_e
743  * @see #ckmc_rsa_padding_algo_e
744  */
745 int ckmc_create_signature(const char *private_key_alias,
746                           const char *password,
747                           const ckmc_raw_buffer_s message,
748                           const ckmc_hash_algo_e hash,
749                           const ckmc_rsa_padding_algo_e padding,
750                           ckmc_raw_buffer_s **ppsignature);
751
752 /**
753  * @brief Verifies a given signature on a given message using a public key and returns the signature
754  *        status.
755  *
756  * @since_tizen 2.3
757  * @privlevel public
758  * @privilege %http://tizen.org/privilege/keymanager
759  *
760  * @remarks If password of policy is provided during storing a key, the same password should be
761  *          provided.
762  *
763  * @param[in] public_key_alias  The name of public key
764  * @param[in] password          The password used in decrypting a public key value
765  * @param[in] message           The input on which the signature is created
766  * @param[in] signature         The signature that is verified with public key
767  * @param[in] hash              The hash algorithm used in verifying signature
768  * @param[in] padding           The RSA padding algorithm used in verifying signature \n
769  *                              It is used only when the signature algorithm is RSA.
770  *
771  * @return @c 0 on success and the signature is valid,
772  *         otherwise a negative error value
773  *
774  * @retval #CKMC_ERROR_NONE                 Successful
775  * @retval #CKMC_ERROR_VERIFICATION_FAILED  The signature is invalid
776  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid
777  * @retval #CKMC_ERROR_DB_LOCKED            A user key is not loaded in memory (a user is not logged
778  *                                          in)
779  * @retval #CKMC_ERROR_DB_ERROR             Failed due to the error with unknown reason
780  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN     Alias does not exist
781  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
782  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
783  *                                          Decryption failed because password is incorrect.
784  *
785  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
786  *
787  * @see ckmc_create_key_pair_rsa()
788  * @see ckmc_create_key_pair_ecdsa()
789  * @see ckmc_verify_signature()
790  * @see #ckmc_hash_algo_e
791  * @see #ckmc_rsa_padding_algo_e
792  */
793 int ckmc_verify_signature(const char *public_key_alias,
794                           const char *password,
795                           const ckmc_raw_buffer_s message,
796                           const ckmc_raw_buffer_s signature,
797                           const ckmc_hash_algo_e hash,
798                           const ckmc_rsa_padding_algo_e padding);
799
800 /**
801  * @deprecated, see ckmc_get_certificate_chain()
802  * @brief Verifies a certificate chain and returns that chain.
803  *
804  * @since_tizen 2.3
805  * @privlevel public
806  * @privilege %http://tizen.org/privilege/keymanager
807  *
808  * @remarks The trusted root certificate of the chain should exist in the system's certificate
809  *          storage.
810  * @remarks You must destroy the newly created @a ppcert_chain_list by calling
811  *          ckmc_cert_list_all_free() if it is no longer needed.
812  *
813  * @param[in] cert               The certificate to be verified
814  * @param[in] untrustedcerts     The untrusted CA certificates to be used in verifying a certificate
815  *                               chain
816  * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
817  *                               If an error occurs, @a *ppcert_chain_list will be null.
818  *
819  * @return @c 0 on success and the signature is valid,
820  *         otherwise a negative error value
821  *
822  * @retval #CKMC_ERROR_NONE                 Successful
823  * @retval #CKMC_ERROR_VERIFICATION_FAILED  The certificate chain is not valid
824  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid
825  * @retval #CKMC_ERROR_DB_LOCKED            A user key is not loaded in memory (a user is not logged
826  *                                          in)
827  * @retval #CKMC_ERROR_DB_ERROR             Failed due to the error with unknown reason
828  * @retval #CKMC_ERROR_INVALID_FORMAT       The format of certificate is not valid
829  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
830  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
831  *                                          Decryption failed because password is incorrect.
832  *
833  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
834  *
835  * @see ckmc_get_cert_chain_with_alias())
836  * @see ckmc_cert_list_all_free()
837  */
838 int ckmc_get_cert_chain(const ckmc_cert_s *cert,
839                         const ckmc_cert_list_s *untrustedcerts,
840                         ckmc_cert_list_s **ppcert_chain_list);
841
842 /**
843  * @deprecated, see ckmc_get_certificate_chain_with_alias()
844  * @brief Verifies a certificate chain using an alias list of untrusted certificates and return that
845  *        chain.
846  *
847  * @since_tizen 2.3
848  * @privlevel public
849  * @privilege %http://tizen.org/privilege/keymanager
850  *
851  * @remarks The trusted root certificate of the chain should exist in the system's certificate
852  *          storage.
853  * @remarks You must destroy the newly created @a ppcert_chain_list by calling
854  *          ckmc_cert_list_all_free() if it is no longer needed.
855  *
856  * @param[in] cert               The certificate to be verified
857  * @param[in] untrustedcerts     The alias list of untrusted CA certificates stored in key manager
858  *                               to be used in verifying a certificate chain
859  * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
860  *                               If an error occurs, @a *ppcert_chain_list will be null.
861  *
862  * @return @c 0 on success and the signature is valid,
863  *         otherwise a negative error value
864  *
865  * @retval #CKMC_ERROR_NONE                 Successful
866  * @retval #CKMC_ERROR_VERIFICATION_FAILED  The certificate chain is not valid
867  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid
868  * @retval #CKMC_ERROR_DB_LOCKED            A user key is not loaded in memory (a user is not logged
869  *                                          in)
870  * @retval #CKMC_ERROR_DB_ERROR             Failed due to the error with unknown reason
871  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN     Alias does not exist
872  * @retval #CKMC_ERROR_INVALID_FORMAT       The format of certificate is not valid
873  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
874  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
875  *                                          Some certificates were encrypted with password and could not
876  *                                          be used.
877  *
878  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
879  *
880  * @see ckmc_get_cert_chain())
881  * @see ckmc_cert_list_all_free()
882  */
883 int ckmc_get_cert_chain_with_alias(const ckmc_cert_s *cert,
884                                    const ckmc_alias_list_s *untrustedcerts,
885                                    ckmc_cert_list_s **ppcert_chain_list);
886
887 /**
888  * @brief Verifies a certificate chain and returns that chain using user entered trusted and
889  *        untrusted CA certificates
890  *
891  * @since_tizen 3.0
892  * @privlevel public
893  * @privilege %http://tizen.org/privilege/keymanager
894  *
895  * @remarks If the trusted root certificates are provided as a user input, these certificates do not
896  *          need to exist in the system's certificate storage.
897  * @remarks You must destroy the newly created @a ppcert_chain_list by calling
898  *          ckmc_cert_list_all_free() if it is no longer needed.
899  *  *
900  * @param[in] cert                    The certificate to be verified
901  * @param[in] untrustedcerts          The untrusted CA certificates to be used in verifying a
902  *                                    certificate chain
903  * @param[in] trustedcerts            The trusted CA certificates to be used in verifying a
904  *                                    certificate chain
905  * @param[in] use_trustedsystemcerts  The flag indicating the use of the trusted root certificates
906  *                                    in the system's certificate storage.
907  * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
908  *                               If an error occurs, @a *ppcert_chain_list will be null.
909  *
910  * @return @c 0 on success and the signature is valid,
911  *         otherwise a negative error value
912  *
913  * @retval #CKMC_ERROR_NONE                 Successful
914  * @retval #CKMC_ERROR_VERIFICATION_FAILED  The certificate chain is not valid
915  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid
916  * @retval #CKMC_ERROR_DB_LOCKED            A user key is not loaded in memory (a user is not logged
917  *                                          in)
918  * @retval #CKMC_ERROR_DB_ERROR             Failed due to the error with unknown reason
919  * @retval #CKMC_ERROR_INVALID_FORMAT       The format of certificate is not valid
920  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
921  *
922  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
923  *
924  * @see ckmc_get_cert_chain_with_alias())
925  * @see ckmc_cert_list_all_free()
926  */
927 int ckmc_get_certificate_chain(const ckmc_cert_s *cert,
928                                const ckmc_cert_list_s *untrustedcerts,
929                                const ckmc_cert_list_s *trustedcerts,
930                                const bool use_trustedsystemcerts,
931                                ckmc_cert_list_s **ppcert_chain_list);
932
933 /**
934  * @brief Verifies a certificate chain and returns that chain using alias lists of untrusted and
935  *        trusted certificates
936  *
937  * @since_tizen 3.0
938  * @privlevel public
939  * @privilege %http://tizen.org/privilege/keymanager
940  *
941  * @remarks If the alias list of trusted root certificates is provided as a user input, these
942  *          certificates do not need to exist in the system's certificate storage.
943  * @remarks You must destroy the newly created @a ppcert_chain_list by calling
944  *          ckmc_cert_list_all_free() if it is no longer needed.
945  *
946  * @param[in] cert                    The certificate to be verified
947  * @param[in] untrustedcerts          The alias list of untrusted CA certificates stored in key
948  *                                    manager to be used in verifying a certificate chain
949  * @param[in] trustedcerts            The alias list of trusted CA certificates stored in key
950  *                                    manager to be used in verifying a certificate chain
951  * @param[in] use_trustedsystemcerts  The flag indicating the use of the trusted root certificates
952  *                                    in the system's certificate storage.
953  * @param[out] ppcert_chain_list The pointer to a newly created certificate chain's handle \n
954  *                               If an error occurs, @a *ppcert_chain_list will be null.
955  *
956  * @return @c 0 on success and the signature is valid,
957  *         otherwise a negative error value
958  *
959  * @retval #CKMC_ERROR_NONE                 Successful
960  * @retval #CKMC_ERROR_VERIFICATION_FAILED  The certificate chain is not valid
961  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid
962  * @retval #CKMC_ERROR_DB_LOCKED            A user key is not loaded in memory (a user is not logged
963  *                                          in)
964  * @retval #CKMC_ERROR_DB_ERROR             Failed due to the error with unknown reason
965  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN     Alias does not exist
966  * @retval #CKMC_ERROR_INVALID_FORMAT       The format of certificate is not valid
967  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
968  * @retval #CKMC_ERROR_AUTHENTICATION_FAILED
969  *                                          Some certificates were encrypted with password and could not
970  *                                          be used.
971  *
972  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
973  *
974  * @see ckmc_get_cert_chain())
975  * @see ckmc_cert_list_all_free()
976  */
977 int ckmc_get_certificate_chain_with_alias(const ckmc_cert_s *cert,
978                                           const ckmc_alias_list_s *untrustedcerts,
979                                           const ckmc_alias_list_s *trustedcerts,
980                                           const bool use_trustedsystemcerts,
981                                           ckmc_cert_list_s **ppcert_chain_list);
982
983 /**
984  * @brief Perform OCSP which checks certificate is whether revoked or not
985  *
986  * @since_tizen 3.0
987  * @privlevel public
988  * @privilege %http://tizen.org/privilege/keymanager
989  *
990  * @param[in] pcert_chain_list   Valid certificate chain to perform OCSP check
991  * @param[out] ocsp_status       The pointer to status result of OCSP check
992  *
993  * @return @c 0 on success, otherwise a negative error value
994  *
995  * @retval #CKMC_ERROR_NONE                 Successful
996  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid
997  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
998  *
999  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
1000  * @pre @a pcert_chain_list is created with ckmc_get_certificate_chain() or
1001  *      ckmc_get_certificate_chain_with_alias()
1002  *
1003  * @see ckmc_get_cert_chain())
1004  * @see ckmc_cert_list_all_free()
1005  */
1006 int ckmc_ocsp_check(const ckmc_cert_list_s *pcert_chain_list, ckmc_ocsp_status_e *ocsp_status);
1007
1008 /**
1009  * @deprecated, see ckmc_set_permission()
1010  * @brief Allows another application to access client's application data
1011  *
1012  * @since_tizen 2.3
1013  * @privlevel public
1014  * @privilege %http://tizen.org/privilege/keymanager
1015  *
1016  * @remarks Data identified by @a alias should exist
1017  *
1018  * @param[in] alias       Data alias for which access will be granted
1019  * @param[in] accessor    Package id of the application that will gain access rights
1020  * @param[in] granted     Rights granted for @a accessor application
1021  *
1022  * @return @c 0 on success, otherwise a negative error value
1023  *
1024  * @retval #CKMC_ERROR_NONE                 Successful
1025  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid
1026  * @retval #CKMC_ERROR_DB_LOCKED            A user key is not loaded in memory (a user is not logged
1027  *                                          in)
1028  * @retval #CKMC_ERROR_DB_ERROR             Failed due to the error with unknown reason
1029  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN     Alias does not exist
1030  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
1031  *
1032  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
1033  *
1034  * @see ckmc_deny_access()
1035  */
1036 int ckmc_allow_access(const char *alias, const char *accessor, ckmc_access_right_e granted);
1037
1038 /**
1039  * @brief Allows another application to access client's application data
1040  *
1041  * @since_tizen 3.0
1042  * @privlevel public
1043  * @privilege %http://tizen.org/privilege/keymanager
1044  *
1045  * @remarks Data identified by @a alias should exist
1046  *
1047  * @param[in] alias       Data alias for which access will be granted
1048  * @param[in] accessor    Package id of the application that will gain access rights
1049  * @param[in] permissions Mask of permissions granted for @a accessor application
1050  *                        (@a ckmc_permission_e)
1051  *                        (previous permission mask will be replaced with the new mask value)
1052  *
1053  * @return @c 0 on success, otherwise a negative error value
1054  *
1055  * @retval #CKMC_ERROR_NONE                 Successful
1056  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid
1057  * @retval #CKMC_ERROR_DB_LOCKED            A user key is not loaded in memory (a user is not logged
1058  *                                          in)
1059  * @retval #CKMC_ERROR_DB_ERROR             Failed due to the error with unknown reason
1060  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN     Alias does not exist
1061  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
1062  *
1063  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
1064  */
1065 int ckmc_set_permission(const char *alias, const char *accessor, int permissions);
1066
1067 /**
1068  * @deprecated, see ckmc_set_permission()
1069  * @brief Revokes another application's access to client's application data
1070  *
1071  * @since_tizen 2.3
1072  * @privlevel public
1073  * @privilege %http://tizen.org/privilege/keymanager
1074  *
1075  * @remarks Data identified by @a alias should exist
1076  * @remarks Only access previously granted with ckmc_allow_access can be revoked.
1077  *
1078  * @param[in] alias       Data alias for which access will be revoked
1079  * @param[in] accessor    Package id of the application that will lose access rights
1080  *
1081  * @return @c 0 on success, otherwise a negative error value
1082  *
1083  * @retval #CKMC_ERROR_NONE                 Successful
1084  * @retval #CKMC_ERROR_INVALID_PARAMETER    Input parameter is invalid or the @a accessor doesn't
1085  *                                          have access to @a alias
1086  * @retval #CKMC_ERROR_DB_LOCKED            A user key is not loaded in memory (a user is not logged
1087  *                                          in)
1088  * @retval #CKMC_ERROR_DB_ERROR             Failed due to the error with unknown reason
1089  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN     Alias does not exist
1090  * @retval #CKMC_ERROR_PERMISSION_DENIED    Failed to access key manager
1091  *
1092  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
1093  *
1094  * @see ckmc_allow_access()
1095  * @see ckmc_set_permission()
1096  */
1097 int ckmc_deny_access(const char *alias, const char *accessor);
1098
1099 /**
1100  * @brief Removes a an entry (no matter of type) from the key manager.
1101  *
1102  * @since_tizen 3.0
1103  * @privlevel public
1104  * @privilege %http://tizen.org/privilege/keymanager
1105  *
1106  * @remarks To remove item, client must have remove permission to the specified item.
1107  * @remarks The item owner can remove by default.
1108  *
1109  * @param[in] alias Item alias to be removed
1110  *
1111  * @return @c 0 on success,
1112  *         otherwise a negative error value
1113  *
1114  * @retval #CKMC_ERROR_NONE              Successful
1115  * @retval #CKMC_ERROR_INVALID_PARAMETER Input parameter is invalid
1116  * @retval #CKMC_ERROR_DB_LOCKED         A user key is not loaded in memory (a user is not logged
1117  *                                       in)
1118  * @retval #CKMC_ERROR_DB_ERROR          Failed due to a database error
1119  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN  Alias does not exist
1120  * @retval #CKMC_ERROR_PERMISSION_DENIED Failed to access key manager
1121  *
1122  * @pre User is already logged in and the user key is already loaded into memory in plain text form.
1123  *
1124  * @see ckmc_save_key()
1125  * @see ckmc_save_cert
1126  * @see ckmc_save_data
1127  * @see ckmc_save_pkcs12
1128  * @see ckmc_create_key_pair_rsa
1129  * @see ckmc_create_key_pair_dsa
1130  * @see ckmc_create_key_pair_ecdsa
1131  */
1132 int ckmc_remove_alias(const char *alias);
1133
1134 #ifdef __cplusplus
1135 }
1136 #endif
1137
1138 /**
1139  * @}
1140  */
1141
1142
1143 #endif /* __TIZEN_CORE_CKMC_MANAGER_H */