//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetName(&ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetName(&ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
result
-_CertServiceProxy::CloseCertificateStore(int certificateStoreCtx)
+_CertServiceProxy::CloseCertificateStore(int certType)
{
result r = E_SUCCESS;
result ret = E_SUCCESS;
ClearLastResult();
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
+ SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
+ SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_CloseCertificateStore(certificateStoreCtx, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_CloseCertificateStore(certType, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
}
result
-_CertServiceProxy::OpenCertificateStoreByType(int type, int& count, int& certificateStoreCtx)
+_CertServiceProxy::OpenCertificateStoreByType(int type, int& count)
{
result r = E_SUCCESS;
result ret = E_SUCCESS;
ClearLastResult();
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
+ SysTryReturnResult(NID_SEC_CERT, type > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
+ SysTryReturnResult(NID_SEC_CERT, type < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_OpenCertificateStoreByType(type, &count, &certificateStoreCtx, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_OpenCertificateStoreByType(type, &count, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
}
result
-_CertServiceProxy::GetCertificateCount(int certificateStoreCtx, int& totalCertCount)
+_CertServiceProxy::GetCertificateCount(int certType, int& totalCertCount)
{
result r = E_SUCCESS;
result ret = E_SUCCESS;
ClearLastResult();
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
+ SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
+ SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetCertificateCount(certificateStoreCtx, &totalCertCount, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetCertificateCount(certType, &totalCertCount, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
}
result
-_CertServiceProxy::GetNextCertificate(int certificateStoreCtx, byte* pBuffer, int& bufferLen)
+_CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer, int& bufferLen)
{
result r = E_SUCCESS;
result ret = E_SUCCESS;
- Tizen::Io::_IpcBuffer certBufferIpc;
+ Tizen::Base::ByteBuffer certBufferIpc;
ClearLastResult();
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
SysTryReturnResult(NID_SEC_CERT, pBuffer != null, E_INVALID_ARG, "Invalid parameter.");
+ SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
+ SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
- certBufferIpc.pBuffer = null;
- certBufferIpc.size = 0;
-
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetNextCertificate(certificateStoreCtx, bufferLen, &certBufferIpc, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetNextCertificate(certType, curPos, bufferLen, &certBufferIpc, &curPos, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
- memcpy(pBuffer, certBufferIpc.pBuffer, certBufferIpc.size);
- bufferLen = certBufferIpc.size;
+ memcpy(pBuffer, certBufferIpc.GetPointer(), certBufferIpc.GetRemaining());
+ bufferLen = certBufferIpc.GetRemaining();
return r;
}
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
SysTryReturnResult(NID_SEC_CERT, ((pOldCert != null) && (oldCertLen > 0)), E_INVALID_ARG, "Invalid input old certificate parameter.");
SysTryReturnResult(NID_SEC_CERT, ((pNewCert != null) && (newCertLen > 0)), E_INVALID_ARG, "Invalid input new certificate parameter.");
+ SysTryReturnResult(NID_SEC_CERT, type > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
+ SysTryReturnResult(NID_SEC_CERT, type < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
oldBufferIpc.pBuffer = pOldCert;
oldBufferIpc.size = oldCertLen;
newBufferIpc.pBuffer = pNewCert;
newBufferIpc.size = newCertLen;
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_UpdateRootCa(type, oldBufferIpc, newBufferIpc, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_UpdateRootCa(type, oldBufferIpc, newBufferIpc, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
certBufferIpc.pBuffer = pBuffer;
certBufferIpc.size = bufLen;
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_RemoveRootCa(type, certBufferIpc, bufLen, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_RemoveRootCa(type, certBufferIpc, bufLen, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_UninstallUserRootCertificateByCertId(certId, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_UninstallUserRootCertificateByCertId(certId, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
certBufferIpc.pBuffer = pCert;
certBufferIpc.size = certLen;
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InsertCaCertificate(type, format, certBufferIpc, certLen, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertCaCertificate(type, format, certBufferIpc, certLen, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
certBufferIpc.pBuffer = pCert;
certBufferIpc.size = certLen;
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InsertUserCaCertificate(format, certBufferIpc, certLen, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertUserCaCertificate(format, certBufferIpc, certLen, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
certBufferIpc.pBuffer = pFilePath;
certBufferIpc.size = strlen(reinterpret_cast< char* >(pFilePath)) + 1;
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InstallUserRootCertificate(certBufferIpc, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InstallUserRootCertificate(certBufferIpc, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
privateKeyBufferIpc.pBuffer = pUserPrivateKey;
privateKeyBufferIpc.size = userPrivateKeyLen;
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InsertUserCertChainPrivateKey(certPackBufferIPC, certChainLen, privateKeyBufferIpc, userPrivateKeyLen, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertUserCertChainPrivateKey(certPackBufferIPC, certChainLen, privateKeyBufferIpc, userPrivateKeyLen, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
certChainPriKeyBufferIpc.pBuffer = pCertchainPrivateKeyBuffer;
certChainPriKeyBufferIpc.size = certChainPrivateKeyLength;
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InsertCertificateChainWithPrivateKey(certChainPriKeyBufferIpc, certChainPrivateKeyLength, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InsertCertificateChainWithPrivateKey(certChainPriKeyBufferIpc, certChainPrivateKeyLength, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
}
result
-_CertServiceProxy::InsertPkcs12Content(char* pPkcs12FilePath, char* pPkcs12ImportPassword)
+_CertServiceProxy::InsertPkcs12Content(char* pPkcs12FilePath, char* pPkcs12ImportPassword, bool checkPrivilege)
{
result r = E_SUCCESS;
result ret = E_SUCCESS;
pkcs12PasswdBufferIpc.pBuffer = pPkcs12ImportPassword;
pkcs12PasswdBufferIpc.size = strlen(reinterpret_cast< char* >(pPkcs12ImportPassword)) + 1;
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_InstallPkcs12Content(pkcs12FileBufferIpc, pkcs12PasswdBufferIpc, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_InstallPkcs12Content(pkcs12FileBufferIpc, pkcs12PasswdBufferIpc, checkPrivilege, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "Instance is not constructed.");
SysTryReturnResult(NID_SEC_CERT, certId >= 1, E_INVALID_ARG, "Invalid input parameter.");
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_DeleteUserCertChainByCertId(certId, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_DeleteUserCertChainByCertId(certId, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
memset(pRetNode, 0, sizeof(*pRetNode));
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetUserCertChainByIssuerAndSubjectNameN(issuerBufferIpc, issuerNameLen, subjectBufferIpc, subNameLen, pRetNode, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertChainByIssuerAndSubjectNameN(issuerBufferIpc, issuerNameLen, subjectBufferIpc, subNameLen, pRetNode, &ret));
SysTryReturn(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
memset(pRetNode, 0, sizeof(*pRetNode));
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetUserCertificateByCertIdN(certId, encodingType, pRetNode, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertificateByCertIdN(certId, encodingType, pRetNode, &ret));
SysTryCatch(NID_SEC_CERT, pMessage != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
SysTryReturnResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "IPC instance is not constructed.");
SysTryReturnResult(NID_SEC_CERT, pCertFieldInfos != null, E_INVALID_ARG, "Invalid input parameter.");
- std::unique_ptr<IPC::Message> pMessage(new (std::nothrow) CertService_GetUserCertFieldInfoByCertId(certId, pCertFieldInfos, &ret));
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetUserCertFieldInfoByCertId(certId, pCertFieldInfos, &ret));
SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = __pIpcClient->SendRequest(pMessage.get());
return r;
}
+
+void
+_CertServiceProxy::RestoreRootCaIntegrity(void)
+{
+ result r = E_SUCCESS;
+
+ ClearLastResult();
+
+ SysTryReturnVoidResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "[%s] IPC instance is not constructed.", GetErrorMessage(E_SYSTEM));
+
+ std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_RestoreRootCaIntegrity());
+ SysTryReturnVoidResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "[%s] Failed to allocate memory.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ r = __pIpcClient->SendRequest(pMessage.get());
+ SysTryReturnVoidResult(NID_SEC_CERT, !IsFailed(r), r, "[%s] Failed to send message.", GetErrorMessage(r));
+}
+
} } }