ctr_test_tools/TwlBackupChecker/TWLBackupBlock/TWLBackupBlock/Blocks.cs
N2891 717ff59ebb 暗号化・復号化モジュール(TWLBackupBlock)を追加
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_test_tools@4 6b0af911-cb57-b745-895f-eec5701120e1
2011-08-08 03:00:09 +00:00

89 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Diagnostics;
namespace TwlBackupBlock
{
/// <summary>
/// ブロックの集合です。
/// </summary>
public class Blocks : ICloneable
{
private const int NUM_BLOCKS = 7;
public Block banner;
public Block header;
public Block signature;
public Block tmd;
public Block content;
public Block saveData;
public Block subBanner;
/// <summary>
/// Blocksクラスの新しいインスタンスを初期化します。
/// </summary>
public Blocks()
{
banner = new Block();
header = new Block();
signature = new Block();
tmd = new Block();
content = new Block();
saveData = new Block();
subBanner = new Block();
}
/// <summary>
/// 指定したインデックスのブロックにアクセスします。
/// </summary>
/// <param name="index">インデックス。</param>
/// <returns>指定したインデックスのブロック。</returns>
public Block this[int index]
{
get
{
switch (index)
{
case 0: return banner;
case 1: return header;
case 2: return signature;
case 3: return tmd;
case 4: return content;
case 5: return saveData;
case 6: return subBanner;
default:
Debug.Assert(false);
return null; // never reach
}
}
}
/// <summary>
/// ブロック数(=7を取得します。
/// </summary>
public int Length
{
get
{
return NUM_BLOCKS;
}
}
/// <summary>
/// Blocksのディープコピーを作成します。
/// </summary>
/// <returns>Blocksのコピー</returns>
public object Clone()
{
Blocks newBlocks = new Blocks();
newBlocks.banner = (Block)banner.Clone();
newBlocks.header = (Block)header.Clone();
newBlocks.signature = (Block)signature.Clone();
newBlocks.tmd = (Block)tmd.Clone();
newBlocks.content = (Block)content.Clone();
newBlocks.saveData = (Block)saveData.Clone();
newBlocks.subBanner = (Block)subBanner.Clone();
return newBlocks;
}
}
}