|
libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | ngc_lfg_ctx |
| LFG context holding the 521-word circular buffer and byte position. More... | |
Macros | |
| #define | NGC_LFG_K 521 |
| LFG buffer size (number of uint32 words in state). | |
| #define | NGC_LFG_J 32 |
| LFG second tap. | |
| #define | NGC_LFG_SEED_SIZE 17 |
| Number of uint32 words needed to seed the LFG. | |
Functions | |
| void | ngc_lfg_set_seed (struct ngc_lfg_ctx *ctx, const uint32_t seed[17]) |
| Initialize the LFG from a 17-word big-endian seed. | |
| void | ngc_lfg_get_bytes (struct ngc_lfg_ctx *ctx, uint8_t *out, size_t count) |
| Generate count bytes of junk data into out. | |
| size_t | ngc_lfg_get_seed (const uint8_t *data, size_t size, size_t data_offset, uint32_t seed_out[17]) |
| Try to extract the LFG seed from a chunk of data. | |
| #define NGC_LFG_J 32 |
LFG second tap.
Definition at line 35 of file lfg.h.
Referenced by lfg_backward(), and lfg_forward().
| #define NGC_LFG_K 521 |
LFG buffer size (number of uint32 words in state).
Definition at line 34 of file lfg.h.
Referenced by lfg_backward(), lfg_forward(), lfg_initialize(), lfg_reinitialize(), ngc_lfg_get_bytes(), and ngc_lfg_get_seed().
| #define NGC_LFG_SEED_SIZE 17 |
Number of uint32 words needed to seed the LFG.
Definition at line 36 of file lfg.h.
Referenced by lfg_initialize(), lfg_reinitialize(), ngc_lfg_get_seed(), ngc_lfg_set_seed(), ngcw_deserialize_junk_map(), ngcw_regenerate_junk_sector(), ngcw_serialize_junk_map(), and wii_reconstruct_group_junk().
| void ngc_lfg_get_bytes | ( | struct ngc_lfg_ctx * | ctx, |
| uint8_t * | out, | ||
| size_t | count ) |
Generate count bytes of junk data into out.
| ctx | LFG context (must be initialized via ngc_lfg_set_seed). |
| out | Output buffer to fill. |
| count | Number of bytes to generate. |
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
Definition at line 82 of file lfg.c.
References ngc_lfg_ctx::buffer, lfg_forward(), NGC_LFG_K, and ngc_lfg_ctx::position_bytes.
Referenced by ngcw_regenerate_junk_sector(), and wii_reconstruct_group_junk().
| size_t ngc_lfg_get_seed | ( | const uint8_t * | data, |
| size_t | size, | ||
| size_t | data_offset, | ||
| uint32_t | seed_out[17] ) |
Try to extract the LFG seed from a chunk of data.
Attempts to reverse-engineer the 17-word seed from a buffer of suspected PRNG output. Requires at least NGC_LFG_K * 4 = 2084 bytes of contiguous PRNG output aligned to uint32 boundaries.
| data | Pointer to the data to test. |
| size | Number of bytes available. |
| data_offset | Byte offset of data[0] within its LFG block (0x8000-aligned for Wii, arbitrary for GC). |
| seed_out | If successful, receives the 17-word seed (big-endian). |
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
< LFG buffer size (number of uint32 words in state).
Definition at line 121 of file lfg.c.
References ngc_lfg_ctx::buffer, lfg_backward(), lfg_forward(), lfg_reinitialize(), NGC_LFG_K, NGC_LFG_SEED_SIZE, ngc_lfg_ctx::position_bytes, and swap32().
| void ngc_lfg_set_seed | ( | struct ngc_lfg_ctx * | ctx, |
| const uint32_t | seed[17] ) |
Initialize the LFG from a 17-word big-endian seed.
| ctx | LFG context to initialize. |
| seed | Array of 17 uint32 seed words (big-endian). |
< Number of uint32 words needed to seed the LFG.
Definition at line 73 of file lfg.c.
References ngc_lfg_ctx::buffer, lfg_initialize(), NGC_LFG_SEED_SIZE, ngc_lfg_ctx::position_bytes, and swap32().
Referenced by ngcw_regenerate_junk_sector(), and wii_reconstruct_group_junk().