2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FSecCert_CertMgrMessages.h
20 * @brief This is the header file for the CertMgr IPC message types.
22 * This is the header file for the CertMgr IPC message types.
25 #include <ipc/ipc_message_macros.h>
26 #include <FIo_IpcCommonParamTraits.h>
27 #include <FIo_IpcMessageStart.h>
28 #include "FSecCert_CertTypes.h"
30 #define IPC_MESSAGE_START CertMgrServiceStart
32 #ifndef _FSEC_CERT_INTERNAL_CERT_MANAGER_MESSAGES_H_
33 #define _FSEC_CERT_INTERNAL_CERT_MANAGER_MESSAGES_H_
38 struct ParamTraits< Tizen::Security::Cert::_CertFieldInfos >
40 typedef Tizen::Security::Cert::_CertFieldInfos param_type;
41 static void Write(Message* pMesg, const param_type& params)
43 pMesg->WriteInt(params.certType);
44 pMesg->WriteInt(params.certFileId);
45 pMesg->WriteBytes(static_cast< const void* >(params.serialNo), Tizen::Security::Cert::_MAX_SERIAL_NUMBER_SIZE + 1);
46 pMesg->WriteBytes(static_cast< const void* >(params.sigAlgorithm), Tizen::Security::Cert::_MAX_CERT_ALGORITHM_SIZE + 1);
47 pMesg->WriteBytes(static_cast< const void* >(params.validityFrom), Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
48 pMesg->WriteBytes(static_cast< const void* >(params.validityTo), Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
49 pMesg->WriteBytes(static_cast< const void* >(params.subjectName), Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
50 pMesg->WriteBytes(static_cast< const void* >(params.issuerName), Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
51 pMesg->WriteBytes(static_cast< const void* >(params.fingerPrint), Tizen::Security::Cert::_MAX_CERT_FINGERPRINT_SIZE + 1);
52 pMesg->WriteInt(params.fingerPrintLen);
53 pMesg->WriteBytes(static_cast< const void* >(params.publicKey), Tizen::Security::Cert::_MAX_CERT_PUBLIC_KEY_SIZE + 1);
54 pMesg->WriteBytes(static_cast< const void* >(params.certTypeFormat), Tizen::Security::Cert::_MAX_CERT_TYPE_SIZE + 1);
55 pMesg->WriteInt(params.certVersion);
56 pMesg->WriteBytes(static_cast< const void* >(params.certTitle), Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
57 pMesg->WriteBytes(static_cast< const void* >(params.certSubTitle), Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
60 static bool Read(const Message* pMesg, void** ppIter, param_type* pParam)
62 const char* pBuffer = null;
65 pMesg->ReadInt(ppIter, &value);
66 pParam->certType = static_cast< Tizen::Security::Cert::_CaCertType >(value);
68 pMesg->ReadInt(ppIter, &value);
69 pParam->certFileId = value;
71 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_SERIAL_NUMBER_SIZE + 1);
72 memcpy(pParam->serialNo, pBuffer, Tizen::Security::Cert::_MAX_SERIAL_NUMBER_SIZE + 1);
74 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_ALGORITHM_SIZE + 1);
75 memcpy(pParam->sigAlgorithm, pBuffer, Tizen::Security::Cert::_MAX_CERT_ALGORITHM_SIZE + 1);
77 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
78 memcpy(pParam->validityFrom, pBuffer, Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
80 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
81 memcpy(pParam->validityTo, pBuffer, Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
83 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
84 memcpy(pParam->subjectName, pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
86 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
87 memcpy(pParam->issuerName, pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
89 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_FINGERPRINT_SIZE + 1);
90 memcpy(pParam->fingerPrint, pBuffer, Tizen::Security::Cert::_MAX_CERT_FINGERPRINT_SIZE + 1);
92 pMesg->ReadInt(ppIter, &value);
93 pParam->fingerPrintLen = value;
95 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_PUBLIC_KEY_SIZE + 1);
96 memcpy(pParam->publicKey, pBuffer, Tizen::Security::Cert::_MAX_CERT_PUBLIC_KEY_SIZE + 1);
98 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_TYPE_SIZE + 1);
99 memcpy(pParam->certTypeFormat, pBuffer, Tizen::Security::Cert::_MAX_CERT_TYPE_SIZE + 1);
101 pMesg->ReadInt(ppIter, &value);
102 pParam->certVersion = value;
104 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
105 memcpy(pParam->certTitle, pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
107 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
108 memcpy(pParam->certSubTitle, pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
112 static void Log(const param_type& p, std::string* l)
119 struct ParamTraits< Tizen::Security::Cert::_CertificateListInfo >
121 typedef Tizen::Security::Cert::_CertificateListInfo param_type;
122 static void Write(Message* pMesg, const param_type& params)
127 param_type* pTemp = const_cast< param_type* >(¶ms);
131 pTemp = pTemp->pNext;
135 pMesg->WriteInt(count);
137 pTemp = const_cast< param_type* >(¶ms);
138 for (index = 0; index < count; index++)
140 pMesg->WriteInt(pTemp->certFileId);
141 pMesg->WriteInt(pTemp->format);
142 pMesg->WriteInt(pTemp->certType);
143 pMesg->WriteInt(pTemp->length);
144 pMesg->WriteInt(pTemp->priKeyLen);
145 pMesg->WriteBytes(static_cast< const void* >(pTemp->certificate), Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
146 pMesg->WriteBytes(static_cast< const void* >(pTemp->privatekey), Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
148 pTemp = pTemp->pNext;
154 static bool Read(const Message* pMesg, void** ppIter, param_type* pParam)
156 const char* pBuffer = null;
160 param_type* pCurrentNode = pParam;
161 param_type* pNewNode = null;
163 pMesg->ReadInt(ppIter, &count);
170 pMesg->ReadInt(ppIter, &value);
171 pCurrentNode->certFileId = value;
173 pMesg->ReadInt(ppIter, &value);
174 pCurrentNode->format = static_cast< Tizen::Security::Cert::_CertFormat >(value);
176 pMesg->ReadInt(ppIter, &value);
177 pCurrentNode->certType = static_cast< Tizen::Security::Cert::_CaCertType >(value);
179 pMesg->ReadInt(ppIter, &value);
180 pCurrentNode->length = value;
182 pMesg->ReadInt(ppIter, &value);
183 pCurrentNode->priKeyLen = value;
185 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
186 memcpy(pCurrentNode->certificate, pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
188 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
189 memcpy(pCurrentNode->privatekey, pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
191 pCurrentNode->pNext = null;
193 for (index = 1; index < count; index++)
195 pNewNode = new (std::nothrow) param_type();
196 SysTryReturn(NID_SEC_CERT, pNewNode != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] failed to allocate memory");
198 pMesg->ReadInt(ppIter, &value);
199 pNewNode->certFileId = value;
201 pMesg->ReadInt(ppIter, &value);
202 pNewNode->format = static_cast< Tizen::Security::Cert::_CertFormat >(value);
204 pMesg->ReadInt(ppIter, &value);
205 pNewNode->certType = static_cast< Tizen::Security::Cert::_CaCertType >(value);
207 pMesg->ReadInt(ppIter, &value);
208 pNewNode->length = value;
210 pMesg->ReadInt(ppIter, &value);
211 pNewNode->priKeyLen = value;
213 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
214 memcpy(pNewNode->certificate, pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
216 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
217 memcpy(pNewNode->privatekey, pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
219 pNewNode->pNext = null;
221 pCurrentNode->pNext = pNewNode;
223 pCurrentNode = pNewNode;
228 static void Log(const param_type& p, std::string* l)
235 struct ParamTraits< Tizen::Security::Cert::_CertInfo >
237 typedef Tizen::Security::Cert::_CertInfo param_type;
239 static void Write(Message* pMesg, const param_type& params)
241 pMesg->WriteInt(params.certId);
242 pMesg->WriteInt(params.certFormat);
243 pMesg->WriteInt(params.certType);
244 pMesg->WriteInt(params.certLength);
245 pMesg->WriteInt(params.privateKeyLen);
246 pMesg->WriteBytes(static_cast< const void* >(params.certificate), Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
247 pMesg->WriteBytes(static_cast< const void* >(params.privatekey), Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
251 static bool Read(const Message* pMesg, void** ppIter, param_type* pParam)
253 const char* pBuffer = null;
256 pMesg->ReadInt(ppIter, &value);
257 pParam->certId = value;
259 pMesg->ReadInt(ppIter, &value);
260 pParam->certFormat = static_cast< Tizen::Security::Cert::_CertFormat >(value);
262 pMesg->ReadInt(ppIter, &value);
263 pParam->certType = static_cast< Tizen::Security::Cert::_CaCertType >(value);
265 pMesg->ReadInt(ppIter, &value);
266 pParam->certLength = value;
268 pMesg->ReadInt(ppIter, &value);
269 pParam->privateKeyLen = value;
271 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
272 memcpy(pParam->certificate, pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
274 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
275 memcpy(pParam->privatekey, pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
279 static void Log(const param_type& p, std::string* l)
286 #endif // _FSEC_CERT_INTERNAL_CERT_MANAGER_MESSAGES_H_
288 IPC_SYNC_MESSAGE_CONTROL0_1(CertService_GetName, result);
289 IPC_SYNC_MESSAGE_CONTROL1_1(CertService_CloseCertificateStore, int, result);
290 IPC_SYNC_MESSAGE_CONTROL1_3(CertService_OpenCertificateStoreByType, int, int, int, result);
291 IPC_SYNC_MESSAGE_CONTROL1_2(CertService_GetCertificateCount, int, int, result);
292 IPC_SYNC_MESSAGE_CONTROL2_2(CertService_GetNextCertificate, int, int, Tizen::Io::_IpcBuffer, result);
293 IPC_SYNC_MESSAGE_CONTROL3_1(CertService_InsertRootCa, int, Tizen::Io::_IpcBuffer, int, result);
294 IPC_SYNC_MESSAGE_CONTROL3_1(CertService_UpdateRootCa, int, Tizen::Io::_IpcBuffer, Tizen::Io::_IpcBuffer, result);
295 IPC_SYNC_MESSAGE_CONTROL3_1(CertService_RemoveRootCa, int, Tizen::Io::_IpcBuffer, int, result);
296 IPC_SYNC_MESSAGE_CONTROL1_1(CertService_UninstallUserRootCertificateByCertId, int, result);
297 IPC_SYNC_MESSAGE_CONTROL4_1(CertService_InsertCaCertificate, int, int, Tizen::Io::_IpcBuffer, long, result);
298 IPC_SYNC_MESSAGE_CONTROL3_1(CertService_InsertUserCaCertificate, int, Tizen::Io::_IpcBuffer, int, result);
299 IPC_SYNC_MESSAGE_CONTROL1_1(CertService_InstallUserRootCertificate, Tizen::Io::_IpcBuffer, result);
300 IPC_SYNC_MESSAGE_CONTROL4_1(CertService_InsertUserCertChainPrivateKey, Tizen::Io::_IpcBuffer, int, Tizen::Io::_IpcBuffer, int, result);
301 IPC_SYNC_MESSAGE_CONTROL2_1(CertService_InsertCertificateChainWithPrivateKey, Tizen::Io::_IpcBuffer, int, result);
302 IPC_SYNC_MESSAGE_CONTROL2_1(CertService_InstallPkcs12Content, Tizen::Io::_IpcBuffer, Tizen::Io::_IpcBuffer, result);
303 IPC_SYNC_MESSAGE_CONTROL1_1(CertService_DeleteUserCertChainByCertId, int, result);
304 IPC_SYNC_MESSAGE_CONTROL4_2(CertService_GetUserCertChainByIssuerAndSubjectNameN, Tizen::Io::_IpcBuffer, int, Tizen::Io::_IpcBuffer, int, Tizen::Security::Cert::_CertificateListInfo, result);
305 IPC_SYNC_MESSAGE_CONTROL2_2(CertService_GetUserCertificateByCertIdN, int, int, Tizen::Security::Cert::_CertInfo, result);
306 IPC_SYNC_MESSAGE_CONTROL1_2(CertService_GetUserCertFieldInfoByCertId, int, Tizen::Security::Cert::_CertFieldInfos, result);