2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FSecCert_CertMgrMessages.h
19 * @brief This is the header file for the CertMgr IPC message types.
21 * This is the header file for the CertMgr IPC message types.
24 #include <ipc/ipc_message_macros.h>
25 #include <FIo_IpcCommonParamTraits.h>
26 #include <FIo_IpcMessageStart.h>
27 #include "FSecCert_CertTypes.h"
29 #define IPC_MESSAGE_START CertMgrServiceStart
31 #ifndef _FSEC_CERT_INTERNAL_CERT_MANAGER_MESSAGES_H_
32 #define _FSEC_CERT_INTERNAL_CERT_MANAGER_MESSAGES_H_
37 struct ParamTraits< Tizen::Security::Cert::_CertFieldInfos >
39 typedef Tizen::Security::Cert::_CertFieldInfos param_type;
40 static void Write(Message* pMesg, const param_type& params)
42 pMesg->WriteInt(params.certType);
43 pMesg->WriteInt(params.certFileId);
44 pMesg->WriteBytes(static_cast< const void* >(params.serialNo), Tizen::Security::Cert::_MAX_SERIAL_NUMBER_SIZE + 1);
45 pMesg->WriteBytes(static_cast< const void* >(params.sigAlgorithm), Tizen::Security::Cert::_MAX_CERT_ALGORITHM_SIZE + 1);
46 pMesg->WriteBytes(static_cast< const void* >(params.validityFrom), Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
47 pMesg->WriteBytes(static_cast< const void* >(params.validityTo), Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
48 pMesg->WriteBytes(static_cast< const void* >(params.subjectName), Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
49 pMesg->WriteBytes(static_cast< const void* >(params.issuerName), Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
50 pMesg->WriteBytes(static_cast< const void* >(params.fingerPrint), Tizen::Security::Cert::_MAX_CERT_FINGERPRINT_SIZE + 1);
51 pMesg->WriteInt(params.fingerPrintLen);
52 pMesg->WriteBytes(static_cast< const void* >(params.publicKey), Tizen::Security::Cert::_MAX_CERT_PUBLIC_KEY_SIZE + 1);
53 pMesg->WriteBytes(static_cast< const void* >(params.certTypeFormat), Tizen::Security::Cert::_MAX_CERT_TYPE_SIZE + 1);
54 pMesg->WriteInt(params.certVersion);
55 pMesg->WriteBytes(static_cast< const void* >(params.certTitle), Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
56 pMesg->WriteBytes(static_cast< const void* >(params.certSubTitle), Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
59 static bool Read(const Message* pMesg, void** ppIter, param_type* pParam)
61 const char* pBuffer = null;
64 pMesg->ReadInt(ppIter, &value);
65 pParam->certType = static_cast< Tizen::Security::Cert::_CaCertType >(value);
67 pMesg->ReadInt(ppIter, &value);
68 pParam->certFileId = value;
70 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_SERIAL_NUMBER_SIZE + 1);
71 memcpy(pParam->serialNo, pBuffer, Tizen::Security::Cert::_MAX_SERIAL_NUMBER_SIZE + 1);
73 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_ALGORITHM_SIZE + 1);
74 memcpy(pParam->sigAlgorithm, pBuffer, Tizen::Security::Cert::_MAX_CERT_ALGORITHM_SIZE + 1);
76 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
77 memcpy(pParam->validityFrom, pBuffer, Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
79 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
80 memcpy(pParam->validityTo, pBuffer, Tizen::Security::Cert::_MAX_CERT_VALIDITY_SIZE + 1);
82 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
83 memcpy(pParam->subjectName, pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
85 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
86 memcpy(pParam->issuerName, pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
88 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_FINGERPRINT_SIZE + 1);
89 memcpy(pParam->fingerPrint, pBuffer, Tizen::Security::Cert::_MAX_CERT_FINGERPRINT_SIZE + 1);
91 pMesg->ReadInt(ppIter, &value);
92 pParam->fingerPrintLen = value;
94 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_PUBLIC_KEY_SIZE + 1);
95 memcpy(pParam->publicKey, pBuffer, Tizen::Security::Cert::_MAX_CERT_PUBLIC_KEY_SIZE + 1);
97 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_TYPE_SIZE + 1);
98 memcpy(pParam->certTypeFormat, pBuffer, Tizen::Security::Cert::_MAX_CERT_TYPE_SIZE + 1);
100 pMesg->ReadInt(ppIter, &value);
101 pParam->certVersion = value;
103 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
104 memcpy(pParam->certTitle, pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
106 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
107 memcpy(pParam->certSubTitle, pBuffer, Tizen::Security::Cert::_MAX_ISSUER_SUBJECT_NAME_SIZE + 1);
111 static void Log(const param_type& p, std::string* l)
118 struct ParamTraits< Tizen::Security::Cert::_CertificateListInfo >
120 typedef Tizen::Security::Cert::_CertificateListInfo param_type;
121 static void Write(Message* pMesg, const param_type& params)
126 param_type* pTemp = const_cast< param_type* >(¶ms);
130 pTemp = pTemp->pNext;
134 pMesg->WriteInt(count);
136 pTemp = const_cast< param_type* >(¶ms);
137 for (index = 0; index < count; index++)
139 pMesg->WriteInt(pTemp->certFileId);
140 pMesg->WriteInt(pTemp->format);
141 pMesg->WriteInt(pTemp->certType);
142 pMesg->WriteInt(pTemp->length);
143 pMesg->WriteInt(pTemp->priKeyLen);
144 pMesg->WriteBytes(static_cast< const void* >(pTemp->certificate), Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
145 pMesg->WriteBytes(static_cast< const void* >(pTemp->privatekey), Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
147 pTemp = pTemp->pNext;
153 static bool Read(const Message* pMesg, void** ppIter, param_type* pParam)
155 const char* pBuffer = null;
159 param_type* pCurrentNode = pParam;
160 param_type* pNewNode = null;
162 pMesg->ReadInt(ppIter, &count);
169 pMesg->ReadInt(ppIter, &value);
170 pCurrentNode->certFileId = value;
172 pMesg->ReadInt(ppIter, &value);
173 pCurrentNode->format = static_cast< Tizen::Security::Cert::_CertFormat >(value);
175 pMesg->ReadInt(ppIter, &value);
176 pCurrentNode->certType = static_cast< Tizen::Security::Cert::_CaCertType >(value);
178 pMesg->ReadInt(ppIter, &value);
179 pCurrentNode->length = value;
181 pMesg->ReadInt(ppIter, &value);
182 pCurrentNode->priKeyLen = value;
184 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
185 memcpy(pCurrentNode->certificate, pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
187 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
188 memcpy(pCurrentNode->privatekey, pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
190 pCurrentNode->pNext = null;
192 for (index = 1; index < count; index++)
194 pNewNode = new (std::nothrow) param_type();
195 SysTryReturn(NID_SEC_CERT, pNewNode != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] failed to allocate memory");
197 pMesg->ReadInt(ppIter, &value);
198 pNewNode->certFileId = value;
200 pMesg->ReadInt(ppIter, &value);
201 pNewNode->format = static_cast< Tizen::Security::Cert::_CertFormat >(value);
203 pMesg->ReadInt(ppIter, &value);
204 pNewNode->certType = static_cast< Tizen::Security::Cert::_CaCertType >(value);
206 pMesg->ReadInt(ppIter, &value);
207 pNewNode->length = value;
209 pMesg->ReadInt(ppIter, &value);
210 pNewNode->priKeyLen = value;
212 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
213 memcpy(pNewNode->certificate, pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
215 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
216 memcpy(pNewNode->privatekey, pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
218 pNewNode->pNext = null;
220 pCurrentNode->pNext = pNewNode;
222 pCurrentNode = pNewNode;
227 static void Log(const param_type& p, std::string* l)
234 struct ParamTraits< Tizen::Security::Cert::_CertInfo >
236 typedef Tizen::Security::Cert::_CertInfo param_type;
238 static void Write(Message* pMesg, const param_type& params)
240 pMesg->WriteInt(params.certId);
241 pMesg->WriteInt(params.certFormat);
242 pMesg->WriteInt(params.certType);
243 pMesg->WriteInt(params.certLength);
244 pMesg->WriteInt(params.privateKeyLen);
245 pMesg->WriteBytes(static_cast< const void* >(params.certificate), Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
246 pMesg->WriteBytes(static_cast< const void* >(params.privatekey), Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
250 static bool Read(const Message* pMesg, void** ppIter, param_type* pParam)
252 const char* pBuffer = null;
255 pMesg->ReadInt(ppIter, &value);
256 pParam->certId = value;
258 pMesg->ReadInt(ppIter, &value);
259 pParam->certFormat = static_cast< Tizen::Security::Cert::_CertFormat >(value);
261 pMesg->ReadInt(ppIter, &value);
262 pParam->certType = static_cast< Tizen::Security::Cert::_CaCertType >(value);
264 pMesg->ReadInt(ppIter, &value);
265 pParam->certLength = value;
267 pMesg->ReadInt(ppIter, &value);
268 pParam->privateKeyLen = value;
270 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
271 memcpy(pParam->certificate, pBuffer, Tizen::Security::Cert::_MAX_CERTIFICATE_SIZE);
273 pMesg->ReadBytes(ppIter, &pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
274 memcpy(pParam->privatekey, pBuffer, Tizen::Security::Cert::_MAX_CERT_PRIVATE_KEY_SIZE);
278 static void Log(const param_type& p, std::string* l)
285 #endif // _FSEC_CERT_INTERNAL_CERT_MANAGER_MESSAGES_H_
287 IPC_SYNC_MESSAGE_CONTROL0_1(CertServer_GetName, result);
288 IPC_SYNC_MESSAGE_CONTROL1_1(CertServer_CloseCertificateStore, int, result);
289 IPC_SYNC_MESSAGE_CONTROL1_2(CertServer_OpenCertificateStoreByType, int, int, result);
290 IPC_SYNC_MESSAGE_CONTROL1_2(CertServer_GetCertificateCount, int, int, result);
291 IPC_SYNC_MESSAGE_CONTROL3_3(CertServer_GetNextCertificate, int, int, int, Tizen::Base::ByteBuffer, int , result);
292 IPC_SYNC_MESSAGE_CONTROL3_1(CertServer_InsertRootCa, int, Tizen::Io::_IpcBuffer, int, result);
293 IPC_SYNC_MESSAGE_CONTROL3_1(CertServer_UpdateRootCa, int, Tizen::Io::_IpcBuffer, Tizen::Io::_IpcBuffer, result);
294 IPC_SYNC_MESSAGE_CONTROL3_1(CertServer_RemoveRootCa, int, Tizen::Io::_IpcBuffer, int, result);
295 IPC_SYNC_MESSAGE_CONTROL1_1(CertServer_UninstallUserRootCertificateByCertId, int, result);
296 IPC_SYNC_MESSAGE_CONTROL4_1(CertServer_InsertCaCertificate, int, int, Tizen::Io::_IpcBuffer, long, result);
297 IPC_SYNC_MESSAGE_CONTROL3_1(CertServer_InsertUserCaCertificate, int, Tizen::Io::_IpcBuffer, int, result);
298 IPC_SYNC_MESSAGE_CONTROL1_1(CertServer_InstallUserRootCertificate, Tizen::Io::_IpcBuffer, result);
299 IPC_SYNC_MESSAGE_CONTROL4_1(CertServer_InsertUserCertChainPrivateKey, Tizen::Io::_IpcBuffer, int, Tizen::Io::_IpcBuffer, int, result);
300 IPC_SYNC_MESSAGE_CONTROL2_1(CertServer_InsertCertificateChainWithPrivateKey, Tizen::Io::_IpcBuffer, int, result);
301 IPC_SYNC_MESSAGE_CONTROL3_1(CertServer_InstallPkcs12Content, Tizen::Io::_IpcBuffer, Tizen::Io::_IpcBuffer, bool, result);
302 IPC_SYNC_MESSAGE_CONTROL1_1(CertServer_DeleteUserCertChainByCertId, int, result);
303 IPC_SYNC_MESSAGE_CONTROL4_2(CertServer_GetUserCertChainByIssuerAndSubjectNameN, Tizen::Io::_IpcBuffer, int, Tizen::Io::_IpcBuffer, int, Tizen::Security::Cert::_CertificateListInfo, result);
304 IPC_SYNC_MESSAGE_CONTROL2_2(CertServer_GetUserCertificateByCertIdN, int, int, Tizen::Security::Cert::_CertInfo, result);
305 IPC_SYNC_MESSAGE_CONTROL1_2(CertServer_GetUserCertFieldInfoByCertId, int, Tizen::Security::Cert::_CertFieldInfos, result);
306 IPC_SYNC_MESSAGE_CONTROL0_0(CertServer_RestoreRootCaIntegrity);