private static string Print(this Package2StorageReader package2) { Result rc = package2.VerifySignature(); Validity signatureValidity = rc.IsSuccess() ? Validity.Valid : Validity.Invalid; int colLen = 36; var sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine("PK21:"); PrintItem(sb, colLen, $"Signature{signatureValidity.GetValidityString()}:", package2.Header.Signature.ToArray()); PrintItem(sb, colLen, "Header Version:", $"{package2.Header.Meta.KeyGeneration:x2}"); for (int i = 0; i < 3; i++) { string name = package2.Header.Meta.PayloadSizes[i] != 0 ? Package2SectionNames[i] : "Empty"; sb.AppendLine($"Section {i} ({name}):"); PrintItem(sb, colLen, " Hash:", package2.Header.Meta.PayloadHashes[i]); PrintItem(sb, colLen, " CTR:", package2.Header.Meta.PayloadIvs[i]); PrintItem(sb, colLen, " Load Address:", $"{package2.Header.Meta.PayloadOffsets[i] + 0x80000000:x8}"); PrintItem(sb, colLen, " Size:", $"{package2.Header.Meta.PayloadSizes[i]:x8}"); } return(sb.ToString()); }
public static void PrintIvfcHashNew(StringBuilder sb, int colLen, int indentSize, NcaFsIntegrityInfoIvfc ivfcInfo, IntegrityStorageType type, Validity masterHashValidity) { string prefix = new string(' ', indentSize); string prefix2 = new string(' ', indentSize + 4); if (type == IntegrityStorageType.RomFs) { PrintItem(sb, colLen, $"{prefix}Master Hash{masterHashValidity.GetValidityString()}:", ivfcInfo.MasterHash.ToArray()); } PrintItem(sb, colLen, $"{prefix}Magic:", MagicToString(ivfcInfo.Magic)); PrintItem(sb, colLen, $"{prefix}Version:", ivfcInfo.Version >> 16); if (type == IntegrityStorageType.Save) { PrintItem(sb, colLen, $"{prefix}Salt Seed:", ivfcInfo.SaltSource.ToArray()); } int levelCount = Math.Max(ivfcInfo.LevelCount - 1, 0); if (type == IntegrityStorageType.Save) { levelCount = 4; } int offsetLen = type == IntegrityStorageType.Save ? 16 : 12; for (int i = 0; i < levelCount; i++) { long hashOffset = 0; if (i != 0) { hashOffset = ivfcInfo.GetLevelOffset(i - 1); } sb.AppendLine($"{prefix}Level {i}:"); PrintItem(sb, colLen, $"{prefix2}Data Offset:", $"0x{ivfcInfo.GetLevelOffset(i).ToString($"x{offsetLen}")}"); PrintItem(sb, colLen, $"{prefix2}Data Size:", $"0x{ivfcInfo.GetLevelSize(i).ToString($"x{offsetLen}")}"); PrintItem(sb, colLen, $"{prefix2}Hash Offset:", $"0x{hashOffset.ToString($"x{offsetLen}")}"); PrintItem(sb, colLen, $"{prefix2}Hash BlockSize:", $"0x{1 << ivfcInfo.GetLevelBlockSize(i):x8}"); } }