#include "ctr_io_interface.h"
#include "sdmmc/sdmmc.h"
#include <stdint.h>
Go to the source code of this file.
|
enum | ctr_nand_crypto_type { NAND_CTR,
NAND_TWL
} |
|
|
int | ctr_nand_crypto_interface_initialize (ctr_nand_crypto_interface *io, uint8_t key_slot, ctr_nand_crypto_type crypto_type, ctr_io_interface *lower_io) |
| Initialize the given NAND crypto io interface object. More...
|
|
void | ctr_nand_crypto_interface_destroy (ctr_nand_crypto_interface *io) |
| Destroys the given NAND crypto io interface object. More...
|
|
int | ctr_nand_crypto_interface_read (void *io, void *buffer, size_t buffer_size, uint64_t position, size_t count) |
| Reads bytes from the given io interface. More...
|
|
int | ctr_nand_crypto_interface_write (void *io, const void *buffer, size_t buffer_size, uint64_t position) |
| Writes bytes to the given io interface. More...
|
|
int | ctr_nand_crypto_interface_read_sector (void *io, void *buffer, size_t buffer_size, size_t sector, size_t count) |
| Reads sectors from the given io interface. More...
|
|
int | ctr_nand_crypto_interface_write_sector (void *io, const void *buffer, size_t buffer_size, size_t sector) |
| Writes sectors from the given io interface. More...
|
|
uint64_t | ctr_nand_crypto_interface_disk_size (void *io) |
| Returns the size of the underlying disk for the given io interface. More...
|
|
size_t | ctr_nand_crypto_interface_sector_size (void *io) |
| Returns the size of the sectors used by the underlying io interface. More...
|
|
Destroys the given NAND crypto io interface object.
- Parameters
-
[in,out] | io | NAND io interface to deinitialize. |
- Postcondition
- The io interface has been destroyed and cannot be used for decrypting NAND without being re-initialized. The lower_io passed at construction/ iniitalization remains valid.
uint64_t ctr_nand_crypto_interface_disk_size |
( |
void * |
io | ) |
|
Returns the size of the underlying disk for the given io interface.
- Returns
- The size of the underlying io interface as reported by it.
Initialize the given NAND crypto io interface object.
- Parameters
-
[out] | io | NAND io crypto interface to initialize. |
[in] | key_slot | Nintendo 3DS AES key slot to use for CTR. |
[in] | crypto_type | Type of the system to taylor encryption to. CTR and TWL sections handle encryption slightly differently. |
[in,out] | lower_io | io interface to use as NAND. The filter does not gain ownership of the lower_io interface, it merely uses it. This pointer must remain valid while the crypto io interface object is in use. |
- Postcondition
- The io interface has been initialized and can be used for decrypting NAND.
int ctr_nand_crypto_interface_read |
( |
void * |
io, |
|
|
void * |
buffer, |
|
|
size_t |
buffer_size, |
|
|
uint64_t |
position, |
|
|
size_t |
count |
|
) |
| |
Reads bytes from the given io interface.
- Parameters
-
[in,out] | io | The io interface to use for reading. |
[out] | buffer | Pointer to the buffer. |
[in] | buffer_size | The size of the buffer in bytes. |
[in] | position | Position/address in the io interface to read from. |
[in] | count | The number of bytes to read. |
- Returns
- 0 upon success, anything else means an error.
int ctr_nand_crypto_interface_read_sector |
( |
void * |
io, |
|
|
void * |
buffer, |
|
|
size_t |
buffer_size, |
|
|
size_t |
sector, |
|
|
size_t |
count |
|
) |
| |
Reads sectors from the given io interface.
Uses whatever the underlying io interface uses for sector size.
- Parameters
-
[in,out] | io | The io interface to use for reading. |
[out] | buffer | Pointer to the buffer. |
[in] | buffer_size | The size of the buffer in bytes. |
[in] | sector | Sector position in the io interface to read from. |
[in] | count | The number of sectors to read. |
- Returns
- 0 upon success, anything else means an error.
size_t ctr_nand_crypto_interface_sector_size |
( |
void * |
io | ) |
|
Returns the size of the sectors used by the underlying io interface.
- Returns
- The size in bytes of the underlying io interface.
int ctr_nand_crypto_interface_write |
( |
void * |
io, |
|
|
const void * |
buffer, |
|
|
size_t |
buffer_size, |
|
|
uint64_t |
position |
|
) |
| |
Writes bytes to the given io interface.
- Parameters
-
[in,out] | io | The io interface to use for writing. |
[in] | buffer | Pointer to the buffer. |
[in] | buffer_size | The size of the buffer, and the number of bytes to write. |
[in] | position | Position/address in the io interface to write to. |
- Returns
- 0 upon success, anything else means an error.
int ctr_nand_crypto_interface_write_sector |
( |
void * |
io, |
|
|
const void * |
buffer, |
|
|
size_t |
buffer_size, |
|
|
size_t |
sector |
|
) |
| |
Writes sectors from the given io interface.
Uses whatever the underlying io interface uses for sector size.
- Parameters
-
[in,out] | io | The io interface to use for writing. |
[in] | buffer | Pointer to the buffer. |
[in] | buffer_size | The size of the buffer, and the number of bytes to write. If the number is not a multiple of the sector size, this function will only write all the full sectors it can, ignoring the end of the buffer that doesn't fit a sector. |
[in] | sector | Sector Position in the io interface to write to. |
- Returns
- 0 upon success, anything else means an error.