diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 377d36eb28..f66e61c07b 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -681,5 +681,23 @@ std::vector CertReader::GetPublicKey() const const auto key_begin = m_bytes.begin() + info.first; return std::vector(key_begin, key_begin + info.second); } + +std::map ParseCertChain(const std::vector& chain) +{ + std::map certs; + + size_t processed = 0; + while (processed != chain.size()) + { + CertReader cert_reader{std::vector(chain.begin() + processed, chain.end())}; + if (!cert_reader.IsValid()) + return certs; + + processed += cert_reader.GetBytes().size(); + const std::string name = cert_reader.GetName(); + certs.emplace(std::move(name), std::move(cert_reader)); + } + return certs; +} } // namespace ES } // namespace IOS diff --git a/Source/Core/Core/IOS/ES/Formats.h b/Source/Core/Core/IOS/ES/Formats.h index 3606b12f49..943f93d8da 100644 --- a/Source/Core/Core/IOS/ES/Formats.h +++ b/Source/Core/Core/IOS/ES/Formats.h @@ -284,5 +284,7 @@ public: private: bool m_is_valid = false; }; + +std::map ParseCertChain(const std::vector& chain); } // namespace ES } // namespace IOS