21#ifndef LIBAARUFORMAT_NGCW_WII_CRYPTO_H
22#define LIBAARUFORMAT_NGCW_WII_CRYPTO_H
28#ifndef AARUFORMAT_CONTEXT_DECLARED
29#define AARUFORMAT_CONTEXT_DECLARED
38#define WII_GROUP_SIZE 0x8000
39#define WII_GROUP_HASH_SIZE 0x0400
40#define WII_GROUP_DATA_SIZE 0x7C00
41#define WII_LOGICAL_PER_GROUP 16
42#define WII_SECTOR_SIZE 2048
43#define WII_MAX_PARTITIONS 32
70 uint64_t logical_sector);
88 void wii_encrypt_group(
const uint8_t key[16],
const uint8_t *hash_block,
const uint8_t *data_in, uint8_t *out);
98 void wii_decrypt_group(
const uint8_t key[16],
const uint8_t *in, uint8_t *hash_block, uint8_t *data_out);
A Wii partition region entry (in-memory representation).
uint32_t start_sector
First physical sector of partition.
uint8_t key[16]
AES-128 partition key.
uint32_t end_sector
End physical sector (exclusive).
Master context representing an open or in‑creation Aaru image.
const uint8_t * wii_get_sector_key(const WiiPartitionRegion *regions, uint32_t region_count, uint64_t logical_sector)
Get the encryption key for a given logical sector (2048-byte).
int32_t wii_deserialize_partition_key_map(const uint8_t *data, uint32_t data_len, WiiPartitionRegion **regions, uint32_t *count)
Deserialize a Wii partition key map from a media tag buffer.
int32_t wii_serialize_partition_key_map(const WiiPartitionRegion *regions, uint32_t count, uint8_t **out_data, uint32_t *out_len)
Serialize a Wii partition key map for storage as a media tag.
void wii_encrypt_group(const uint8_t key[16], const uint8_t *hash_block, const uint8_t *data_in, uint8_t *out)
Encrypt a Wii group (0x8000 bytes) from separate hash_block + data.
bool wii_is_sector_encrypted(const WiiPartitionRegion *regions, uint32_t region_count, uint64_t logical_sector)
Check if a logical sector is in an encrypted region.
void wii_decrypt_group(const uint8_t key[16], const uint8_t *in, uint8_t *hash_block, uint8_t *data_out)
Decrypt a Wii group (0x8000 bytes) into separate hash_block + data.
void wii_lazy_init(aaruformat_context *ctx)
Lazy initialization: load partition key map from media tags.