# HG changeset patch # User Matt Johnston # Date 1370448288 -28800 # Node ID 03da5ff767e99e154b0207cf0131449871458ea8 # Parent 76f3ed943180e8000530f25443568da66cef622e Some debug ifdefs Decrypt should use the next key for cli auth (Decrpyt is incorrect) diff -r 76f3ed943180 -r 03da5ff767e9 main.c --- a/main.c Wed Jun 05 23:08:08 2013 +0800 +++ b/main.c Thu Jun 06 00:04:48 2013 +0800 @@ -186,8 +186,13 @@ //TCCR2A = _BV(COM2A1) | _BV(COM2A0) | _BV(WGM21); // toggle on match TCCR1A = _BV(COM1A0); +#ifdef SIM_DEBUG + // systemclock/8 + TCCR1B = _BV(CS11); +#else // systemclock/64 TCCR1B = _BV(CS11) | _BV(CS10); +#endif TCNT1 = 0; OCR1A = SLEEP_COMPARE; // interrupt @@ -408,7 +413,9 @@ return; } memcpy(avr_keys[key_index], new_key, sizeof(new_key)); +#ifndef SIM_DEBUG eeprom_write(avr_keys, avr_keys); +#endif } static void @@ -429,7 +436,9 @@ return; } +#ifndef SIM_DEBUG long_delay(200); +#endif hmac_sha1(outdata, avr_keys[key_index], KEYLEN*8, indata, HMACLEN*8); @@ -456,11 +465,12 @@ return; } +#ifndef SIM_DEBUG long_delay(200); - +#endif // check the signature - hmac_sha1(output, avr_keys[key_index], KEYLEN*8, &data[HMACLEN], AESLEN*8); + hmac_sha1(output, avr_keys[key_index+1], KEYLEN*8, &data[HMACLEN], AESLEN*8); if (memcmp(output, data, HMACLEN) != 0) { printf_P(PSTR("FAIL: hmac mismatch\n")); @@ -792,6 +802,13 @@ sei(); +#if 0 + // encryption test + cmd_set_avr_key("1 6161626263636464656566666767686800000000"); + cmd_set_avr_key("2 7979757569696f6f646465656666717164646969"); + cmd_decrypt("1 ecd858ee07a8e16575723513d2d072a7565865e40ba302059bfc650d4491268448102119"); +#endif + // doesn't return do_comms(); diff -r 76f3ed943180 -r 03da5ff767e9 pihelp.atsln --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pihelp.atsln Thu Jun 06 00:04:48 2013 +0800 @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Atmel Studio Solution File, Format Version 11.00 +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "pihelp", "pihelp.cproj", "{4DE891F7-343E-4919-A547-808A4AAE3A39}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|AVR = Debug|AVR + Release|AVR = Release|AVR + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4DE891F7-343E-4919-A547-808A4AAE3A39}.Debug|AVR.ActiveCfg = Debug|AVR + {4DE891F7-343E-4919-A547-808A4AAE3A39}.Debug|AVR.Build.0 = Debug|AVR + {4DE891F7-343E-4919-A547-808A4AAE3A39}.Release|AVR.ActiveCfg = Release|AVR + {4DE891F7-343E-4919-A547-808A4AAE3A39}.Release|AVR.Build.0 = Release|AVR + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff -r 76f3ed943180 -r 03da5ff767e9 pihelp.atsuo Binary file pihelp.atsuo has changed diff -r 76f3ed943180 -r 03da5ff767e9 pihelp.cproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pihelp.cproj Thu Jun 06 00:04:48 2013 +0800 @@ -0,0 +1,156 @@ + + + + 2.0 + 6.1 + com.Atmel.AVRGCC8.C + {4de891f7-343e-4919-a547-808a4aae3a39} + ATmega328P + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + pihelp + pihelp + pihelp + Native + true + false + + + 0 + true + 0x20000000 + true + + 2 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.simulator + + com.atmel.avrdbg.tool.simulator + Simulator + + + + + + 127.0.0.1 + 52727 + False + + + + + + + True + True + True + True + True + True + + + NDEBUG + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + + + + + True + True + True + True + True + True + + + DEBUG + + + True + True + Default (-g2) + True + -std=gnu99 -DSIM_DEBUG + + + libm + + + Default (-Wa,-g) + + + + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + compile + + + + \ No newline at end of file