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_CertServiceProxy.cpp
20 * @brief This is the implementation file for the _CertServiceProxy class.
23 #include <unique_ptr.h>
28 #include <FBaseSysLog.h>
29 #include <FIo_IpcClient.h>
30 #include "FSecCert_CertMgrMessages.h"
31 #include "FSecCert_CertServiceProxy.h"
32 #include "FSecCert_CertService.h"
36 using namespace Tizen::Io;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Base::Runtime;
41 namespace Tizen { namespace Security { namespace Cert
44 _IpcClient* _CertServiceProxy::__pIpcClient = null;
45 _CertServiceProxy* _CertServiceProxy::__pCertServiceProxy = null;
47 _CertServiceProxy::_CertServiceProxy(void)
52 _CertServiceProxy::~_CertServiceProxy(void)
58 _CertServiceProxy::GetInstance(void)
61 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
62 if (__pCertServiceProxy == null)
64 pthread_once(&once_block, Construct);
67 return __pCertServiceProxy;
72 _CertServiceProxy::Construct(void)
74 static _CertServiceProxy certServiceProxy;
75 static _IpcClient ipcClient;
77 result r = ipcClient.Construct(L"osp.security.ipcserver.certmanager", null);
78 SysTryReturnVoidResult(NID_SEC_CERT, !IsFailed(r), r, "[%s] Failed to construct IPC client(Cert-Mgr)", GetErrorMessage(r));
80 __pIpcClient = &ipcClient;
81 __pCertServiceProxy = &certServiceProxy;
86 _CertServiceProxy::GetName()
89 result ret = E_SUCCESS;
93 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
95 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetName(&ret));
96 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
98 r = __pIpcClient->SendRequest(pMessage.get());
99 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
100 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
107 _CertServiceProxy::CloseCertificateStore(int certificateStoreCtx)
109 result r = E_SUCCESS;
110 result ret = E_SUCCESS;
114 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
116 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_CloseCertificateStore(certificateStoreCtx, &ret));
117 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
119 r = __pIpcClient->SendRequest(pMessage.get());
120 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
121 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
127 _CertServiceProxy::OpenCertificateStoreByType(int type, int& count, int& certificateStoreCtx)
129 result r = E_SUCCESS;
130 result ret = E_SUCCESS;
134 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
136 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_OpenCertificateStoreByType(type, &count, &certificateStoreCtx, &ret));
137 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
139 r = __pIpcClient->SendRequest(pMessage.get());
140 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
141 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
147 _CertServiceProxy::GetCertificateCount(int certificateStoreCtx, int& totalCertCount)
149 result r = E_SUCCESS;
150 result ret = E_SUCCESS;
154 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
156 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetCertificateCount(certificateStoreCtx, &totalCertCount, &ret));
157 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
159 r = __pIpcClient->SendRequest(pMessage.get());
160 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
161 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
167 _CertServiceProxy::GetNextCertificate(int certificateStoreCtx, byte* pBuffer, int& bufferLen)
169 result r = E_SUCCESS;
170 result ret = E_SUCCESS;
172 Tizen::Io::_IpcBuffer certBufferIpc;
176 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
177 SysTryReturnResult(NID_SEC_CERT, pBuffer != null, E_INVALID_ARG, "Invalid parameter.");
179 certBufferIpc.pBuffer = null;
180 certBufferIpc.size = 0;
182 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetNextCertificate(certificateStoreCtx, bufferLen, &certBufferIpc, &ret));
183 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
185 r = __pIpcClient->SendRequest(pMessage.get());
186 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
187 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
189 memcpy(pBuffer, certBufferIpc.pBuffer, certBufferIpc.size);
190 bufferLen = certBufferIpc.size;
196 _CertServiceProxy::UpdateCaCertificate(int type, byte* pOldCert, int oldCertLen, byte* pNewCert, int newCertLen)
198 result r = E_SUCCESS;
199 result ret = E_SUCCESS;
201 Tizen::Io::_IpcBuffer oldBufferIpc = {0, };
202 Tizen::Io::_IpcBuffer newBufferIpc = {0, };
206 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
207 SysTryReturnResult(NID_SEC_CERT, ((pOldCert != null) && (oldCertLen > 0)), E_INVALID_ARG, "Invalid input old certificate parameter.");
208 SysTryReturnResult(NID_SEC_CERT, ((pNewCert != null) && (newCertLen > 0)), E_INVALID_ARG, "Invalid input new certificate parameter.");
210 oldBufferIpc.pBuffer = pOldCert;
211 oldBufferIpc.size = oldCertLen;
213 newBufferIpc.pBuffer = pNewCert;
214 newBufferIpc.size = newCertLen;
216 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_UpdateRootCa(type, oldBufferIpc, newBufferIpc, &ret));
217 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
219 r = __pIpcClient->SendRequest(pMessage.get());
220 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
221 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
227 _CertServiceProxy::RemoveCaCertificate(int type, byte* pBuffer, int bufLen)
229 result r = E_SUCCESS;
230 result ret = E_SUCCESS;
231 Tizen::Io::_IpcBuffer certBufferIpc;
235 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
236 SysTryReturnResult(NID_SEC_CERT, ((pBuffer != null) && (bufLen > 0)), E_INVALID_ARG, "Invalid input parameters.");
238 certBufferIpc.pBuffer = pBuffer;
239 certBufferIpc.size = bufLen;
241 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_RemoveRootCa(type, certBufferIpc, bufLen, &ret));
242 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
244 r = __pIpcClient->SendRequest(pMessage.get());
245 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
246 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
252 _CertServiceProxy::RemoveUserCaCertificateByCertId(int certId)
254 result r = E_SUCCESS;
255 result ret = E_SUCCESS;
259 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
260 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
262 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_UninstallUserRootCertificateByCertId(certId, &ret));
263 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
265 r = __pIpcClient->SendRequest(pMessage.get());
266 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
267 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
273 _CertServiceProxy::InsertCaCertificate(int type, int format, byte* pCert, long certLen)
275 result r = E_SUCCESS;
276 result ret = E_SUCCESS;
277 Tizen::Io::_IpcBuffer certBufferIpc;
281 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
282 SysTryReturnResult(NID_SEC_CERT, ((pCert != null) && (certLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
284 certBufferIpc.pBuffer = pCert;
285 certBufferIpc.size = certLen;
287 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InsertCaCertificate(type, format, certBufferIpc, certLen, &ret));
288 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
290 r = __pIpcClient->SendRequest(pMessage.get());
291 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
292 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
298 _CertServiceProxy::InsertUserCaCertificate(int format, char* pCert, int certLen)
300 result r = E_SUCCESS;
301 result ret = E_SUCCESS;
302 Tizen::Io::_IpcBuffer certBufferIpc;
306 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
307 SysTryReturnResult(NID_SEC_CERT, ((pCert != null) && (certLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
309 certBufferIpc.pBuffer = pCert;
310 certBufferIpc.size = certLen;
312 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InsertUserCaCertificate(format, certBufferIpc, certLen, &ret));
313 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
315 r = __pIpcClient->SendRequest(pMessage.get());
316 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
317 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
323 _CertServiceProxy::InsertUserCaCertificate(byte* pFilePath)
325 result r = E_SUCCESS;
326 result ret = E_SUCCESS;
327 Tizen::Io::_IpcBuffer certBufferIpc;
329 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
330 SysTryReturnResult(NID_SEC_CERT, pFilePath != null, E_INVALID_ARG, "Invalid input parameter.");
332 certBufferIpc.pBuffer = pFilePath;
333 certBufferIpc.size = strlen(reinterpret_cast< char* >(pFilePath)) + 1;
335 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InstallUserRootCertificate(certBufferIpc, &ret));
336 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
338 r = __pIpcClient->SendRequest(pMessage.get());
339 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
340 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
346 //User Certificate APIs
349 _CertServiceProxy::InsertUserCertChainPrivateKey(char* pCertchainBuffer, int certChainLen, char* pUserPrivateKey, int userPrivateKeyLen)
351 result r = E_SUCCESS;
352 result ret = E_SUCCESS;
353 Tizen::Io::_IpcBuffer certPackBufferIPC;
354 Tizen::Io::_IpcBuffer privateKeyBufferIpc;
356 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
357 SysTryReturnResult(NID_SEC_CERT, ((pCertchainBuffer != null) && (certChainLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
359 certPackBufferIPC.pBuffer = pCertchainBuffer;
360 certPackBufferIPC.size = certChainLen;
362 privateKeyBufferIpc.pBuffer = pUserPrivateKey;
363 privateKeyBufferIpc.size = userPrivateKeyLen;
365 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InsertUserCertChainPrivateKey(certPackBufferIPC, certChainLen, privateKeyBufferIpc, userPrivateKeyLen, &ret));
366 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
368 r = __pIpcClient->SendRequest(pMessage.get());
369 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
370 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
376 _CertServiceProxy::InsertCertificateChainWithPrivateKey(char* pCertchainPrivateKeyBuffer, int certChainPrivateKeyLength)
378 result r = E_SUCCESS;
379 result ret = E_SUCCESS;
380 Tizen::Io::_IpcBuffer certChainPriKeyBufferIpc;
382 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
383 SysTryReturnResult(NID_SEC_CERT, ((pCertchainPrivateKeyBuffer != null) && (certChainPrivateKeyLength > 0)), E_INVALID_ARG, "Invalid input parameter.");
385 certChainPriKeyBufferIpc.pBuffer = pCertchainPrivateKeyBuffer;
386 certChainPriKeyBufferIpc.size = certChainPrivateKeyLength;
388 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InsertCertificateChainWithPrivateKey(certChainPriKeyBufferIpc, certChainPrivateKeyLength, &ret));
389 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
391 r = __pIpcClient->SendRequest(pMessage.get());
392 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
393 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
399 _CertServiceProxy::InsertPkcs12Content(char* pPkcs12FilePath, char* pPkcs12ImportPassword)
401 result r = E_SUCCESS;
402 result ret = E_SUCCESS;
403 Tizen::Io::_IpcBuffer pkcs12FileBufferIpc;
404 Tizen::Io::_IpcBuffer pkcs12PasswdBufferIpc;
406 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
407 SysTryReturnResult(NID_SEC_CERT, pPkcs12FilePath != null, E_INVALID_ARG, "Invalid input parameter.");
409 pkcs12FileBufferIpc.pBuffer = pPkcs12FilePath;
410 pkcs12FileBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12FilePath)) + 1;
412 pkcs12PasswdBufferIpc.pBuffer = pPkcs12ImportPassword;
413 pkcs12PasswdBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12ImportPassword)) + 1;
415 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InstallPkcs12Content(pkcs12FileBufferIpc, pkcs12PasswdBufferIpc, &ret));
416 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
418 r = __pIpcClient->SendRequest(pMessage.get());
419 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
420 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
425 _CertServiceProxy::RemoveUserCertificateByCertId(int certId)
427 result r = E_SUCCESS;
428 result ret = E_SUCCESS;
432 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "Instance is not constructed.");
433 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
435 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_DeleteUserCertificateByCertId(certId, &ret));
436 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
438 r = __pIpcClient->SendRequest(pMessage.get());
439 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
440 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
446 _CertServiceProxy::RemoveUserCertChainByCertId(int certId)
448 result r = E_SUCCESS;
449 result ret = E_SUCCESS;
453 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "Instance is not constructed.");
454 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
456 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_DeleteUserCertChainByCertId(certId, &ret));
457 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
459 r = __pIpcClient->SendRequest(pMessage.get());
460 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
461 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
467 _CertServiceProxy::GetUserCertChainByIssuerAndSubjectNameN(char* pIssuerName, int issuerNameLen, char* pSubjectName, int subNameLen, _CertificateListInfo*& pUserCertListInfoTypesRef)
469 result r = E_SUCCESS;
470 result ret = E_SUCCESS;
471 _CertificateListInfo* pRetNode = null;
472 Tizen::Io::_IpcBuffer issuerBufferIpc;
473 Tizen::Io::_IpcBuffer subjectBufferIpc;
475 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPCInstance is not constructed.");
476 SysTryReturnResult(NID_SEC_CERT, pIssuerName != null, E_INVALID_ARG, "Invalid Parameters");
477 SysTryReturnResult(NID_SEC_CERT, pSubjectName != null, E_INVALID_ARG, "Invalid Parameters");
479 issuerBufferIpc.pBuffer = pIssuerName;
480 issuerBufferIpc.size = issuerNameLen;
482 subjectBufferIpc.pBuffer = pSubjectName;
483 subjectBufferIpc.size = subNameLen;
485 pRetNode = new (std::nothrow) _CertificateListInfo();
486 SysTryReturnResult(NID_SEC_CERT, pRetNode != null, E_OUT_OF_MEMORY, "Unable to allocate");
488 memset(pRetNode, 0, sizeof(*pRetNode));
490 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetUserCertChainByIssuerAndSubjectNameN(issuerBufferIpc, issuerNameLen, subjectBufferIpc, subNameLen, pRetNode, &ret));
491 SysTryReturn(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
493 r = __pIpcClient->SendRequest(pMessage.get());
494 SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to send message.", GetErrorMessage(r));
495 SysTryCatch(NID_SEC_CERT, !IsFailed(ret), r = ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
497 pUserCertListInfoTypesRef = pRetNode;
502 _CertService::FreeCertList(pRetNode);
511 _CertServiceProxy::GetUserCertificateByCertIdN(int certId, int encodingType)
513 result r = E_SUCCESS;
514 result ret = E_SUCCESS;
516 _CertInfo* pRetNode = null;
518 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, null, "IPC instance is not constructed.");
520 pRetNode = new (std::nothrow) _CertInfo();
521 SysTryReturnResult(NID_SEC_CERT, pRetNode != null, null, "Unable to allocate");
523 memset(pRetNode, 0, sizeof(*pRetNode));
525 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetUserCertificateByCertIdN(certId, encodingType, pRetNode, &ret));
526 SysTryCatch(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
528 r = __pIpcClient->SendRequest(pMessage.get());
529 SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to send message.", GetErrorMessage(r));
530 SysTryCatch(NID_SEC_CERT, !IsFailed(ret), r = ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
535 _CertService::FreeCertificateInfo(pRetNode);
543 _CertServiceProxy::GetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCertFieldInfos)
545 result r = E_SUCCESS;
546 result ret = E_SUCCESS;
550 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
551 SysTryReturnResult(NID_SEC_CERT, pCertFieldInfos != null, E_INVALID_ARG, "Invalid input parameter.");
553 std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetUserCertFieldInfoByCertId(certId, pCertFieldInfos, &ret));
554 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
556 r = __pIpcClient->SendRequest(pMessage.get());
557 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
558 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));