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) { void main_final(void) {
init_nick(); init_nick();
if(GLOBAL(privacy)>2){ //firstboot if(GLOBAL(privacy)>2){ //firstboot
if(execute_file("1boot.int",0,0)){ if(execute_file("1boot.int")){
lcdPrintln("Badge SETUP"); lcdPrintln("Badge SETUP");
lcdPrintln("error."); lcdPrintln("error.");
lcdPrintln("Features may"); lcdPrintln("Features may");

View File

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

View File

@ -16,7 +16,8 @@ void LightCheck(void){
iocon=IOCON_PIO1_11; iocon=IOCON_PIO1_11;
// iodir=gpioGetDir(RB_LED3); // 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); gpioSetDir(RB_LED3, gpioDirection_Input);
IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_AD7|IOCON_PIO1_11_ADMODE_ANALOG; IOCON_PIO1_11 = IOCON_PIO1_11_FUNC_AD7|IOCON_PIO1_11_ADMODE_ANALOG;

View File

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

View File

@ -1,7 +1,7 @@
#ifndef _EXECUTE_H_ #ifndef _EXECUTE_H_
#define _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); void executeSelect(char *ext);
#endif #endif