From fe2cff4a622a2f046d224774fd257d0433888b78 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 29 Jan 2013 20:49:48 +0000 Subject: some more cleanup acutally using constant time compare :) git-svn-id: https://svn.spreadspace.org/avr/trunk@94 aa12f405-d877-488e-9caf-2d797e2a1cc7 --- usb-i2c-sl018/tuer-rfid.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'usb-i2c-sl018') diff --git a/usb-i2c-sl018/tuer-rfid.c b/usb-i2c-sl018/tuer-rfid.c index e51e361..e991302 100644 --- a/usb-i2c-sl018/tuer-rfid.c +++ b/usb-i2c-sl018/tuer-rfid.c @@ -306,11 +306,11 @@ uint8_t generate_csum(uint8_t* data) return sum2<<4 | sum1; } -bool compare_keyslots(const keyslot_t* a, const keyslot_t* b) // constant time compare +uint8_t compare_keyslots(const keyslot_t* a, const keyslot_t* b) // constant time compare { uint8_t tmp=0, i; for(i=0; ibyte[i] ^ a->byte[i]); + tmp |= a->byte[i] ^ b->byte[i]; return tmp; } @@ -323,12 +323,12 @@ bool check_card(const uint8_t * uid, uint8_t uid_len) uid_len = uid_len > sizeof(keyslot_t) ? sizeof(keyslot_t) : uid_len; for (uint8_t pos=0; posdata,uid_len)) { sl018_cmd(SL018CMD_ComRedLedOn); - fprintf(stdio,"open/close\n\r"); // TODO: open/close door! + fprintf(stdio,"Card allowed - opening/closing door\n\r"); // TODO: open/close door! _delay_ms(255); sl018_cmd(SL018CMD_ComRedLedOff); + } else { + fprintf(stdio,"Card not found in Database\n\r"); } } else { fprintf(stdio,"Unknown Card Type %02x\n\r",type); -- cgit v1.2.3