72eb0c083d9c6fe9ecd981823b620daed9575bd2
[platform/core/security/cert-svc.git] / vcore / src / cert-svc / cprimitives.h
1 /**
2  * Copyright (c) 2011 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        vcore_api_extension.h
18  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version     1.0
20  * @brief       This is C api for ValidationCore.
21  */
22 #ifndef _CERTSVC_C_API_EXTENDED_H_
23 #define _CERTSVC_C_API_EXTENDED_H_
24
25 #include <openssl/evp.h>
26 #include <openssl/x509.h>
27
28 #include <cert-svc/ccert.h>
29 #include <cert-svc/cstring.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  * This will return pointer to X509 base openssl struct. This struct must be release by function
37  * certsvc_certificate_free_x509.
38  *
39  * vcore_instance_free or vcore_instance_reset will not free memory allocated by this function!
40  *
41  * @param[in] certificate Pointer to certificate.
42  * @param[out] cert Duplicate of certificate.
43  * @return CERTSVC_SUCCESS, CERTSVC_WRONG_ARGUMENT, CERTSVC_FAIL
44  */
45 int certsvc_certificate_dup_x509(CertSvcCertificate certificate, X509** cert);
46
47 /**
48  * Release X509 struct allocated by certsvc_certificate_new_x509_copy function.
49  *
50  * @param[in] x509_copy Pointer to openssl struct.
51  */
52 void certsvc_certificate_free_x509(X509 *x509_copy);
53
54 /**
55  * This will return pointer to EVP_PKEY base openssl struct. This struct must
56  * be release with function certsvc_pkcs12_free_evp_pkey
57  *
58  * @param[in] instance
59  * @param[in] storeType Refers to VPN_STORE / WIFI_STORE / EMAIL_STORE / SYSTEM_STORE / ALL_STORE.
60  * @param[in] gname Pkcs12 identificator.
61  * @param[out] pkey Duplicate of private key.
62  * @return CERTSVC_SUCCESS, CERT_FAIL
63  */
64
65 int certsvc_pkcs12_dup_evp_pkey_from_store(CertSvcInstance instance,
66                                            CertStoreType storeType,
67                                            CertSvcString gname,
68                                            EVP_PKEY** pkey);
69
70 void certsvc_pkcs12_free_evp_pkey(EVP_PKEY* pkey);
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif