libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
ps3_crypto.h File Reference
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Functions

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.
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).
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_lazy_init (aaruformat_context *ctx)
 Lazy-initialize PS3 encryption state from context media tags.

Function Documentation

◆ ps3_decrypt_sector()

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).

Parameters
disc_key16-byte disc key.
sector_numSector number (for IV derivation).
dataBuffer to decrypt in-place.
lengthNumber of bytes (must be multiple of 16).

Definition at line 63 of file ps3_crypto.c.

References aes128_cbc_decrypt(), and ps3_derive_iv().

Referenced by aaruf_write_sector().

◆ ps3_derive_disc_key()

void ps3_derive_disc_key ( const uint8_t data1[16],
uint8_t disc_key[16] )

Derive a PS3 disc key from a data1 key.

disc_key = AES-128-CBC-Encrypt(PS3_ERK, PS3_ERK_IV, data1)

Parameters
data116-byte data1 key (from disc or IRD).
disc_keyOutput: 16-byte derived disc key.

Definition at line 39 of file ps3_crypto.c.

References aes128_cbc_encrypt(), PS3_ERK, and PS3_ERK_IV.

Referenced by ps3_lazy_init().

◆ ps3_derive_iv()

void ps3_derive_iv ( uint64_t sector_num,
uint8_t iv[16] )

Derive the per-sector AES IV from a sector number.

IV = sector number as 128-bit big-endian integer, zero-padded left.

Parameters
sector_numSector number.
ivOutput: 16-byte IV buffer.

Definition at line 45 of file ps3_crypto.c.

Referenced by ps3_decrypt_sector(), and ps3_encrypt_sector().

◆ ps3_encrypt_sector()

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).

Parameters
disc_key16-byte disc key.
sector_numSector number (for IV derivation).
dataBuffer to encrypt in-place.
lengthNumber of bytes (must be multiple of 16).

Definition at line 56 of file ps3_crypto.c.

References aes128_cbc_encrypt(), and ps3_derive_iv().

Referenced by aaruf_read_sector().

◆ ps3_lazy_init()

void ps3_lazy_init ( aaruformat_context * ctx)

Lazy-initialize PS3 encryption state from context media tags.

Reads kMediaTagPs3DiscKey and kMediaTagPs3EncryptionMap from the context's media tag hash table. Safe to call multiple times (no-op after first init). On failure, leaves fields NULL so callers degrade gracefully.

Parameters
ctxThe aaruformat context.

Definition at line 70 of file ps3_crypto.c.

References mediaTagEntry::data, kMediaTagPs3Data1, kMediaTagPs3DiscKey, kMediaTagPs3EncryptionMap, mediaTagEntry::length, aaruformat_context::mediaTags, ps3_derive_disc_key(), ps3_deserialize_encryption_map(), aaruformat_context::ps3_disc_key, aaruformat_context::ps3_plaintext_region_count, and aaruformat_context::ps3_plaintext_regions.

Referenced by aaruf_read_sector(), and aaruf_write_sector().