diff --git a/interfaces/innerkits/appverify/include/common/hap_verify_log.h b/interfaces/innerkits/appverify/include/common/hap_verify_log.h index eaf4a238b2c4268d16c8bc7e74aea1cbcdccd4d7..1e75eede6a93de89d675a49678ab6b69c59884dc 100644 --- a/interfaces/innerkits/appverify/include/common/hap_verify_log.h +++ b/interfaces/innerkits/appverify/include/common/hap_verify_log.h @@ -21,19 +21,35 @@ namespace OHOS { namespace Security { namespace Verify { -static constexpr uint32_t APPVERIFY_DOMAIN = 0xD0011FE; -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, APPVERIFY_DOMAIN, "HapVerify"}; - -#define HAPVERIFY_LOG_DEBUG(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Debug(label, "%{public}s: " fmt, __func__, ##__VA_ARGS__) -#define HAPVERIFY_LOG_INFO(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Info(label, "%{public}s: " fmt, __func__, ##__VA_ARGS__) -#define HAPVERIFY_LOG_WARN(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Warn(label, "%{public}s: " fmt, __func__, ##__VA_ARGS__) -#define HAPVERIFY_LOG_ERROR(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Error(label, "%{public}s: " fmt, __func__, ##__VA_ARGS__) -#define HAPVERIFY_LOG_FATAL(label, fmt, ...) \ - OHOS::HiviewDFX::HiLog::Fatal(label, "%{public}s: " fmt, __func__, ##__VA_ARGS__) + +#ifndef HAPVERIFY_LOG_DOMAIN +#define HAPVERIFY_LOG_DOMAIN 0xD0011FE +#endif + +#ifndef HAPVERIFY_APP_LOG_TAG +#define HAPVERIFY_APP_LOG_TAG "HapVerify" +#endif + +#define FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) +#define HAPVERIFY_LOG_DEBUG(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, HAPVERIFY_LOG_DOMAIN, HAPVERIFY_APP_LOG_TAG, \ + "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__)) + +#define HAPVERIFY_LOG_INFO(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, HAPVERIFY_LOG_DOMAIN, HAPVERIFY_APP_LOG_TAG, \ + "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__)) + +#define HAPVERIFY_LOG_WARN(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, HAPVERIFY_LOG_DOMAIN, HAPVERIFY_APP_LOG_TAG, \ + "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__)) + +#define HAPVERIFY_LOG_ERROR(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, HAPVERIFY_LOG_DOMAIN, HAPVERIFY_APP_LOG_TAG, \ + "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__)) + +#define HAPVERIFY_LOG_FATAL(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, HAPVERIFY_LOG_DOMAIN, HAPVERIFY_APP_LOG_TAG, \ + "[%{public}s(%{public}s:%{public}d)]" fmt, FILENAME, __FUNCTION__, __LINE__, ##__VA_ARGS__)) } // namespace Verify } // namespace Security } // namespace OHOS diff --git a/interfaces/innerkits/appverify/src/common/hap_byte_buffer.cpp b/interfaces/innerkits/appverify/src/common/hap_byte_buffer.cpp index aa37b823f70d1600d8f8765a0ffb8dcd6ab6148c..a46e8c3ee25034124c8ec6b5f6f1dd9a1cd53b44 100644 --- a/interfaces/innerkits/appverify/src/common/hap_byte_buffer.cpp +++ b/interfaces/innerkits/appverify/src/common/hap_byte_buffer.cpp @@ -38,7 +38,7 @@ HapByteBuffer::HapByteBuffer(const HapByteBuffer& other) : buffer(nullptr), posi Init(other.GetCapacity()); if (buffer != nullptr && capacity > 0) { if (memcpy_s(buffer.get(), capacity, other.GetBufferPtr(), other.GetCapacity()) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); return; } position = other.GetPosition(); @@ -60,7 +60,7 @@ void HapByteBuffer::Init(int32_t bufferCapacity) capacity = bufferCapacity; } } else { - HAPVERIFY_LOG_INFO(LABEL, "bufferCapacity %{public}d is too small", bufferCapacity); + HAPVERIFY_LOG_INFO("bufferCapacity %{public}d is too small", bufferCapacity); } } @@ -74,7 +74,7 @@ HapByteBuffer& HapByteBuffer::operator=(const HapByteBuffer& other) Init(other.GetCapacity()); if (buffer != nullptr && other.GetBufferPtr() != nullptr && capacity > 0) { if (memcpy_s(buffer.get(), capacity, other.GetBufferPtr(), other.GetCapacity()) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); return *this; } position = other.GetPosition(); @@ -86,17 +86,17 @@ HapByteBuffer& HapByteBuffer::operator=(const HapByteBuffer& other) bool HapByteBuffer::CheckInputForGettingData(int32_t index, int32_t dataLen) { if (buffer == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "buffer is nullptr"); + HAPVERIFY_LOG_ERROR("buffer is nullptr"); return false; } if (index < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid index %{public}d", index); + HAPVERIFY_LOG_ERROR("invalid index %{public}d", index); return false; } long long getDataLast = static_cast(position) + static_cast(index) + static_cast(dataLen); if (getDataLast > static_cast(limit)) { - HAPVERIFY_LOG_ERROR(LABEL, "position %{public}d, index %{public}d, limit %{public}d", + HAPVERIFY_LOG_ERROR("position %{public}d, index %{public}d, limit %{public}d", position, index, limit); return false; } @@ -106,7 +106,7 @@ bool HapByteBuffer::CheckInputForGettingData(int32_t index, int32_t dataLen) bool HapByteBuffer::GetInt64(long long& value) { if (!GetInt64(0, value)) { - HAPVERIFY_LOG_ERROR(LABEL, "GetInt64 failed"); + HAPVERIFY_LOG_ERROR("GetInt64 failed"); return false; } position += sizeof(long long); @@ -116,12 +116,12 @@ bool HapByteBuffer::GetInt64(long long& value) bool HapByteBuffer::GetInt64(int32_t index, long long& value) { if (!CheckInputForGettingData(index, sizeof(long long))) { - HAPVERIFY_LOG_ERROR(LABEL, "Failed to get Int64"); + HAPVERIFY_LOG_ERROR("Failed to get Int64"); return false; } if (memcpy_s(&value, sizeof(value), (buffer.get() + position + index), sizeof(long long)) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); return false; } return true; @@ -140,7 +140,7 @@ const char* HapByteBuffer::GetBufferPtr() const bool HapByteBuffer::GetInt32(int32_t& value) { if (!GetInt32(0, value)) { - HAPVERIFY_LOG_ERROR(LABEL, "GetInt32 failed"); + HAPVERIFY_LOG_ERROR("GetInt32 failed"); return false; } position += sizeof(int32_t); @@ -150,12 +150,12 @@ bool HapByteBuffer::GetInt32(int32_t& value) bool HapByteBuffer::GetInt32(int32_t index, int32_t& value) { if (!CheckInputForGettingData(index, sizeof(int32_t))) { - HAPVERIFY_LOG_ERROR(LABEL, "Failed to get Int32"); + HAPVERIFY_LOG_ERROR("Failed to get Int32"); return false; } if (memcpy_s(&value, sizeof(value), (buffer.get() + position + index), sizeof(int32_t)) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); return false; } return true; @@ -164,12 +164,12 @@ bool HapByteBuffer::GetInt32(int32_t index, int32_t& value) bool HapByteBuffer::GetUInt32(int32_t index, uint32_t& value) { if (!CheckInputForGettingData(index, sizeof(uint32_t))) { - HAPVERIFY_LOG_ERROR(LABEL, "Failed to get UInt32"); + HAPVERIFY_LOG_ERROR("Failed to get UInt32"); return false; } if (memcpy_s(&value, sizeof(value), (buffer.get() + position + index), sizeof(uint32_t)) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); return false; } return true; @@ -178,7 +178,7 @@ bool HapByteBuffer::GetUInt32(int32_t index, uint32_t& value) bool HapByteBuffer::GetUInt32(uint32_t& value) { if (!GetUInt32(0, value)) { - HAPVERIFY_LOG_ERROR(LABEL, "GetUInt32 failed"); + HAPVERIFY_LOG_ERROR("GetUInt32 failed"); return false; } position += sizeof(uint32_t); @@ -188,12 +188,12 @@ bool HapByteBuffer::GetUInt32(uint32_t& value) bool HapByteBuffer::GetUInt16(int32_t index, uint16_t& value) { if (!CheckInputForGettingData(index, sizeof(uint16_t))) { - HAPVERIFY_LOG_ERROR(LABEL, "Failed to get UInt16"); + HAPVERIFY_LOG_ERROR("Failed to get UInt16"); return false; } if (memcpy_s(&value, sizeof(value), (buffer.get() + position + index), sizeof(uint16_t)) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); return false; } return true; @@ -203,7 +203,7 @@ void HapByteBuffer::PutInt32(int32_t offset, int32_t value) { if (buffer != nullptr && offset >= 0 && limit - offset >= static_cast(sizeof(value))) { if (memcpy_s((buffer.get() + offset), (limit - offset), &value, sizeof(value)) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); } } } @@ -212,7 +212,7 @@ void HapByteBuffer::PutByte(int32_t offset, char value) { if (buffer != nullptr && offset >= 0 && limit - offset >= static_cast(sizeof(value))) { if (memcpy_s((buffer.get() + offset), (limit - offset), (&value), sizeof(value)) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); } } } @@ -221,7 +221,7 @@ void HapByteBuffer::PutData(int32_t offset, const char data[], int32_t len) { if (buffer != nullptr && data != nullptr && offset >= 0 && len > 0 && (limit - offset) >= len) { if (memcpy_s((buffer.get() + offset), (limit - offset), data, len) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); } } } @@ -236,14 +236,14 @@ void HapByteBuffer::SetPosition(int32_t pos) void HapByteBuffer::Slice() { if (position >= capacity || limit > capacity || position >= limit || buffer == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "position %{public}d capacity %{public}d limit %{public}d error", + HAPVERIFY_LOG_ERROR("position %{public}d capacity %{public}d limit %{public}d error", position, capacity, limit); return; } int32_t newCapacity = limit - position; std::unique_ptr newBuffer = std::make_unique(newCapacity); if (memcpy_s(newBuffer.get(), newCapacity, (buffer.get() + position), (limit - position)) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); return; } buffer.reset(newBuffer.release()); @@ -291,13 +291,13 @@ bool HapByteBuffer::IsEqual(const HapByteBuffer& other) return true; } if (capacity != other.GetCapacity() || other.GetBufferPtr() == nullptr || buffer == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid input"); + HAPVERIFY_LOG_ERROR("invalid input"); return false; } const char* otherBuffer = other.GetBufferPtr(); for (int32_t i = 0; i < capacity; i++) { if (buffer[i] != otherBuffer[i]) { - HAPVERIFY_LOG_ERROR(LABEL, "diff value[%{public}d]: %{public}x %{public}x", + HAPVERIFY_LOG_ERROR("diff value[%{public}d]: %{public}x %{public}x", i, buffer[i], otherBuffer[i]); return false; } @@ -308,12 +308,12 @@ bool HapByteBuffer::IsEqual(const HapByteBuffer& other) bool HapByteBuffer::IsEqual(const std::string& other) { if (capacity != static_cast(other.size()) || buffer == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid input"); + HAPVERIFY_LOG_ERROR("invalid input"); return false; } for (int32_t i = 0; i < capacity; i++) { if (buffer[i] != other[i]) { - HAPVERIFY_LOG_ERROR(LABEL, "diff value[%{public}d]: %{public}x %{public}x", + HAPVERIFY_LOG_ERROR("diff value[%{public}d]: %{public}x %{public}x", i, buffer[i], other[i]); return false; } diff --git a/interfaces/innerkits/appverify/src/common/hap_file_data_source.cpp b/interfaces/innerkits/appverify/src/common/hap_file_data_source.cpp index e9d75365b06fe3eb05fbd378bba79396b5e0df8b..a74f25185673c399e8060a408c46983b51dca072 100644 --- a/interfaces/innerkits/appverify/src/common/hap_file_data_source.cpp +++ b/interfaces/innerkits/appverify/src/common/hap_file_data_source.cpp @@ -48,7 +48,7 @@ void HapFileDataSource::Reset() bool HapFileDataSource::ReadDataAndDigestUpdate(const DigestParameter& digestParam, int32_t chunkSize) { if (!hapFileRandomAccess.ReadFileFromOffsetAndDigestUpdate(digestParam, chunkSize, fileOffset + sourcePosition)) { - HAPVERIFY_LOG_ERROR(LABEL, "ReadFileFromOffsetAndDigestUpdate failed"); + HAPVERIFY_LOG_ERROR("ReadFileFromOffsetAndDigestUpdate failed"); return false; } sourcePosition += chunkSize; diff --git a/interfaces/innerkits/appverify/src/common/random_access_file.cpp b/interfaces/innerkits/appverify/src/common/random_access_file.cpp index 5f6a3c079d9793df482711747592c7aae86e7527..7ad4008248a7266f812edd0b73f959b82a34cb49 100644 --- a/interfaces/innerkits/appverify/src/common/random_access_file.cpp +++ b/interfaces/innerkits/appverify/src/common/random_access_file.cpp @@ -51,13 +51,13 @@ bool RandomAccessFile::Init(const std::string& filePath) } if (memoryPageSize <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "getting pagesize failed: %{public}d", memoryPageSize); + HAPVERIFY_LOG_ERROR("getting pagesize failed: %{public}d", memoryPageSize); return false; } fileLength = lseek(fd, 0, SEEK_END); if (fileLength < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "getting fileLength failed: %{public}lld", fileLength); + HAPVERIFY_LOG_ERROR("getting fileLength failed: %{public}lld", fileLength); return false; } return true; @@ -81,7 +81,7 @@ bool RandomAccessFile::CheckLittleEndian() long long RandomAccessFile::DoMMap(int32_t bufCapacity, long long offset, MmapInfo& mmapInfo) { if (!CheckLittleEndian()) { - HAPVERIFY_LOG_ERROR(LABEL, "CheckLittleEndian: failed"); + HAPVERIFY_LOG_ERROR("CheckLittleEndian: failed"); return MMAP_FAILED; } mmapInfo.mapAddr = reinterpret_cast(MAP_FAILED); @@ -97,7 +97,7 @@ long long RandomAccessFile::DoMMap(int32_t bufCapacity, long long offset, MmapIn mmapInfo.mapAddr = reinterpret_cast(mmap(nullptr, mmapInfo.mmapSize, PROT_READ, MAP_SHARED | MAP_POPULATE, fd, mmapInfo.mmapPosition)); if (mmapInfo.mapAddr == MAP_FAILED) { - HAPVERIFY_LOG_ERROR(LABEL, "MAP_FAILED: %{public}d", errno); + HAPVERIFY_LOG_ERROR("MAP_FAILED: %{public}d", errno); return MMAP_FAILED; } return 0; @@ -148,7 +148,7 @@ bool RandomAccessFile::ReadFileFromOffsetAndDigestUpdate(const DigestParameter& MmapInfo mmapInfo; long long ret = DoMMap(chunkSize, offset, mmapInfo); if (ret < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "DoMMap failed: %{public}lld", ret); + HAPVERIFY_LOG_ERROR("DoMMap failed: %{public}lld", ret); return false; } diff --git a/interfaces/innerkits/appverify/src/init/device_type_manager.cpp b/interfaces/innerkits/appverify/src/init/device_type_manager.cpp index 4693c066a8e9c347549e622a32161751146d156d..e8d1baf0981d44c02abfdc9e60a120453197d773 100644 --- a/interfaces/innerkits/appverify/src/init/device_type_manager.cpp +++ b/interfaces/innerkits/appverify/src/init/device_type_manager.cpp @@ -52,7 +52,7 @@ bool DeviceTypeManager::GetDeviceType() const bool DeviceTypeManager::GetDeviceTypeInfo() { bool currentDeviceType = GetDeviceType(); - HAPVERIFY_LOG_DEBUG(LABEL, "current device is type: %{public}d", static_cast(currentDeviceType)); + HAPVERIFY_LOG_DEBUG("current device is type: %{public}d", static_cast(currentDeviceType)); if (currentDeviceType == deviceType) { return currentDeviceType; @@ -65,7 +65,7 @@ bool DeviceTypeManager::GetDeviceTypeInfo() /* Device type change from commercial to debugging */ bool ret = rootCertsObj.EnableDebug() && trustedAppSourceManager.EnableDebug(); if (!ret) { - HAPVERIFY_LOG_ERROR(LABEL, "Enable debug failed"); + HAPVERIFY_LOG_ERROR("Enable debug failed"); rootCertsObj.DisableDebug(); trustedAppSourceManager.DisableDebug(); getDeviceTypeMtx.unlock(); diff --git a/interfaces/innerkits/appverify/src/init/hap_crl_manager.cpp b/interfaces/innerkits/appverify/src/init/hap_crl_manager.cpp index c80f0d0a83dc3b5008e1af7cf99c3150372e9f04..2640e9b0296c064b6ee725e937e1972269cff890 100644 --- a/interfaces/innerkits/appverify/src/init/hap_crl_manager.cpp +++ b/interfaces/innerkits/appverify/src/init/hap_crl_manager.cpp @@ -73,30 +73,30 @@ bool HapCrlManager::ParseCrls(HapByteBuffer& crlsBuffer) { uint32_t numOfCrl; if (!crlsBuffer.GetUInt32(0, numOfCrl)) { - HAPVERIFY_LOG_ERROR(LABEL, "get numOfCrl failed"); + HAPVERIFY_LOG_ERROR("get numOfCrl failed"); return false; } int32_t hasUsed = static_cast(sizeof(numOfCrl)); crlsBuffer.SetPosition(hasUsed); - HAPVERIFY_LOG_DEBUG(LABEL, "total crl num: %{public}u", numOfCrl); + HAPVERIFY_LOG_DEBUG("total crl num: %{public}u", numOfCrl); while (numOfCrl && hasUsed <= crlsBuffer.GetCapacity()) { int32_t crlLen; if (!crlsBuffer.GetInt32(crlLen)) { - HAPVERIFY_LOG_ERROR(LABEL, "get crlLen failed"); + HAPVERIFY_LOG_ERROR("get crlLen failed"); return false; } hasUsed += static_cast(sizeof(crlLen)); X509_CRL* crl = HapCertVerifyOpensslUtils::GetX509CrlFromDerBuffer(crlsBuffer, hasUsed, crlLen); if (crl == nullptr) { - HAPVERIFY_LOG_WARN(LABEL, "crl file is destroyed"); + HAPVERIFY_LOG_WARN("crl file is destroyed"); return false; } std::string crlIssuer; if (!HapCertVerifyOpensslUtils::GetIssuerFromX509Crl(crl, crlIssuer)) { X509_CRL_free(crl); - HAPVERIFY_LOG_WARN(LABEL, "GetIssuerFromX509Crl failed"); + HAPVERIFY_LOG_WARN("GetIssuerFromX509Crl failed"); return false; } @@ -107,7 +107,7 @@ bool HapCrlManager::ParseCrls(HapByteBuffer& crlsBuffer) hasUsed += crlLen; crlsBuffer.SetPosition(hasUsed); - HAPVERIFY_LOG_INFO(LABEL, "get %{public}ust crl's Issuer: %{public}s", numOfCrl, crlIssuer.c_str()); + HAPVERIFY_LOG_INFO("get %{public}ust crl's Issuer: %{public}s", numOfCrl, crlIssuer.c_str()); numOfCrl--; } return true; @@ -119,13 +119,13 @@ bool HapCrlManager::ReadCrls(HapByteBuffer& crlsBuffer) crlRandomAccess.Init(HAP_CRL_FILE_PATH); long long fileLen = crlRandomAccess.GetLength(); if (fileLen <= 0) { - HAPVERIFY_LOG_WARN(LABEL, "crl fileLen: %{public}lld", fileLen); + HAPVERIFY_LOG_WARN("crl fileLen: %{public}lld", fileLen); return true; } crlsBuffer.SetCapacity(fileLen); long long readLen = crlRandomAccess.ReadFileFullyFromOffset(crlsBuffer, 0); if (readLen != fileLen) { - HAPVERIFY_LOG_ERROR(LABEL, "read file len: %{public}lld is not same as %{public}lld", readLen, fileLen); + HAPVERIFY_LOG_ERROR("read file len: %{public}lld is not same as %{public}lld", readLen, fileLen); return false; } return true; @@ -136,7 +136,7 @@ void HapCrlManager::WriteCrlsToFile() crlMtx.lock(); std::ofstream crlFile(HAP_CRL_FILE_PATH, std::ofstream::out | std::ofstream::trunc | std::ofstream::binary); if (!crlFile.is_open()) { - HAPVERIFY_LOG_ERROR(LABEL, "open %{public}s failed", HAP_CRL_FILE_PATH.c_str()); + HAPVERIFY_LOG_ERROR("open %{public}s failed", HAP_CRL_FILE_PATH.c_str()); crlMtx.unlock(); return; } @@ -145,7 +145,7 @@ void HapCrlManager::WriteCrlsToFile() for (auto crlPair : crlsMap) { HapCertVerifyOpensslUtils::WriteX509CrlToStream(crlFile, crlPair.second); } - HAPVERIFY_LOG_INFO(LABEL, "Write %{public}u crls to file done", numOfCrl); + HAPVERIFY_LOG_INFO("Write %{public}u crls to file done", numOfCrl); crlFile.close(); crlMtx.unlock(); } @@ -173,7 +173,7 @@ void HapCrlManager::UpdateCrlByIssuer(const std::string& issuer, X509_CRL* crl) bool HapCrlManager::CrlCheck(X509* cert, X509_CRL* targetCrl, Pkcs7Context& pkcs7Context) { if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid input"); + HAPVERIFY_LOG_ERROR("invalid input"); return false; } @@ -181,7 +181,7 @@ bool HapCrlManager::CrlCheck(X509* cert, X509_CRL* targetCrl, Pkcs7Context& pkcs /* crl in package compare with local crl, and decide which one to use */ targetCrl = GetFinalCrl(targetCrl, pkcs7Context); if (targetCrl == nullptr) { - HAPVERIFY_LOG_INFO(LABEL, "no crl"); + HAPVERIFY_LOG_INFO("no crl"); crlMtx.unlock(); return true; } @@ -191,7 +191,7 @@ bool HapCrlManager::CrlCheck(X509* cert, X509_CRL* targetCrl, Pkcs7Context& pkcs std::string certSuject; HapCertVerifyOpensslUtils::GetSerialNumberFromX509(cert, certNumber); HapCertVerifyOpensslUtils::GetSubjectFromX509(cert, certSuject); - HAPVERIFY_LOG_ERROR(LABEL, "cert(issuer: %{public}s, subject: %{public}s, number:%{public}lld) is revoked", + HAPVERIFY_LOG_ERROR("cert(issuer: %{public}s, subject: %{public}s, number:%{public}lld) is revoked", pkcs7Context.certIssuer.c_str(), certSuject.c_str(), certNumber); crlMtx.unlock(); return false; @@ -220,7 +220,7 @@ X509_CRL* HapCrlManager::GetFinalCrl(X509_CRL* crlInPackage, Pkcs7Context& pkcs7 const ASN1_TIME* localCrlUpdateTime = X509_CRL_get0_lastUpdate(localCrl); const ASN1_TIME* packageCrlUpdateTime = X509_CRL_get0_lastUpdate(crlInPackage); if (localCrlUpdateTime == nullptr || packageCrlUpdateTime == nullptr) { - HAPVERIFY_LOG_INFO(LABEL, "crl no update time"); + HAPVERIFY_LOG_INFO("crl no update time"); return nullptr; } if (ASN1_TIME_compare(localCrlUpdateTime, packageCrlUpdateTime) >= 0) { diff --git a/interfaces/innerkits/appverify/src/init/trusted_root_ca.cpp b/interfaces/innerkits/appverify/src/init/trusted_root_ca.cpp index a5c08be771628484437f9f8cb7b88bc808c68cff..90bebfe8fe061bdc2a18c01b57271041bfa35945 100644 --- a/interfaces/innerkits/appverify/src/init/trusted_root_ca.cpp +++ b/interfaces/innerkits/appverify/src/init/trusted_root_ca.cpp @@ -56,7 +56,7 @@ bool TrustedRootCa::EnableDebug() isDebug = GetTrustedRootCAFromJson(rootCertsForTest, TRUSTED_ROOT_CA_TEST_FILE_PATH); if (isDebug) { - HAPVERIFY_LOG_INFO(LABEL, "parse root certs test success, certs num: %{public}zu", rootCertsForTest.size()); + HAPVERIFY_LOG_INFO("parse root certs test success, certs num: %{public}zu", rootCertsForTest.size()); } return isDebug; } @@ -83,7 +83,7 @@ bool TrustedRootCa::Init() isInit = GetTrustedRootCAFromJson(rootCerts, TRUSTED_ROOT_CA_FILE_PATH); if (isInit) { - HAPVERIFY_LOG_INFO(LABEL, "parse root certs success, certs num: %{public}zu", rootCerts.size()); + HAPVERIFY_LOG_INFO("parse root certs success, certs num: %{public}zu", rootCerts.size()); } return isInit; } @@ -102,7 +102,7 @@ bool TrustedRootCa::GetTrustedRootCAFromJson(StringCertMap& rootCertMap, const s nlohmann::json trustedRootCAJson; std::string errorInfo; if (!JsonParserUtils::ReadTrustedRootCAFromJson(trustedRootCAJson, filePath, errorInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "get jsonObj from %{public}s failed, because %{public}s", + HAPVERIFY_LOG_ERROR("get jsonObj from %{public}s failed, because %{public}s", filePath.c_str(), errorInfo.c_str()); return false; } @@ -112,7 +112,7 @@ bool TrustedRootCa::GetTrustedRootCAFromJson(StringCertMap& rootCertMap, const s for (auto jsonPair : trustedRootCAJsonMap) { X509* cert = HapCertVerifyOpensslUtils::GetX509CertFromPemString(jsonPair.second); if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "GetX509CertFromPemString failed, key: %{public}s value: %{public}s", + HAPVERIFY_LOG_ERROR("GetX509CertFromPemString failed, key: %{public}s value: %{public}s", jsonPair.first.c_str(), jsonPair.second.c_str()); return false; } @@ -120,7 +120,7 @@ bool TrustedRootCa::GetTrustedRootCAFromJson(StringCertMap& rootCertMap, const s } if (rootCertMap.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "no root cert"); + HAPVERIFY_LOG_ERROR("no root cert"); return false; } return true; @@ -138,7 +138,7 @@ X509* TrustedRootCa::FindMatchedRoot(X509* caCert) } if (isDebug) { - HAPVERIFY_LOG_INFO(LABEL, "try to match with test root"); + HAPVERIFY_LOG_INFO("try to match with test root"); root = FindMatchedRoot(rootCertsForTest, caCert); } return root; diff --git a/interfaces/innerkits/appverify/src/init/trusted_source_manager.cpp b/interfaces/innerkits/appverify/src/init/trusted_source_manager.cpp index 5acab9570286cab83aa62a626be825fa6898131e..d8e8dc4ed11c7963a218a80d84419746b19bfa34 100644 --- a/interfaces/innerkits/appverify/src/init/trusted_source_manager.cpp +++ b/interfaces/innerkits/appverify/src/init/trusted_source_manager.cpp @@ -65,7 +65,7 @@ bool TrustedSourceManager::EnableDebug() isDebug = GetAppTrustedSources(appTrustedSourcesForTest, versionForTest, releaseTimeForTest, APP_TRUSTED_SOURCE_TEST_FILE_PATH); if (isDebug) { - HAPVERIFY_LOG_INFO(LABEL, "trusted app source test version: %{public}s, releaseTime: %{public}s, Size:" + HAPVERIFY_LOG_INFO("trusted app source test version: %{public}s, releaseTime: %{public}s, Size:" " %{public}zu", versionForTest.c_str(), releaseTimeForTest.c_str(), appTrustedSourcesForTest.size()); } return isDebug; @@ -85,7 +85,7 @@ bool TrustedSourceManager::Init() isInit = GetAppTrustedSources(appTrustedSources, version, releaseTime, APP_TRUSTED_SOURCE_FILE_PATH); if (isInit) { - HAPVERIFY_LOG_INFO(LABEL, "trusted app source version: %{public}s, releaseTime: %{public}s, Size:" + HAPVERIFY_LOG_INFO("trusted app source version: %{public}s, releaseTime: %{public}s, Size:" " %{public}zu", version.c_str(), releaseTime.c_str(), appTrustedSources.size()); } return isInit; @@ -103,30 +103,30 @@ bool TrustedSourceManager::GetAppTrustedSources(SourceInfoVec& trustedAppSources nlohmann::json trustedSourceJson; std::string errorInfo; if (!JsonParserUtils::ReadTrustedRootCAFromJson(trustedSourceJson, filePath, errorInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "get jsonObj from %{public}s failed, because %{public}s", + HAPVERIFY_LOG_ERROR("get jsonObj from %{public}s failed, because %{public}s", filePath.c_str(), errorInfo.c_str()); return false; } if (!JsonParserUtils::GetJsonString(trustedSourceJson, KEY_OF_APP_TRUSTED_SOURCE_VERSION, souucesVersion)) { - HAPVERIFY_LOG_ERROR(LABEL, "get version failed"); + HAPVERIFY_LOG_ERROR("get version failed"); return false; } if (!JsonParserUtils::GetJsonString(trustedSourceJson, KEY_OF_APP_TRUSTED_SOURCE_RELEASETIME, souucesReleaseTime)) { - HAPVERIFY_LOG_ERROR(LABEL, "get releaseTime failed"); + HAPVERIFY_LOG_ERROR("get releaseTime failed"); return false; } JsonObjVec trustedAppSourceJson; if (!JsonParserUtils::ParseJsonToObjVec(trustedSourceJson, KEY_OF_APP_TRUSTED_SOURCE, trustedAppSourceJson)) { - HAPVERIFY_LOG_ERROR(LABEL, "get JsonObjVec failed"); + HAPVERIFY_LOG_ERROR("get JsonObjVec failed"); return false; } if (!ParseTrustedAppSourceJson(trustedAppSources, trustedAppSourceJson)) { - HAPVERIFY_LOG_ERROR(LABEL, "parse JsonObjVec failed"); + HAPVERIFY_LOG_ERROR("parse JsonObjVec failed"); return false; } if (trustedAppSources.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "no app trusted source"); + HAPVERIFY_LOG_ERROR("no app trusted source"); return false; } return true; @@ -138,38 +138,38 @@ bool TrustedSourceManager::ParseTrustedAppSourceJson(SourceInfoVec& trustedAppSo for (auto appSource : trustedAppSourceJson) { HapAppSourceInfo hapAppSource; if (!JsonParserUtils::GetJsonString(appSource, KEY_OF_SOURCE_NAME, hapAppSource.sourceName)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get sourceName Failed"); + HAPVERIFY_LOG_ERROR("Get sourceName Failed"); return false; } hapAppSource.source = GetTrustedSource(hapAppSource.sourceName); if (!JsonParserUtils::GetJsonString(appSource, KEY_OF_APP_SIGNING_CERT, hapAppSource.appSigningCert)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get appSigningCert Failed"); + HAPVERIFY_LOG_ERROR("Get appSigningCert Failed"); return false; } if (!JsonParserUtils::GetJsonString(appSource, KEY_OF_PROFILE_SIGNING_CERTIFICATE, hapAppSource.profileSigningCertificate)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get profileSigningCertificate Failed"); + HAPVERIFY_LOG_ERROR("Get profileSigningCertificate Failed"); return false; } if (!JsonParserUtils::GetJsonString(appSource, KEY_OF_PROFILE_DEBUG_SIGNING_CERTIFICATE, hapAppSource.profileDebugSigningCertificate)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get profileDebugSigningCertificate Failed"); + HAPVERIFY_LOG_ERROR("Get profileDebugSigningCertificate Failed"); return false; } if (!JsonParserUtils::GetJsonString(appSource, KEY_OF_ISSUER, hapAppSource.issuer)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get issuer Failed"); + HAPVERIFY_LOG_ERROR("Get issuer Failed"); return false; } if (!JsonParserUtils::GetJsonInt(appSource, KEY_OF_MAX_CERTS_PATH, hapAppSource.maxCertsPath)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get maxCertsPath Failed"); + HAPVERIFY_LOG_ERROR("Get maxCertsPath Failed"); return false; } if (!JsonParserUtils::GetJsonStringVec(appSource, KEY_OF_CRITIALCAL_CERT_EXTENSION, hapAppSource.critialcalCertExtension)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get critialcalCertExtension Failed"); + HAPVERIFY_LOG_ERROR("Get critialcalCertExtension Failed"); return false; } - HAPVERIFY_LOG_INFO(LABEL, "trusted app source: %{public}s", EncapTrustedAppSourceString(hapAppSource).c_str()); + HAPVERIFY_LOG_INFO("trusted app source: %{public}s", EncapTrustedAppSourceString(hapAppSource).c_str()); trustedAppSources.push_back(hapAppSource); } return true; diff --git a/interfaces/innerkits/appverify/src/init/trusted_ticket_manager.cpp b/interfaces/innerkits/appverify/src/init/trusted_ticket_manager.cpp index 97fddc838c745b38920d204ad9bb7e60f8f04287..f804c9db3e412ae31ed79b5d338f00569b31c0e3 100644 --- a/interfaces/innerkits/appverify/src/init/trusted_ticket_manager.cpp +++ b/interfaces/innerkits/appverify/src/init/trusted_ticket_manager.cpp @@ -58,7 +58,7 @@ bool TrustedTicketManager::Init() isInit = GetTicketTrustedSources(TicketTrustedSources, version, releaseTime, TICKET_TRUSTED_SOURCE_FILE_PATH); if (isInit) { - HAPVERIFY_LOG_INFO(LABEL, "trusted ticket source version: %{public}s, releaseTime: %{public}s, Size:" + HAPVERIFY_LOG_INFO("trusted ticket source version: %{public}s, releaseTime: %{public}s, Size:" " %{public}zu", version.c_str(), releaseTime.c_str(), TicketTrustedSources.size()); } return isInit; @@ -76,30 +76,30 @@ bool TrustedTicketManager::GetTicketTrustedSources(TicketSourceInfoVec& trustedT nlohmann::json trustedSourceJson; std::string errorInfo; if (!JsonParserUtils::ReadTrustedRootCAFromJson(trustedSourceJson, filePath, errorInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "get jsonObj from %{public}s failed, because %{public}s", + HAPVERIFY_LOG_ERROR("get jsonObj from %{public}s failed, because %{public}s", filePath.c_str(), errorInfo.c_str()); return false; } if (!JsonParserUtils::GetJsonString(trustedSourceJson, KEY_OF_TICKET_TRUSTED_SOURCE_VERSION, sourcesVersion)) { - HAPVERIFY_LOG_ERROR(LABEL, "get version failed"); + HAPVERIFY_LOG_ERROR("get version failed"); return false; } if (!JsonParserUtils::GetJsonString(trustedSourceJson, KEY_OF_TICKET_TRUSTED_SOURCE_RELEASETIME, sourcesReleaseTime)) { - HAPVERIFY_LOG_ERROR(LABEL, "get releaseTime failed"); + HAPVERIFY_LOG_ERROR("get releaseTime failed"); return false; } JsonObjVec trustedTicketJson; if (!JsonParserUtils::ParseJsonToObjVec(trustedSourceJson, KEY_OF_TICKET_TRUSTED_SOURCE, trustedTicketJson)) { - HAPVERIFY_LOG_ERROR(LABEL, "get JsonObjVec failed"); + HAPVERIFY_LOG_ERROR("get JsonObjVec failed"); return false; } if (!ParseTrustedTicketSourceJson(trustedTicketSources, trustedTicketJson)) { - HAPVERIFY_LOG_ERROR(LABEL, "parse JsonObjVec failed"); + HAPVERIFY_LOG_ERROR("parse JsonObjVec failed"); return false; } if (trustedTicketSources.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "no ticket trusted source"); + HAPVERIFY_LOG_ERROR("no ticket trusted source"); return false; } return true; @@ -111,29 +111,29 @@ bool TrustedTicketManager::ParseTrustedTicketSourceJson(TicketSourceInfoVec& tru for (auto TicketSource : trustedTicketJson) { HapTicketSourceInfo hapTicketSource; if (!JsonParserUtils::GetJsonString(TicketSource, KEY_OF_SOURCE_NAME, hapTicketSource.sourceName)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get sourceName Failed"); + HAPVERIFY_LOG_ERROR("Get sourceName Failed"); return false; } hapTicketSource.source = OTHER_TRUSTED_SOURCE; if (!JsonParserUtils::GetJsonString(TicketSource, KEY_OF_TICKET_SIGNING_CERT, hapTicketSource.ticketSigningCert)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get ticketSigningCert Failed"); + HAPVERIFY_LOG_ERROR("Get ticketSigningCert Failed"); return false; } if (!JsonParserUtils::GetJsonString(TicketSource, KEY_OF_ISSUER, hapTicketSource.issuer)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get issuer Failed"); + HAPVERIFY_LOG_ERROR("Get issuer Failed"); return false; } if (!JsonParserUtils::GetJsonInt(TicketSource, KEY_OF_MAX_CERTS_PATH, hapTicketSource.maxCertsPath)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get maxCertsPath Failed"); + HAPVERIFY_LOG_ERROR("Get maxCertsPath Failed"); return false; } if (!JsonParserUtils::GetJsonStringVec(TicketSource, KEY_OF_CRITIALCAL_CERT_EXTENSION, hapTicketSource.critialcalCertExtension)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get critialcalCertExtension Failed"); + HAPVERIFY_LOG_ERROR("Get critialcalCertExtension Failed"); return false; } - HAPVERIFY_LOG_INFO(LABEL, "trusted ticket source: %{public}s", + HAPVERIFY_LOG_INFO("trusted ticket source: %{public}s", EncapTrustedTicketSourceString(hapTicketSource).c_str()); trustedTicketSources.push_back(hapTicketSource); } diff --git a/interfaces/innerkits/appverify/src/provision/provision_info.cpp b/interfaces/innerkits/appverify/src/provision/provision_info.cpp index 739d563adf66e82aae9a758c562d943572463e6c..5ab00d2fbe25255b113c8f5a4cdc12d8c1d324cb 100644 --- a/interfaces/innerkits/appverify/src/provision/provision_info.cpp +++ b/interfaces/innerkits/appverify/src/provision/provision_info.cpp @@ -67,7 +67,7 @@ ProvisionInfo &ProvisionInfo::operator=(const ProvisionInfo &info) return *this; } if (memcpy_s(profileBlockData, info.profileBlockLength, originalProfile, info.profileBlockLength) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); } } this->appServiceCapabilities = info.appServiceCapabilities; diff --git a/interfaces/innerkits/appverify/src/provision/provision_verify.cpp b/interfaces/innerkits/appverify/src/provision/provision_verify.cpp index f2f2e8ca2d6204109dcb9ad5dc30f9dc3cb7c656..2f4a20fa110b4266b726ede9cca1908519f0ed54 100644 --- a/interfaces/innerkits/appverify/src/provision/provision_verify.cpp +++ b/interfaces/innerkits/appverify/src/provision/provision_verify.cpp @@ -239,13 +239,13 @@ void from_json(const json& obj, ProvisionInfo& out) #define RETURN_IF_STRING_IS_EMPTY(str, msg) \ if (str.empty()) { \ - HAPVERIFY_LOG_ERROR(LABEL, msg); \ + HAPVERIFY_LOG_ERROR(msg); \ return PROVISION_INVALID; \ } #define RETURN_IF_INT_IS_NON_POSITIVE(num, msg) \ if (num <= 0) { \ - HAPVERIFY_LOG_ERROR(LABEL, msg); \ + HAPVERIFY_LOG_ERROR(msg); \ return PROVISION_INVALID; \ } @@ -253,7 +253,7 @@ AppProvisionVerifyResult ParseProvision(const string& appProvision, ProvisionInf { json obj = json::parse(appProvision, nullptr, false); if (obj.is_discarded() || (!obj.is_structured())) { - HAPVERIFY_LOG_ERROR(LABEL, "Parsing appProvision failed. json: %{public}s", appProvision.c_str()); + HAPVERIFY_LOG_ERROR("Parsing appProvision failed. json: %{public}s", appProvision.c_str()); return PROVISION_INVALID; } obj.get_to(info); @@ -270,7 +270,7 @@ AppProvisionVerifyResult ParseProvision(const string& appProvision, ProvisionInf } RETURN_IF_STRING_IS_EMPTY(info.bundleInfo.bundleName, "Tag bundle-name is empty.") if (info.bundleInfo.bundleName == GENERIC_BUNDLE_NAME) { - HAPVERIFY_LOG_DEBUG(LABEL, "generic package name: %{public}s, is used.", GENERIC_BUNDLE_NAME.c_str()); + HAPVERIFY_LOG_DEBUG("generic package name: %{public}s, is used.", GENERIC_BUNDLE_NAME.c_str()); } if (info.versionCode >= VERSION_CODE_TWO) { RETURN_IF_STRING_IS_EMPTY(info.bundleInfo.apl, "Tag apl is empty."); @@ -286,10 +286,10 @@ inline bool CheckDeviceID(const std::vector& deviceIds, const strin if (iter == deviceIds.end()) { DeviceTypeManager& deviceTypeManager = DeviceTypeManager::GetInstance(); if (!deviceTypeManager.GetDeviceTypeInfo()) { - HAPVERIFY_LOG_ERROR(LABEL, "current device is not authorized"); + HAPVERIFY_LOG_ERROR("current device is not authorized"); return false; } - HAPVERIFY_LOG_INFO(LABEL, "current device is a debug device"); + HAPVERIFY_LOG_INFO("current device is a debug device"); } return true; } @@ -298,15 +298,15 @@ AppProvisionVerifyResult CheckDeviceID(ProvisionInfo& info) { // Checking device ids if (info.debugInfo.deviceIds.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "device-id list is empty."); + HAPVERIFY_LOG_ERROR("device-id list is empty."); return PROVISION_DEVICE_UNAUTHORIZED; } - HAPVERIFY_LOG_DEBUG(LABEL, "number of device ids in list: %{public}u", + HAPVERIFY_LOG_DEBUG("number of device ids in list: %{public}u", static_cast(info.debugInfo.deviceIds.size())); if (info.debugInfo.deviceIdType != VALUE_DEVICE_ID_TYPE_UDID) { - HAPVERIFY_LOG_ERROR(LABEL, "type of device ID is not supported."); + HAPVERIFY_LOG_ERROR("type of device ID is not supported."); return PROVISION_UNSUPPORTED_DEVICE_TYPE; } @@ -314,20 +314,20 @@ AppProvisionVerifyResult CheckDeviceID(ProvisionInfo& info) #ifndef STANDARD_SYSTEM int32_t ret = OHOS::AccountSA::OhosAccountKits::GetInstance().GetUdid(deviceId); if (ret != 0) { - HAPVERIFY_LOG_ERROR(LABEL, "obtaining current device id failed (%{public}d).", ret); + HAPVERIFY_LOG_ERROR("obtaining current device id failed (%{public}d).", ret); return PROVISION_DEVICE_UNAUTHORIZED; } #else char udid[DEV_UUID_LEN] = {0}; int32_t ret = GetDevUdid(udid, sizeof(udid)); if (ret != EC_SUCCESS) { - HAPVERIFY_LOG_ERROR(LABEL, "obtaining current device id failed (%{public}d).", static_cast(ret)); + HAPVERIFY_LOG_ERROR("obtaining current device id failed (%{public}d).", static_cast(ret)); return PROVISION_DEVICE_UNAUTHORIZED; } deviceId = std::string(udid, sizeof(udid) - 1); #endif // STANDARD_SYSTEM if (deviceId.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "device-id of current device is empty."); + HAPVERIFY_LOG_ERROR("device-id of current device is empty."); return PROVISION_DEVICE_UNAUTHORIZED; } @@ -344,13 +344,13 @@ void SetRdDevice(bool isRdDevice) AppProvisionVerifyResult ParseAndVerify(const string& appProvision, ProvisionInfo& info) { - HAPVERIFY_LOG_DEBUG(LABEL, "Enter HarmonyAppProvision Verify"); + HAPVERIFY_LOG_DEBUG("Enter HarmonyAppProvision Verify"); AppProvisionVerifyResult ret = ParseProvision(appProvision, info); if (ret != PROVISION_OK) { return ret; } #ifndef X86_EMULATOR_MODE - HAPVERIFY_LOG_DEBUG(LABEL, "rd device status is %{public}d", g_isRdDevice); + HAPVERIFY_LOG_DEBUG("rd device status is %{public}d", g_isRdDevice); if (info.type == ProvisionType::DEBUG && !g_isRdDevice) { ret = CheckDeviceID(info); if (ret != PROVISION_OK) { @@ -358,7 +358,7 @@ AppProvisionVerifyResult ParseAndVerify(const string& appProvision, ProvisionInf } } #endif - HAPVERIFY_LOG_DEBUG(LABEL, "Leave HarmonyAppProvision Verify"); + HAPVERIFY_LOG_DEBUG("Leave HarmonyAppProvision Verify"); return PROVISION_OK; } @@ -366,7 +366,7 @@ AppProvisionVerifyResult ParseProfile(const std::string& appProvision, Provision { json obj = json::parse(appProvision, nullptr, false); if (obj.is_discarded() || (!obj.is_structured())) { - HAPVERIFY_LOG_ERROR(LABEL, "Parsing appProvision failed. json: %{public}s", appProvision.c_str()); + HAPVERIFY_LOG_ERROR("Parsing appProvision failed. json: %{public}s", appProvision.c_str()); return PROVISION_INVALID; } obj.get_to(info); diff --git a/interfaces/innerkits/appverify/src/ticket/ticket_verify.cpp b/interfaces/innerkits/appverify/src/ticket/ticket_verify.cpp index b47c75392b5c87da57268dbcf9c9eb9bb8b49eed..a6a5c2612511f676cce9a9e2ef2e7c4c27f28285 100644 --- a/interfaces/innerkits/appverify/src/ticket/ticket_verify.cpp +++ b/interfaces/innerkits/appverify/src/ticket/ticket_verify.cpp @@ -48,7 +48,7 @@ bool CheckTicketFilePath(const std::string& filePath, std::string& standardFileP { char path[PATH_MAX + 1] = { 0x00 }; if (filePath.size() > PATH_MAX || realpath(filePath.c_str(), path) == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "filePath is not a standard path"); + HAPVERIFY_LOG_ERROR("filePath is not a standard path"); return false; } standardFilePath = std::string(path); @@ -79,15 +79,15 @@ AppProvisionVerifyResult CheckDevice(ProvisionInfo& info) { // Checking device ids if (info.debugInfo.deviceIds.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "device-id list is empty."); + HAPVERIFY_LOG_ERROR("device-id list is empty."); return PROVISION_DEVICE_UNAUTHORIZED; } - HAPVERIFY_LOG_DEBUG(LABEL, "number of device ids in list: %{public}u", + HAPVERIFY_LOG_DEBUG("number of device ids in list: %{public}u", static_cast(info.debugInfo.deviceIds.size())); if (info.debugInfo.deviceIdType != VALUE_DEVICE_TYPE_UDID) { - HAPVERIFY_LOG_ERROR(LABEL, "type of device ID is not supported."); + HAPVERIFY_LOG_ERROR("type of device ID is not supported."); return PROVISION_UNSUPPORTED_DEVICE_TYPE; } @@ -95,20 +95,20 @@ AppProvisionVerifyResult CheckDevice(ProvisionInfo& info) #ifndef STANDARD_SYSTEM int32_t ret = OHOS::AccountSA::OhosAccountKits::GetInstance().GetUdid(deviceId); if (ret != 0) { - HAPVERIFY_LOG_ERROR(LABEL, "obtaining current device id failed (%{public}d).", ret); + HAPVERIFY_LOG_ERROR("obtaining current device id failed (%{public}d).", ret); return PROVISION_DEVICE_UNAUTHORIZED; } #else char udid[DEV_UUID_LEN] = {0}; int32_t ret = GetDevUdid(udid, sizeof(udid)); if (ret != EC_SUCCESS) { - HAPVERIFY_LOG_ERROR(LABEL, "obtaining current device id failed (%{public}d).", static_cast(ret)); + HAPVERIFY_LOG_ERROR("obtaining current device id failed (%{public}d).", static_cast(ret)); return PROVISION_DEVICE_UNAUTHORIZED; } deviceId = std::string(udid, sizeof(udid) - 1); #endif // STANDARD_SYSTEM if (deviceId.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "device-id of current device is empty."); + HAPVERIFY_LOG_ERROR("device-id of current device is empty."); return PROVISION_DEVICE_UNAUTHORIZED; } @@ -121,7 +121,7 @@ AppProvisionVerifyResult CheckDevice(ProvisionInfo& info) int32_t CompareTicketAndProfile(const ProvisionInfo& ticketInfo, const ProvisionInfo& profileInfo) { if (ticketInfo.bundleInfo.bundleName != profileInfo.bundleInfo.bundleName) { - HAPVERIFY_LOG_ERROR(LABEL, "ticket bundlename doesn't match"); + HAPVERIFY_LOG_ERROR("ticket bundlename doesn't match"); return TICKET_NOT_MATCH; } @@ -131,12 +131,12 @@ int32_t CompareTicketAndProfile(const ProvisionInfo& ticketInfo, const Provision if (ticketInfo.type == DEBUG) { if (ticketInfo.bundleInfo.developmentCertificate != profileInfo.bundleInfo.developmentCertificate) { - HAPVERIFY_LOG_ERROR(LABEL, "ticket developmentCertificate doesn't match"); + HAPVERIFY_LOG_ERROR("ticket developmentCertificate doesn't match"); return TICKET_NOT_MATCH; } } else { if (ticketInfo.bundleInfo.distributionCertificate != profileInfo.bundleInfo.distributionCertificate) { - HAPVERIFY_LOG_ERROR(LABEL, "ticket distributionCertificate doesn't match"); + HAPVERIFY_LOG_ERROR("ticket distributionCertificate doesn't match"); return TICKET_NOT_MATCH; } } @@ -144,7 +144,7 @@ int32_t CompareTicketAndProfile(const ProvisionInfo& ticketInfo, const Provision if (!ticketInfo.permissions.restrictedCapabilities.empty()) { if (!CheckPermissions(ticketInfo.permissions.restrictedCapabilities, profileInfo.permissions.restrictedCapabilities)) { - HAPVERIFY_LOG_ERROR(LABEL, "ticket restrictedCapabilities doesn't match"); + HAPVERIFY_LOG_ERROR("ticket restrictedCapabilities doesn't match"); return TICKET_PERMISSION_ERROR; } } @@ -152,7 +152,7 @@ int32_t CompareTicketAndProfile(const ProvisionInfo& ticketInfo, const Provision if (!ticketInfo.permissions.restrictedPermissions.empty()) { if (!CheckPermissions(ticketInfo.permissions.restrictedPermissions, profileInfo.permissions.restrictedPermissions)) { - HAPVERIFY_LOG_ERROR(LABEL, "ticket restrictedPermissions doesn't match"); + HAPVERIFY_LOG_ERROR("ticket restrictedPermissions doesn't match"); return TICKET_PERMISSION_ERROR; } } @@ -164,24 +164,24 @@ bool VerifyTicketSignature(HapByteBuffer& ticketBlock, Pkcs7Context& pkcs7Contex const unsigned char* pkcs7Block = reinterpret_cast(ticketBlock.GetBufferPtr()); uint32_t pkcs7Len = static_cast(ticketBlock.GetCapacity()); if (!HapVerifyOpensslUtils::ParsePkcs7Package(pkcs7Block, pkcs7Len, pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "Parse ticket pkcs7 failed"); + HAPVERIFY_LOG_ERROR("Parse ticket pkcs7 failed"); return false; } ticket = std::string(pkcs7Context.content.GetBufferPtr(), pkcs7Context.content.GetCapacity()); if (!HapVerifyOpensslUtils::GetCertChains(pkcs7Context.p7, pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "GetCertChains from ticket pkcs7 failed"); + HAPVERIFY_LOG_ERROR("GetCertChains from ticket pkcs7 failed"); return false; } if (!HapVerifyOpensslUtils::VerifyPkcs7(pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "verify ticket signature failed"); + HAPVERIFY_LOG_ERROR("verify ticket signature failed"); return false; } std::string certSubject; if (!HapCertVerifyOpensslUtils::GetSubjectFromX509(pkcs7Context.certChains[0][0], certSubject)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get info of sign cert from ticket failed"); + HAPVERIFY_LOG_ERROR("Get info of sign cert from ticket failed"); return false; } @@ -189,11 +189,11 @@ bool VerifyTicketSignature(HapByteBuffer& ticketBlock, Pkcs7Context& pkcs7Contex pkcs7Context.matchResult = trustedTicketSourceManager.IsTrustedSource(certSubject, pkcs7Context.certIssuer, pkcs7Context.certChains[0].size()); if (pkcs7Context.matchResult.matchState == DO_NOT_MATCH) { - HAPVERIFY_LOG_ERROR(LABEL, "Ticket signature is not trusted source, subject: %{public}s, issuer: %{public}s", + HAPVERIFY_LOG_ERROR("Ticket signature is not trusted source, subject: %{public}s, issuer: %{public}s", certSubject.c_str(), pkcs7Context.certIssuer.c_str()); return false; } - HAPVERIFY_LOG_INFO(LABEL, "Ticket subject: %{public}s, issuer: %{public}s", + HAPVERIFY_LOG_INFO("Ticket subject: %{public}s, issuer: %{public}s", certSubject.c_str(), pkcs7Context.certIssuer.c_str()); return true; } @@ -216,39 +216,39 @@ int32_t TicketParseAndVerify(const std::string& ticket, ProvisionInfo& ticketInf int32_t VerifyTicket(const std::string& filePath, const ProvisionInfo& profileInfo) { - HAPVERIFY_LOG_DEBUG(LABEL, "Enter Ticket Verify"); + HAPVERIFY_LOG_DEBUG("Enter Ticket Verify"); RandomAccessFile ticketFile; if (!ticketFile.Init(filePath)) { - HAPVERIFY_LOG_ERROR(LABEL, "open %{public}s failed", filePath.c_str()); + HAPVERIFY_LOG_ERROR("open %{public}s failed", filePath.c_str()); return OPEN_TICKET_FILE_ERROR; } long long fileLength = ticketFile.GetLength(); if (fileLength > TICKET_MAX_SIZE) { - HAPVERIFY_LOG_ERROR(LABEL, "file length %{public}lld is too larger", fileLength); + HAPVERIFY_LOG_ERROR("file length %{public}lld is too larger", fileLength); return OPEN_TICKET_FILE_ERROR; } int32_t fileLen = static_cast(fileLength); HapByteBuffer ticketBlock(fileLen); long long ret = ticketFile.ReadFileFullyFromOffset(ticketBlock, 0); if (ret < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "read data from ticket error: %{public}lld", ret); + HAPVERIFY_LOG_ERROR("read data from ticket error: %{public}lld", ret); return TICKET_READ_FAIL; } Pkcs7Context pkcs7Context; std::string ticket; if (!VerifyTicketSignature(ticketBlock, pkcs7Context, ticket)) { - HAPVERIFY_LOG_ERROR(LABEL, "verify ticket signature failed"); + HAPVERIFY_LOG_ERROR("verify ticket signature failed"); return SIGNATURE_VERIFY_FAIL; } ProvisionInfo ticketInfo; int32_t ticketRet = TicketParseAndVerify(ticket, ticketInfo, profileInfo); if (ticketRet != TICKET_OK) { - HAPVERIFY_LOG_ERROR(LABEL, "ticket parse failed, error: %{public}d", static_cast(ticketRet)); + HAPVERIFY_LOG_ERROR("ticket parse failed, error: %{public}d", static_cast(ticketRet)); return ticketRet; } - HAPVERIFY_LOG_DEBUG(LABEL, "Leave Ticket Verify"); + HAPVERIFY_LOG_DEBUG("Leave Ticket Verify"); return TICKET_VERIFY_SUCCESS; } @@ -262,10 +262,10 @@ bool CheckTicketSource(const ProvisionInfo& profileInfo) int32_t ret = VerifyTicket(standardFilePath, profileInfo); if (ret != TICKET_VERIFY_SUCCESS) { - HAPVERIFY_LOG_ERROR(LABEL, "ticket verify failed, result: %{public}d", ret); + HAPVERIFY_LOG_ERROR("ticket verify failed, result: %{public}d", ret); return false; } - HAPVERIFY_LOG_INFO(LABEL, "Ticket verify success"); + HAPVERIFY_LOG_INFO("Ticket verify success"); return true; } } // namespace Verify diff --git a/interfaces/innerkits/appverify/src/util/hap_cert_verify_openssl_utils.cpp b/interfaces/innerkits/appverify/src/util/hap_cert_verify_openssl_utils.cpp index 18649be5d1082836b70672f51387177bf63d135d..400970ef916876a8e7273bbb5994cafd6252b358 100644 --- a/interfaces/innerkits/appverify/src/util/hap_cert_verify_openssl_utils.cpp +++ b/interfaces/innerkits/appverify/src/util/hap_cert_verify_openssl_utils.cpp @@ -42,13 +42,13 @@ X509* HapCertVerifyOpensslUtils::GetX509CertFromPemString(const std::string& pem BIO* pemBio = BIO_new(BIO_s_mem()); if (pemBio == nullptr) { HapVerifyOpensslUtils::GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "BIO_new failed"); + HAPVERIFY_LOG_ERROR("BIO_new failed"); return nullptr; } int32_t strLen = static_cast(pemString.size()); if (BIO_write(pemBio, pemString.c_str(), strLen) != strLen) { HapVerifyOpensslUtils::GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "BIO_write failed"); + HAPVERIFY_LOG_ERROR("BIO_write failed"); BIO_free_all(pemBio); return nullptr; } @@ -65,7 +65,7 @@ X509* HapCertVerifyOpensslUtils::GetX509CertFromBase64String(const std::string& int32_t len = EVP_DecodeBlock(decodeBuffer.get(), input, base64String.size()); if (len <= 0) { HapVerifyOpensslUtils::GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "base64Decode failed, len: %{public}d", len); + HAPVERIFY_LOG_ERROR("base64Decode failed, len: %{public}d", len); return nullptr; } @@ -78,12 +78,12 @@ bool HapCertVerifyOpensslUtils::GetPublickeyBase64FromPemCert(const std::string& { X509* cert = GetX509CertFromPemString(certStr); if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "GetX509CertFromPemString failed"); + HAPVERIFY_LOG_ERROR("GetX509CertFromPemString failed"); return false; } if (!GetPublickeyBase64(cert, publicKey)) { - HAPVERIFY_LOG_ERROR(LABEL, "X509_get_pubkey failed"); + HAPVERIFY_LOG_ERROR("X509_get_pubkey failed"); HapVerifyOpensslUtils::GetOpensslErrorMessage(); X509_free(cert); return false; @@ -94,15 +94,15 @@ bool HapCertVerifyOpensslUtils::GetPublickeyBase64FromPemCert(const std::string& bool HapCertVerifyOpensslUtils::GetFingerprintBase64FromPemCert(const std::string& certStr, std::string& fingerprint) { - HAPVERIFY_LOG_DEBUG(LABEL, "GetFingerprintBase64FromPemCert begin"); + HAPVERIFY_LOG_DEBUG("GetFingerprintBase64FromPemCert begin"); X509* cert = GetX509CertFromPemString(certStr); if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "GetX509CertFromPemString failed"); + HAPVERIFY_LOG_ERROR("GetX509CertFromPemString failed"); return false; } int32_t certLen = i2d_X509(cert, nullptr); if (certLen <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "certLen %{public}d, i2d_X509 failed", certLen); + HAPVERIFY_LOG_ERROR("certLen %{public}d, i2d_X509 failed", certLen); HapVerifyOpensslUtils::GetOpensslErrorMessage(); X509_free(cert); return false; @@ -112,7 +112,7 @@ bool HapCertVerifyOpensslUtils::GetFingerprintBase64FromPemCert(const std::strin unsigned char* derCertificateBackup = derCertificate.get(); if (i2d_X509(cert, &derCertificateBackup) <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "i2d_X509 failed"); + HAPVERIFY_LOG_ERROR("i2d_X509 failed"); HapVerifyOpensslUtils::GetOpensslErrorMessage(); X509_free(cert); return false; @@ -126,14 +126,14 @@ bool HapCertVerifyOpensslUtils::GetFingerprintBase64FromPemCert(const std::strin for (int32_t index = 0; index < SHA256_DIGEST_LENGTH; ++index) { if (sprintf_s(buff, sizeof(buff), "%02X", hash[index]) < 0) { fingerprint.clear(); - HAPVERIFY_LOG_ERROR(LABEL, "transforms hash string to hexadecimal string failed"); + HAPVERIFY_LOG_ERROR("transforms hash string to hexadecimal string failed"); X509_free(cert); return false; } fingerprint += buff; } X509_free(cert); - HAPVERIFY_LOG_DEBUG(LABEL, "GetFingerprintBase64FromPemCert end %{public}s", fingerprint.c_str()); + HAPVERIFY_LOG_DEBUG("GetFingerprintBase64FromPemCert end %{public}s", fingerprint.c_str()); return true; } @@ -141,14 +141,14 @@ bool HapCertVerifyOpensslUtils::GetPublickeyBase64(const X509* cert, std::string { EVP_PKEY *pkey = X509_get0_pubkey(cert); if (pkey == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "X509_get0_pubkey failed"); + HAPVERIFY_LOG_ERROR("X509_get0_pubkey failed"); HapVerifyOpensslUtils::GetOpensslErrorMessage(); return false; } int32_t keyLen = i2d_PublicKey(pkey, nullptr); if (keyLen <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "keyLen %{public}d, i2d_PublicKey failed", keyLen); + HAPVERIFY_LOG_ERROR("keyLen %{public}d, i2d_PublicKey failed", keyLen); HapVerifyOpensslUtils::GetOpensslErrorMessage(); return false; } @@ -157,7 +157,7 @@ bool HapCertVerifyOpensslUtils::GetPublickeyBase64(const X509* cert, std::string std::unique_ptr base64PublicKey = std::make_unique(base64KeyLen); unsigned char* derCertificateBackup = derPublicKey.get(); if (i2d_PublicKey(pkey, &derCertificateBackup) <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "i2d_PublicKey failed"); + HAPVERIFY_LOG_ERROR("i2d_PublicKey failed"); HapVerifyOpensslUtils::GetOpensslErrorMessage(); return false; } @@ -169,10 +169,10 @@ bool HapCertVerifyOpensslUtils::GetPublickeyBase64(const X509* cert, std::string bool HapCertVerifyOpensslUtils::GetOrganizationFromPemCert(const std::string& certStr, std::string& organization) { - HAPVERIFY_LOG_DEBUG(LABEL, "GetFingerprintBase64FromPemCert begin"); + HAPVERIFY_LOG_DEBUG("GetFingerprintBase64FromPemCert begin"); X509* cert = GetX509CertFromPemString(certStr); if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "GetX509CertFromPemString failed"); + HAPVERIFY_LOG_ERROR("GetX509CertFromPemString failed"); return false; } X509_NAME* name = X509_get_subject_name(cert); @@ -194,13 +194,13 @@ int32_t HapCertVerifyOpensslUtils::CalculateLenAfterBase64Encode(int32_t len) bool HapCertVerifyOpensslUtils::CompareX509Cert(const X509* certA, const std::string& base64Cert) { if (certA == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "certA is nullptr"); + HAPVERIFY_LOG_ERROR("certA is nullptr"); return false; } X509* certB = GetX509CertFromPemString(base64Cert); if (certB == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "generate certB failed"); + HAPVERIFY_LOG_ERROR("generate certB failed"); return false; } bool ret = (X509_cmp(certA, certB) == 0); @@ -212,23 +212,23 @@ X509_CRL* HapCertVerifyOpensslUtils::GetX509CrlFromDerBuffer( const HapByteBuffer& crlBuffer, int32_t offset, int32_t len) { if (crlBuffer.GetBufferPtr() == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid input, crlbuffer is null"); + HAPVERIFY_LOG_ERROR("invalid input, crlbuffer is null"); return nullptr; } if ((len <= 0) || (offset < 0) || (crlBuffer.GetCapacity() - len < offset)) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid input, offset: %{public}d, len: %{public}d", offset, len); + HAPVERIFY_LOG_ERROR("invalid input, offset: %{public}d, len: %{public}d", offset, len); return nullptr; } BIO* derBio = BIO_new(BIO_s_mem()); if (derBio == nullptr) { HapVerifyOpensslUtils::GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "BIO_new failed"); + HAPVERIFY_LOG_ERROR("BIO_new failed"); return nullptr; } if (BIO_write(derBio, crlBuffer.GetBufferPtr() + offset, len) != len) { HapVerifyOpensslUtils::GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "BIO_write failed"); + HAPVERIFY_LOG_ERROR("BIO_write failed"); BIO_free_all(derBio); return nullptr; } @@ -240,18 +240,18 @@ X509_CRL* HapCertVerifyOpensslUtils::GetX509CrlFromDerBuffer( void HapCertVerifyOpensslUtils::WriteX509CrlToStream(std::ofstream& crlFile, X509_CRL* crl) { if (!crlFile.is_open()) { - HAPVERIFY_LOG_ERROR(LABEL, "fill is not open"); + HAPVERIFY_LOG_ERROR("fill is not open"); return; } BIO* derBio = BIO_new(BIO_s_mem()); if (derBio == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "BIO_new failed"); + HAPVERIFY_LOG_ERROR("BIO_new failed"); return; } if (crl == nullptr || i2d_X509_CRL_bio(derBio, crl) == 0) { BIO_free_all(derBio); - HAPVERIFY_LOG_ERROR(LABEL, "i2d_X509_CRL_bio failed"); + HAPVERIFY_LOG_ERROR("i2d_X509_CRL_bio failed"); return; } @@ -299,7 +299,7 @@ void HapCertVerifyOpensslUtils::ClearCertVisitSign(CertSign& certVisitSign) bool HapCertVerifyOpensslUtils::GetCertsChain(CertChain& certsChain, CertSign& certVisitSign) { if (certsChain.empty() || certVisitSign.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "input is invalid"); + HAPVERIFY_LOG_ERROR("input is invalid"); return false; } @@ -316,7 +316,7 @@ bool HapCertVerifyOpensslUtils::GetCertsChain(CertChain& certsChain, CertSign& c if (issuerCert == nullptr) { std::string caIssuer; GetIssuerFromX509(certsChain[certsChain.size() - 1], caIssuer); - HAPVERIFY_LOG_ERROR(LABEL, "it do not come from trusted root, issuer: %{public}s", caIssuer.c_str()); + HAPVERIFY_LOG_ERROR("it do not come from trusted root, issuer: %{public}s", caIssuer.c_str()); return false; } if (X509_cmp(issuerCert, certsChain[certsChain.size() - 1]) == 0) { @@ -330,7 +330,7 @@ bool HapCertVerifyOpensslUtils::GetCertsChain(CertChain& certsChain, CertSign& c X509* HapCertVerifyOpensslUtils::FindCertOfIssuer(X509* cert, CertSign& certVisitSign) { if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "input is invalid"); + HAPVERIFY_LOG_ERROR("input is invalid"); return nullptr; } @@ -354,14 +354,14 @@ X509* HapCertVerifyOpensslUtils::FindCertOfIssuer(X509* cert, CertSign& certVisi bool HapCertVerifyOpensslUtils::CertVerify(X509* cert, const X509* issuerCert) { if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "input is invalid"); + HAPVERIFY_LOG_ERROR("input is invalid"); return false; } EVP_PKEY* caPublicKey = X509_get0_pubkey(issuerCert); if (caPublicKey == nullptr) { HapVerifyOpensslUtils::GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "get pubkey from caCert failed"); + HAPVERIFY_LOG_ERROR("get pubkey from caCert failed"); return false; } return X509_verify(cert, caPublicKey) > 0; @@ -375,13 +375,13 @@ bool HapCertVerifyOpensslUtils::VerifyCertChainPeriodOfValidity(CertChain& certs for (uint32_t i = 0; i < certsChain.size() - 1; i++) { if (certsChain[i] == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "%{public}dst cert is nullptr", i); + HAPVERIFY_LOG_ERROR("%{public}dst cert is nullptr", i); return false; } const ASN1_TIME* notBefore = X509_get0_notBefore(certsChain[i]); const ASN1_TIME* notAfter = X509_get0_notAfter(certsChain[i]); if (!CheckSignTimeInValidPeriod(signTime, notBefore, notAfter)) { - HAPVERIFY_LOG_ERROR(LABEL, "%{public}dst cert is not in period of validity", i); + HAPVERIFY_LOG_ERROR("%{public}dst cert is not in period of validity", i); return false; } } @@ -409,21 +409,21 @@ bool HapCertVerifyOpensslUtils::CheckSignTimeInValidPeriod(const ASN1_TYPE* sign const ASN1_TIME* notBefore, const ASN1_TIME* notAfter) { if (!CheckAsn1TimeIsValid(notBefore) || !CheckAsn1TimeIsValid(notAfter)) { - HAPVERIFY_LOG_ERROR(LABEL, "no valid period"); + HAPVERIFY_LOG_ERROR("no valid period"); return false; } if (!CheckAsn1TypeIsValid(signTime)) { - HAPVERIFY_LOG_ERROR(LABEL, "signTime is invalid"); + HAPVERIFY_LOG_ERROR("signTime is invalid"); return false; } if (ASN1_TIME_compare(notBefore, signTime->value.asn1_string) > 0 || ASN1_TIME_compare(notAfter, signTime->value.asn1_string) < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "Out of valid period, signTime: %{public}s, notBefore: %{public}s, " + HAPVERIFY_LOG_ERROR("Out of valid period, signTime: %{public}s, notBefore: %{public}s, " "notAfter: %{public}s", signTime->value.asn1_string->data, notBefore->data, notAfter->data); return false; } - HAPVERIFY_LOG_DEBUG(LABEL, "signTime type: %{public}d, data: %{public}s, notBefore: %{public}s, " + HAPVERIFY_LOG_DEBUG("signTime type: %{public}d, data: %{public}s, notBefore: %{public}s, " "notAfter: %{public}s", signTime->type, signTime->value.asn1_string->data, notBefore->data, notAfter->data); return true; } @@ -431,13 +431,13 @@ bool HapCertVerifyOpensslUtils::CheckSignTimeInValidPeriod(const ASN1_TYPE* sign bool HapCertVerifyOpensslUtils::VerifyCrl(CertChain& certsChain, STACK_OF(X509_CRL)* crls, Pkcs7Context& pkcs7Context) { if (certsChain.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "cert chain is null"); + HAPVERIFY_LOG_ERROR("cert chain is null"); return false; } /* get signed cert's issuer and then it will be used to find local crl */ if (!GetIssuerFromX509(certsChain[0], pkcs7Context.certIssuer)) { - HAPVERIFY_LOG_ERROR(LABEL, "get issuer of signed cert failed"); + HAPVERIFY_LOG_ERROR("get issuer of signed cert failed"); return false; } X509_CRL* targetCrl = GetCrlBySignedCertIssuer(crls, certsChain[0]); @@ -446,7 +446,7 @@ bool HapCertVerifyOpensslUtils::VerifyCrl(CertChain& certsChain, STACK_OF(X509_C /* if it include crl, it must be verified by ca cert */ if (X509_CRL_verify(targetCrl, X509_get0_pubkey(certsChain[1])) <= 0) { HapVerifyOpensslUtils::GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "verify crlInPackage failed"); + HAPVERIFY_LOG_ERROR("verify crlInPackage failed"); return false; } } @@ -487,52 +487,52 @@ bool HapCertVerifyOpensslUtils::X509NameCompare(const X509_NAME* a, const X509_N bool HapCertVerifyOpensslUtils::GetSubjectFromX509(const X509* cert, std::string& subject) { if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "cert is nullptr"); + HAPVERIFY_LOG_ERROR("cert is nullptr"); return false; } X509_NAME* name = X509_get_subject_name(cert); subject = GetDnToString(name); - HAPVERIFY_LOG_DEBUG(LABEL, "subject = %{public}s", subject.c_str()); + HAPVERIFY_LOG_DEBUG("subject = %{public}s", subject.c_str()); return true; } bool HapCertVerifyOpensslUtils::GetIssuerFromX509(const X509* cert, std::string& issuer) { if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "cert is nullptr"); + HAPVERIFY_LOG_ERROR("cert is nullptr"); return false; } X509_NAME* name = X509_get_issuer_name(cert); issuer = GetDnToString(name); - HAPVERIFY_LOG_DEBUG(LABEL, "cert issuer = %{public}s", issuer.c_str()); + HAPVERIFY_LOG_DEBUG("cert issuer = %{public}s", issuer.c_str()); return true; } bool HapCertVerifyOpensslUtils::GetSerialNumberFromX509(const X509* cert, long long& certNumber) { if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "cert is nullptr"); + HAPVERIFY_LOG_ERROR("cert is nullptr"); return false; } const ASN1_INTEGER* certSN = X509_get0_serialNumber(cert); certNumber = ASN1_INTEGER_get(certSN); - HAPVERIFY_LOG_DEBUG(LABEL, "cert number = %{public}lld", certNumber); + HAPVERIFY_LOG_DEBUG("cert number = %{public}lld", certNumber); return true; } bool HapCertVerifyOpensslUtils::GetIssuerFromX509Crl(const X509_CRL* crl, std::string& issuer) { if (crl == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "clr is nullptr"); + HAPVERIFY_LOG_ERROR("clr is nullptr"); return false; } X509_NAME* name = X509_CRL_get_issuer(crl); if (name == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "crl issuer nullptr"); + HAPVERIFY_LOG_ERROR("crl issuer nullptr"); return false; } issuer = GetDnToString(name); diff --git a/interfaces/innerkits/appverify/src/util/hap_profile_verify_utils.cpp b/interfaces/innerkits/appverify/src/util/hap_profile_verify_utils.cpp index 8973384ecf841d58527d74fd79c6e32077d036e2..a1f8ca33c983c827c9031a1ceee0af887c0f7fe8 100644 --- a/interfaces/innerkits/appverify/src/util/hap_profile_verify_utils.cpp +++ b/interfaces/innerkits/appverify/src/util/hap_profile_verify_utils.cpp @@ -31,13 +31,13 @@ bool HapProfileVerifyUtils::ParseProfile(Pkcs7Context& profilePkcs7Context, cons if (hapPkcs7Context.matchResult.matchState == MATCH_WITH_SIGN && hapPkcs7Context.matchResult.source == APP_GALLARY) { profile = std::string(pkcs7ProfileBlock.GetBufferPtr(), pkcs7ProfileBlock.GetCapacity()); - HAPVERIFY_LOG_DEBUG(LABEL, "hap include unsigned provision"); + HAPVERIFY_LOG_DEBUG("hap include unsigned provision"); return true; } const unsigned char* pkcs7Block = reinterpret_cast(pkcs7ProfileBlock.GetBufferPtr()); uint32_t pkcs7Len = static_cast(pkcs7ProfileBlock.GetCapacity()); if (!HapVerifyOpensslUtils::ParsePkcs7Package(pkcs7Block, pkcs7Len, profilePkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "parse pkcs7 failed"); + HAPVERIFY_LOG_ERROR("parse pkcs7 failed"); return false; } @@ -48,12 +48,12 @@ bool HapProfileVerifyUtils::ParseProfile(Pkcs7Context& profilePkcs7Context, cons bool HapProfileVerifyUtils::VerifyProfile(Pkcs7Context& pkcs7Context) { if (!HapVerifyOpensslUtils::GetCertChains(pkcs7Context.p7, pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "GetCertChains from pkcs7 failed"); + HAPVERIFY_LOG_ERROR("GetCertChains from pkcs7 failed"); return false; } if (!HapVerifyOpensslUtils::VerifyPkcs7(pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "verify profile signature failed"); + HAPVERIFY_LOG_ERROR("verify profile signature failed"); return false; } @@ -61,7 +61,7 @@ bool HapProfileVerifyUtils::VerifyProfile(Pkcs7Context& pkcs7Context) std::string certIssuer; if (!HapCertVerifyOpensslUtils::GetSubjectFromX509(pkcs7Context.certChains[0][0], certSubject) || !HapCertVerifyOpensslUtils::GetIssuerFromX509(pkcs7Context.certChains[0][0], certIssuer)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get info of sign cert failed"); + HAPVERIFY_LOG_ERROR("Get info of sign cert failed"); return false; } @@ -69,11 +69,11 @@ bool HapProfileVerifyUtils::VerifyProfile(Pkcs7Context& pkcs7Context) pkcs7Context.matchResult = trustedSourceManager.IsTrustedSource(certSubject, certIssuer, PROFILE_BLOB, pkcs7Context.certChains[0].size()); if (pkcs7Context.matchResult.matchState == DO_NOT_MATCH) { - HAPVERIFY_LOG_ERROR(LABEL, "profile signature is not trusted source, subject: %{public}s, issuer: %{public}s", + HAPVERIFY_LOG_ERROR("profile signature is not trusted source, subject: %{public}s, issuer: %{public}s", certSubject.c_str(), certIssuer.c_str()); return false; } - HAPVERIFY_LOG_DEBUG(LABEL, "profile subject: %{public}s, issuer: %{public}s", + HAPVERIFY_LOG_DEBUG("profile subject: %{public}s, issuer: %{public}s", certSubject.c_str(), certIssuer.c_str()); return true; } diff --git a/interfaces/innerkits/appverify/src/util/hap_signing_block_utils.cpp b/interfaces/innerkits/appverify/src/util/hap_signing_block_utils.cpp index 5bfcd366b138389c158c77d35e0f4818b78e83dd..b8b4d8bb5d3ae4128090cd0e9eecd16143ff806c 100644 --- a/interfaces/innerkits/appverify/src/util/hap_signing_block_utils.cpp +++ b/interfaces/innerkits/appverify/src/util/hap_signing_block_utils.cpp @@ -59,19 +59,19 @@ bool HapSigningBlockUtils::FindHapSignature(RandomAccessFile& hapFile, Signature { std::pair eocdAndOffsetInFile; if (!FindEocdInHap(hapFile, eocdAndOffsetInFile)) { - HAPVERIFY_LOG_ERROR(LABEL, "find EoCD failed"); + HAPVERIFY_LOG_ERROR("find EoCD failed"); return false; } signInfo.hapEocd = eocdAndOffsetInFile.first; signInfo.hapEocdOffset = eocdAndOffsetInFile.second; if (!GetCentralDirectoryOffset(signInfo.hapEocd, signInfo.hapEocdOffset, signInfo.hapCentralDirOffset)) { - HAPVERIFY_LOG_ERROR(LABEL, "get CD offset failed"); + HAPVERIFY_LOG_ERROR("get CD offset failed"); return false; } if (!FindHapSigningBlock(hapFile, signInfo.hapCentralDirOffset, signInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "find signing block failed"); + HAPVERIFY_LOG_ERROR("find signing block failed"); return false; } return true; @@ -85,7 +85,7 @@ bool HapSigningBlockUtils::FindEocdInHap(RandomAccessFile& hapFile, std::pair(offsetValue); if (centralDirectoryOffset > eocdOffset) { - HAPVERIFY_LOG_ERROR(LABEL, "centralDirOffset %{public}lld is larger than eocdOffset %{public}lld", + HAPVERIFY_LOG_ERROR("centralDirOffset %{public}lld is larger than eocdOffset %{public}lld", centralDirectoryOffset, eocdOffset); return false; } long long centralDirectorySize = static_cast(sizeValue); if (centralDirectoryOffset + centralDirectorySize != eocdOffset) { - HAPVERIFY_LOG_ERROR(LABEL, "centralDirOffset %{public}lld add centralDirSize %{public}lld is not equal\ + HAPVERIFY_LOG_ERROR("centralDirOffset %{public}lld add centralDirSize %{public}lld is not equal\ to eocdOffset %{public}lld", centralDirectoryOffset, centralDirectorySize, eocdOffset); return false; } @@ -203,7 +203,7 @@ bool HapSigningBlockUtils::GetCentralDirectoryOffset(HapByteBuffer& eocd, long l bool HapSigningBlockUtils::SetUnsignedInt32(HapByteBuffer& buffer, int32_t offset, long long value) { if ((value < 0) || (value > static_cast(UINT_MAX))) { - HAPVERIFY_LOG_ERROR(LABEL, "uint32 value of out range: %{public}lld", value); + HAPVERIFY_LOG_ERROR("uint32 value of out range: %{public}lld", value); return false; } buffer.PutInt32(offset, static_cast(value)); @@ -214,7 +214,7 @@ bool HapSigningBlockUtils::FindHapSigningBlock(RandomAccessFile& hapFile, long l SignatureInfo& signInfo) { if (centralDirOffset < HAP_SIG_BLOCK_MIN_SIZE) { - HAPVERIFY_LOG_ERROR(LABEL, "HAP too small for HAP Signing Block: %{public}lld", centralDirOffset); + HAPVERIFY_LOG_ERROR("HAP too small for HAP Signing Block: %{public}lld", centralDirOffset); return false; } /* @@ -227,17 +227,17 @@ bool HapSigningBlockUtils::FindHapSigningBlock(RandomAccessFile& hapFile, long l HapByteBuffer hapBlockHead(ZIP_HEAD_OF_SIGNING_BLOCK_LENGTH); long long ret = hapFile.ReadFileFullyFromOffset(hapBlockHead, centralDirOffset - hapBlockHead.GetCapacity()); if (ret < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "read hapBlockHead error: %{public}lld", ret); + HAPVERIFY_LOG_ERROR("read hapBlockHead error: %{public}lld", ret); return false; } HapSignBlockHead hapSignBlockHead; if (!ParseSignBlockHead(hapSignBlockHead, hapBlockHead)) { - HAPVERIFY_LOG_ERROR(LABEL, "ParseSignBlockHead failed"); + HAPVERIFY_LOG_ERROR("ParseSignBlockHead failed"); return false; } if (!CheckSignBlockHead(hapSignBlockHead)) { - HAPVERIFY_LOG_ERROR(LABEL, "hapSignBlockHead is invalid"); + HAPVERIFY_LOG_ERROR("hapSignBlockHead is invalid"); return false; } @@ -245,7 +245,7 @@ bool HapSigningBlockUtils::FindHapSigningBlock(RandomAccessFile& hapFile, long l long long blockArrayLen = hapSignBlockHead.hapSignBlockSize - ZIP_HEAD_OF_SIGNING_BLOCK_LENGTH; long long hapSignBlockOffset = centralDirOffset - hapSignBlockHead.hapSignBlockSize; if (hapSignBlockOffset < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "HAP Signing Block offset out of range %{public}lld", hapSignBlockOffset); + HAPVERIFY_LOG_ERROR("HAP Signing Block offset out of range %{public}lld", hapSignBlockOffset); return false; } signInfo.hapSigningBlockOffset = hapSignBlockOffset; @@ -263,19 +263,19 @@ bool HapSigningBlockUtils::CheckSignBlockHead(const HapSignBlockHead& hapSignBlo if ((hapSignBlockHead.hapSignBlockMagicLo != magic_low) || (hapSignBlockHead.hapSignBlockMagicHi != magic_high)) { - HAPVERIFY_LOG_ERROR(LABEL, "No HAP Signing Block before ZIP Central Directory"); + HAPVERIFY_LOG_ERROR("No HAP Signing Block before ZIP Central Directory"); return false; } if ((hapSignBlockHead.hapSignBlockSize < ZIP_HEAD_OF_SIGNING_BLOCK_LENGTH) || (hapSignBlockHead.hapSignBlockSize > MAX_HAP_SIGN_BLOCK_SIZE)) { - HAPVERIFY_LOG_ERROR(LABEL, "HAP Signing Block size out of range %{public}lld", + HAPVERIFY_LOG_ERROR("HAP Signing Block size out of range %{public}lld", hapSignBlockHead.hapSignBlockSize); return false; } if (hapSignBlockHead.blockCount > MAX_BLOCK_COUNT) { - HAPVERIFY_LOG_ERROR(LABEL, "HAP Signing Block count out of range %{public}d", hapSignBlockHead.blockCount); + HAPVERIFY_LOG_ERROR("HAP Signing Block count out of range %{public}d", hapSignBlockHead.blockCount); return false; } @@ -319,25 +319,25 @@ bool HapSigningBlockUtils::FindHapSubSigningBlock(RandomAccessFile& hapFile, int long long offsetMax = hapSignBlockOffset + blockArrayLen; long long readLen = 0; long long readHeadOffset = hapSignBlockOffset; - HAPVERIFY_LOG_DEBUG(LABEL, "hapSignBlockOffset %{public}lld blockArrayLen: %{public}lld blockCount: %{public}d", + HAPVERIFY_LOG_DEBUG("hapSignBlockOffset %{public}lld blockArrayLen: %{public}lld blockCount: %{public}d", hapSignBlockOffset, blockArrayLen, blockCount); for (int32_t i = 0; i < blockCount; i++) { HapByteBuffer hapBlockHead(ZIP_CD_SIZE_OFFSET_IN_EOCD); long long ret = hapFile.ReadFileFullyFromOffset(hapBlockHead, readHeadOffset); if (ret < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "read hapBlockHead error: %{public}lld", ret); + HAPVERIFY_LOG_ERROR("read hapBlockHead error: %{public}lld", ret); return false; } HapSubSignBlockHead subSignBlockHead; if (!ParseSubSignBlockHead(subSignBlockHead, hapBlockHead)) { - HAPVERIFY_LOG_ERROR(LABEL, "ParseSubSignBlockHead failed"); + HAPVERIFY_LOG_ERROR("ParseSubSignBlockHead failed"); return false; } readLen += sizeof(HapSubSignBlockHead); readHeadOffset += sizeof(HapSubSignBlockHead); if (readHeadOffset > offsetMax) { - HAPVERIFY_LOG_ERROR(LABEL, "find %{public}dst next head offset error", i); + HAPVERIFY_LOG_ERROR("find %{public}dst next head offset error", i); return false; } @@ -345,11 +345,11 @@ bool HapSigningBlockUtils::FindHapSubSigningBlock(RandomAccessFile& hapFile, int long long headLength = static_cast(subSignBlockHead.length); /* check subSignBlockHead */ if ((offsetMax - headOffset) < hapSignBlockOffset) { - HAPVERIFY_LOG_ERROR(LABEL, "Find %{public}dst subblock data offset error", i); + HAPVERIFY_LOG_ERROR("Find %{public}dst subblock data offset error", i); return false; } if ((blockArrayLen - headLength) < readLen) { - HAPVERIFY_LOG_ERROR(LABEL, "no enough data to be read for %{public}dst subblock", i); + HAPVERIFY_LOG_ERROR("no enough data to be read for %{public}dst subblock", i); return false; } @@ -357,13 +357,13 @@ bool HapSigningBlockUtils::FindHapSubSigningBlock(RandomAccessFile& hapFile, int HapByteBuffer signBuffer(subSignBlockHead.length); ret = hapFile.ReadFileFullyFromOffset(signBuffer, dataOffset); if (ret < 0) { - HAPVERIFY_LOG_ERROR(LABEL, "read %{public}dst subblock error: %{public}lld", i, ret); + HAPVERIFY_LOG_ERROR("read %{public}dst subblock error: %{public}lld", i, ret); return false; } readLen += headLength; if (!ClassifyHapSubSigningBlock(signInfo, signBuffer, subSignBlockHead.type)) { - HAPVERIFY_LOG_ERROR(LABEL, "ClassifyHapSubSigningBlock error, type is %{public}d", + HAPVERIFY_LOG_ERROR("ClassifyHapSubSigningBlock error, type is %{public}d", subSignBlockHead.type); return false; } @@ -371,7 +371,7 @@ bool HapSigningBlockUtils::FindHapSubSigningBlock(RandomAccessFile& hapFile, int /* size of block must be equal to the sum of all subblocks length */ if (readLen != blockArrayLen) { - HAPVERIFY_LOG_ERROR(LABEL, "readLen: %{public}lld is not same as blockArrayLen: %{public}lld", + HAPVERIFY_LOG_ERROR("readLen: %{public}lld is not same as blockArrayLen: %{public}lld", readLen, blockArrayLen); return false; } @@ -385,7 +385,7 @@ bool HapSigningBlockUtils::ClassifyHapSubSigningBlock(SignatureInfo& signInfo, switch (type) { case HAP_SIGN_BLOB: { if (signInfo.hapSignatureBlock.GetCapacity() != 0) { - HAPVERIFY_LOG_ERROR(LABEL, "find more than one hap sign block"); + HAPVERIFY_LOG_ERROR("find more than one hap sign block"); break; } signInfo.hapSignatureBlock = subBlock; @@ -424,7 +424,7 @@ bool HapSigningBlockUtils::VerifyHapIntegrity( Pkcs7Context& digestInfo, RandomAccessFile& hapFile, SignatureInfo& signInfo) { if (!SetUnsignedInt32(signInfo.hapEocd, ZIP_CD_OFFSET_IN_EOCD, signInfo.hapSigningBlockOffset)) { - HAPVERIFY_LOG_ERROR(LABEL, "Set central dir offset failed"); + HAPVERIFY_LOG_ERROR("Set central dir offset failed"); return false; } @@ -437,18 +437,18 @@ bool HapSigningBlockUtils::VerifyHapIntegrity( DigestParameter digestParam = GetDigestParameter(nId); HapByteBuffer chunkDigest; if (!ComputeDigestsForEachChunk(digestParam, content, ZIP_BLOCKS_NUM_NEED_DIGEST, chunkDigest)) { - HAPVERIFY_LOG_ERROR(LABEL, "Compute Content Digests failed, alg: %{public}d", nId); + HAPVERIFY_LOG_ERROR("Compute Content Digests failed, alg: %{public}d", nId); return false; } HapByteBuffer actualDigest; if (!ComputeDigestsWithOptionalBlock(digestParam, signInfo.optionBlocks, chunkDigest, actualDigest)) { - HAPVERIFY_LOG_ERROR(LABEL, "Compute Final Digests failed, alg: %{public}d", nId); + HAPVERIFY_LOG_ERROR("Compute Final Digests failed, alg: %{public}d", nId); return false; } if (!digestInfo.content.IsEqual(actualDigest)) { - HAPVERIFY_LOG_ERROR(LABEL, "digest of contents verify failed, alg %{public}d", nId); + HAPVERIFY_LOG_ERROR("digest of contents verify failed, alg %{public}d", nId); return false; } return true; @@ -460,7 +460,7 @@ bool HapSigningBlockUtils::ComputeDigestsWithOptionalBlock(const DigestParameter unsigned char out[EVP_MAX_MD_SIZE]; int32_t digestLen = HapVerifyOpensslUtils::GetDigest(chunkDigest, optionalBlocks, digestParam, out); if (digestLen != digestParam.digestOutputSizeBytes) { - HAPVERIFY_LOG_ERROR(LABEL, "GetDigest failed, outLen is not right, %{public}u, %{public}d", + HAPVERIFY_LOG_ERROR("GetDigest failed, outLen is not right, %{public}u, %{public}d", digestLen, digestParam.digestOutputSizeBytes); return false; } @@ -475,7 +475,7 @@ bool HapSigningBlockUtils::GetSumOfChunkDigestLen(DataSource* contents[], int32_ { for (int32_t i = 0; i < len; i++) { if (contents[i] == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "contents[%{public}d] is nullptr", i); + HAPVERIFY_LOG_ERROR("contents[%{public}d] is nullptr", i); return false; } contents[i]->Reset(); @@ -483,12 +483,12 @@ bool HapSigningBlockUtils::GetSumOfChunkDigestLen(DataSource* contents[], int32_ } if (chunkCount <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "no content for digest"); + HAPVERIFY_LOG_ERROR("no content for digest"); return false; } if (chunkDigestLen < 0 || ((INT_MAX - ZIP_CHUNK_DIGEST_PRIFIX_LEN) / chunkCount) < chunkDigestLen) { - HAPVERIFY_LOG_ERROR(LABEL, "overflow chunkCount: %{public}d, chunkDigestLen: %{public}d", + HAPVERIFY_LOG_ERROR("overflow chunkCount: %{public}d, chunkDigestLen: %{public}d", chunkCount, chunkDigestLen); return false; } @@ -503,7 +503,7 @@ bool HapSigningBlockUtils::ComputeDigestsForEachChunk(const DigestParameter& dig int32_t chunkCount = 0; int32_t sumOfChunksLen = 0; if (!GetSumOfChunkDigestLen(contents, len, digestParam.digestOutputSizeBytes, chunkCount, sumOfChunksLen)) { - HAPVERIFY_LOG_ERROR(LABEL, "GetSumOfChunkDigestLen failed"); + HAPVERIFY_LOG_ERROR("GetSumOfChunkDigestLen failed"); return false; } result.SetCapacity(sumOfChunksLen); @@ -518,18 +518,18 @@ bool HapSigningBlockUtils::ComputeDigestsForEachChunk(const DigestParameter& dig while (contents[i]->HasRemaining()) { int32_t chunkSize = std::min(contents[i]->Remaining(), CHUNK_SIZE); if (!InitDigestPrefix(digestParam, chunkContentPrefix, chunkSize)) { - HAPVERIFY_LOG_ERROR(LABEL, "InitDigestPrefix failed"); + HAPVERIFY_LOG_ERROR("InitDigestPrefix failed"); return false; } if (!contents[i]->ReadDataAndDigestUpdate(digestParam, chunkSize)) { - HAPVERIFY_LOG_ERROR(LABEL, "Copy Partial Buffer failed, count: %{public}d", chunkIndex); + HAPVERIFY_LOG_ERROR("Copy Partial Buffer failed, count: %{public}d", chunkIndex); return false; } int32_t digestLen = HapVerifyOpensslUtils::GetDigest(digestParam, out); if (digestLen != digestParam.digestOutputSizeBytes) { - HAPVERIFY_LOG_ERROR(LABEL, "GetDigest failed len: %{public}d digestSizeBytes: %{public}d", + HAPVERIFY_LOG_ERROR("GetDigest failed len: %{public}d digestSizeBytes: %{public}d", digestLen, digestParam.digestOutputSizeBytes); return false; } @@ -568,17 +568,17 @@ bool HapSigningBlockUtils::InitDigestPrefix(const DigestParameter& digestParam, unsigned char (&chunkContentPrefix)[ZIP_CHUNK_DIGEST_PRIFIX_LEN], int32_t chunkLen) { if (memcpy_s((chunkContentPrefix + 1), ZIP_CHUNK_DIGEST_PRIFIX_LEN - 1, (&chunkLen), sizeof(chunkLen)) != EOK) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy_s failed"); + HAPVERIFY_LOG_ERROR("memcpy_s failed"); return false; } if (!HapVerifyOpensslUtils::DigestInit(digestParam)) { - HAPVERIFY_LOG_ERROR(LABEL, "DigestInit failed"); + HAPVERIFY_LOG_ERROR("DigestInit failed"); return false; } if (!HapVerifyOpensslUtils::DigestUpdate(digestParam, chunkContentPrefix, ZIP_CHUNK_DIGEST_PRIFIX_LEN)) { - HAPVERIFY_LOG_ERROR(LABEL, "DigestUpdate failed"); + HAPVERIFY_LOG_ERROR("DigestUpdate failed"); return false; } return true; diff --git a/interfaces/innerkits/appverify/src/util/hap_verify_openssl_utils.cpp b/interfaces/innerkits/appverify/src/util/hap_verify_openssl_utils.cpp index ebed1cc5c755709302a73571b5f1402d4f747143..009b3f4a683db752d460ed43877798f31d41c701 100644 --- a/interfaces/innerkits/appverify/src/util/hap_verify_openssl_utils.cpp +++ b/interfaces/innerkits/appverify/src/util/hap_verify_openssl_utils.cpp @@ -50,18 +50,18 @@ bool HapVerifyOpensslUtils::ParsePkcs7Package(const unsigned char packageData[], uint32_t packageLen, Pkcs7Context& pkcs7Context) { if (packageData == nullptr || packageLen == 0) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid input"); + HAPVERIFY_LOG_ERROR("invalid input"); return false; } pkcs7Context.p7 = d2i_PKCS7(nullptr, &packageData, packageLen); if (!CheckPkcs7SignedDataIsValid(pkcs7Context.p7)) { GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "p7 is invalid"); + HAPVERIFY_LOG_ERROR("p7 is invalid"); return false; } if (!GetContentInfo(pkcs7Context.p7->d.sign->contents, pkcs7Context.content)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get content from pkcs7 failed"); + HAPVERIFY_LOG_ERROR("Get content from pkcs7 failed"); return false; } return true; @@ -70,7 +70,7 @@ bool HapVerifyOpensslUtils::ParsePkcs7Package(const unsigned char packageData[], bool HapVerifyOpensslUtils::GetCertChains(PKCS7* p7, Pkcs7Context& pkcs7Context) { if (!CheckPkcs7SignedDataIsValid(p7)) { - HAPVERIFY_LOG_ERROR(LABEL, "p7 is invalid"); + HAPVERIFY_LOG_ERROR("p7 is invalid"); return false; } @@ -79,13 +79,13 @@ bool HapVerifyOpensslUtils::GetCertChains(PKCS7* p7, Pkcs7Context& pkcs7Context) Pkcs7SignerInfoStack* signerInfoStack = PKCS7_get_signer_info(p7); if (signerInfoStack == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "get signerInfoStack error"); + HAPVERIFY_LOG_ERROR("get signerInfoStack error"); GetOpensslErrorMessage(); return false; } int32_t signCount = sk_PKCS7_SIGNER_INFO_num(signerInfoStack); if (signCount <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "can not find signinfo"); + HAPVERIFY_LOG_ERROR("can not find signinfo"); return false; } @@ -93,13 +93,13 @@ bool HapVerifyOpensslUtils::GetCertChains(PKCS7* p7, Pkcs7Context& pkcs7Context) /* get ith signInfo */ PKCS7_SIGNER_INFO* signInfo = sk_PKCS7_SIGNER_INFO_value(signerInfoStack, i); if (signInfo == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "signInfo %{public}dst is nullptr", i); + HAPVERIFY_LOG_ERROR("signInfo %{public}dst is nullptr", i); return false; } /* GET X509 certificate */ X509* cert = PKCS7_cert_from_signer_info(p7, signInfo); if (cert == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "get cert for %{public}dst signInfo failed", i); + HAPVERIFY_LOG_ERROR("get cert for %{public}dst signInfo failed", i); return false; } CertChain certChain; @@ -108,7 +108,7 @@ bool HapVerifyOpensslUtils::GetCertChains(PKCS7* p7, Pkcs7Context& pkcs7Context) HapCertVerifyOpensslUtils::ClearCertVisitSign(certVisitSign); certVisitSign[cert] = true; if (!VerifyCertChain(pkcs7Context.certChains[i], p7, signInfo, pkcs7Context, certVisitSign)) { - HAPVERIFY_LOG_ERROR(LABEL, "verify %{public}dst certchain failed", i); + HAPVERIFY_LOG_ERROR("verify %{public}dst certchain failed", i); return false; } } @@ -119,16 +119,16 @@ bool HapVerifyOpensslUtils::VerifyCertChain(CertChain& certsChain, PKCS7* p7, PKCS7_SIGNER_INFO* signInfo, Pkcs7Context& pkcs7Context, CertSign& certVisitSign) { if (!HapCertVerifyOpensslUtils::GetCertsChain(certsChain, certVisitSign)) { - HAPVERIFY_LOG_ERROR(LABEL, "get cert chain for signInfo failed"); + HAPVERIFY_LOG_ERROR("get cert chain for signInfo failed"); return false; } ASN1_TYPE* signTime = PKCS7_get_signed_attribute(signInfo, NID_pkcs9_signingTime); if (!HapCertVerifyOpensslUtils::VerifyCertChainPeriodOfValidity(certsChain, signTime)) { - HAPVERIFY_LOG_ERROR(LABEL, "VerifyCertChainPeriodOfValidity for signInfo failed"); + HAPVERIFY_LOG_ERROR("VerifyCertChainPeriodOfValidity for signInfo failed"); return false; } if (!HapCertVerifyOpensslUtils::VerifyCrl(certsChain, p7->d.sign->crl, pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "VerifyCrl for signInfo failed"); + HAPVERIFY_LOG_ERROR("VerifyCrl for signInfo failed"); return false; } return true; @@ -145,12 +145,12 @@ bool HapVerifyOpensslUtils::CheckPkcs7SignedDataIsValid(const PKCS7* p7) bool HapVerifyOpensslUtils::VerifyPkcs7(Pkcs7Context& pkcs7Context) { if (!CheckPkcs7SignedDataIsValid(pkcs7Context.p7)) { - HAPVERIFY_LOG_ERROR(LABEL, "p7 type is invalid signed_data_pkcs7"); + HAPVERIFY_LOG_ERROR("p7 type is invalid signed_data_pkcs7"); return false; } if (!VerifyPkcs7SignedData(pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "verify p7 error"); + HAPVERIFY_LOG_ERROR("verify p7 error"); return false; } return true; @@ -161,7 +161,7 @@ bool HapVerifyOpensslUtils::VerifyPkcs7SignedData(Pkcs7Context& pkcs7Context) /* get signed data which was used to be signed */ BIO* p7Bio = PKCS7_dataDecode(pkcs7Context.p7, nullptr, nullptr, nullptr); if (p7Bio == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "get p7bio error"); + HAPVERIFY_LOG_ERROR("get p7bio error"); GetOpensslErrorMessage(); return false; } @@ -173,7 +173,7 @@ bool HapVerifyOpensslUtils::VerifyPkcs7SignedData(Pkcs7Context& pkcs7Context) } Pkcs7SignerInfoStack* signerInfoStack = PKCS7_get_signer_info(pkcs7Context.p7); if (signerInfoStack == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "get signerInfoStack error"); + HAPVERIFY_LOG_ERROR("get signerInfoStack error"); BIO_free_all(p7Bio); GetOpensslErrorMessage(); return false; @@ -181,13 +181,13 @@ bool HapVerifyOpensslUtils::VerifyPkcs7SignedData(Pkcs7Context& pkcs7Context) /* get the num of signInfo */ int32_t signCount = sk_PKCS7_SIGNER_INFO_num(signerInfoStack); if (signCount <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "can not find signinfo"); + HAPVERIFY_LOG_ERROR("can not find signinfo"); BIO_free_all(p7Bio); return false; } for (int32_t i = 0; i < signCount; i++) { if (!VerifySignInfo(signerInfoStack, p7Bio, i, pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "Verify %{public}dst signInfo failed", i); + HAPVERIFY_LOG_ERROR("Verify %{public}dst signInfo failed", i); BIO_free_all(p7Bio); return false; } @@ -199,13 +199,13 @@ bool HapVerifyOpensslUtils::VerifyPkcs7SignedData(Pkcs7Context& pkcs7Context) bool HapVerifyOpensslUtils::VerifySignInfo(STACK_OF(PKCS7_SIGNER_INFO)* signerInfoStack, BIO* p7Bio, int32_t signInfoNum, Pkcs7Context& pkcs7Context) { if (signerInfoStack == nullptr || p7Bio == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid input"); + HAPVERIFY_LOG_ERROR("invalid input"); return false; } /* get signInfo */ PKCS7_SIGNER_INFO* signInfo = sk_PKCS7_SIGNER_INFO_value(signerInfoStack, signInfoNum); if (signInfo == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "signInfo %{public}dst is nullptr", signInfoNum); + HAPVERIFY_LOG_ERROR("signInfo %{public}dst is nullptr", signInfoNum); return false; } /* GET X509 certificate */ @@ -214,17 +214,17 @@ bool HapVerifyOpensslUtils::VerifySignInfo(STACK_OF(PKCS7_SIGNER_INFO)* signerIn if (isShaWithRsaPss) { EVP_PKEY* pkey = X509_get0_pubkey(cert); if (pkey == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "signInfo %{public}dst X509_get_pubkey failed", signInfoNum); + HAPVERIFY_LOG_ERROR("signInfo %{public}dst X509_get_pubkey failed", signInfoNum); return false; } - HAPVERIFY_LOG_DEBUG(LABEL, "use RSA/pss"); + HAPVERIFY_LOG_DEBUG("use RSA/pss"); if (!VerifyShaWithRsaPss(signInfo, p7Bio, pkey, isShaWithRsaPss)) { - HAPVERIFY_LOG_ERROR(LABEL, "VerifyShaWithRsaPss %{public}dst signInfo failed", signInfoNum); + HAPVERIFY_LOG_ERROR("VerifyShaWithRsaPss %{public}dst signInfo failed", signInfoNum); return false; } } else { if (PKCS7_signatureVerify(p7Bio, pkcs7Context.p7, signInfo, cert) <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "PKCS7_signatureVerify %{public}dst signInfo failed", signInfoNum); + HAPVERIFY_LOG_ERROR("PKCS7_signatureVerify %{public}dst signInfo failed", signInfoNum); GetOpensslErrorMessage(); return false; } @@ -236,12 +236,12 @@ bool HapVerifyOpensslUtils::IsEnablePss(const PKCS7_SIGNER_INFO* signInfo) { char oId[MAX_OID_LENGTH]; if (signInfo->digest_enc_alg == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "signInfo->digest_enc_alg is nullptr"); + HAPVERIFY_LOG_ERROR("signInfo->digest_enc_alg is nullptr"); return false; } int32_t len = OBJ_obj2txt(oId, sizeof(oId), signInfo->digest_enc_alg->algorithm, 1); if (len < 0 || len >= MAX_OID_LENGTH) { - HAPVERIFY_LOG_ERROR(LABEL, "Get length of oId failed"); + HAPVERIFY_LOG_ERROR("Get length of oId failed"); return false; } return PKCS7_EXT_SHAWITHRSA_PSS.compare(0, PKCS7_EXT_SHAWITHRSA_PSS.size(), oId, len) == 0; @@ -251,23 +251,23 @@ bool HapVerifyOpensslUtils::VerifyShaWithRsaPss(const PKCS7_SIGNER_INFO* signInf BIO* p7Bio, EVP_PKEY* pkey, bool isPss) { if (signInfo->digest_alg == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "signInfo->digest_alg is nullptr"); + HAPVERIFY_LOG_ERROR("signInfo->digest_alg is nullptr"); return false; } int32_t mdType = OBJ_obj2nid(signInfo->digest_alg->algorithm); const EVP_MD_CTX* mdCtx = FindMdCtxInBio(p7Bio, mdType); EVP_MD_CTX* mdCtxTmp = EVP_MD_CTX_new(); if (mdCtxTmp == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "EVP_MD_CTX_new failed"); + HAPVERIFY_LOG_ERROR("EVP_MD_CTX_new failed"); return false; } if (!EVP_MD_CTX_copy_ex(mdCtxTmp, mdCtx)) { - HAPVERIFY_LOG_ERROR(LABEL, "EVP_MD_CTX_copy_ex failed"); + HAPVERIFY_LOG_ERROR("EVP_MD_CTX_copy_ex failed"); EVP_MD_CTX_free(mdCtxTmp); return false; } if (!VerifyPkcs7AuthAttributes(signInfo, mdCtxTmp, mdType)) { - HAPVERIFY_LOG_ERROR(LABEL, "VerifyPkcs7AuthAttributes failed"); + HAPVERIFY_LOG_ERROR("VerifyPkcs7AuthAttributes failed"); EVP_MD_CTX_free(mdCtxTmp); return false; } @@ -275,7 +275,7 @@ bool HapVerifyOpensslUtils::VerifyShaWithRsaPss(const PKCS7_SIGNER_INFO* signInf unsigned char digest[EVP_MAX_MD_SIZE]; uint32_t digestLen; if (EVP_DigestFinal_ex(mdCtxTmp, digest, &digestLen) <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "Digest content failed"); + HAPVERIFY_LOG_ERROR("Digest content failed"); GetOpensslErrorMessage(); EVP_MD_CTX_free(mdCtxTmp); return false; @@ -283,7 +283,7 @@ bool HapVerifyOpensslUtils::VerifyShaWithRsaPss(const PKCS7_SIGNER_INFO* signInf EVP_MD_CTX_free(mdCtxTmp); if (!VerifyShaWithRsaPss(signInfo, pkey, isPss, digest, digestLen)) { - HAPVERIFY_LOG_ERROR(LABEL, "VerifyShaWithRsaPss failed"); + HAPVERIFY_LOG_ERROR("VerifyShaWithRsaPss failed"); GetOpensslErrorMessage(); return false; } @@ -296,7 +296,7 @@ const EVP_MD_CTX* HapVerifyOpensslUtils::FindMdCtxInBio(BIO* p7Bio, int32_t mdTy while (p7Bio) { BIO_get_md_ctx(p7Bio, &mdCtx); if (mdCtx == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "Get null from bio"); + HAPVERIFY_LOG_ERROR("Get null from bio"); return nullptr; } if ((EVP_MD_CTX_type(mdCtx) == mdType) || (EVP_MD_pkey_type(EVP_MD_CTX_md(mdCtx)) == mdType)) { @@ -315,18 +315,18 @@ bool HapVerifyOpensslUtils::VerifyPkcs7AuthAttributes( unsigned char digest[EVP_MAX_MD_SIZE]; uint32_t digestLen; if (EVP_DigestFinal_ex(mdCtx, digest, &digestLen) <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "Digest content failed"); + HAPVERIFY_LOG_ERROR("Digest content failed"); GetOpensslErrorMessage(); return false; } ASN1_OCTET_STRING* digestInAttribute = PKCS7_digest_from_attributes(authAttributes); if (!AsnStringCmp(digestInAttribute, digest, static_cast(digestLen))) { - HAPVERIFY_LOG_ERROR(LABEL, "AsnStringCmp failed"); + HAPVERIFY_LOG_ERROR("AsnStringCmp failed"); return false; } if (!EVP_VerifyInit_ex(mdCtx, EVP_get_digestbynid(mdType), nullptr)) { - HAPVERIFY_LOG_ERROR(LABEL, "EVP_VerifyInit_ex failed"); + HAPVERIFY_LOG_ERROR("EVP_VerifyInit_ex failed"); GetOpensslErrorMessage(); return false; } @@ -335,12 +335,12 @@ bool HapVerifyOpensslUtils::VerifyPkcs7AuthAttributes( int32_t attributesLen = ASN1_item_i2d(reinterpret_cast(authAttributes), &attributesData, ASN1_ITEM_rptr(PKCS7_ATTR_VERIFY)); if (attributesLen <= 0 || attributesData == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "ASN1_item_i2d failed"); + HAPVERIFY_LOG_ERROR("ASN1_item_i2d failed"); GetOpensslErrorMessage(); return false; } if (!EVP_VerifyUpdate(mdCtx, attributesData, attributesLen)) { - HAPVERIFY_LOG_ERROR(LABEL, "EVP_VerifyUpdate failed"); + HAPVERIFY_LOG_ERROR("EVP_VerifyUpdate failed"); GetOpensslErrorMessage(); OPENSSL_free(attributesData); return false; @@ -353,24 +353,24 @@ bool HapVerifyOpensslUtils::VerifyPkcs7AuthAttributes( bool HapVerifyOpensslUtils::AsnStringCmp(const ASN1_OCTET_STRING* asnStr, const unsigned char data[], int32_t len) { if (asnStr == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "asnStr is nullptr"); + HAPVERIFY_LOG_ERROR("asnStr is nullptr"); return false; } if (asnStr->data == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "asnStr->data is nullptr"); + HAPVERIFY_LOG_ERROR("asnStr->data is nullptr"); return false; } if (data == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "data is nullptr"); + HAPVERIFY_LOG_ERROR("data is nullptr"); return false; } if (asnStr->length != len) { - HAPVERIFY_LOG_ERROR(LABEL, "asnStr->length: %{public}d is not equal to len: %{public}d", asnStr->length, len); + HAPVERIFY_LOG_ERROR("asnStr->length: %{public}d is not equal to len: %{public}d", asnStr->length, len); return false; } for (int32_t i = 0; i < len; i++) { if (asnStr->data[i] != data[i]) { - HAPVERIFY_LOG_ERROR(LABEL, "%{public}dst data is not equal", i); + HAPVERIFY_LOG_ERROR("%{public}dst data is not equal", i); return false; } } @@ -382,31 +382,31 @@ bool HapVerifyOpensslUtils::VerifyShaWithRsaPss(const PKCS7_SIGNER_INFO* signInf { EVP_PKEY_CTX* pkeyCtx = EVP_PKEY_CTX_new(pkey, nullptr); if (pkeyCtx == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "EVP_PKEY_CTX_new failed"); + HAPVERIFY_LOG_ERROR("EVP_PKEY_CTX_new failed"); GetOpensslErrorMessage(); return false; } if (EVP_PKEY_verify_init(pkeyCtx) <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "EVP_PKEY_verify_init failed"); + HAPVERIFY_LOG_ERROR("EVP_PKEY_verify_init failed"); GetOpensslErrorMessage(); EVP_PKEY_CTX_free(pkeyCtx); return false; } if (signInfo->digest_alg == nullptr || signInfo->enc_digest == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "no digest_alg or enc_digest in signInfo"); + HAPVERIFY_LOG_ERROR("no digest_alg or enc_digest in signInfo"); EVP_PKEY_CTX_free(pkeyCtx); return false; } int32_t mdType = OBJ_obj2nid(signInfo->digest_alg->algorithm); if ((isPss && EVP_PKEY_CTX_set_rsa_padding(pkeyCtx, RSA_PKCS1_PSS_PADDING) <= 0) || (EVP_PKEY_CTX_set_signature_md(pkeyCtx, EVP_get_digestbynid(mdType)) <= 0)) { - HAPVERIFY_LOG_ERROR(LABEL, "set rsa_padding or signature_md failed"); + HAPVERIFY_LOG_ERROR("set rsa_padding or signature_md failed"); GetOpensslErrorMessage(); EVP_PKEY_CTX_free(pkeyCtx); return false; } if (EVP_PKEY_verify(pkeyCtx, signInfo->enc_digest->data, signInfo->enc_digest->length, digest, digestLen) <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "EVP_PKEY_verify failed"); + HAPVERIFY_LOG_ERROR("EVP_PKEY_verify failed"); GetOpensslErrorMessage(); EVP_PKEY_CTX_free(pkeyCtx); return false; @@ -420,7 +420,7 @@ bool HapVerifyOpensslUtils::GetPublickeys(const CertChain& signCertChain, { for (uint32_t i = 0; i < signCertChain.size(); i++) { if (!GetPublickeyFromCertificate(signCertChain[i], SignatureVec)) { - HAPVERIFY_LOG_ERROR(LABEL, "%{public}ust Get Publickey failed", i); + HAPVERIFY_LOG_ERROR("%{public}ust Get Publickey failed", i); return false; } } @@ -432,7 +432,7 @@ bool HapVerifyOpensslUtils::GetSignatures(const CertChain& signCertChain, { for (uint32_t i = 0; i < signCertChain.size(); i++) { if (!GetDerCert(signCertChain[i], SignatureVec)) { - HAPVERIFY_LOG_ERROR(LABEL, "%{public}ust GetDerCert failed", i); + HAPVERIFY_LOG_ERROR("%{public}ust GetDerCert failed", i); return false; } } @@ -447,7 +447,7 @@ bool HapVerifyOpensslUtils::GetDerCert(X509* ptrX509, std::vector& int32_t certLen = i2d_X509(ptrX509, nullptr); if (certLen <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "certLen %{public}d, i2d_X509 failed", certLen); + HAPVERIFY_LOG_ERROR("certLen %{public}d, i2d_X509 failed", certLen); GetOpensslErrorMessage(); return false; } @@ -456,7 +456,7 @@ bool HapVerifyOpensslUtils::GetDerCert(X509* ptrX509, std::vector& std::unique_ptr base64Certificate = std::make_unique(base64CertLen); unsigned char* derCertificateBackup = derCertificate.get(); if (i2d_X509(ptrX509, &derCertificateBackup) <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "i2d_X509 failed"); + HAPVERIFY_LOG_ERROR("i2d_X509 failed"); GetOpensslErrorMessage(); return false; } @@ -475,7 +475,7 @@ bool HapVerifyOpensslUtils::GetPublickeyFromCertificate(const X509* ptrX509, std std::string publicKey; if (!HapCertVerifyOpensslUtils::GetPublickeyBase64(ptrX509, publicKey)) { - HAPVERIFY_LOG_ERROR(LABEL, "GetPublickeyBase64 Failed"); + HAPVERIFY_LOG_ERROR("GetPublickeyBase64 Failed"); return false; } publicKeyVec.emplace_back(publicKey); @@ -485,26 +485,26 @@ bool HapVerifyOpensslUtils::GetPublickeyFromCertificate(const X509* ptrX509, std bool HapVerifyOpensslUtils::GetContentInfo(const PKCS7* p7ContentInfo, HapByteBuffer& content) { if ((p7ContentInfo == nullptr) || !PKCS7_type_is_data(p7ContentInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "p7ContentInfo is invalid"); + HAPVERIFY_LOG_ERROR("p7ContentInfo is invalid"); return false; } ASN1_OCTET_STRING* strContentInfo = p7ContentInfo->d.data; if (strContentInfo == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "strContentInfo is invalid"); + HAPVERIFY_LOG_ERROR("strContentInfo is invalid"); return false; } int32_t strContentInfoLen = strContentInfo->length; unsigned char* strContentInfoData = strContentInfo->data; if (strContentInfoData == nullptr || strContentInfoLen <= 0) { - HAPVERIFY_LOG_ERROR(LABEL, "ASN1_OCTET_STRING is invalid"); + HAPVERIFY_LOG_ERROR("ASN1_OCTET_STRING is invalid"); return false; } content.SetCapacity(strContentInfoLen); content.PutData(0, reinterpret_cast(strContentInfoData), strContentInfoLen); - HAPVERIFY_LOG_DEBUG(LABEL, "strContentInfoLen: %{public}d", strContentInfoLen); + HAPVERIFY_LOG_DEBUG("strContentInfoLen: %{public}d", strContentInfoLen); return true; } @@ -516,11 +516,11 @@ int32_t HapVerifyOpensslUtils::GetDigestAlgorithmOutputSizeBytes(int32_t nId) bool HapVerifyOpensslUtils::CheckDigestParameter(const DigestParameter& digestParameter) { if (digestParameter.md == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "md is nullptr"); + HAPVERIFY_LOG_ERROR("md is nullptr"); return false; } if (digestParameter.ptrCtx == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "ptrCtx is nullptr"); + HAPVERIFY_LOG_ERROR("ptrCtx is nullptr"); return false; } return true; @@ -533,7 +533,7 @@ bool HapVerifyOpensslUtils::DigestInit(const DigestParameter& digestParameter) } if (EVP_DigestInit(digestParameter.ptrCtx, digestParameter.md) <= 0) { GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "EVP_DigestInit failed"); + HAPVERIFY_LOG_ERROR("EVP_DigestInit failed"); return false; } return true; @@ -544,7 +544,7 @@ bool HapVerifyOpensslUtils::DigestUpdate(const DigestParameter& digestParameter, const unsigned char content[], int32_t len) { if (content == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "content is nullptr"); + HAPVERIFY_LOG_ERROR("content is nullptr"); return false; } if (!CheckDigestParameter(digestParameter)) { @@ -552,7 +552,7 @@ bool HapVerifyOpensslUtils::DigestUpdate(const DigestParameter& digestParameter, } if (EVP_DigestUpdate(digestParameter.ptrCtx, content, len) <= 0) { GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "EVP_DigestUpdate chunk failed"); + HAPVERIFY_LOG_ERROR("EVP_DigestUpdate chunk failed"); return false; } return true; @@ -566,7 +566,7 @@ int32_t HapVerifyOpensslUtils::GetDigest(const DigestParameter& digestParameter, } if (EVP_DigestFinal(digestParameter.ptrCtx, out, &outLen) <= 0) { GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "EVP_DigestFinal failed"); + HAPVERIFY_LOG_ERROR("EVP_DigestFinal failed"); outLen = 0; } return outLen; @@ -578,23 +578,23 @@ int32_t HapVerifyOpensslUtils::GetDigest(const HapByteBuffer& chunk, const std:: int32_t chunkLen = chunk.Remaining(); uint32_t outLen = 0; if (digestParameter.md == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "md is nullprt"); + HAPVERIFY_LOG_ERROR("md is nullprt"); return outLen; } if (digestParameter.ptrCtx == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "ptrCtx is nullprt"); + HAPVERIFY_LOG_ERROR("ptrCtx is nullprt"); return outLen; } if (EVP_DigestInit(digestParameter.ptrCtx, digestParameter.md) <= 0) { GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "EVP_DigestInit failed"); + HAPVERIFY_LOG_ERROR("EVP_DigestInit failed"); return outLen; } if (EVP_DigestUpdate(digestParameter.ptrCtx, chunk.GetBufferPtr(), chunkLen) <= 0) { GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "EVP_DigestUpdate chunk failed"); + HAPVERIFY_LOG_ERROR("EVP_DigestUpdate chunk failed"); return outLen; } for (int32_t i = 0; i < static_cast(optionalBlocks.size()); i++) { @@ -602,14 +602,14 @@ int32_t HapVerifyOpensslUtils::GetDigest(const HapByteBuffer& chunk, const std:: if (EVP_DigestUpdate(digestParameter.ptrCtx, optionalBlocks[i].optionalBlockValue.GetBufferPtr(), chunkLen) <= 0) { GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "EVP_DigestUpdate %{public}dst optional block failed", i); + HAPVERIFY_LOG_ERROR("EVP_DigestUpdate %{public}dst optional block failed", i); return outLen; } } if (EVP_DigestFinal(digestParameter.ptrCtx, out, &outLen) <= 0) { GetOpensslErrorMessage(); - HAPVERIFY_LOG_ERROR(LABEL, "EVP_DigestFinal failed"); + HAPVERIFY_LOG_ERROR("EVP_DigestFinal failed"); outLen = 0; } return outLen; @@ -621,7 +621,7 @@ void HapVerifyOpensslUtils::GetOpensslErrorMessage() char errOpenssl[OPENSSL_ERR_MESSAGE_MAX_LEN]; while ((retOpenssl = ERR_get_error()) != 0) { ERR_error_string(retOpenssl, errOpenssl); - HAPVERIFY_LOG_ERROR(LABEL, "openssl err: %{public}lu, message: %{public}s", retOpenssl, errOpenssl); + HAPVERIFY_LOG_ERROR("openssl err: %{public}lu, message: %{public}s", retOpenssl, errOpenssl); } } @@ -644,7 +644,7 @@ int32_t HapVerifyOpensslUtils::GetDigestAlgorithmId(int32_t signAlgorithm) case ALGORITHM_SHA512_WITH_DSA: return NID_sha512; default: - HAPVERIFY_LOG_ERROR(LABEL, "signAlgorithm: %{public}d error", signAlgorithm); + HAPVERIFY_LOG_ERROR("signAlgorithm: %{public}d error", signAlgorithm); return NID_undef; } } diff --git a/interfaces/innerkits/appverify/src/verify/hap_verify_v2.cpp b/interfaces/innerkits/appverify/src/verify/hap_verify_v2.cpp index 2eb778986fc5383ccb3c6befb0e6bfa230d3fda3..6910834a790eed25887809a6e6158c24c55156a6 100644 --- a/interfaces/innerkits/appverify/src/verify/hap_verify_v2.cpp +++ b/interfaces/innerkits/appverify/src/verify/hap_verify_v2.cpp @@ -43,7 +43,7 @@ const std::string HapVerifyV2::HSP_APP_PATTERN = "[^]*.hsp$"; int32_t HapVerifyV2::Verify(const std::string& filePath, HapVerifyResult& hapVerifyV1Result) { - HAPVERIFY_LOG_DEBUG(LABEL, "Start Verify"); + HAPVERIFY_LOG_DEBUG("Start Verify"); std::string standardFilePath; if (!CheckFilePath(filePath, standardFilePath)) { return FILE_PATH_INVALID; @@ -51,7 +51,7 @@ int32_t HapVerifyV2::Verify(const std::string& filePath, HapVerifyResult& hapVer RandomAccessFile hapFile; if (!hapFile.Init(standardFilePath)) { - HAPVERIFY_LOG_ERROR(LABEL, "open standard file failed"); + HAPVERIFY_LOG_ERROR("open standard file failed"); return OPEN_FILE_ERROR; } @@ -63,14 +63,14 @@ bool HapVerifyV2::CheckFilePath(const std::string& filePath, std::string& standa { char path[PATH_MAX + 1] = { 0x00 }; if (filePath.size() > PATH_MAX || realpath(filePath.c_str(), path) == nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "filePath is not a standard path"); + HAPVERIFY_LOG_ERROR("filePath is not a standard path"); return false; } standardFilePath = std::string(path); if (!std::regex_match(standardFilePath, std::regex(HAP_APP_PATTERN)) && !std::regex_match(standardFilePath, std::regex(HSP_APP_PATTERN)) && !std::regex_match(standardFilePath, std::regex(HQF_APP_PATTERN))) { - HAPVERIFY_LOG_ERROR(LABEL, "file is not hap, hsp or hqf package"); + HAPVERIFY_LOG_ERROR("file is not hap, hsp or hqf package"); return false; } return true; @@ -97,27 +97,27 @@ int32_t HapVerifyV2::Verify(RandomAccessFile& hapFile, HapVerifyResult& hapVerif bool profileNeedWriteCrl = false; if (!VerifyAppSourceAndParseProfile(pkcs7Context, hapSignInfo.optionBlocks[profileIndex].optionalBlockValue, hapVerifyV1Result, profileNeedWriteCrl)) { - HAPVERIFY_LOG_ERROR(LABEL, "APP source is not trusted"); + HAPVERIFY_LOG_ERROR("APP source is not trusted"); return APP_SOURCE_NOT_TRUSTED; } if (!GetDigestAndAlgorithm(pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get digest failed"); + HAPVERIFY_LOG_ERROR("Get digest failed"); return GET_DIGEST_FAIL; } std::vector publicKeys; if (!HapVerifyOpensslUtils::GetPublickeys(pkcs7Context.certChains[0], publicKeys)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get publicKeys failed"); + HAPVERIFY_LOG_ERROR("Get publicKeys failed"); return GET_PUBLICKEY_FAIL; } hapVerifyV1Result.SetPublicKey(publicKeys); std::vector certSignatures; if (!HapVerifyOpensslUtils::GetSignatures(pkcs7Context.certChains[0], certSignatures)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get sianatures failed"); + HAPVERIFY_LOG_ERROR("Get sianatures failed"); return GET_SIGNATURE_FAIL; } hapVerifyV1Result.SetSignature(certSignatures); if (!HapSigningBlockUtils::VerifyHapIntegrity(pkcs7Context, hapFile, hapSignInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "Verify Integrity failed"); + HAPVERIFY_LOG_ERROR("Verify Integrity failed"); return VERIFY_INTEGRITY_FAIL; } WriteCrlIfNeed(pkcs7Context, profileNeedWriteCrl); @@ -129,15 +129,15 @@ bool HapVerifyV2::VerifyAppPkcs7(Pkcs7Context& pkcs7Context, const HapByteBuffer const unsigned char* pkcs7Block = reinterpret_cast(hapSignatureBlock.GetBufferPtr()); uint32_t pkcs7Len = static_cast(hapSignatureBlock.GetCapacity()); if (!HapVerifyOpensslUtils::ParsePkcs7Package(pkcs7Block, pkcs7Len, pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "parse pkcs7 failed"); + HAPVERIFY_LOG_ERROR("parse pkcs7 failed"); return false; } if (!HapVerifyOpensslUtils::GetCertChains(pkcs7Context.p7, pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "GetCertChains from pkcs7 failed"); + HAPVERIFY_LOG_ERROR("GetCertChains from pkcs7 failed"); return false; } if (!HapVerifyOpensslUtils::VerifyPkcs7(pkcs7Context)) { - HAPVERIFY_LOG_ERROR(LABEL, "verify signature failed"); + HAPVERIFY_LOG_ERROR("verify signature failed"); return false; } return true; @@ -148,10 +148,10 @@ bool HapVerifyV2::VerifyAppSourceAndParseProfile(Pkcs7Context& pkcs7Context, { std::string certSubject; if (!HapCertVerifyOpensslUtils::GetSubjectFromX509(pkcs7Context.certChains[0][0], certSubject)) { - HAPVERIFY_LOG_ERROR(LABEL, "Get info of sign cert failed"); + HAPVERIFY_LOG_ERROR("Get info of sign cert failed"); return false; } - HAPVERIFY_LOG_DEBUG(LABEL, "App signature subject: %{public}s, issuer: %{public}s", + HAPVERIFY_LOG_DEBUG("App signature subject: %{public}s, issuer: %{public}s", certSubject.c_str(), pkcs7Context.certIssuer.c_str()); TrustedSourceManager& trustedSourceManager = TrustedSourceManager::GetInstance(); @@ -161,12 +161,12 @@ bool HapVerifyV2::VerifyAppSourceAndParseProfile(Pkcs7Context& pkcs7Context, Pkcs7Context profileContext; std::string profile; if (!HapProfileVerifyUtils::ParseProfile(profileContext, pkcs7Context, hapProfileBlock, profile)) { - HAPVERIFY_LOG_ERROR(LABEL, "Parse profile pkcs7 failed"); + HAPVERIFY_LOG_ERROR("Parse profile pkcs7 failed"); return false; } if (!VerifyProfileSignature(pkcs7Context, profileContext)) { - HAPVERIFY_LOG_ERROR(LABEL, "VerifyProfileSignature failed"); + HAPVERIFY_LOG_ERROR("VerifyProfileSignature failed"); return false; } /* @@ -178,16 +178,16 @@ bool HapVerifyV2::VerifyAppSourceAndParseProfile(Pkcs7Context& pkcs7Context, ProvisionInfo provisionInfo; if (pkcs7Context.matchResult.matchState == DO_NOT_MATCH) { if (!HapProfileVerifyUtils::VerifyProfile(profileContext)) { - HAPVERIFY_LOG_ERROR(LABEL, "profile verify failed"); + HAPVERIFY_LOG_ERROR("profile verify failed"); return false; } AppProvisionVerifyResult profileRet = ParseAndVerify(profile, provisionInfo); if (profileRet != PROVISION_OK) { - HAPVERIFY_LOG_ERROR(LABEL, "profile parsing failed, error: %{public}d", static_cast(profileRet)); + HAPVERIFY_LOG_ERROR("profile parsing failed, error: %{public}d", static_cast(profileRet)); return false; } if (!VerifyProfileInfo(pkcs7Context, profileContext, provisionInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "VerifyProfileInfo failed"); + HAPVERIFY_LOG_ERROR("VerifyProfileInfo failed"); return false; } isCallParseAndVerify = true; @@ -198,7 +198,7 @@ bool HapVerifyV2::VerifyAppSourceAndParseProfile(Pkcs7Context& pkcs7Context, } if (!GenerateAppId(provisionInfo) || !GenerateFingerprint(provisionInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "Generate appId or generate fingerprint failed"); + HAPVERIFY_LOG_ERROR("Generate appId or generate fingerprint failed"); return false; } SetOrganization(provisionInfo); @@ -214,7 +214,7 @@ bool HapVerifyV2::VerifyProfileSignature(const Pkcs7Context& pkcs7Context, Pkcs7 if (pkcs7Context.matchResult.matchState == MATCH_WITH_SIGN && pkcs7Context.matchResult.source == APP_THIRD_PARTY_PRELOAD) { if (!HapProfileVerifyUtils::VerifyProfile(profileContext)) { - HAPVERIFY_LOG_ERROR(LABEL, "profile verify failed"); + HAPVERIFY_LOG_ERROR("profile verify failed"); return false; } } @@ -226,14 +226,14 @@ bool HapVerifyV2::GenerateAppId(ProvisionInfo& provisionInfo) std::string& certInProfile = provisionInfo.bundleInfo.distributionCertificate; if (provisionInfo.bundleInfo.distributionCertificate.empty()) { certInProfile = provisionInfo.bundleInfo.developmentCertificate; - HAPVERIFY_LOG_DEBUG(LABEL, "use development Certificate"); + HAPVERIFY_LOG_DEBUG("use development Certificate"); } std::string publicKey; if (!HapCertVerifyOpensslUtils::GetPublickeyBase64FromPemCert(certInProfile, publicKey)) { return false; } provisionInfo.appId = publicKey; - HAPVERIFY_LOG_DEBUG(LABEL, "provisionInfo.appId: %{public}s", provisionInfo.appId.c_str()); + HAPVERIFY_LOG_DEBUG("provisionInfo.appId: %{public}s", provisionInfo.appId.c_str()); return true; } @@ -242,15 +242,15 @@ bool HapVerifyV2::GenerateFingerprint(ProvisionInfo& provisionInfo) std::string& certInProfile = provisionInfo.bundleInfo.distributionCertificate; if (provisionInfo.bundleInfo.distributionCertificate.empty()) { certInProfile = provisionInfo.bundleInfo.developmentCertificate; - HAPVERIFY_LOG_DEBUG(LABEL, "use development Certificate"); + HAPVERIFY_LOG_DEBUG("use development Certificate"); } std::string fingerprint; if (!HapCertVerifyOpensslUtils::GetFingerprintBase64FromPemCert(certInProfile, fingerprint)) { - HAPVERIFY_LOG_ERROR(LABEL, "Generate fingerprint from pem certificate failed"); + HAPVERIFY_LOG_ERROR("Generate fingerprint from pem certificate failed"); return false; } provisionInfo.fingerprint = fingerprint; - HAPVERIFY_LOG_DEBUG(LABEL, "fingerprint is : %{public}s", fingerprint.c_str()); + HAPVERIFY_LOG_DEBUG("fingerprint is : %{public}s", fingerprint.c_str()); return true; } @@ -259,25 +259,25 @@ void HapVerifyV2::SetProfileBlockData(const Pkcs7Context& pkcs7Context, const Ha { if (pkcs7Context.matchResult.matchState == MATCH_WITH_SIGN && pkcs7Context.matchResult.source == APP_GALLARY) { - HAPVERIFY_LOG_DEBUG(LABEL, "profile is from app gallary and unnecessary to set profile block"); + HAPVERIFY_LOG_DEBUG("profile is from app gallary and unnecessary to set profile block"); return; } provisionInfo.profileBlockLength = hapProfileBlock.GetCapacity(); - HAPVERIFY_LOG_DEBUG(LABEL, "profile block data length is %{public}d", provisionInfo.profileBlockLength); + HAPVERIFY_LOG_DEBUG("profile block data length is %{public}d", provisionInfo.profileBlockLength); if (provisionInfo.profileBlockLength == 0) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid profile block"); + HAPVERIFY_LOG_ERROR("invalid profile block"); return; } provisionInfo.profileBlock = std::make_unique(provisionInfo.profileBlockLength); unsigned char *profileBlockData = provisionInfo.profileBlock.get(); const unsigned char *originalProfile = reinterpret_cast(hapProfileBlock.GetBufferPtr()); if (profileBlockData == nullptr || originalProfile ==nullptr) { - HAPVERIFY_LOG_ERROR(LABEL, "invalid profileBlockData or originalProfile"); + HAPVERIFY_LOG_ERROR("invalid profileBlockData or originalProfile"); return; } if (memcpy_s(profileBlockData, provisionInfo.profileBlockLength, originalProfile, provisionInfo.profileBlockLength) != 0) { - HAPVERIFY_LOG_ERROR(LABEL, "memcpy failed"); + HAPVERIFY_LOG_ERROR("memcpy failed"); } } @@ -290,17 +290,17 @@ bool HapVerifyV2::VerifyProfileInfo(const Pkcs7Context& pkcs7Context, const Pkcs std::string& certInProfile = provisionInfo.bundleInfo.developmentCertificate; if (provisionInfo.type == ProvisionType::RELEASE) { if (!IsAppDistributedTypeAllowInstall(provisionInfo.distributionType, provisionInfo)) { - HAPVERIFY_LOG_ERROR(LABEL, "untrusted source app with release profile distributionType: %{public}d", + HAPVERIFY_LOG_ERROR("untrusted source app with release profile distributionType: %{public}d", static_cast(provisionInfo.distributionType)); return false; } certInProfile = provisionInfo.bundleInfo.distributionCertificate; - HAPVERIFY_LOG_DEBUG(LABEL, "allow install app with release profile distributionType: %{public}d", + HAPVERIFY_LOG_DEBUG("allow install app with release profile distributionType: %{public}d", static_cast(provisionInfo.distributionType)); } - HAPVERIFY_LOG_DEBUG(LABEL, "provisionInfo.type: %{public}d", static_cast(provisionInfo.type)); + HAPVERIFY_LOG_DEBUG("provisionInfo.type: %{public}d", static_cast(provisionInfo.type)); if (!HapCertVerifyOpensslUtils::CompareX509Cert(pkcs7Context.certChains[0][0], certInProfile)) { - HAPVERIFY_LOG_ERROR(LABEL, "developed cert is not same as signed cert"); + HAPVERIFY_LOG_ERROR("developed cert is not same as signed cert"); return false; } return true; @@ -313,7 +313,7 @@ bool HapVerifyV2::IsAppDistributedTypeAllowInstall(const AppDistType& type, cons return false; case AppDistType::APP_GALLERY: if (CheckTicketSource(provisionInfo)) { - HAPVERIFY_LOG_INFO(LABEL, "current device is allowed to install opentest application"); + HAPVERIFY_LOG_INFO("current device is allowed to install opentest application"); return true; } return false; @@ -335,7 +335,7 @@ bool HapVerifyV2::CheckProfileSignatureIsRight(const MatchingStates& matchState, } else if (matchState == MATCH_WITH_PROFILE_DEBUG && type == ProvisionType::DEBUG) { return true; } - HAPVERIFY_LOG_ERROR(LABEL, "isTrustedSource: %{public}d is not match with profile type: %{public}d", + HAPVERIFY_LOG_ERROR("isTrustedSource: %{public}d is not match with profile type: %{public}d", static_cast(matchState), static_cast(type)); return false; } @@ -357,7 +357,7 @@ bool HapVerifyV2::ParseAndVerifyProfileIfNeed(const std::string& profile, } AppProvisionVerifyResult profileRet = ParseAndVerify(profile, provisionInfo); if (profileRet != PROVISION_OK) { - HAPVERIFY_LOG_ERROR(LABEL, "profile parse failed, error: %{public}d", static_cast(profileRet)); + HAPVERIFY_LOG_ERROR("profile parse failed, error: %{public}d", static_cast(profileRet)); return false; } return true; @@ -379,24 +379,24 @@ bool HapVerifyV2::GetDigestAndAlgorithm(Pkcs7Context& digest) /* length of sizeof(digestblock - 4) */ int32_t digestBlockLen; if (!digest.content.GetInt32(DIGEST_BLOCK_LEN_OFFSET, digestBlockLen)) { - HAPVERIFY_LOG_ERROR(LABEL, "get digestBlockLen failed"); + HAPVERIFY_LOG_ERROR("get digestBlockLen failed"); return false; } /* Algorithm ID */ if (!digest.content.GetInt32(DIGEST_ALGORITHM_OFFSET, digest.digestAlgorithm)) { - HAPVERIFY_LOG_ERROR(LABEL, "get digestAlgorithm failed"); + HAPVERIFY_LOG_ERROR("get digestAlgorithm failed"); return false; } /* length of digest */ int32_t digestlen; if (!digest.content.GetInt32(DIGEST_LEN_OFFSET, digestlen)) { - HAPVERIFY_LOG_ERROR(LABEL, "get digestlen failed"); + HAPVERIFY_LOG_ERROR("get digestlen failed"); return false; } int32_t sum = sizeof(digestlen) + sizeof(digest.digestAlgorithm) + digestlen; if (sum != digestBlockLen) { - HAPVERIFY_LOG_ERROR(LABEL, "digestBlockLen: %{public}d is not equal to sum: %{public}d", + HAPVERIFY_LOG_ERROR("digestBlockLen: %{public}d is not equal to sum: %{public}d", digestBlockLen, sum); return false; } @@ -410,7 +410,7 @@ bool HapVerifyV2::GetDigestAndAlgorithm(Pkcs7Context& digest) int32_t HapVerifyV2::ParseHapProfile(const std::string& filePath, HapVerifyResult& hapVerifyV1Result) { - HAPVERIFY_LOG_INFO(LABEL, "start to ParseHapProfile"); + HAPVERIFY_LOG_INFO("start to ParseHapProfile"); std::string standardFilePath; if (!CheckFilePath(filePath, standardFilePath)) { return FILE_PATH_INVALID; @@ -418,7 +418,7 @@ int32_t HapVerifyV2::ParseHapProfile(const std::string& filePath, HapVerifyResul RandomAccessFile hapFile; if (!hapFile.Init(standardFilePath)) { - HAPVERIFY_LOG_ERROR(LABEL, "open standard file failed"); + HAPVERIFY_LOG_ERROR("open standard file failed"); return OPEN_FILE_ERROR; } @@ -436,11 +436,11 @@ int32_t HapVerifyV2::ParseHapProfile(const std::string& filePath, HapVerifyResul uint32_t pkcs7Len = static_cast(pkcs7ProfileBlock.GetCapacity()); Pkcs7Context profileContext; if (!HapVerifyOpensslUtils::ParsePkcs7Package(pkcs7Block, pkcs7Len, profileContext)) { - HAPVERIFY_LOG_ERROR(LABEL, "parse pkcs7 failed"); + HAPVERIFY_LOG_ERROR("parse pkcs7 failed"); return false; } std::string profile = std::string(profileContext.content.GetBufferPtr(), profileContext.content.GetCapacity()); - HAPVERIFY_LOG_DEBUG(LABEL, "profile is %{public}s", profile.c_str()); + HAPVERIFY_LOG_DEBUG("profile is %{public}s", profile.c_str()); ProvisionInfo info; auto ret = ParseProfile(profile, info); if (ret != PROVISION_OK) { @@ -448,7 +448,7 @@ int32_t HapVerifyV2::ParseHapProfile(const std::string& filePath, HapVerifyResul } if (!GenerateFingerprint(info)) { - HAPVERIFY_LOG_ERROR(LABEL, "Generate appId or generate fingerprint failed"); + HAPVERIFY_LOG_ERROR("Generate appId or generate fingerprint failed"); return PROFILE_PARSE_FAIL; } SetOrganization(info); @@ -465,7 +465,7 @@ int32_t HapVerifyV2::ParseHapSignatureInfo(const std::string& filePath, Signatur RandomAccessFile hapFile; if (!hapFile.Init(standardFilePath)) { - HAPVERIFY_LOG_ERROR(LABEL, "open standard file failed"); + HAPVERIFY_LOG_ERROR("open standard file failed"); return OPEN_FILE_ERROR; } @@ -479,12 +479,12 @@ void HapVerifyV2::SetOrganization(ProvisionInfo& provisionInfo) { std::string& certInProfile = provisionInfo.bundleInfo.distributionCertificate; if (provisionInfo.bundleInfo.distributionCertificate.empty()) { - HAPVERIFY_LOG_ERROR(LABEL, "distributionCertificate is empty"); + HAPVERIFY_LOG_ERROR("distributionCertificate is empty"); return; } std::string organization; if (!HapCertVerifyOpensslUtils::GetOrganizationFromPemCert(certInProfile, organization)) { - HAPVERIFY_LOG_ERROR(LABEL, "Generate organization from pem certificate failed"); + HAPVERIFY_LOG_ERROR("Generate organization from pem certificate failed"); return; } provisionInfo.organization = organization;