freemyipod r157 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r156‎ | r157 | r158 >
Date:14:18, 18 August 2010
Author:theseven
Status:new
Tags:
Comment:
Expose hardware key AES and HMAC-SHA1 via the monitor interface
Modified paths:
  • /embios/trunk/usb/usb.c (modified) (history)

Diff [purge]

Index: embios/trunk/usb/usb.c
@@ -40,6 +40,12 @@
4141 #ifdef HAVE_BOOTFLASH
4242 #include "bootflash.h"
4343 #endif
 44+#ifdef HAVE_HWKEYAES
 45+#include "hwkeyaes.h"
 46+#endif
 47+#ifdef HAVE_HMACSHA1
 48+#include "hmacsha1.h"
 49+#endif
4450
4551
4652 static uint8_t ctrlresp[2] CACHEALIGN_ATTR;
@@ -61,7 +67,9 @@
6268 DBGACTION_EXECIMAGE,
6369 DBGACTION_EXECFIRMWARE,
6470 DBGACTION_READBOOTFLASH,
65 - DBGACTION_WRITEBOOTFLASH
 71+ DBGACTION_WRITEBOOTFLASH,
 72+ DBGACTION_HWKEYAES,
 73+ DBGACTION_HMACSHA1
6674 };
6775
6876 static uint32_t dbgstack[0x100] STACK_ATTR;
@@ -538,6 +546,21 @@
539547 if (set_dbgaction(DBGACTION_EXECFIRMWARE, 0)) break;
540548 dbgactionaddr = dbgrecvbuf[1];
541549 break;
 550+#ifdef HAVE_HWKEYAES
 551+ case 25: // HWKEYAES
 552+ if (set_dbgaction(DBGACTION_HWKEYAES, 0)) break;
 553+ dbgactiontype = ((uint8_t*)dbgrecvbuf)[4];
 554+ dbgactionoffset = ((uint16_t*)dbgrecvbuf)[3];
 555+ dbgactionaddr = dbgrecvbuf[2];
 556+ dbgactionlength = dbgrecvbuf[3];
 557+#endif
 558+#ifdef HAVE_HMACSHA1
 559+ case 26: // HMACSHA1
 560+ if (set_dbgaction(DBGACTION_HMACSHA1, 0)) break;
 561+ dbgactionaddr = dbgrecvbuf[1];
 562+ dbgactionlength = dbgrecvbuf[2];
 563+ dbgactionoffset = dbgrecvbuf[3];
 564+#endif
542565 default:
543566 dbgsendbuf[0] = 2;
544567 size = 16;
@@ -643,6 +666,21 @@
644667 usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
645668 break;
646669 #endif
 670+#ifdef HAVE_HWKEYAES
 671+ case DBGACTION_HWKEYAES:
 672+ hwkeyaes((enum hwkeyaes_direction) dbgactiontype, dbgactionoffset,
 673+ (void*)dbgactionaddr, dbgactionlength);
 674+ dbgasyncsendbuf[0] = 1;
 675+ usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
 676+ break;
 677+#endif
 678+#ifdef HAVE_HMACSHA1
 679+ case DBGACTION_HMACSHA1:
 680+ hmacsha1((void*)dbgactionaddr, dbgactionlength, (void*)dbgactionoffset);
 681+ dbgasyncsendbuf[0] = 1;
 682+ usb_drv_send_nonblocking(dbgendpoints[1], dbgasyncsendbuf, 16);
 683+ break;
 684+#endif
647685 }
648686 dbgaction = DBGACTION_IDLE;
649687 }