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::Base::ByteBuffer 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 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetNextCertificate(certType, curPos, bufferLen, &certBufferIpc, &curPos, &ret));
187 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
189 r = __pIpcClient->SendRequest(pMessage.get());
190 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
191 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
193 memcpy(pBuffer, certBufferIpc.GetPointer(), certBufferIpc.GetRemaining());
194 bufferLen = certBufferIpc.GetRemaining();
200 _CertServiceProxy::UpdateCaCertificate(int type, byte* pOldCert, int oldCertLen, byte* pNewCert, int newCertLen)
202 result r = E_SUCCESS;
203 result ret = E_SUCCESS;
205 Tizen::Io::_IpcBuffer oldBufferIpc = {0, };
206 Tizen::Io::_IpcBuffer newBufferIpc = {0, };
210 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
211 SysTryReturnResult(NID_SEC_CERT, ((pOldCert != null) && (oldCertLen > 0)), E_INVALID_ARG, "Invalid input old certificate parameter.");
212 SysTryReturnResult(NID_SEC_CERT, ((pNewCert != null) && (newCertLen > 0)), E_INVALID_ARG, "Invalid input new certificate parameter.");
213 SysTryReturnResult(NID_SEC_CERT, type > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
214 SysTryReturnResult(NID_SEC_CERT, type < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
216 oldBufferIpc.pBuffer = pOldCert;
217 oldBufferIpc.size = oldCertLen;
219 newBufferIpc.pBuffer = pNewCert;
220 newBufferIpc.size = newCertLen;
222 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_UpdateRootCa(type, oldBufferIpc, newBufferIpc, &ret));
223 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
225 r = __pIpcClient->SendRequest(pMessage.get());
226 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
227 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
233 _CertServiceProxy::RemoveCaCertificate(int type, byte* pBuffer, int bufLen)
235 result r = E_SUCCESS;
236 result ret = E_SUCCESS;
237 Tizen::Io::_IpcBuffer certBufferIpc;
241 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
242 SysTryReturnResult(NID_SEC_CERT, ((pBuffer != null) && (bufLen > 0)), E_INVALID_ARG, "Invalid input parameters.");
244 certBufferIpc.pBuffer = pBuffer;
245 certBufferIpc.size = bufLen;
247 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_RemoveRootCa(type, certBufferIpc, bufLen, &ret));
248 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
250 r = __pIpcClient->SendRequest(pMessage.get());
251 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
252 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
258 _CertServiceProxy::RemoveUserCaCertificateByCertId(int certId)
260 result r = E_SUCCESS;
261 result ret = E_SUCCESS;
265 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
266 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
268 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_UninstallUserRootCertificateByCertId(certId, &ret));
269 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
271 r = __pIpcClient->SendRequest(pMessage.get());
272 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
273 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
279 _CertServiceProxy::InsertCaCertificate(int type, int format, byte* pCert, long certLen)
281 result r = E_SUCCESS;
282 result ret = E_SUCCESS;
283 Tizen::Io::_IpcBuffer certBufferIpc;
287 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
288 SysTryReturnResult(NID_SEC_CERT, ((pCert != null) && (certLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
290 certBufferIpc.pBuffer = pCert;
291 certBufferIpc.size = certLen;
293 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertCaCertificate(type, format, certBufferIpc, certLen, &ret));
294 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
296 r = __pIpcClient->SendRequest(pMessage.get());
297 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
298 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
304 _CertServiceProxy::InsertUserCaCertificate(int format, char* pCert, int certLen)
306 result r = E_SUCCESS;
307 result ret = E_SUCCESS;
308 Tizen::Io::_IpcBuffer certBufferIpc;
312 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
313 SysTryReturnResult(NID_SEC_CERT, ((pCert != null) && (certLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
315 certBufferIpc.pBuffer = pCert;
316 certBufferIpc.size = certLen;
318 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertUserCaCertificate(format, certBufferIpc, certLen, &ret));
319 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
321 r = __pIpcClient->SendRequest(pMessage.get());
322 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
323 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
329 _CertServiceProxy::InsertUserCaCertificate(byte* pFilePath)
331 result r = E_SUCCESS;
332 result ret = E_SUCCESS;
333 Tizen::Io::_IpcBuffer certBufferIpc;
335 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
336 SysTryReturnResult(NID_SEC_CERT, pFilePath != null, E_INVALID_ARG, "Invalid input parameter.");
338 certBufferIpc.pBuffer = pFilePath;
339 certBufferIpc.size = strlen(reinterpret_cast< char* >(pFilePath)) + 1;
341 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InstallUserRootCertificate(certBufferIpc, &ret));
342 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
344 r = __pIpcClient->SendRequest(pMessage.get());
345 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
346 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
352 //User Certificate APIs
355 _CertServiceProxy::InsertUserCertChainPrivateKey(char* pCertchainBuffer, int certChainLen, char* pUserPrivateKey, int userPrivateKeyLen)
357 result r = E_SUCCESS;
358 result ret = E_SUCCESS;
359 Tizen::Io::_IpcBuffer certPackBufferIPC;
360 Tizen::Io::_IpcBuffer privateKeyBufferIpc;
362 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
363 SysTryReturnResult(NID_SEC_CERT, ((pCertchainBuffer != null) && (certChainLen > 0)), E_INVALID_ARG, "Invalid input parameter.");
365 certPackBufferIPC.pBuffer = pCertchainBuffer;
366 certPackBufferIPC.size = certChainLen;
368 privateKeyBufferIpc.pBuffer = pUserPrivateKey;
369 privateKeyBufferIpc.size = userPrivateKeyLen;
371 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertUserCertChainPrivateKey(certPackBufferIPC, certChainLen, privateKeyBufferIpc, userPrivateKeyLen, &ret));
372 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
374 r = __pIpcClient->SendRequest(pMessage.get());
375 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
376 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
382 _CertServiceProxy::InsertCertificateChainWithPrivateKey(char* pCertchainPrivateKeyBuffer, int certChainPrivateKeyLength)
384 result r = E_SUCCESS;
385 result ret = E_SUCCESS;
386 Tizen::Io::_IpcBuffer certChainPriKeyBufferIpc;
388 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
389 SysTryReturnResult(NID_SEC_CERT, ((pCertchainPrivateKeyBuffer != null) && (certChainPrivateKeyLength > 0)), E_INVALID_ARG, "Invalid input parameter.");
391 certChainPriKeyBufferIpc.pBuffer = pCertchainPrivateKeyBuffer;
392 certChainPriKeyBufferIpc.size = certChainPrivateKeyLength;
394 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertCertificateChainWithPrivateKey(certChainPriKeyBufferIpc, certChainPrivateKeyLength, &ret));
395 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
397 r = __pIpcClient->SendRequest(pMessage.get());
398 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
399 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
405 _CertServiceProxy::InsertPkcs12Content(char* pPkcs12FilePath, char* pPkcs12ImportPassword, bool checkPrivilege)
407 result r = E_SUCCESS;
408 result ret = E_SUCCESS;
409 Tizen::Io::_IpcBuffer pkcs12FileBufferIpc;
410 Tizen::Io::_IpcBuffer pkcs12PasswdBufferIpc;
412 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
413 SysTryReturnResult(NID_SEC_CERT, pPkcs12FilePath != null, E_INVALID_ARG, "Invalid input parameter.");
415 pkcs12FileBufferIpc.pBuffer = pPkcs12FilePath;
416 pkcs12FileBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12FilePath)) + 1;
418 pkcs12PasswdBufferIpc.pBuffer = pPkcs12ImportPassword;
419 pkcs12PasswdBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12ImportPassword)) + 1;
421 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InstallPkcs12Content(pkcs12FileBufferIpc, pkcs12PasswdBufferIpc, checkPrivilege, &ret));
422 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
424 r = __pIpcClient->SendRequest(pMessage.get());
425 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
426 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
432 _CertServiceProxy::RemoveUserCertChainByCertId(int certId)
434 result r = E_SUCCESS;
435 result ret = E_SUCCESS;
439 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "Instance is not constructed.");
440 SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
442 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_DeleteUserCertChainByCertId(certId, &ret));
443 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
445 r = __pIpcClient->SendRequest(pMessage.get());
446 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
447 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
453 _CertServiceProxy::GetUserCertChainByIssuerAndSubjectNameN(char* pIssuerName, int issuerNameLen, char* pSubjectName, int subNameLen, _CertificateListInfo*& pUserCertListInfoTypesRef)
455 result r = E_SUCCESS;
456 result ret = E_SUCCESS;
457 _CertificateListInfo* pRetNode = null;
458 Tizen::Io::_IpcBuffer issuerBufferIpc;
459 Tizen::Io::_IpcBuffer subjectBufferIpc;
461 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPCInstance is not constructed.");
462 SysTryReturnResult(NID_SEC_CERT, pIssuerName != null, E_INVALID_ARG, "Invalid Parameters");
463 SysTryReturnResult(NID_SEC_CERT, pSubjectName != null, E_INVALID_ARG, "Invalid Parameters");
465 issuerBufferIpc.pBuffer = pIssuerName;
466 issuerBufferIpc.size = issuerNameLen;
468 subjectBufferIpc.pBuffer = pSubjectName;
469 subjectBufferIpc.size = subNameLen;
471 pRetNode = new (std::nothrow) _CertificateListInfo();
472 SysTryReturnResult(NID_SEC_CERT, pRetNode != null, E_OUT_OF_MEMORY, "Unable to allocate");
474 memset(pRetNode, 0, sizeof(*pRetNode));
476 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertChainByIssuerAndSubjectNameN(issuerBufferIpc, issuerNameLen, subjectBufferIpc, subNameLen, pRetNode, &ret));
477 SysTryReturn(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
479 r = __pIpcClient->SendRequest(pMessage.get());
480 SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to send message.", GetErrorMessage(r));
481 SysTryCatch(NID_SEC_CERT, !IsFailed(ret), r = ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
483 pUserCertListInfoTypesRef = pRetNode;
488 _CertService::FreeCertList(pRetNode);
497 _CertServiceProxy::GetUserCertificateByCertIdN(int certId, int encodingType)
499 result r = E_SUCCESS;
500 result ret = E_SUCCESS;
502 _CertInfo* pRetNode = null;
504 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, null, "IPC instance is not constructed.");
506 pRetNode = new (std::nothrow) _CertInfo();
507 SysTryReturnResult(NID_SEC_CERT, pRetNode != null, null, "Unable to allocate");
509 memset(pRetNode, 0, sizeof(*pRetNode));
511 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertificateByCertIdN(certId, encodingType, pRetNode, &ret));
512 SysTryCatch(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
514 r = __pIpcClient->SendRequest(pMessage.get());
515 SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Failed to send message.", GetErrorMessage(r));
516 SysTryCatch(NID_SEC_CERT, !IsFailed(ret), r = ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
521 _CertService::FreeCertificateInfo(pRetNode);
529 _CertServiceProxy::GetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCertFieldInfos)
531 result r = E_SUCCESS;
532 result ret = E_SUCCESS;
536 SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
537 SysTryReturnResult(NID_SEC_CERT, pCertFieldInfos != null, E_INVALID_ARG, "Invalid input parameter.");
539 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertFieldInfoByCertId(certId, pCertFieldInfos, &ret));
540 SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
542 r = __pIpcClient->SendRequest(pMessage.get());
543 SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
544 SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
550 _CertServiceProxy::RestoreRootCaIntegrity(void)
552 result r = E_SUCCESS;
556 SysTryReturnVoidResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "[%s] IPC instance is not constructed.", GetErrorMessage(E_SYSTEM));
558 std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_RestoreRootCaIntegrity());
559 SysTryReturnVoidResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "[%s] Failed to allocate memory.", GetErrorMessage(E_OUT_OF_MEMORY));
561 r = __pIpcClient->SendRequest(pMessage.get());
562 SysTryReturnVoidResult(NID_SEC_CERT, !IsFailed(r), r, "[%s] Failed to send message.", GetErrorMessage(r));