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) CertServer_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 certType)
109 result r = E_SUCCESS;
110 result ret = E_SUCCESS;
114 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
115 SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
116 SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
118 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_CloseCertificateStore(certType, &ret));
119 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
121 r = __pIpcClient->SendRequest(pMessage.get());
122 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
123 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
129 _CertServiceProxy::OpenCertificateStoreByType(int type, int& count)
131 result r = E_SUCCESS;
132 result ret = E_SUCCESS;
136 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
137 SysTryReturnResult(NID_SEC_CERT, type > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
138 SysTryReturnResult(NID_SEC_CERT, type < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
140 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_OpenCertificateStoreByType(type, &count, &ret));
141 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
143 r = __pIpcClient->SendRequest(pMessage.get());
144 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
145 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
151 _CertServiceProxy::GetCertificateCount(int certType, int& totalCertCount)
153 result r = E_SUCCESS;
154 result ret = E_SUCCESS;
158 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
159 SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
160 SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
162 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetCertificateCount(certType, &totalCertCount, &ret));
163 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
165 r = __pIpcClient->SendRequest(pMessage.get());
166 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
167 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
173 _CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer, int& bufferLen)
175 result r = E_SUCCESS;
176 result ret = E_SUCCESS;
178 Tizen::Io::_IpcBuffer certBufferIpc;
182 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
183 SysTryReturnResult(NID_SEC_CERT, pBuffer != null, E_INVALID_ARG, "Invalid parameter.");
184 SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
185 SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
187 certBufferIpc.pBuffer = null;
188 certBufferIpc.size = 0;
190 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetNextCertificate(certType, curPos, bufferLen, &certBufferIpc, &curPos, &ret));
191 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
193 r = __pIpcClient->SendRequest(pMessage.get());
194 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
195 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
197 memcpy(pBuffer, certBufferIpc.pBuffer, certBufferIpc.size);
198 bufferLen = certBufferIpc.size;
204 _CertServiceProxy::UpdateCaCertificate(int type, byte* pOldCert, int oldCertLen, byte* pNewCert, int newCertLen)
206 result r = E_SUCCESS;
207 result ret = E_SUCCESS;
209 Tizen::Io::_IpcBuffer oldBufferIpc = {0, };
210 Tizen::Io::_IpcBuffer newBufferIpc = {0, };
214 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
215 SysTryReturnResult(NID_SEC_CERT, ((pOldCert != null) && (oldCertLen > 0)), E_INVALID_ARG, "Invalid input old certificate parameter.");
216 SysTryReturnResult(NID_SEC_CERT, ((pNewCert != null) && (newCertLen > 0)), E_INVALID_ARG, "Invalid input new certificate parameter.");
217 SysTryReturnResult(NID_SEC_CERT, type > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
218 SysTryReturnResult(NID_SEC_CERT, type < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
220 oldBufferIpc.pBuffer = pOldCert;
221 oldBufferIpc.size = oldCertLen;
223 newBufferIpc.pBuffer = pNewCert;
224 newBufferIpc.size = newCertLen;
226 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_UpdateRootCa(type, oldBufferIpc, newBufferIpc, &ret));
227 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
229 r = __pIpcClient->SendRequest(pMessage.get());
230 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
231 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
237 _CertServiceProxy::RemoveCaCertificate(int type, byte* pBuffer, int bufLen)
239 result r = E_SUCCESS;
240 result ret = E_SUCCESS;
241 Tizen::Io::_IpcBuffer certBufferIpc;
245 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
246 SysTryReturnResult(NID_SEC_CERT, ((pBuffer != null) && (bufLen > 0)), E_INVALID_ARG, "Invalid input parameters.");
248 certBufferIpc.pBuffer = pBuffer;
249 certBufferIpc.size = bufLen;
251 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_RemoveRootCa(type, certBufferIpc, bufLen, &ret));
252 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
254 r = __pIpcClient->SendRequest(pMessage.get());
255 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
256 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
262 _CertServiceProxy::RemoveUserCaCertificateByCertId(int certId)
264 result r = E_SUCCESS;
265 result ret = E_SUCCESS;
269 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
270 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
272 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_UninstallUserRootCertificateByCertId(certId, &ret));
273 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
275 r = __pIpcClient->SendRequest(pMessage.get());
276 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
277 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
283 _CertServiceProxy::InsertCaCertificate(int type, int format, byte* pCert, long certLen)
285 result r = E_SUCCESS;
286 result ret = E_SUCCESS;
287 Tizen::Io::_IpcBuffer certBufferIpc;
291 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
292 SysTryReturnResult(NID_SEC_CERT, ((pCert != null) && (certLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
294 certBufferIpc.pBuffer = pCert;
295 certBufferIpc.size = certLen;
297 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertCaCertificate(type, format, certBufferIpc, certLen, &ret));
298 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
300 r = __pIpcClient->SendRequest(pMessage.get());
301 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
302 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
308 _CertServiceProxy::InsertUserCaCertificate(int format, char* pCert, int certLen)
310 result r = E_SUCCESS;
311 result ret = E_SUCCESS;
312 Tizen::Io::_IpcBuffer certBufferIpc;
316 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
317 SysTryReturnResult(NID_SEC_CERT, ((pCert != null) && (certLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
319 certBufferIpc.pBuffer = pCert;
320 certBufferIpc.size = certLen;
322 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertUserCaCertificate(format, certBufferIpc, certLen, &ret));
323 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
325 r = __pIpcClient->SendRequest(pMessage.get());
326 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
327 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
333 _CertServiceProxy::InsertUserCaCertificate(byte* pFilePath)
335 result r = E_SUCCESS;
336 result ret = E_SUCCESS;
337 Tizen::Io::_IpcBuffer certBufferIpc;
339 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
340 SysTryReturnResult(NID_SEC_CERT, pFilePath != null, E_INVALID_ARG, "Invalid input parameter.");
342 certBufferIpc.pBuffer = pFilePath;
343 certBufferIpc.size = strlen(reinterpret_cast< char* >(pFilePath)) + 1;
345 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InstallUserRootCertificate(certBufferIpc, &ret));
346 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
348 r = __pIpcClient->SendRequest(pMessage.get());
349 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
350 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
356 //User Certificate APIs
359 _CertServiceProxy::InsertUserCertChainPrivateKey(char* pCertchainBuffer, int certChainLen, char* pUserPrivateKey, int userPrivateKeyLen)
361 result r = E_SUCCESS;
362 result ret = E_SUCCESS;
363 Tizen::Io::_IpcBuffer certPackBufferIPC;
364 Tizen::Io::_IpcBuffer privateKeyBufferIpc;
366 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
367 SysTryReturnResult(NID_SEC_CERT, ((pCertchainBuffer != null) && (certChainLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
369 certPackBufferIPC.pBuffer = pCertchainBuffer;
370 certPackBufferIPC.size = certChainLen;
372 privateKeyBufferIpc.pBuffer = pUserPrivateKey;
373 privateKeyBufferIpc.size = userPrivateKeyLen;
375 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertUserCertChainPrivateKey(certPackBufferIPC, certChainLen, privateKeyBufferIpc, userPrivateKeyLen, &ret));
376 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
378 r = __pIpcClient->SendRequest(pMessage.get());
379 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
380 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
386 _CertServiceProxy::InsertCertificateChainWithPrivateKey(char* pCertchainPrivateKeyBuffer, int certChainPrivateKeyLength)
388 result r = E_SUCCESS;
389 result ret = E_SUCCESS;
390 Tizen::Io::_IpcBuffer certChainPriKeyBufferIpc;
392 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
393 SysTryReturnResult(NID_SEC_CERT, ((pCertchainPrivateKeyBuffer != null) && (certChainPrivateKeyLength > 0)), E_INVALID_ARG, "Invalid input parameter.");
395 certChainPriKeyBufferIpc.pBuffer = pCertchainPrivateKeyBuffer;
396 certChainPriKeyBufferIpc.size = certChainPrivateKeyLength;
398 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertCertificateChainWithPrivateKey(certChainPriKeyBufferIpc, certChainPrivateKeyLength, &ret));
399 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
401 r = __pIpcClient->SendRequest(pMessage.get());
402 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
403 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
409 _CertServiceProxy::InsertPkcs12Content(char* pPkcs12FilePath, char* pPkcs12ImportPassword)
411 result r = E_SUCCESS;
412 result ret = E_SUCCESS;
413 Tizen::Io::_IpcBuffer pkcs12FileBufferIpc;
414 Tizen::Io::_IpcBuffer pkcs12PasswdBufferIpc;
416 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
417 SysTryReturnResult(NID_SEC_CERT, pPkcs12FilePath != null, E_INVALID_ARG, "Invalid input parameter.");
419 pkcs12FileBufferIpc.pBuffer = pPkcs12FilePath;
420 pkcs12FileBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12FilePath)) + 1;
422 pkcs12PasswdBufferIpc.pBuffer = pPkcs12ImportPassword;
423 pkcs12PasswdBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12ImportPassword)) + 1;
425 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InstallPkcs12Content(pkcs12FileBufferIpc, pkcs12PasswdBufferIpc, &ret));
426 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
428 r = __pIpcClient->SendRequest(pMessage.get());
429 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
430 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
436 _CertServiceProxy::RemoveUserCertChainByCertId(int certId)
438 result r = E_SUCCESS;
439 result ret = E_SUCCESS;
443 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "Instance is not constructed.");
444 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
446 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_DeleteUserCertChainByCertId(certId, &ret));
447 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
449 r = __pIpcClient->SendRequest(pMessage.get());
450 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
451 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
457 _CertServiceProxy::GetUserCertChainByIssuerAndSubjectNameN(char* pIssuerName, int issuerNameLen, char* pSubjectName, int subNameLen, _CertificateListInfo*& pUserCertListInfoTypesRef)
459 result r = E_SUCCESS;
460 result ret = E_SUCCESS;
461 _CertificateListInfo* pRetNode = null;
462 Tizen::Io::_IpcBuffer issuerBufferIpc;
463 Tizen::Io::_IpcBuffer subjectBufferIpc;
465 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPCInstance is not constructed.");
466 SysTryReturnResult(NID_SEC_CERT, pIssuerName != null, E_INVALID_ARG, "Invalid Parameters");
467 SysTryReturnResult(NID_SEC_CERT, pSubjectName != null, E_INVALID_ARG, "Invalid Parameters");
469 issuerBufferIpc.pBuffer = pIssuerName;
470 issuerBufferIpc.size = issuerNameLen;
472 subjectBufferIpc.pBuffer = pSubjectName;
473 subjectBufferIpc.size = subNameLen;
475 pRetNode = new (std::nothrow) _CertificateListInfo();
476 SysTryReturnResult(NID_SEC_CERT, pRetNode != null, E_OUT_OF_MEMORY, "Unable to allocate");
478 memset(pRetNode, 0, sizeof(*pRetNode));
480 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertChainByIssuerAndSubjectNameN(issuerBufferIpc, issuerNameLen, subjectBufferIpc, subNameLen, pRetNode, &ret));
481 SysTryReturn(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
483 r = __pIpcClient->SendRequest(pMessage.get());
484 SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to send message.", GetErrorMessage(r));
485 SysTryCatch(NID_SEC_CERT, !IsFailed(ret), r = ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
487 pUserCertListInfoTypesRef = pRetNode;
492 _CertService::FreeCertList(pRetNode);
501 _CertServiceProxy::GetUserCertificateByCertIdN(int certId, int encodingType)
503 result r = E_SUCCESS;
504 result ret = E_SUCCESS;
506 _CertInfo* pRetNode = null;
508 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, null, "IPC instance is not constructed.");
510 pRetNode = new (std::nothrow) _CertInfo();
511 SysTryReturnResult(NID_SEC_CERT, pRetNode != null, null, "Unable to allocate");
513 memset(pRetNode, 0, sizeof(*pRetNode));
515 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertificateByCertIdN(certId, encodingType, pRetNode, &ret));
516 SysTryCatch(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
518 r = __pIpcClient->SendRequest(pMessage.get());
519 SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to send message.", GetErrorMessage(r));
520 SysTryCatch(NID_SEC_CERT, !IsFailed(ret), r = ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
525 _CertService::FreeCertificateInfo(pRetNode);
533 _CertServiceProxy::GetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCertFieldInfos)
535 result r = E_SUCCESS;
536 result ret = E_SUCCESS;
540 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
541 SysTryReturnResult(NID_SEC_CERT, pCertFieldInfos != null, E_INVALID_ARG, "Invalid input parameter.");
543 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertFieldInfoByCertId(certId, pCertFieldInfos, &ret));
544 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
546 r = __pIpcClient->SendRequest(pMessage.get());
547 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
548 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));