Fix doc related to exportable flag
[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, certificates and data of a user and additional crypto functions.
20  */
21
22
23 #ifndef __TIZEN_CORE_CKMC_MANAGER_H
24 #define __TIZEN_CORE_CKMC_MANAGER_H
25
26 #include <stddef.h>
27 #include <sys/types.h>
28 #include <tizen.h>
29 #include <ckmc/ckmc-type.h>
30 #include <ckmc/ckmc-error.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /**
37  * @addtogroup CAPI_KEY_MANAGER_CLIENT_MODULE
38  * @{
39  */
40
41
42 /**
43  * @brief Stores a key inside key manager based on the provided policy.
44  *
45  * @since_tizen 2.3
46  * @privlevel public
47  * @privilege %http://tizen.org/privilege/keymanager
48  *
49  * @remarks Currently only four types of keys are supported for this API. These are RSA public/private key and ECDSA /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.
53  *
54  * @param[in] alias the name of a key to be stored
55  * @param[in] key a key's binary value to be stored.
56  * @param[in] policy about how to store a key securely.
57  *
58  * @return 0 on success, otherwise a negative error value
59  * @retval #CKMC_ERROR_NONE Successful
60  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
61  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
62  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS alias already exists.
63  * @retval #CKMC_ERROR_INVALID_FORMAT the format of raw_key is not valid.
64  * @retval #CKMC_ERROR_DB_ERROR failed due to other DB transaction unexpectedly.
65  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
66  *
67  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
68  *
69  * @see ckmc_remove_key()
70  * @see ckmc_get_key()
71  * @see ckmc_get_key_alias_list()
72  * @see #ckmc_key_s
73  * @see #ckmc_policy_s
74  */
75 int ckmc_save_key(const char *alias, const ckmc_key_s key, const ckmc_policy_s policy);
76
77 /**
78  * @brief Removes a key from key manager
79  *
80  * @since_tizen 2.3
81  * @privlevel public
82  * @privilege %http://tizen.org/privilege/keymanager
83  *
84  * @remarks a client can remove only keys stored by the client.
85  *
86  * @param[in] alias the name of a key to be removed
87  *
88  * @return 0 on success, otherwise a negative error value
89  * @retval #CKMC_ERROR_NONE Successful
90  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
91  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
92  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
93  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
94  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
95  *
96  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
97  *
98  * @see ckmc_save_key()
99  * @see ckmc_get_key()
100  * @see ckmc_get_key_alias_list()
101  */
102 int ckmc_remove_key(const char *alias);
103
104 /**
105  * @brief Gets a key from key manager
106  *
107  * @since_tizen 2.3
108  * @privlevel public
109  * @privilege %http://tizen.org/privilege/keymanager
110  *
111  * @remarks a client can access only data stored by the client and non-restricted data stored by other clients.
112  * @remarks A newly created ppkey should be destroyed by calling ckmc_key_free() if it is no longer needed.
113  *
114  * @param[in] alias the name of a key to retrieve
115  * @param[in] password used in decrypting a key value. If password of policy is provided in ckmc_save_key(), the same password should be provided.
116  * @param[out] ppkey a pointer to a newly created ckmc_key_s handle
117  *
118  * @return 0 on success, otherwise a negative error value
119  * @retval #CKMC_ERROR_NONE Successful
120  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
121  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
122  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
123  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
124  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
125  * @retval #CKMC_ERROR_NOT_EXPORTABLE a key is not exportable and could not be returned to client
126  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
127  *
128  * @see ckmc_save_key()
129  * @see ckmc_remove_key()
130  * @see ckmc_get_key_alias_list()
131  */
132 int ckmc_get_key(const char *alias, const char *password, ckmc_key_s **ppkey);
133
134 /**
135  * @brief Gets a all alias of keys to which the client can access
136  *
137  * @since_tizen 2.3
138  * @privlevel public
139  * @privilege %http://tizen.org/privilege/keymanager
140  *
141  * @remarks a client can access only data stored by the client and non-restricted data stored by other clients.
142  * @remarks A newly created ppalias_list should be destroyed by calling ckmc_alias_list_all_free() if it is no longer needed.
143  *
144  * @param[out] ppalias_list a pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys. If there is no available key alias, *ppalias_list will be null.
145  *
146  * @return 0 on success, otherwise a negative error value
147  * @retval #CKMC_ERROR_NONE Successful
148  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
149  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
150  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
151  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
152  *
153  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
154  *
155  * @see ckmc_save_key()
156  * @see ckmc_remove_key()
157  * @see ckmc_get_key()
158  */
159 int ckmc_get_key_alias_list(ckmc_alias_list_s** ppalias_list);
160
161
162
163
164 /**
165  * @brief Stores a certificate inside key manager based on the provided policy.
166  *
167  * @since_tizen 2.3
168  * @privlevel public
169  * @privilege %http://tizen.org/privilege/keymanager
170  *
171  * @param[in] alias the name of a certificate to be stored
172  * @param[in] cert a certificate's binary value to be stored.
173  * @param[in] policy about how to store a certificate securely.
174  *
175  * @return 0 on success, otherwise a negative error value
176  * @retval #CKMC_ERROR_NONE Successful
177  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
178  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
179  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS alias already exists.
180  * @retval #CKMC_ERROR_INVALID_FORMAT the format of raw_cert is not valid.
181  * @retval #CKMC_ERROR_DB_ERROR failed due to other DB transaction unexpectedly.
182  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
183  *
184  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
185  *
186  * @see ckmc_remove_cert()
187  * @see ckmc_get_cert()
188  * @see ckmc_get_cert_alias_list()
189  * @see #ckmc_cert_s
190  * @see #ckmc_policy_s
191  */
192 int ckmc_save_cert(const char *alias, const ckmc_cert_s cert, const ckmc_policy_s policy);
193
194 /**
195  * @brief Removes a certificate from key manager
196  *
197  * @since_tizen 2.3
198  * @privlevel public
199  * @privilege %http://tizen.org/privilege/keymanager
200  *
201  * @remarks a client can remove only certificates stored by the client.
202  *
203  * @param[in] alias the name of a certificate to be removed
204  *
205  * @return 0 on success, otherwise a negative error value
206  * @retval #CKMC_ERROR_NONE Successful
207  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
208  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
209  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
210  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
211  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
212  *
213  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
214  *
215  * @see ckmc_save_cert()
216  * @see ckmc_get_cert()
217  * @see ckmc_get_cert_alias_list()
218  */
219 int ckmc_remove_cert(const char *alias);
220
221 /**
222  * @brief Gets a certificate from key manager
223  *
224  * @since_tizen 2.3
225  * @privlevel public
226  * @privilege %http://tizen.org/privilege/keymanager
227  *
228  * @remarks a client can access only certificate stored by the client and non-restricted certificate stored by other clients.
229  * @remarks A newly created ppcert should be destroyed by calling ckmc_cert_free() if it is no longer needed.
230  *
231  * @param[in] alias the name of a certificate to retrieve
232  * @param[in] password used in decrypting a certificate value. If password of policy is provided in ckmc_save_cert(), the same password should be provided.
233  * @param[out] ppcert a pointer to a newly created ckmc_cert_s handle
234  *
235  * @return 0 on success, otherwise a negative error value
236  * @retval #CKMC_ERROR_NONE Successful
237  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
238  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
239  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
240  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
241  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
242  * @retval #CKMC_ERROR_NOT_EXPORTABLE a certification is not exportable and could not be returned to client
243  *
244  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
245  *
246  * @see ckmc_save_cert()
247  * @see ckmc_remove_cert()
248  * @see ckmc_get_cert_alias_list()
249  */
250 int ckmc_get_cert(const char *alias, const char *password, ckmc_cert_s **ppcert);
251
252 /**
253  * @brief Gets a all alias of certificates to which the client can access
254  *
255  * @since_tizen 2.3
256  * @privlevel public
257  * @privilege %http://tizen.org/privilege/keymanager
258  *
259  * @remarks a client can access only data stored by the client and non-restricted data stored by other clients.
260  * @remarks A newly created ppalias_list should be destroyed by calling ckmc_alias_list_all_free() if it is no longer needed.
261  *
262  * @param[out] ppalias_list a pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys. If there is no available key alias, *ppalias_list will be null.
263  *
264  * @return 0 on success, otherwise a negative error value
265  * @retval #CKMC_ERROR_NONE Successful
266  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
267  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
268  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
269  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
270  *
271  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
272  *
273  * @see ckmc_save_cert()
274  * @see ckmc_remove_cert()
275  * @see ckmc_get_cert()
276  */
277 int ckmc_get_cert_alias_list(ckmc_alias_list_s** ppalias_list);
278
279
280
281
282 /**
283  * @brief Stores a data inside key manager based on the provided policy.
284  *
285  * @since_tizen 2.3
286  * @privlevel public
287  * @privilege %http://tizen.org/privilege/keymanager
288  *
289  * @param[in] alias the name of a data to be stored
290  * @param[in] data a binary value to be stored.
291  * @param[in] policy about how to store a data securely.
292  *
293  * @return 0 on success, otherwise a negative error value
294  * @retval #CKMC_ERROR_NONE Successful
295  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
296  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
297  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS alias already exists.
298  * @retval #CKMC_ERROR_DB_ERROR failed due to other DB transaction unexpectedly.
299  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
300  *
301  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
302  *
303  * @see ckmc_remove_data()
304  * @see ckmc_get_data()
305  * @see ckmc_get_data_alias_list()
306  * @see #ckmc_raw_buffer_s
307  * @see #ckmc_policy_s
308  */
309 int ckmc_save_data(const char *alias, ckmc_raw_buffer_s data, const ckmc_policy_s policy);
310
311 /**
312  * @brief Removes a data from key manager
313  *
314  * @since_tizen 2.3
315  * @privlevel public
316  * @privilege %http://tizen.org/privilege/keymanager
317  *
318  * @remarks a client can remove only data stored by the client.
319  *
320  * @param[in] alias the name of a data to be removed
321  *
322  * @return 0 on success, otherwise a negative error value
323  * @retval #CKMC_ERROR_NONE Successful
324  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
325  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
326  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
327  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
328  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
329  *
330  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
331  *
332  * @see ckmc_save_data()
333  * @see ckmc_get_data()
334  * @see ckmc_get_data_alias_list()
335  */
336 int ckmc_remove_data(const char *alias);
337
338 /**
339  * @brief Gets a data from key manager
340  *
341  * @since_tizen 2.3
342  * @privlevel public
343  * @privilege %http://tizen.org/privilege/keymanager
344  *
345  * @remarks a client can access only data stored by the client and non-restricted data stored by other clients.
346  * @remarks A newly created ppdata should be destroyed by calling ckmc_buffer_free() if it is no longer needed.
347  *
348  * @param[in] alias the name of a data to retrieve
349  * @param[in] password used in decrypting a data value. If password of policy is provided in ckmc_save_data(), the same password should be provided.
350  * @param[out] ppdata a pointer to a newly created ckmc_raw_buffer_s handle
351  *
352  * @return 0 on success, otherwise a negative error value
353  * @retval #CKMC_ERROR_NONE Successful
354  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
355  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
356  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
357  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
358  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
359  * @retval #CKMC_ERROR_NOT_EXPORTABLE data is not exportable and could not be returned to client
360  *
361  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
362  *
363  * @see ckmc_save_data()
364  * @see ckmc_remove_data()
365  * @see ckmc_get_data_alias_list()
366  */
367 int ckmc_get_data(const char *alias, const char *password, ckmc_raw_buffer_s **ppdata);
368
369 /**
370  * @brief Gets a all alias of data to which the client can access
371  *
372  * @since_tizen 2.3
373  * @privlevel public
374  * @privilege %http://tizen.org/privilege/keymanager
375  *
376  * @remarks a client can access only data stored by the client and non-restricted data stored by other clients.
377  * @remarks A newly created ppalias_list should be destroyed by calling ckmc_alias_list_all_free() if it is no longer needed.
378  *
379  * @param[out] ppalias_list a pointer to a newly created ckmc_alias_list_s handle containing all available alias of keys. If there is no available key alias, *ppalias_list will be null.
380  *
381  * @return 0 on success, otherwise a negative error value
382  * @retval #CKMC_ERROR_NONE Successful
383  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
384  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
385  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
386  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
387  *
388  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
389  *
390  * @see ckmc_save_data()
391  * @see ckmc_remove_data()
392  * @see ckmc_get_data()
393  */
394 int ckmc_get_data_alias_list(ckmc_alias_list_s** ppalias_list);
395
396
397
398
399 /**
400  * @brief Creates RSA private/public key pair and stores them inside key manager based on each policy.
401  *
402  * @since_tizen 2.3
403  * @privlevel public
404  * @privilege %http://tizen.org/privilege/keymanager
405  *
406  * @remarks if password in policy is provided, the key is additionally encrypted with the password in policy.
407  *
408  * @param[in] size the size of key strength to be created. 1024, 2048, and 4096 are supported.
409  * @param[in] private_key_alias the name of private key to be stored.
410  * @param[in] public_key_alias the name of public key to be stored.
411  * @param[in] policy_private_key about how to store a private key securely.
412  * @param[in] policy_public_key about how to store a public key securely.
413  *
414  * @return 0 on success, 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_ALIAS_EXISTS alias already exists.
419  * @retval #CKMC_ERROR_DB_ERROR failed due to other DB transaction unexpectedly.
420  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
421  *
422  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
423  *
424  * @see ckmc_create_key_pair_ecdsa()
425  * @see ckmc_create_signature()
426  * @see ckmc_verify_signature()
427  */
428 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);
429
430 /**
431  * @brief Creates ECDSA private/public key pair and stores them inside key manager based on each policy.
432  *
433  * @since_tizen 2.3
434  * @privlevel public
435  * @privilege %http://tizen.org/privilege/keymanager
436  *
437  * @remarks if password in policy is provided, the key is additionally encrypted with the password in policy.
438  *
439  * @param[in] type the type of eliptic curve of ECDSA.
440  * @param[in] private_key_alias the name of private key to be stored.
441  * @param[in] public_key_alias the name of public key to be stored.
442  * @param[in] policy_private_key about how to store a private key securely.
443  * @param[in] policy_public_key about how to store a public key securely.
444  *
445  * @return 0 on success, otherwise a negative error value
446  * @retval #CKMC_ERROR_NONE Successful
447  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
448  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
449  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS alias already exists.
450  * @retval #CKMC_ERROR_DB_ERROR failed due to other DB transaction unexpectedly.
451  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
452  *
453  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
454  *
455  * @see ckmc_create_key_pair_rsa()
456  * @see ckmc_create_signature()
457  * @see ckmc_verify_signature()
458  * @see #ckmc_ec_type_e
459  */
460 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);
461
462 /**
463  * @brief Creates a signature on a given message using a private key and returns the signature
464  *
465  * @since_tizen 2.3
466  * @privlevel public
467  * @privilege %http://tizen.org/privilege/keymanager
468  *
469  * @remarks If password of policy is provided during storing a key, the same password should be provided.
470  * @remarks A newly created ppsignature should be destroyed by calling ckmc_buffer_free() if it is no longer needed.
471  *
472  *
473  * @param[in] private_key_alias the name of private key.
474  * @param[in] password used in decrypting a private key value.
475  * @param[in] message signed with a private key .
476  * @param[in] hash the hash algorithm used in creating signature.
477  * @param[in] padding the RSA padding algorithm used in creating signature. It is used only when the signature algorithm is RSA.
478  * @param[out] ppsignature a pointer to a newly created signature's. If an error occurs, *ppsignature will be null.
479  *
480  * @return 0 on success, otherwise a negative error value
481  * @retval #CKMC_ERROR_NONE Successful
482  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
483  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
484  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
485  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
486  *
487  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
488  *
489  * @see ckmc_create_key_pair_rsa()
490  * @see ckmc_create_key_pair_ecdsa()
491  * @see ckmc_verify_signature()
492  * @see ckmc_buffer_free()
493  * @see #ckmc_hash_algo_e
494  * @see #ckmc_rsa_padding_algo_e
495  */
496 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);
497
498 /**
499  * @brief Verifies a given signature on a given message using a public key and returns the signature status.
500  *
501  * @since_tizen 2.3
502  * @privlevel public
503  * @privilege %http://tizen.org/privilege/keymanager
504  *
505  * @remarks If password of policy is provided during storing a key, the same password should be provided.
506  *
507  * @param[in] public_key_alias the name of public key.
508  * @param[in] password used in decrypting a public key value.
509  * @param[in] message a input on which the signature is created.
510  * @param[in] signature verified with public key.
511  * @param[in] hash the hash algorithm used in verifying signature.
512  * @param[in] padding the RSA padding algorithm used in verifying signature. It is used only when the signature algorithm is RSA.
513  *
514  * @return 0 on success and the signature is valid, otherwise a negative error value
515  * @retval #CKMC_ERROR_NONE Successful
516  * @retval #CKMC_ERROR_VERIFICATION_FAILED the signature is invalid
517  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
518  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
519  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
520  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
521  *
522  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
523  *
524  * @see ckmc_create_key_pair_rsa()
525  * @see ckmc_create_key_pair_ecdsa()
526  * @see ckmc_verify_signature()
527  * @see #ckmc_hash_algo_e
528  * @see #ckmc_rsa_padding_algo_e
529  */
530 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);
531
532 /**
533  * @brief Verifies a certificate chain and return that chain.
534  *
535  * @since_tizen 2.3
536  * @privlevel public
537  * @privilege %http://tizen.orckmc_buffer_freeg/privilege/keymanager
538  *
539  * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
540  * @remarks A newly created ppcert_chain_list should be destroyed by calling ckmc_cert_list_all_free() if it is no longer needed.
541  *
542  * @param[in] cert the certificate to be verified
543  * @param[in] untrustedcerts the untrusted CA certificates to be used in verifying a certificate chain.
544  * @param[out] ppcert_chain_list a pointer to a newly created certificate chain's handle. If an error occurs, *ppcert_chain_list will be null.
545  *
546  * @return 0 on success and the signature is valid, otherwise a negative error value
547  * @retval #CKMC_ERROR_NONE Successful
548  * @retval #CKMC_ERROR_VERIFICATION_FAILED the certificate chain is not valid
549  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
550  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
551  * @retval #CKMC_ERROR_INVALID_FORMAT the format of certificate is not valid.
552  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
553  *
554  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
555  *
556  * @see ckmc_get_cert_chain_with_alias())
557  * @see ckmc_cert_list_all_free()
558  */
559 int ckmc_get_cert_chain(const ckmc_cert_s *cert, const ckmc_cert_list_s *untrustedcerts, ckmc_cert_list_s **ppcert_chain_list);
560
561 /**
562  * @brief Verifies a certificate chain using a alias list of untrusted certificates and return that chain.
563  *
564  * @since_tizen 2.3
565  * @privlevel public
566  * @privilege %http://tizen.org/privilege/keymanager
567  *
568  * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
569  * @remarks A newly created ppcert_chain_list should be destroyed by calling ckmc_cert_list_all_free() if it is no longer needed.
570  *
571  * @param[in] cert the certificate to be verified
572  * @param[in] untrustedcerts an alias list of untrusted CA certificates stored in key manager to be used in verifying a certificate chain.
573  * @param[out] ppcert_chain_list a pointer to a newly created certificate chain's handle. If an error occurs, *ppcert_chain_list will be null.
574  *
575  * @return 0 on success and the signature is valid, otherwise a negative error value
576  * @retval #CKMC_ERROR_NONE Successful
577  * @retval #CKMC_ERROR_VERIFICATION_FAILED the certificate chain is not valid
578  * @retval #CKMC_ERROR_INVALID_PARAMETER input parameter is invalid
579  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
580  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
581  * @retval #CKMC_ERROR_INVALID_FORMAT the format of certificate is not valid.
582  * @retval #CKMC_ERROR_PERMISSION_DENIED failed to access key manager
583  *
584  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
585  *
586  * @see ckmc_get_cert_chain())
587  * @see ckmc_cert_list_all_free()
588  */
589 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);
590
591
592 #ifdef __cplusplus
593 }
594 #endif
595
596 /**
597  * @}
598  */
599
600
601 #endif /* __TIZEN_CORE_CKMC_MANAGER_H */