introduce wrapper for SHA1 functionality
This commit is contained in:
1 parent
91169333e9
commit
dd29a54cf6
27 files changed
+256
-199
No files matched your search
@@ -14,11 +14,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <mbedtls/sha1.h>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Crypto/SHA1.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/NandPaths.h"
|
||||
#include "Common/StringUtil.h"
|
||||
@@ -109,10 +109,8 @@ static size_t GetIssuerOffset(SignatureType signature_type)
|
||||
|
||||
std::array<u8, 20> SignedBlobReader::GetSha1() const
|
||||
{
|
||||
std::array<u8, 20> sha1;
|
||||
const size_t skip = GetIssuerOffset(GetSignatureType());
|
||||
mbedtls_sha1_ret(m_bytes.data() + skip, m_bytes.size() - skip, sha1.data());
|
||||
return sha1;
|
||||
return Common::SHA1::CalculateDigest(m_bytes.data() + skip, m_bytes.size() - skip);
|
||||
}
|
||||
|
||||
bool SignedBlobReader::IsSignatureValid() const
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <mbedtls/sha1.h>
|
||||
|
||||
#include "Common/Crypto/SHA1.h"
|
||||
#include "Common/Crypto/ec.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/ScopeGuard.h"
|
||||
@@ -171,9 +170,8 @@ ReturnCode ESDevice::VerifySign(const std::vector<u8>& hash, const std::vector<u
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::array<u8, 20> sha1;
|
||||
mbedtls_sha1_ret(hash.data(), hash.size(), sha1.data());
|
||||
ret = iosc.VerifyPublicKeySign(sha1, ap_cert, ecc_signature, PID_ES);
|
||||
const auto hash_digest = Common::SHA1::CalculateDigest(hash);
|
||||
ret = iosc.VerifyPublicKeySign(hash_digest, ap_cert, ecc_signature, PID_ES);
|
||||
if (ret != IPC_SUCCESS)
|
||||
{
|
||||
ERROR_LOG_FMT(IOS_ES, "VerifySign: IOSC_VerifyPublicKeySign(data) failed with error {}", ret);
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <mbedtls/sha1.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Crypto/SHA1.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/NandPaths.h"
|
||||
#include "Common/ScopeGuard.h"
|
||||
@@ -197,9 +197,7 @@ ESDevice::GetStoredContentsFromTMD(const ES::TMDReader& tmd,
|
||||
std::vector<u8> content_data(file->GetStatus()->size);
|
||||
if (!file->Read(content_data.data(), content_data.size()))
|
||||
return false;
|
||||
std::array<u8, 20> sha1{};
|
||||
mbedtls_sha1_ret(content_data.data(), content_data.size(), sha1.data());
|
||||
return sha1 == content.sha1;
|
||||
return Common::SHA1::CalculateDigest(content_data) == content.sha1;
|
||||
});
|
||||
|
||||
return stored_contents;
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <mbedtls/sha1.h>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/Crypto/SHA1.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/NandPaths.h"
|
||||
#include "Core/CommonTitles.h"
|
||||
@@ -353,9 +353,7 @@ IPCReply ESDevice::ImportContentData(Context& context, const IOCtlVRequest& requ
|
||||
|
||||
static bool CheckIfContentHashMatches(const std::vector<u8>& content, const ES::Content& info)
|
||||
{
|
||||
std::array<u8, 20> sha1;
|
||||
mbedtls_sha1_ret(content.data(), info.size, sha1.data());
|
||||
return sha1 == info.sha1;
|
||||
return Common::SHA1::CalculateDigest(content.data(), info.size) == info.sha1;
|
||||
}
|
||||
|
||||
static std::string GetImportContentPath(u64 title_id, u32 content_id)
|
||||
|
||||
Reference in new issue
Block a user