Remove remaining cert-svc c codes
[platform/core/security/cert-svc.git] / vcore / vcore / Client.h
1 /**
2  * Copyright (c) 2015 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        Client.h
18  * @author      Madhan A K (madhan.ak@samsung.com)
19  * @version     1.0
20  * @brief       cert-svc client interface for cert-server.
21  */
22
23 #ifndef CERT_SVC_CLIENT_H_
24 #define CERT_SVC_CLIENT_H_
25
26 #include <cert-svc/cerror.h>
27 #include <cert-svc/ccert.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #define VCORE_MAX_FILENAME_SIZE     128
34 #define VCORE_MAX_RECV_DATA_SIZE    8192    //4096, internal buffer = 4KB*2. /*Note:system store cert size is bigger than 4KB*/
35 #define VCORE_MAX_SEND_DATA_SIZE    8192    //4096, internal buffer = 4KB*2.
36 #define VCORE_MAX_GROUP_ID_SIZE     32
37 #define VCORE_MAX_APPID_SIZE        32
38 #define VCORE_MAX_PASSWORD_SIZE     32
39 #define VCORE_SOCKET_ERROR          (-0x01C10000) // TIZEN_ERROR_CONNECTION  /*Connection error*/
40 #define VCORE_SOCK_PATH             "/tmp/CertSocket"
41 #define VCORE_PKEY_TEMP_PATH        "/tmp/tmpData"
42
43 typedef enum {
44     CERTSVC_EXTRACT_CERT,
45     CERTSVC_EXTRACT_SYSTEM_CERT,
46     CERTSVC_DELETE_CERT,
47     CERTSVC_INSTALL_CERTIFICATE,
48     CERTSVC_GET_CERTIFICATE_STATUS,
49     CERTSVC_SET_CERTIFICATE_STATUS,
50     CERTSVC_CHECK_ALIAS_EXISTS,
51     CERTSVC_GET_CERTIFICATE_LIST,
52     CERTSVC_GET_CERTIFICATE_ALIAS,
53     CERTSVC_GET_USER_CERTIFICATE_LIST,
54     CERTSVC_GET_ROOT_CERTIFICATE_LIST,
55     CERTSVC_LOAD_CERTIFICATES,
56 } VcoreRequestType;
57
58 typedef struct {
59     VcoreRequestType reqType;
60     CertStoreType    storeType;
61     char             gname[VCORE_MAX_FILENAME_SIZE * 2 + 1]; /* for gname */
62     char             common_name[VCORE_MAX_FILENAME_SIZE * 2 + 1]; /* for common_name */
63     char             private_key_gname[VCORE_MAX_FILENAME_SIZE * 2 + 1]; /* for private_key_gname */
64     char             associated_gname[VCORE_MAX_FILENAME_SIZE * 2 + 1]; /* for associated_gname */
65     char             dataBlock[VCORE_MAX_SEND_DATA_SIZE];    /* for cert & key buffer */
66     size_t           dataBlockLen;
67     CertStatus       certStatus;
68     int              is_root_app;
69     CertType         certType;
70 } VcoreRequestData;
71
72 typedef struct {
73     char             gname[VCORE_MAX_FILENAME_SIZE * 2 + 1];
74     char             title[VCORE_MAX_FILENAME_SIZE * 2 + 1];
75     CertStatus       status;
76     CertStoreType    storeType;
77 } VcoreCertResponseData;
78
79
80 typedef struct {
81     char             dataBlock[VCORE_MAX_RECV_DATA_SIZE];
82     size_t           dataBlockLen;
83 } ResponseCertBlock;
84
85 typedef struct {
86     char                   dataBlock[VCORE_MAX_RECV_DATA_SIZE];
87     size_t                 dataBlockLen;
88     CertStatus             certStatus;
89     char                   common_name[VCORE_MAX_FILENAME_SIZE* 2 + 1]; /*for common_name*/
90     int                    result;
91     int                    isAliasUnique;
92     size_t                 certCount;
93     VcoreCertResponseData* certList;
94     size_t                 certBlockCount;
95     ResponseCertBlock*     certBlockList; // array
96 } VcoreResponseData;
97
98
99
100 int vcore_client_set_certificate_status_to_store(CertStoreType storeType, int is_root_app, const char *gname, CertStatus status);
101 int vcore_client_get_certificate_status_from_store(CertStoreType storeType, const char *gname, CertStatus *status);
102 int vcore_client_check_alias_exist_in_store(CertStoreType storeType, const char *alias, int *isUnique);
103 int vcore_client_install_certificate_to_store(CertStoreType storeType, const char *gname, const char *common_name, const char *private_key_gname, const char *associated_gname, const char *dataBlock, size_t dataBlockLen, CertType certType);
104 int vcore_client_get_certificate_from_store(CertStoreType storeType, const char *gname, char **certData, size_t *certSize, CertType certType);
105 int vcore_client_delete_certificate_from_store(CertStoreType storeType, const char *gname);
106 VcoreResponseData cert_svc_client_comm(VcoreRequestData *client_data);
107 int vcore_client_get_certificate_list_from_store(CertStoreType storeType, int is_root_app, CertSvcStoreCertList **certList, size_t *length);
108 int vcore_client_get_root_certificate_list_from_store(CertStoreType storeType, CertSvcStoreCertList **certList, size_t *length);
109 int vcore_client_get_end_user_certificate_list_from_store(CertStoreType storeType, CertSvcStoreCertList **certList, size_t *length);
110 int vcore_client_get_certificate_alias_from_store(CertStoreType storeType, const char *gname, char **alias);
111 int vcore_client_load_certificates_from_store(CertStoreType storeType, const char *gname, char ***certs, size_t *ncerts);
112
113 #ifdef __cplusplus
114 }
115 #endif
116
117 #endif