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_CertServiceProxy.cpp
19 * @brief This is the implementation file for the _CertServiceProxy class.
22 #include <unique_ptr.h>
27 #include <FBaseSysLog.h>
28 #include <FIo_IpcClient.h>
29 #include "FSecCert_CertMgrMessages.h"
30 #include "FSecCert_CertServiceProxy.h"
31 #include "FSecCert_CertService.h"
35 using namespace Tizen::Io;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Base::Runtime;
40 namespace Tizen { namespace Security { namespace Cert
43 _IpcClient* _CertServiceProxy::__pIpcClient = null;
44 _CertServiceProxy* _CertServiceProxy::__pCertServiceProxy = null;
46 _CertServiceProxy::_CertServiceProxy(void)
51 _CertServiceProxy::~_CertServiceProxy(void)
57 _CertServiceProxy::GetInstance(void)
60 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
61 if (__pCertServiceProxy == null)
63 pthread_once(&once_block, Construct);
66 return __pCertServiceProxy;
71 _CertServiceProxy::Construct(void)
73 static _CertServiceProxy certServiceProxy;
74 static _IpcClient ipcClient;
76 result r = ipcClient.Construct(L"osp.security.ipcserver.certmanager", null);
77 SysTryReturnVoidResult(NID_SEC_CERT, !IsFailed(r), r, "[%s] Failed to construct IPC client(Cert-Mgr)", GetErrorMessage(r));
79 __pIpcClient = &ipcClient;
80 __pCertServiceProxy = &certServiceProxy;
85 _CertServiceProxy::GetName()
88 result ret = E_SUCCESS;
92 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
94 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetName(&ret));
95 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
97 r = __pIpcClient->SendRequest(pMessage.get());
98 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
99 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
106 _CertServiceProxy::CloseCertificateStore(int certType)
108 result r = E_SUCCESS;
109 result ret = E_SUCCESS;
113 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
114 SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
115 SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
117 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_CloseCertificateStore(certType, &ret));
118 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
120 r = __pIpcClient->SendRequest(pMessage.get());
121 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
122 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
128 _CertServiceProxy::OpenCertificateStoreByType(int type, int& count)
130 result r = E_SUCCESS;
131 result ret = E_SUCCESS;
135 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
136 SysTryReturnResult(NID_SEC_CERT, type > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
137 SysTryReturnResult(NID_SEC_CERT, type < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
139 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_OpenCertificateStoreByType(type, &count, &ret));
140 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
142 r = __pIpcClient->SendRequest(pMessage.get());
143 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
144 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
150 _CertServiceProxy::GetCertificateCount(int certType, int& totalCertCount)
152 result r = E_SUCCESS;
153 result ret = E_SUCCESS;
157 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
158 SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
159 SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
161 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetCertificateCount(certType, &totalCertCount, &ret));
162 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
164 r = __pIpcClient->SendRequest(pMessage.get());
165 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
166 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
172 _CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer, int& bufferLen)
174 result r = E_SUCCESS;
175 result ret = E_SUCCESS;
177 Tizen::Io::_IpcBuffer certBufferIpc;
181 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
182 SysTryReturnResult(NID_SEC_CERT, pBuffer != null, E_INVALID_ARG, "Invalid parameter.");
183 SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
184 SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
186 certBufferIpc.pBuffer = null;
187 certBufferIpc.size = 0;
189 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetNextCertificate(certType, curPos, bufferLen, &certBufferIpc, &curPos, &ret));
190 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
192 r = __pIpcClient->SendRequest(pMessage.get());
193 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
194 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
196 memcpy(pBuffer, certBufferIpc.pBuffer, certBufferIpc.size);
197 bufferLen = certBufferIpc.size;
203 _CertServiceProxy::UpdateCaCertificate(int type, byte* pOldCert, int oldCertLen, byte* pNewCert, int newCertLen)
205 result r = E_SUCCESS;
206 result ret = E_SUCCESS;
208 Tizen::Io::_IpcBuffer oldBufferIpc = {0, };
209 Tizen::Io::_IpcBuffer newBufferIpc = {0, };
213 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
214 SysTryReturnResult(NID_SEC_CERT, ((pOldCert != null) && (oldCertLen > 0)), E_INVALID_ARG, "Invalid input old certificate parameter.");
215 SysTryReturnResult(NID_SEC_CERT, ((pNewCert != null) && (newCertLen > 0)), E_INVALID_ARG, "Invalid input new certificate parameter.");
216 SysTryReturnResult(NID_SEC_CERT, type > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
217 SysTryReturnResult(NID_SEC_CERT, type < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
219 oldBufferIpc.pBuffer = pOldCert;
220 oldBufferIpc.size = oldCertLen;
222 newBufferIpc.pBuffer = pNewCert;
223 newBufferIpc.size = newCertLen;
225 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_UpdateRootCa(type, oldBufferIpc, newBufferIpc, &ret));
226 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
228 r = __pIpcClient->SendRequest(pMessage.get());
229 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
230 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
236 _CertServiceProxy::RemoveCaCertificate(int type, byte* pBuffer, int bufLen)
238 result r = E_SUCCESS;
239 result ret = E_SUCCESS;
240 Tizen::Io::_IpcBuffer certBufferIpc;
244 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
245 SysTryReturnResult(NID_SEC_CERT, ((pBuffer != null) && (bufLen > 0)), E_INVALID_ARG, "Invalid input parameters.");
247 certBufferIpc.pBuffer = pBuffer;
248 certBufferIpc.size = bufLen;
250 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_RemoveRootCa(type, certBufferIpc, bufLen, &ret));
251 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
253 r = __pIpcClient->SendRequest(pMessage.get());
254 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
255 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
261 _CertServiceProxy::RemoveUserCaCertificateByCertId(int certId)
263 result r = E_SUCCESS;
264 result ret = E_SUCCESS;
268 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
269 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
271 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_UninstallUserRootCertificateByCertId(certId, &ret));
272 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
274 r = __pIpcClient->SendRequest(pMessage.get());
275 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
276 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
282 _CertServiceProxy::InsertCaCertificate(int type, int format, byte* pCert, long certLen)
284 result r = E_SUCCESS;
285 result ret = E_SUCCESS;
286 Tizen::Io::_IpcBuffer certBufferIpc;
290 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
291 SysTryReturnResult(NID_SEC_CERT, ((pCert != null) && (certLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
293 certBufferIpc.pBuffer = pCert;
294 certBufferIpc.size = certLen;
296 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertCaCertificate(type, format, certBufferIpc, certLen, &ret));
297 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
299 r = __pIpcClient->SendRequest(pMessage.get());
300 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
301 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
307 _CertServiceProxy::InsertUserCaCertificate(int format, char* pCert, int certLen)
309 result r = E_SUCCESS;
310 result ret = E_SUCCESS;
311 Tizen::Io::_IpcBuffer certBufferIpc;
315 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
316 SysTryReturnResult(NID_SEC_CERT, ((pCert != null) && (certLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
318 certBufferIpc.pBuffer = pCert;
319 certBufferIpc.size = certLen;
321 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertUserCaCertificate(format, certBufferIpc, certLen, &ret));
322 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
324 r = __pIpcClient->SendRequest(pMessage.get());
325 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
326 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
332 _CertServiceProxy::InsertUserCaCertificate(byte* pFilePath)
334 result r = E_SUCCESS;
335 result ret = E_SUCCESS;
336 Tizen::Io::_IpcBuffer certBufferIpc;
338 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
339 SysTryReturnResult(NID_SEC_CERT, pFilePath != null, E_INVALID_ARG, "Invalid input parameter.");
341 certBufferIpc.pBuffer = pFilePath;
342 certBufferIpc.size = strlen(reinterpret_cast< char* >(pFilePath)) + 1;
344 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InstallUserRootCertificate(certBufferIpc, &ret));
345 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
347 r = __pIpcClient->SendRequest(pMessage.get());
348 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
349 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
355 //User Certificate APIs
358 _CertServiceProxy::InsertUserCertChainPrivateKey(char* pCertchainBuffer, int certChainLen, char* pUserPrivateKey, int userPrivateKeyLen)
360 result r = E_SUCCESS;
361 result ret = E_SUCCESS;
362 Tizen::Io::_IpcBuffer certPackBufferIPC;
363 Tizen::Io::_IpcBuffer privateKeyBufferIpc;
365 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
366 SysTryReturnResult(NID_SEC_CERT, ((pCertchainBuffer != null) && (certChainLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
368 certPackBufferIPC.pBuffer = pCertchainBuffer;
369 certPackBufferIPC.size = certChainLen;
371 privateKeyBufferIpc.pBuffer = pUserPrivateKey;
372 privateKeyBufferIpc.size = userPrivateKeyLen;
374 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertUserCertChainPrivateKey(certPackBufferIPC, certChainLen, privateKeyBufferIpc, userPrivateKeyLen, &ret));
375 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
377 r = __pIpcClient->SendRequest(pMessage.get());
378 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
379 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
385 _CertServiceProxy::InsertCertificateChainWithPrivateKey(char* pCertchainPrivateKeyBuffer, int certChainPrivateKeyLength)
387 result r = E_SUCCESS;
388 result ret = E_SUCCESS;
389 Tizen::Io::_IpcBuffer certChainPriKeyBufferIpc;
391 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
392 SysTryReturnResult(NID_SEC_CERT, ((pCertchainPrivateKeyBuffer != null) && (certChainPrivateKeyLength > 0)), E_INVALID_ARG, "Invalid input parameter.");
394 certChainPriKeyBufferIpc.pBuffer = pCertchainPrivateKeyBuffer;
395 certChainPriKeyBufferIpc.size = certChainPrivateKeyLength;
397 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertCertificateChainWithPrivateKey(certChainPriKeyBufferIpc, certChainPrivateKeyLength, &ret));
398 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
400 r = __pIpcClient->SendRequest(pMessage.get());
401 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
402 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
408 _CertServiceProxy::InsertPkcs12Content(char* pPkcs12FilePath, char* pPkcs12ImportPassword, bool checkPrivilege)
410 result r = E_SUCCESS;
411 result ret = E_SUCCESS;
412 Tizen::Io::_IpcBuffer pkcs12FileBufferIpc;
413 Tizen::Io::_IpcBuffer pkcs12PasswdBufferIpc;
415 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
416 SysTryReturnResult(NID_SEC_CERT, pPkcs12FilePath != null, E_INVALID_ARG, "Invalid input parameter.");
418 pkcs12FileBufferIpc.pBuffer = pPkcs12FilePath;
419 pkcs12FileBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12FilePath)) + 1;
421 pkcs12PasswdBufferIpc.pBuffer = pPkcs12ImportPassword;
422 pkcs12PasswdBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12ImportPassword)) + 1;
424 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InstallPkcs12Content(pkcs12FileBufferIpc, pkcs12PasswdBufferIpc, checkPrivilege, &ret));
425 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
427 r = __pIpcClient->SendRequest(pMessage.get());
428 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
429 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
435 _CertServiceProxy::RemoveUserCertChainByCertId(int certId)
437 result r = E_SUCCESS;
438 result ret = E_SUCCESS;
442 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "Instance is not constructed.");
443 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
445 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_DeleteUserCertChainByCertId(certId, &ret));
446 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
448 r = __pIpcClient->SendRequest(pMessage.get());
449 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
450 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
456 _CertServiceProxy::GetUserCertChainByIssuerAndSubjectNameN(char* pIssuerName, int issuerNameLen, char* pSubjectName, int subNameLen, _CertificateListInfo*& pUserCertListInfoTypesRef)
458 result r = E_SUCCESS;
459 result ret = E_SUCCESS;
460 _CertificateListInfo* pRetNode = null;
461 Tizen::Io::_IpcBuffer issuerBufferIpc;
462 Tizen::Io::_IpcBuffer subjectBufferIpc;
464 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPCInstance is not constructed.");
465 SysTryReturnResult(NID_SEC_CERT, pIssuerName != null, E_INVALID_ARG, "Invalid Parameters");
466 SysTryReturnResult(NID_SEC_CERT, pSubjectName != null, E_INVALID_ARG, "Invalid Parameters");
468 issuerBufferIpc.pBuffer = pIssuerName;
469 issuerBufferIpc.size = issuerNameLen;
471 subjectBufferIpc.pBuffer = pSubjectName;
472 subjectBufferIpc.size = subNameLen;
474 pRetNode = new (std::nothrow) _CertificateListInfo();
475 SysTryReturnResult(NID_SEC_CERT, pRetNode != null, E_OUT_OF_MEMORY, "Unable to allocate");
477 memset(pRetNode, 0, sizeof(*pRetNode));
479 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertChainByIssuerAndSubjectNameN(issuerBufferIpc, issuerNameLen, subjectBufferIpc, subNameLen, pRetNode, &ret));
480 SysTryReturn(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
482 r = __pIpcClient->SendRequest(pMessage.get());
483 SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to send message.", GetErrorMessage(r));
484 SysTryCatch(NID_SEC_CERT, !IsFailed(ret), r = ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
486 pUserCertListInfoTypesRef = pRetNode;
491 _CertService::FreeCertList(pRetNode);
500 _CertServiceProxy::GetUserCertificateByCertIdN(int certId, int encodingType)
502 result r = E_SUCCESS;
503 result ret = E_SUCCESS;
505 _CertInfo* pRetNode = null;
507 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, null, "IPC instance is not constructed.");
509 pRetNode = new (std::nothrow) _CertInfo();
510 SysTryReturnResult(NID_SEC_CERT, pRetNode != null, null, "Unable to allocate");
512 memset(pRetNode, 0, sizeof(*pRetNode));
514 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertificateByCertIdN(certId, encodingType, pRetNode, &ret));
515 SysTryCatch(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
517 r = __pIpcClient->SendRequest(pMessage.get());
518 SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to send message.", GetErrorMessage(r));
519 SysTryCatch(NID_SEC_CERT, !IsFailed(ret), r = ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
524 _CertService::FreeCertificateInfo(pRetNode);
532 _CertServiceProxy::GetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCertFieldInfos)
534 result r = E_SUCCESS;
535 result ret = E_SUCCESS;
539 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
540 SysTryReturnResult(NID_SEC_CERT, pCertFieldInfos != null, E_INVALID_ARG, "Invalid input parameter.");
542 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertFieldInfoByCertId(certId, pCertFieldInfos, &ret));
543 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
545 r = __pIpcClient->SendRequest(pMessage.get());
546 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
547 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
553 _CertServiceProxy::RestoreRootCaIntegrity(void)
555 result r = E_SUCCESS;
559 SysTryReturnVoidResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "[%s] IPC instance is not constructed.", GetErrorMessage(E_SYSTEM));
561 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_RestoreRootCaIntegrity());
562 SysTryReturnVoidResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "[%s] Failed to allocate memory.", GetErrorMessage(E_OUT_OF_MEMORY));
564 r = __pIpcClient->SendRequest(pMessage.get());
565 SysTryReturnVoidResult(NID_SEC_CERT, !IsFailed(r), r, "[%s] Failed to send message.", GetErrorMessage(r));