|
libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
|
#include <stdint.h>#include <stdlib.h>#include <string.h>#include <aaruformat.h>#include "../lib/aes128.h"#include "ps3_crypto.h"#include "ps3_encryption_map.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. | |
Variables | |
| static const uint8_t | PS3_ERK [16] |
| static const uint8_t | PS3_ERK_IV [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).
| disc_key | 16-byte disc key. |
| sector_num | Sector number (for IV derivation). |
| data | Buffer to decrypt in-place. |
| length | Number 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().
| 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)
| data1 | 16-byte data1 key (from disc or IRD). |
| disc_key | Output: 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().
| 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.
| sector_num | Sector number. |
| iv | Output: 16-byte IV buffer. |
Definition at line 45 of file ps3_crypto.c.
Referenced by ps3_decrypt_sector(), and 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).
| disc_key | 16-byte disc key. |
| sector_num | Sector number (for IV derivation). |
| data | Buffer to encrypt in-place. |
| length | Number 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().
| 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.
| ctx | The 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().
|
static |
Definition at line 32 of file ps3_crypto.c.
Referenced by ps3_derive_disc_key().
|
static |
Definition at line 36 of file ps3_crypto.c.
Referenced by ps3_derive_disc_key().