}
r = __caCertDbStore.CheckDuplicateCertificate(certType, reinterpret_cast< byte* >(subjectName), lenSubjectName);
- if(!IsFailed(r))
+ if (!IsFailed(r))
{
return E_FILE_ALREADY_EXIST;
}
- SysTryReturnResult(NID_SEC_CERT, r==E_DATA_NOT_FOUND, r, "Failed to check duplicate");
+ SysTryReturnResult(NID_SEC_CERT, r == E_DATA_NOT_FOUND, r, "Failed to check duplicate");
//Get the last installed certificate id from db table
//No need to update record as only file data changed.
return E_SUCCESS;
}
-
+
return r;
}
pTbsCert = pCurCert->GetTbsCertInstance();
SysTryReturnResult(NID_SEC_CERT, pTbsCert != null, E_SYSTEM, "Failed to get certificate to be signed instance.");
- r = __caCertDbStore.CheckDuplicateCertificate(certType, reinterpret_cast< byte* >(pTbsCert->GetSubjectName()), strlen(reinterpret_cast< char* >(pTbsCert->GetSubjectName())));
- if(r != E_SUCCESS)
+ r = __caCertDbStore.CheckDuplicateCertificate(certType, reinterpret_cast< byte* >(pTbsCert->GetSubjectName()), strlen(reinterpret_cast< char* >(pTbsCert->GetSubjectName())));
+ if (r != E_SUCCESS)
{
SysTryReturn(NID_SEC_CERT, r == E_DATA_NOT_FOUND, r, r, "[%s] Failed to check duplicate.", GetErrorMessage(r));
r = __userCertDbStore.CheckDuplicateCertificate(reinterpret_cast< byte* >(subjectNameBuffer), lenSubjectName);
SysTryReturnResult(NID_SEC_CERT, IsFailed(r), E_FILE_ALREADY_EXIST, "File already exists.");
- SysTryReturnResult(NID_SEC_CERT, r==E_DATA_NOT_FOUND, r, "Failed to check duplicate");
+ SysTryReturnResult(NID_SEC_CERT, r == E_DATA_NOT_FOUND, r, "Failed to check duplicate");
//Get the last installed certificate id from db table
__userCertDbStore.GetCurrentCertId(certId);
memcpy(certRecord.certPubKeyHash, pId64.get(), keyIdB64Length); //Base64 encoded device id
certRecord.certFormat = static_cast< int >(certFormat);
- std::unique_ptr< char > pFileName(Tizen::Base::_StringConverter::CopyToCharArrayN(tempFileName));
+ std::unique_ptr< char[] > pFileName(Tizen::Base::_StringConverter::CopyToCharArrayN(tempFileName));
SysTryReturnResult(NID_SEC_CERT, pFileName != null, E_SYSTEM, "Failed to get attributes.");
strcpy(certRecord.fileName, pFileName.get());
certRecord.issuerNameLen = lenIssuerName;
memcpy(certRecord.issuerName, szIssuerName, lenIssuerName);
- std::unique_ptr< char > pPriKeyFileName(Tizen::Base::_StringConverter::CopyToCharArrayN(privateKeyFile));
+ std::unique_ptr< char[] > pPriKeyFileName(Tizen::Base::_StringConverter::CopyToCharArrayN(privateKeyFile));
SysTryReturnResult(NID_SEC_CERT, pPriKeyFileName != null, E_SYSTEM, "Failed to get attributes.");
strcpy(certRecord.prvKeyPath, pPriKeyFileName.get());
pBio = BIO_new(BIO_s_mem());
SysTryCatch(NID_SEC_CERT, pBio != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
- std::unique_ptr<unsigned char[]> pCertBuffer(new (std::nothrow) unsigned char[readCnt]);
+ std::unique_ptr< unsigned char[] > pCertBuffer(new (std::nothrow) unsigned char[readCnt]);
SysTryCatch(NID_SEC_CERT, pCertBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
- memcpy(static_cast<void*>(pCertBuffer.get()), certBufData, readCnt);
+ memcpy(static_cast< void* >(pCertBuffer.get()), certBufData, readCnt);
certBufferLen = readCnt;
const unsigned char* pTemp = pCertBuffer.get();
SysTryReturnResult(NID_SEC_CERT, pCert != null, E_INVALID_ARG, "Initial params not set.");
SysTryReturnResult(NID_SEC_CERT, pCertInfo != null, E_INVALID_ARG, "Initial params not set.");
+ memset(pCertInfo, 0, sizeof(_CertFieldInfos));
+
pTbsCert = pCert->GetTbsCertInstance();
SysTryReturnResult(NID_SEC_CERT, pTbsCert != null, E_SYSTEM, "Failed to get certificate to be signed instance.");
{
Tizen::Base::DateTime notBefore;
Tizen::Base::DateTime notAfter;
+
pTbsCert->GetAfterTimes(notAfter);
pTbsCert->GetBeforeTimes(notBefore);
+
memset(pCertInfo->validityFrom, 0, _MAX_CERT_VALIDITY_SIZE + 1);
memset(pCertInfo->validityTo, 0, _MAX_CERT_VALIDITY_SIZE + 1);
_CertTime::FormatDateTime(notBefore, pCertInfo->validityFrom);
+
_CertTime::FormatDateTime(notAfter, pCertInfo->validityTo);
+
}
if (field & _CERT_FIELD_SUBJECT)
}
else if (pX509Cert->Parse(pCertBuffer, certBufferLen) == E_SUCCESS)
{
- std::unique_ptr< byte, ByteDeleter > pCertBuf(static_cast<byte*>(malloc(sizeof(byte) * certBufferLen)));
+ std::unique_ptr< byte, ByteDeleter > pCertBuf(static_cast< byte* >(malloc(sizeof(byte) * certBufferLen)));
SysTryReturn(NID_SEC_CERT, pCertBuf != null, _CERT_UNKNOWN, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
memcpy(pCertBuf.get(), pCertBuffer, certBufferLen);
certBufLen = _Base64::GetDecodedSize(certBufferLen);
SysTryReturn(NID_SEC_CERT, certBufLen > 0, _CERT_UNKNOWN, E_SYSTEM, "[E_SYSTEM] Invalid certificate length.");
- std::unique_ptr< byte, ByteDeleter > pCertBuf(static_cast<byte*>(malloc(sizeof(byte) * certBufLen)));
+ std::unique_ptr< byte, ByteDeleter > pCertBuf(static_cast< byte* >(malloc(sizeof(byte) * certBufLen)));
SysTryReturn(NID_SEC_CERT, pCertBuf != null, _CERT_UNKNOWN, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory.");
memset(pCertBuf.get(), 0, certBufLen);
SysTryReturnResult(NID_SEC_CERT, pFile != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = pFile->Construct(certPath, "r");
- SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+ SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
pBuffer.reset(new (std::nothrow) ByteBuffer());
SysTryReturnResult(NID_SEC_CERT, pBuffer != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = pBuffer->Construct(_BUF_SIZE);
- SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+ SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
pTempBuffer = pBuffer.get();
r = pFile->Read(*pTempBuffer);
- SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+ SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
pTempBuffer->Flip();
SysTryReturnResult(NID_SEC_CERT, pBuffer != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
r = pCert->Construct(*pTempBuffer);
- SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
+ SysTryCatch(NID_SEC_CERT, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
continue;
- CATCH:
+CATCH:
SysSecureLog(NID_SEC_CERT, "Remove broken certificate %d", certRecord.certId);
r = pCaCertDbStore->RemoveCertificateById(certRecord.certId);
String formattedStr;
String cutomizedPattern = L"yyyy-MM-dd HH:mm:ss";
LocaleManager localeManager;
+ int len = 0;
ClearLastResult();
SysTryReturnVoidResult(NID_SEC_CERT, pFormattedDatTime != null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input argument.");
pDateFormatter->ApplyPattern(cutomizedPattern);
r = pDateFormatter->Format(time, formattedStr);
- SysTryReturnVoidResult(NID_SEC_CERT, !IsFailed(r), r, "[%s] Failed to create time formet.", GetErrorMessage(r));
+ SysTryReturnVoidResult(NID_SEC_CERT, !IsFailed(r), r, "[%s] Failed to create time format.", GetErrorMessage(r));
- std::unique_ptr< char > pTemp(Tizen::Base::_StringConverter::CopyToCharArrayN(formattedStr));
+ std::unique_ptr< char[] > pTemp(Tizen::Base::_StringConverter::CopyToCharArrayN(formattedStr));
SysTryReturnVoidResult(NID_SEC_CERT, pTemp != null, GetLastResult(), "[%s] Failed to convert string array.", GetErrorMessage(GetLastResult()));
- memcpy(pFormattedDatTime, pTemp.get(), strlen(pTemp.get()) + 1);
+ len = strlen(pTemp.get());
+ memcpy(pFormattedDatTime, pTemp.get(), len);
+ pFormattedDatTime[len] = '\0';
+
}