#ifndef READMBMLOADER_H #define READMBMLOADER_H #include #include using namespace std; class Key { public: Key() : Modulo(NULL), sha1hash(NULL), rsakey(NULL) {} ~Key() { if (Modulo) delete [] Modulo; if (sha1hash) delete [] sha1hash; if (rsakey) RSA_free(rsakey); rsakey = NULL; }; void SetKey(unsigned char *buffer); void PrintKey(); int WritePEM(const char *fname); unsigned long ID; unsigned long Type; unsigned long Rights; unsigned long ModuloLength; unsigned long EValue; unsigned char *Modulo; unsigned char *sha1hash; RSA *rsakey; }; class CertPK { public: CertPK() : Name(NULL), Keys(NULL), NumberKeys(0), SignerInfo(NULL), Signature(NULL), sha1hash(NULL) {} ~CertPK() { if (Name) delete [] Name; if (Keys) { for (int i=0; iID == KeyID) return i; } return -1; } char *Name; unsigned long CertType; unsigned long MinVerPK; unsigned long MinVerPPA; unsigned long MinVerRD1; unsigned long MinVerRD2; unsigned long MinVerISW; unsigned long MinVerKI; unsigned long MinVerPAU; unsigned long MinVerPAS; unsigned long WatchdogParam; unsigned long NumberKeys; Key **Keys; unsigned long Rights; unsigned long MSV; unsigned long MSVMask; unsigned char *SignerInfo; unsigned long SignatureInfo; unsigned long SignatureKeyID; unsigned char *Signature; unsigned long SignatureSize; unsigned char *sha1hash; }; class DirEntry { public: DirEntry() {} ~DirEntry() {} void SetDirEntry(unsigned char *buffer); void PrintDirEntry(); unsigned long Offset; unsigned long Size; unsigned long Unknown1; unsigned long Unknown2; unsigned long LoadAddress; char Name[12]; }; class Directory { public: Directory() {} ~Directory() { for (vector::iterator iter=EntryList.begin(); iter!=EntryList.end(); iter++) { delete *iter; } EntryList.clear(); } void SetDirectory(unsigned char *buffer, unsigned long nOffset); DirEntry *FindDirEntry(const char *entryName); void PrintDirectory(); vector EntryList; unsigned long Offset; }; class MTD0 { public: MTD0() : mtdSettingsDir(NULL), mtdCertDir(NULL), mtdCertPK(NULL) {} ~MTD0() { if (mtdSettingsDir) delete mtdSettingsDir; if (mtdCertDir) delete mtdCertDir; if (mtdCertPK) delete mtdCertPK; } void SetMTD0(unsigned char *buffer); void PrintMTD0(); Directory *mtdSettingsDir; Directory *mtdCertDir; //ChSettings *mtdChSettings; //ChRam *mtdChRam; CertPK *mtdCertPK; //CertPPA *mtdCertPPA; //CertISW *mtdCertISW; }; #endif // READMBMLOADER_H