/// <summary> /// Opens an <see cref="IStorage"/> for the specified <see cref="Package1Section"/>. /// </summary> /// <param name="sectionType">The section to open.</param> /// <returns>If the section can be decrypted, an <see cref="IStorage"/>of that /// section; otherwise, <see langword="null"/>.</returns> public IStorage OpenSectionStorage(Package1Section sectionType) { if (!IsDecrypted) { return(null); } int offset = Unsafe.SizeOf <Package1Pk11Header>() + GetSectionOffset(sectionType); int size = GetSectionSize(sectionType); return(new SubStorage(Pk11Storage, offset, size)); }
public int GetSectionSize(Package1Section sectionType) { if (!IsDecrypted) { return(0); } return(sectionType switch { Package1Section.Bootloader => _pk11Header.BootloaderSize, Package1Section.SecureMonitor => _pk11Header.SecureMonitorSize, Package1Section.WarmBoot => _pk11Header.WarmBootSize, _ => 0 });