Introduce certsvc_pkcs12_import_from_file_to_store_ret_list()
[platform/core/security/cert-svc.git] / src / vcore / pkcs12.h
1 /**
2  * Copyright (c) 2016 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        pkcs12.h
18  * @author      Jacek Migacz (j.migacz@samsung.com)
19  * @version     1.0
20  * @brief       PKCS#12 container manipulation routines.
21  */
22 #pragma once
23
24 #include <cert-svc/ccert.h>
25
26 /**
27  * To import the p12/pfx/crt/pem file to specified store (WIFI_STORE/VPN_STORE/EMAIL_STORE).
28  *
29  * @param[in] storeType Refers to WIFI_STORE / VPN_STORE / EMAIL_STORE / ALL_STORE.
30  * @param[in] path Path to file.
31  * @param[in] password Password for opening the file.
32  * @param[in] alias Logical name for certificate bundle identification (can't be empty).
33  * @param[out] certList     cert list in store returned in linked list. Free by
34  *                          certsvc_pkcs12_free_certificate_list_loaded_from_store()
35  *                          after use. Pass NULL if you don't want to return a list.
36  * @param[out] length       length of output @a certList. Pass NULL if you don't
37  *                                                       want to return a list.
38  * @return CERTSVC_SUCCESS, CERTSVC_FAIL, CERTSVC_DUPLICATED_ALIAS, CERTSVC_IO_ERROR, CERTSVC_WRONG_ARGUMENT, CERTSVC_BAD_ALLOC.
39  */
40 int pkcs12_import_from_file_to_store(CertStoreType storeType, const char *path,
41                                                                          const char *password, const char *alias, CertSvcStoreCertList **certList,
42                                                                          size_t *length);
43
44 /**
45  * TO check if the p12/pfx file is protected by password or not.
46  *
47  * @param[in] filePath Where the file is located.
48  * @param[out] passworded A boolean value to state if the file is protected by password or not.
49  * @return CERTSVC_SUCCESS, CERTSVC_FAIL, CERTSVC_IO_ERROR, CERTSVC_WRONG_ARGUMENT.
50  */
51 int pkcs12_has_password(const char *filepath, int *passworded);