Reflect ACR comments for enum and struct in core API
[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_SUCCESS Successful
60  * @retval #CKMC_ERROR_INPUT_PARAM 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_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
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_SUCCESS Successful
90  * @retval #CKMC_ERROR_INPUT_PARAM 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_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
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_SUCCESS Successful
120  * @retval #CKMC_ERROR_INPUT_PARAM 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_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
125  *
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_SUCCESS Successful
148  * @retval #CKMC_ERROR_INPUT_PARAM 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_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
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_SUCCESS Successful
177  * @retval #CKMC_ERROR_INPUT_PARAM 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_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
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_SUCCESS Successful
207  * @retval #CKMC_ERROR_INPUT_PARAM 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_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
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_SUCCESS Successful
237  * @retval #CKMC_ERROR_INPUT_PARAM 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_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
242  *
243  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
244  *
245  * @see ckmc_save_cert()
246  * @see ckmc_remove_cert()
247  * @see ckmc_get_cert_alias_list()
248  */
249 int ckmc_get_cert(const char *alias, const char *password, ckmc_cert_s **ppcert);
250
251 /**
252  * @brief Gets a all alias of certificates to which the client can access
253  *
254  * @since_tizen 2.3
255  * @privlevel public
256  * @privilege %http://tizen.org/privilege/keymanager
257  *
258  * @remarks a client can access only data stored by the client and non-restricted data stored by other clients.
259  * @remarks A newly created ppalias_list should be destroyed by calling ckmc_alias_list_all_free() if it is no longer needed.
260  *
261  * @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.
262  *
263  * @return 0 on success, otherwise a negative error value
264  * @retval #CKMC_SUCCESS Successful
265  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
266  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
267  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
268  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
269  *
270  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
271  *
272  * @see ckmc_save_cert()
273  * @see ckmc_remove_cert()
274  * @see ckmc_get_cert()
275  */
276 int ckmc_get_cert_alias_list(ckmc_alias_list_s** ppalias_list);
277
278
279
280
281 /**
282  * @brief Stores a data inside key manager based on the provided policy.
283  *
284  * @since_tizen 2.3
285  * @privlevel public
286  * @privilege %http://tizen.org/privilege/keymanager
287  *
288  * @param[in] alias the name of a data to be stored
289  * @param[in] data a binary value to be stored.
290  * @param[in] policy about how to store a data securely.
291  *
292  * @return 0 on success, otherwise a negative error value
293  * @retval #CKMC_SUCCESS Successful
294  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
295  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
296  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS alias already exists.
297  * @retval #CKMC_ERROR_DB_ERROR failed due to other DB transaction unexpectedly.
298  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
299  *
300  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
301  *
302  * @see ckmc_remove_data()
303  * @see ckmc_get_data()
304  * @see ckmc_get_data_alias_list()
305  * @see #ckmc_raw_buffer_s
306  * @see #ckmc_policy_s
307  */
308 int ckmc_save_data(const char *alias, ckmc_raw_buffer_s data, const ckmc_policy_s policy);
309
310 /**
311  * @brief Removes a data from key manager
312  *
313  * @since_tizen 2.3
314  * @privlevel public
315  * @privilege %http://tizen.org/privilege/keymanager
316  *
317  * @remarks a client can remove only data stored by the client.
318  *
319  * @param[in] alias the name of a data to be removed
320  *
321  * @return 0 on success, otherwise a negative error value
322  * @retval #CKMC_SUCCESS Successful
323  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
324  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
325  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
326  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
327  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
328  *
329  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
330  *
331  * @see ckmc_save_data()
332  * @see ckmc_get_data()
333  * @see ckmc_get_data_alias_list()
334  */
335 int ckmc_remove_data(const char *alias);
336
337 /**
338  * @brief Gets a data from key manager
339  *
340  * @since_tizen 2.3
341  * @privlevel public
342  * @privilege %http://tizen.org/privilege/keymanager
343  *
344  * @remarks a client can access only data stored by the client and non-restricted data stored by other clients.
345  * @remarks A newly created ppdata should be destroyed by calling ckmc_buffer_free() if it is no longer needed.
346  *
347  * @param[in] alias the name of a data to retrieve
348  * @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.
349  * @param[out] ppdata a pointer to a newly created ckmc_raw_buffer_s handle
350  *
351  * @return 0 on success, otherwise a negative error value
352  * @retval #CKMC_SUCCESS Successful
353  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
354  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
355  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
356  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
357  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
358  *
359  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
360  *
361  * @see ckmc_save_data()
362  * @see ckmc_remove_data()
363  * @see ckmc_get_data_alias_list()
364  */
365 int ckmc_get_data(const char *alias, const char *password, ckmc_raw_buffer_s **ppdata);
366
367 /**
368  * @brief Gets a all alias of data to which the client can access
369  *
370  * @since_tizen 2.3
371  * @privlevel public
372  * @privilege %http://tizen.org/privilege/keymanager
373  *
374  * @remarks a client can access only data stored by the client and non-restricted data stored by other clients.
375  * @remarks A newly created ppalias_list should be destroyed by calling ckmc_alias_list_all_free() if it is no longer needed.
376  *
377  * @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.
378  *
379  * @return 0 on success, otherwise a negative error value
380  * @retval #CKMC_SUCCESS Successful
381  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
382  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
383  * @retval #CKMC_ERROR_DB_ERROR failed due to the error with unknown reason
384  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
385  *
386  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
387  *
388  * @see ckmc_save_data()
389  * @see ckmc_remove_data()
390  * @see ckmc_get_data()
391  */
392 int ckmc_get_data_alias_list(ckmc_alias_list_s** ppalias_list);
393
394
395
396
397 /**
398  * @brief Creates RSA private/public key pair and stores them inside key manager based on each policy.
399  *
400  * @since_tizen 2.3
401  * @privlevel public
402  * @privilege %http://tizen.org/privilege/keymanager
403  *
404  * @remarks if password in policy is provided, the key is additionally encrypted with the password in policy.
405  *
406  * @param[in] size the size of key strength to be created. 1024, 2048, and 4096 are supported.
407  * @param[in] private_key_alias the name of private key to be stored.
408  * @param[in] public_key_alias the name of public key to be stored.
409  * @param[in] policy_private_key about how to store a private key securely.
410  * @param[in] policy_public_key about how to store a public key securely.
411  *
412  * @return 0 on success, otherwise a negative error value
413  * @retval #CKMC_SUCCESS Successful
414  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
415  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
416  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS alias already exists.
417  * @retval #CKMC_ERROR_DB_ERROR failed due to other DB transaction unexpectedly.
418  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
419  *
420  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
421  *
422  * @see ckmc_create_key_pair_ecdsa()
423  * @see ckmc_create_signature()
424  * @see ckmc_verify_signature()
425  */
426 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);
427
428 /**
429  * @brief Creates ECDSA private/public key pair and stores them inside key manager based on each policy.
430  *
431  * @since_tizen 2.3
432  * @privlevel public
433  * @privilege %http://tizen.org/privilege/keymanager
434  *
435  * @remarks if password in policy is provided, the key is additionally encrypted with the password in policy.
436  *
437  * @param[in] type the type of eliptic curve of ECDSA.
438  * @param[in] private_key_alias the name of private key to be stored.
439  * @param[in] public_key_alias the name of public key to be stored.
440  * @param[in] policy_private_key about how to store a private key securely.
441  * @param[in] policy_public_key about how to store a public key securely.
442  *
443  * @return 0 on success, otherwise a negative error value
444  * @retval #CKMC_SUCCESS Successful
445  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
446  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
447  * @retval #CKMC_ERROR_DB_ALIAS_EXISTS alias already exists.
448  * @retval #CKMC_ERROR_DB_ERROR failed due to other DB transaction unexpectedly.
449  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
450  *
451  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
452  *
453  * @see ckmc_create_key_pair_rsa()
454  * @see ckmc_create_signature()
455  * @see ckmc_verify_signature()
456  * @see #ckmc_ec_type_e
457  */
458 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);
459
460 /**
461  * @brief Creates a signature on a given message using a private key and returns the signature
462  *
463  * @since_tizen 2.3
464  * @privlevel public
465  * @privilege %http://tizen.org/privilege/keymanager
466  *
467  * @remarks If password of policy is provided during storing a key, the same password should be provided.
468  * @remarks A newly created ppsignature should be destroyed by calling ckmc_buffer_free() if it is no longer needed.
469  *
470  *
471  * @param[in] private_key_alias the name of private key.
472  * @param[in] password used in decrypting a private key value.
473  * @param[in] message signed with a private key .
474  * @param[in] hash the hash algorithm used in creating signature.
475  * @param[in] padding the RSA padding algorithm used in creating signature. It is used only when the signature algorithm is RSA.
476  * @param[out] ppsignature a pointer to a newly created signature's. If an error occurs, *ppsignature will be null.
477  *
478  * @return 0 on success, otherwise a negative error value
479  * @retval #CKMC_SUCCESS Successful
480  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
481  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
482  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
483  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
484  *
485  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
486  *
487  * @see ckmc_create_key_pair_rsa()
488  * @see ckmc_create_key_pair_ecdsa()
489  * @see ckmc_verify_signature()
490  * @see ckmc_buffer_free()
491  * @see #ckmc_hash_algo_e
492  * @see #ckmc_rsa_padding_algo_e
493  */
494 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);
495
496 /**
497  * @brief Verifies a given signature on a given message using a public key and returns the signature status.
498  *
499  * @since_tizen 2.3
500  * @privlevel public
501  * @privilege %http://tizen.org/privilege/keymanager
502  *
503  * @remarks If password of policy is provided during storing a key, the same password should be provided.
504  *
505  * @param[in] public_key_alias the name of public key.
506  * @param[in] password used in decrypting a public key value.
507  * @param[in] message a input on which the signature is created.
508  * @param[in] signature verified with public key.
509  * @param[in] hash the hash algorithm used in verifying signature.
510  * @param[in] padding the RSA padding algorithm used in verifying signature. It is used only when the signature algorithm is RSA.
511  *
512  * @return 0 on success and the signature is valid, otherwise a negative error value
513  * @retval #CKMC_SUCCESS Successful
514  * @retval #CKMC_ERROR_VERIFICATION_FAILED the signature is invalid
515  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
516  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
517  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
518  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
519  *
520  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
521  *
522  * @see ckmc_create_key_pair_rsa()
523  * @see ckmc_create_key_pair_ecdsa()
524  * @see ckmc_verify_signature()
525  * @see #ckmc_hash_algo_e
526  * @see #ckmc_rsa_padding_algo_e
527  */
528 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);
529
530 /**
531  * @brief Verifies a certificate chain and return that chain.
532  *
533  * @since_tizen 2.3
534  * @privlevel public
535  * @privilege %http://tizen.orckmc_buffer_freeg/privilege/keymanager
536  *
537  * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
538  * @remarks A newly created ppcert_chain_list should be destroyed by calling ckmc_cert_list_all_free() if it is no longer needed.
539  *
540  * @param[in] cert the certificate to be verified
541  * @param[in] untrustedcerts the untrusted CA certificates to be used in verifying a certificate chain.
542  * @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.
543  *
544  * @return 0 on success and the signature is valid, otherwise a negative error value
545  * @retval #CKMC_SUCCESS Successful
546  * @retval #CKMC_ERROR_VERIFICATION_FAILED the certificate chain is not valid
547  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
548  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
549  * @retval #CKMC_ERROR_INVALID_FORMAT the format of certificate is not valid.
550  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
551  *
552  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
553  *
554  * @see ckmc_get_cert_chain_with_alias())
555  * @see ckmc_cert_list_all_free()
556  */
557 int ckmc_get_cert_chain(const ckmc_cert_s *cert, const ckmc_cert_list_s *untrustedcerts, ckmc_cert_list_s **ppcert_chain_list);
558
559 /**
560  * @brief Verifies a certificate chain using a alias list of untrusted certificates and return that chain.
561  *
562  * @since_tizen 2.3
563  * @privlevel public
564  * @privilege %http://tizen.org/privilege/keymanager
565  *
566  * @remarks The trusted root certificate of the chain should exist in the system's certificate storage.
567  * @remarks A newly created ppcert_chain_list should be destroyed by calling ckmc_cert_list_all_free() if it is no longer needed.
568  *
569  * @param[in] cert the certificate to be verified
570  * @param[in] untrustedcerts an alias list of untrusted CA certificates stored in key manager to be used in verifying a certificate chain.
571  * @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.
572  *
573  * @return 0 on success and the signature is valid, otherwise a negative error value
574  * @retval #CKMC_SUCCESS Successful
575  * @retval #CKMC_ERROR_VERIFICATION_FAILED the certificate chain is not valid
576  * @retval #CKMC_ERROR_INPUT_PARAM input parameter is invalid
577  * @retval #CKMC_ERROR_DB_LOCKED a user key is not loaded in memory(a user is not logged in)
578  * @retval #CKMC_ERROR_DB_ALIAS_UNKNOWN alias doesn't exists.
579  * @retval #CKMC_ERROR_INVALID_FORMAT the format of certificate is not valid.
580  * @retval #CKMC_ERROR_FILE_ACCESS_DENIED provided file doesn't exists or cannot be accessed
581  *
582  * @pre User must be already logged in and his user key is already loaded into memory in plain text form.
583  *
584  * @see ckmc_get_cert_chain())
585  * @see ckmc_cert_list_all_free()
586  */
587 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);
588
589
590 #ifdef __cplusplus
591 }
592 #endif
593
594 /**
595  * @}
596  */
597
598
599 #endif /* __TIZEN_CORE_CKMC_MANAGER_H */