mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-14 07:04:49 -04:00
Kaitai-based Intel ACM and BootGuard parsers
As the first step towards automated parsing, this change set replaces outdated BootGuard-related parsers with shiny new KaitaiStruct-based ones. It also does the following: - improves Intel FIT definitions by using the relevant specification - adds sha1, sha384, sha512 and sm3 digest implementations - updates LZMA SDK to v22.01 - moves GUIDs out of include files to prevent multiple instantiations - enforces C++11 - adds Kaitai-based parsers for Intel FIT, BootGuard v1 and BootGuard v2 structures - makes many small refactorings here, there and everywhere
This commit is contained in:
parent
8600bc3ab3
commit
934ce1f3f8
81 changed files with 15212 additions and 5279 deletions
162
common/generated/intel_keym_v1.cpp
Normal file
162
common/generated/intel_keym_v1.cpp
Normal file
|
@ -0,0 +1,162 @@
|
|||
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
|
||||
|
||||
#include "intel_keym_v1.h"
|
||||
#include "../kaitai/exceptions.h"
|
||||
|
||||
intel_keym_v1_t::intel_keym_v1_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, intel_keym_v1_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = this; (void)p__root;
|
||||
m_km_hash = 0;
|
||||
m_key_signature = 0;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::_read() {
|
||||
m_structure_id = static_cast<intel_keym_v1_t::structure_ids_t>(m__io->read_u8le());
|
||||
if (!(structure_id() == intel_keym_v1_t::STRUCTURE_IDS_KEYM)) {
|
||||
throw kaitai::validation_not_equal_error<intel_keym_v1_t::structure_ids_t>(intel_keym_v1_t::STRUCTURE_IDS_KEYM, structure_id(), _io(), std::string("/seq/0"));
|
||||
}
|
||||
m_version = m__io->read_u1();
|
||||
{
|
||||
uint8_t _ = version();
|
||||
if (!(_ < 32)) {
|
||||
throw kaitai::validation_expr_error<uint8_t>(version(), _io(), std::string("/seq/1"));
|
||||
}
|
||||
}
|
||||
m_km_version = m__io->read_u1();
|
||||
m_km_svn = m__io->read_u1();
|
||||
m_km_id = m__io->read_u1();
|
||||
m_km_hash = new km_hash_t(m__io, this, m__root);
|
||||
m_key_signature = new key_signature_t(m__io, this, m__root);
|
||||
}
|
||||
|
||||
intel_keym_v1_t::~intel_keym_v1_t() {
|
||||
_clean_up();
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::_clean_up() {
|
||||
if (m_km_hash) {
|
||||
delete m_km_hash; m_km_hash = 0;
|
||||
}
|
||||
if (m_key_signature) {
|
||||
delete m_key_signature; m_key_signature = 0;
|
||||
}
|
||||
}
|
||||
|
||||
intel_keym_v1_t::km_hash_t::km_hash_t(kaitai::kstream* p__io, intel_keym_v1_t* p__parent, intel_keym_v1_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::km_hash_t::_read() {
|
||||
m_hash_algorithm_id = m__io->read_u2le();
|
||||
m_len_hash = m__io->read_u2le();
|
||||
m_hash = m__io->read_bytes(len_hash());
|
||||
}
|
||||
|
||||
intel_keym_v1_t::km_hash_t::~km_hash_t() {
|
||||
_clean_up();
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::km_hash_t::_clean_up() {
|
||||
}
|
||||
|
||||
intel_keym_v1_t::public_key_t::public_key_t(kaitai::kstream* p__io, intel_keym_v1_t::key_signature_t* p__parent, intel_keym_v1_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::public_key_t::_read() {
|
||||
m_version = m__io->read_u1();
|
||||
m_size_bits = m__io->read_u2le();
|
||||
m_exponent = m__io->read_u4le();
|
||||
m_modulus = m__io->read_bytes((size_bits() / 8));
|
||||
}
|
||||
|
||||
intel_keym_v1_t::public_key_t::~public_key_t() {
|
||||
_clean_up();
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::public_key_t::_clean_up() {
|
||||
}
|
||||
|
||||
intel_keym_v1_t::signature_t::signature_t(kaitai::kstream* p__io, intel_keym_v1_t::key_signature_t* p__parent, intel_keym_v1_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::signature_t::_read() {
|
||||
m_version = m__io->read_u1();
|
||||
m_size_bits = m__io->read_u2le();
|
||||
m_hash_algorithm_id = m__io->read_u2le();
|
||||
m_signature = m__io->read_bytes((size_bits() / 8));
|
||||
}
|
||||
|
||||
intel_keym_v1_t::signature_t::~signature_t() {
|
||||
_clean_up();
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::signature_t::_clean_up() {
|
||||
}
|
||||
|
||||
intel_keym_v1_t::key_signature_t::key_signature_t(kaitai::kstream* p__io, intel_keym_v1_t* p__parent, intel_keym_v1_t* p__root) : kaitai::kstruct(p__io) {
|
||||
m__parent = p__parent;
|
||||
m__root = p__root;
|
||||
m_public_key = 0;
|
||||
m_signature = 0;
|
||||
|
||||
try {
|
||||
_read();
|
||||
} catch(...) {
|
||||
_clean_up();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::key_signature_t::_read() {
|
||||
m_version = m__io->read_u1();
|
||||
m_key_id = m__io->read_u2le();
|
||||
m_public_key = new public_key_t(m__io, this, m__root);
|
||||
m_sig_scheme = m__io->read_u2le();
|
||||
m_signature = new signature_t(m__io, this, m__root);
|
||||
}
|
||||
|
||||
intel_keym_v1_t::key_signature_t::~key_signature_t() {
|
||||
_clean_up();
|
||||
}
|
||||
|
||||
void intel_keym_v1_t::key_signature_t::_clean_up() {
|
||||
if (m_public_key) {
|
||||
delete m_public_key; m_public_key = 0;
|
||||
}
|
||||
if (m_signature) {
|
||||
delete m_signature; m_signature = 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue