mirror of
https://github.com/rvtr/ctr_test_tools.git
synced 2025-06-19 09:05:31 -04:00

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_test_tools@11 6b0af911-cb57-b745-895f-eec5701120e1
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
|
|
namespace TwlBackupBlock
|
|
{
|
|
/// <summary>
|
|
/// データブロックです。
|
|
/// </summary>
|
|
public class Block : ICloneable
|
|
{
|
|
private const int MAC_SIZE = 16;
|
|
private const int IV_SIZE = 16;
|
|
|
|
public AbstractBody body;
|
|
public byte[] mac;
|
|
public byte[] iv;
|
|
|
|
/// <summary>
|
|
/// Blockクラスの新しいインスタンスを初期化します。
|
|
/// </summary>
|
|
public Block()
|
|
{
|
|
body = null;
|
|
mac = null;
|
|
iv = null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 指定したデータ本体、MAC、IVを使用して、Blockクラスの新しいインスタンスを初期化します。
|
|
/// </summary>
|
|
/// <param name="body">データ本体。</param>
|
|
/// <param name="mac">MAC。</param>
|
|
/// <param name="iv">IV。</param>
|
|
public Block(AbstractBody body, byte[] mac, byte[] iv)
|
|
{
|
|
Debug.Assert(mac.Length == MAC_SIZE);
|
|
Debug.Assert(iv.Length == IV_SIZE);
|
|
|
|
this.body = body;
|
|
this.mac = mac;
|
|
this.iv = iv;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Blockのディープコピーを作成します。
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public object Clone()
|
|
{
|
|
return new Block((AbstractBody)body.Clone(), (byte[])mac.Clone(), (byte[])iv.Clone());
|
|
}
|
|
}
|
|
}
|