Merge branch 'master' of github.com:r0ket/r0ket

This commit is contained in:
Stefan `Sec` Zehl 2011-08-05 17:45:11 +02:00
commit 07081cb94c
5 changed files with 36 additions and 47 deletions

View File

@ -21,7 +21,7 @@ void fancyNickname();
void main_final(void) {
init_nick();
if(GLOBAL(privacy)>2){ //firstboot
if(execute_file("1boot.int",0,0)){
if(execute_file("1boot.int")){
lcdPrintln("Badge SETUP");
lcdPrintln("error.");
lcdPrintln("Features may");

View File

@ -21,7 +21,7 @@ void simpleNickname(void);
void fancyNickname(void) {
if(GLOBAL(l0nick)){
if(execute_file(GLOBAL(nickl0),0,0))
if(execute_file(GLOBAL(nickl0)))
GLOBAL(l0nick)=0;
}

View File

@ -16,7 +16,8 @@ void LightCheck(void){
iocon=IOCON_PIO1_11;
// iodir=gpioGetDir(RB_LED3);
iodir= (GPIO_GPIO1DIR & (1 << (RB_LED3) ))?1:0;
//LED3 is on pin 11
iodir= (GPIO_GPIO1DIR & (1 << (11) ))?1:0;
gpioSetDir(RB_LED3, gpioDirection_Input);
IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_AD7|IOCON_PIO1_11_ADMODE_ANALOG;

View File

@ -12,15 +12,13 @@
#include "basic/xxtea.h"
const uint32_t signature_key[4] = {0x123456,0,0,0x234567};
const uint32_t decode_key[4] = {0x123456,0,0,0x234567};
//const uint32_t decode_key[4] = {0,0,0,0};
#include "SECRETS"
extern void * sram_top;
//extern void * sram_top;
/**************************************************************************/
uint8_t execute_file (const char * fname, uint8_t checksignature, uint8_t decode){
uint8_t execute_file (const char * fname){
FRESULT res;
FIL file;
UINT readbytes;
@ -48,20 +46,19 @@ uint8_t execute_file (const char * fname, uint8_t checksignature, uint8_t decode
if(res){
return -1;
};
if( decode || checksignature )
//only accept files with fixed length
//if( readbytes != 2048 )
#ifdef ENCRYPT_L0DABLE
uint32_t *data;
uint32_t len;
if( readbytes & 0x3 ){
lcdPrint("readbytes&3");
lcdRefresh();
while(1);
return -1;
}
if( checksignature ){
uint32_t mac[4];
uint32_t *data = (uint32_t*)dst;
uint32_t len = readbytes/4;
xxtea_cbcmac(mac, (uint32_t*)dst, len-4, signature_key);
data = (uint32_t*)dst;
len = readbytes/4;
xxtea_cbcmac(mac, (uint32_t*)dst, len-4, l0dable_sign_key);
if( data[len-4] != mac[0] || data[len-3] != mac[1]
|| data[len-2] != mac[2] || data[len-1] != mac[3] ){
lcdClear();
@ -74,19 +71,10 @@ uint8_t execute_file (const char * fname, uint8_t checksignature, uint8_t decode
while(1);
return -1;
}
//lcdPrint("macok");
//lcdRefresh();
//while(1);
}
if( decode ){
uint32_t *data = (uint32_t*)dst;
uint32_t len = readbytes/4;
xxtea_decode_words(data, len-4, decode_key);
}
//lcdPrintInt(readbytes);
//lcdPrintln(" bytes");
//lcdRefresh();
data = (uint32_t*)dst;
len = readbytes/4;
xxtea_decode_words(data, len-4, l0dable_crypt_key);
#endif
dst=(void (*)(void)) ((uint32_t)(dst) | 1); // Enable Thumb mode!
dst();
@ -103,6 +91,6 @@ void executeSelect(char *ext){
filename[2]=0;
if( selectFile(filename+2,ext) == 0)
execute_file(filename,0,0);
execute_file(filename);
};

View File

@ -1,7 +1,7 @@
#ifndef _EXECUTE_H_
#define _EXECUTE_H_
uint8_t execute_file (const char * fname, uint8_t checksignature, uint8_t decode);
uint8_t execute_file (const char * fname);
void executeSelect(char *ext);
#endif