public WiiPartitionGroupEncryptionState(int maxSize, byte[] key, byte[] h3Table)
        {
            if (maxSize % 0x8000 != 0)
            {
                throw new HandledException("Max group size is not a multiple of 0x8000");
            }

            _h3Table = h3Table;
            _maxSize = maxSize;
            _blocks  = new block[maxSize / 0x8000];

            PartitionHashTable h1 = null;
            PartitionHashTable h2 = new PartitionHashTable(8);

            for (int i = 0; i < _blocks.Length; i++)
            {
                if (i % 8 == 0)                     //share the h2 hash table across 8 blocks
                {
                    h1 = new PartitionHashTable(8); //8 lots of 8 blocks = 64 blocks
                }

                _blocks[i] = new block(i, h1, h2, key);
            }

            _unusedBlankHash = _blocks[0].Sha1.ComputeHash(new byte[0x400]);
        }
 public block(int index, PartitionHashTable h1Table, PartitionHashTable h2Table, byte[] key)
 {
     this.Index       = index;
     this.Offset      = index * 0x8000;
     this.DataOffset  = index * 0x8000 + 0x400;
     this.Aes         = Aes.Create();
     this.Sha1        = SHA1.Create();
     this.Aes.Padding = PaddingMode.None;
     this.Aes.Key     = key;
     this.H0Table     = new PartitionHashTable(31); //31 data sectors of 0x400 in a block
     this.H1Table     = h1Table;
     this.H2Table     = h2Table;
 }
 public block(int index, PartitionHashTable h1Table, PartitionHashTable h2Table, byte[] key)
 {
     Index       = index;
     Offset      = index * 0x8000;
     DataOffset  = index * 0x8000 + 0x400;
     Aes         = Aes.Create();
     Sha1        = SHA1.Create();
     Aes.Padding = PaddingMode.None;
     Aes.Key     = key;
     H0Table     = new PartitionHashTable(31); //31 data sectors of 0x400 in a block
     H1Table     = h1Table;
     H2Table     = h2Table;
 }