libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
ps3_encryption_map.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "ps3_encryption_map.h"

Go to the source code of this file.

Functions

static uint32_t read_be32 (const uint8_t *p)
static uint32_t read_le32 (const uint8_t *p)
static void write_le32 (uint8_t *p, uint32_t v)
int32_t ps3_parse_encryption_map (const uint8_t *sector0, uint32_t length, Ps3PlaintextRegion **regions, uint32_t *count)
 Parse the encryption map from PS3 disc sector 0 (big-endian on disc).
int32_t ps3_serialize_encryption_map (const Ps3PlaintextRegion *regions, uint32_t count, uint8_t **out_data, uint32_t *out_length)
 Serialize plaintext regions to little-endian binary for storage as a media tag.
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).
bool ps3_is_sector_encrypted (const Ps3PlaintextRegion *plaintext_regions, uint32_t region_count, uint64_t sector_address)
 Check whether a sector is encrypted (i.e., not in any plaintext region).

Function Documentation

◆ ps3_deserialize_encryption_map()

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

Parameters
dataSerialized data buffer.
lengthLength of data buffer.
regionsOutput: allocated array of plaintext regions. Caller must free().
countOutput: number of regions.
Returns
0 on success, negative error code on failure.

Definition at line 117 of file ps3_encryption_map.c.

References Ps3PlaintextRegion::end_sector, PS3_MAX_PLAINTEXT_REGIONS, read_le32(), and Ps3PlaintextRegion::start_sector.

Referenced by ps3_lazy_init().

◆ ps3_is_sector_encrypted()

bool ps3_is_sector_encrypted ( const Ps3PlaintextRegion * plaintext_regions,
uint32_t region_count,
uint64_t sector_address )

Check whether a sector is encrypted (i.e., not in any plaintext region).

Parameters
plaintext_regionsArray of plaintext regions.
region_countNumber of regions.
sector_addressSector number to check.
Returns
true if the sector is encrypted (not in any plaintext region).

Definition at line 151 of file ps3_encryption_map.c.

Referenced by aaruf_read_sector(), and aaruf_write_sector().

◆ ps3_parse_encryption_map()

int32_t ps3_parse_encryption_map ( const uint8_t * sector0,
uint32_t length,
Ps3PlaintextRegion ** regions,
uint32_t * count )

Parse the encryption map from PS3 disc sector 0 (big-endian on disc).

Parameters
sector0Pointer to the 2048-byte sector 0 data.
lengthLength of sector0 data (must be >= 264).
regionsOutput: allocated array of plaintext regions. Caller must free().
countOutput: number of regions.
Returns
0 on success, negative error code on failure.

Definition at line 48 of file ps3_encryption_map.c.

References Ps3PlaintextRegion::end_sector, PS3_MAX_PLAINTEXT_REGIONS, read_be32(), and Ps3PlaintextRegion::start_sector.

◆ ps3_serialize_encryption_map()

int32_t ps3_serialize_encryption_map ( const Ps3PlaintextRegion * regions,
uint32_t count,
uint8_t ** out_data,
uint32_t * out_length )

Serialize plaintext regions to little-endian binary for storage as a media tag.

Format: [4B region_count LE] + region_count × [4B start LE, 4B end LE]

Parameters
regionsArray of plaintext regions.
countNumber of regions.
out_dataOutput: allocated buffer. Caller must free().
out_lengthOutput: size of the buffer in bytes.
Returns
0 on success, negative error code on failure.

Definition at line 94 of file ps3_encryption_map.c.

References PS3_MAX_PLAINTEXT_REGIONS, and write_le32().

◆ read_be32()

uint32_t read_be32 ( const uint8_t * p)
static

Definition at line 28 of file ps3_encryption_map.c.

Referenced by ps3_parse_encryption_map().

◆ read_le32()

uint32_t read_le32 ( const uint8_t * p)
static

Definition at line 34 of file ps3_encryption_map.c.

Referenced by ps3_deserialize_encryption_map().

◆ write_le32()

void write_le32 ( uint8_t * p,
uint32_t v )
static

Definition at line 40 of file ps3_encryption_map.c.

Referenced by ps3_serialize_encryption_map().