32static const uint8_t
PS3_ERK[16] = {0x38, 0x0B, 0xCF, 0x0B, 0x53, 0x45, 0x5B, 0x3C,
33 0x78, 0x17, 0xAB, 0x4F, 0xA3, 0xBA, 0x90, 0xED};
36static const uint8_t
PS3_ERK_IV[16] = {0x69, 0x47, 0x47, 0x72, 0xAF, 0x6F, 0xDA, 0xB3,
37 0x42, 0x74, 0x3A, 0xEF, 0xAA, 0x18, 0x62, 0x87};
41 memcpy(disc_key, data1, 16);
49 for(
int i = 15; i >= 0 && sector_num > 0; i--)
51 iv[i] = (uint8_t)(sector_num & 0xFF);
56void ps3_encrypt_sector(
const uint8_t disc_key[16], uint64_t sector_num, uint8_t *data, uint32_t length)
63void ps3_decrypt_sector(
const uint8_t disc_key[16], uint64_t sector_num, uint8_t *data, uint32_t length)
72 if(ctx == NULL)
return;
79 HASH_FIND_INT(ctx->
mediaTags, &tag, item);
81 if(item != NULL && item->
length == 16)
91 HASH_FIND_INT(ctx->
mediaTags, &tag, item);
93 if(item != NULL && item->
length == 16)
107 HASH_FIND_INT(ctx->
mediaTags, &tag, item);
109 if(item != NULL && item->
length >= 4)
void aes128_cbc_decrypt(const uint8_t key[16], const uint8_t iv[16], uint8_t *data, uint32_t length)
AES-128 CBC decrypt data in-place.
void aes128_cbc_encrypt(const uint8_t key[16], const uint8_t iv[16], uint8_t *data, uint32_t length)
AES-128 CBC encrypt data in-place.
static const uint8_t PS3_ERK_IV[16]
void ps3_lazy_init(aaruformat_context *ctx)
Lazy-initialize PS3 encryption state from context media tags.
void ps3_derive_disc_key(const uint8_t data1[16], uint8_t disc_key[16])
Derive a PS3 disc key from a data1 key.
void ps3_derive_iv(uint64_t sector_num, uint8_t iv[16])
Derive the per-sector AES IV from a sector number.
static const uint8_t PS3_ERK[16]
void ps3_decrypt_sector(const uint8_t disc_key[16], uint64_t sector_num, uint8_t *data, uint32_t length)
Decrypt a sector using PS3 disc encryption (AES-128-CBC).
void ps3_encrypt_sector(const uint8_t disc_key[16], uint64_t sector_num, uint8_t *data, uint32_t length)
Encrypt a sector using PS3 disc encryption (AES-128-CBC).
int32_t ps3_deserialize_encryption_map(const uint8_t *data, uint32_t length, Ps3PlaintextRegion **regions, uint32_t *count)
Deserialize plaintext regions from little-endian binary (media tag format).
A plaintext (unencrypted) region on a PS3 disc.
Master context representing an open or in‑creation Aaru image.
uint8_t * ps3_disc_key
Cached disc key (16 bytes), NULL if not loaded.
uint32_t ps3_plaintext_region_count
Number of plaintext regions.
mediaTagEntry * mediaTags
Hash table of extra media tags (uthash root).
void * ps3_plaintext_regions
Parsed Ps3PlaintextRegion array (max 32), NULL if not loaded.
Hash table entry for an arbitrary media tag (e.g., proprietary drive/medium descriptor).
uint8_t * data
Tag data blob (opaque to library core); length bytes long.
uint32_t length
Length in bytes of data.