/usr/bin/avos:MPK load key()
From ArchosDocs
Description
Reads a key from flash memory at offset 0x10000 + offset and write it to dest.
The Code
int MPK_load_key(char *dest, int offset)
{
struct {
int addr; // -0x18
int size; // -0x14
int buf; // -0x10
} argp;
int read_count; // -0x0C
int read_ok; // -0x08
read_ok = 0;
argp.size = 144; // size to read
argp.buf = dest; // destination buffer
argp.addr = 0x10000 + offset; // address to read from
read_count = 0;
while(read_count <= 1) {
if(read_ok != 0)
break;
if(FLASH_Init() == 0) {
if(FLASH_Read(&argp)) {
read_ok = MPK_check(dest);
FLASH_Exit();
read_count++;
continue;
}
}
FLASH_Exit();
}
if(read_ok == 0)
return -1;
return 0;
}

