Require the ivect to be provided to mifare_cbc_des().

- Store ivect in the struct mifare_desfire_tag;
- Reset it before and after authentication;
- Reset before each crypto operation (for now).
This commit is contained in:
Romain Tartiere 2010-10-29 12:22:47 +00:00
parent 87a04904bc
commit 356219e21b
4 changed files with 28 additions and 19 deletions

View file

@ -21,6 +21,8 @@
#include <freefare.h>
#include "freefare_internal.h"
uint8_t null_ivect[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
void
test_mifare_rol (void)
{
@ -39,7 +41,7 @@ test_mifare_desfire_des_receive (void)
uint8_t expected_data[8] = { 0x73, 0x0d, 0xdf, 0xad, 0xa4, 0xd2, 0x07, 0x89 };
uint8_t expected_key[8] = { 1, 1, 1, 1, 1, 1, 1, 1 };
mifare_cbc_des (key, data, 8, MD_RECEIVE, 0);
mifare_cbc_des (key, null_ivect, data, 8, MD_RECEIVE, 0);
cut_assert_equal_memory (&expected_data, 8, &data, 8, cut_message ("Wrong data"));
cut_assert_equal_memory (&expected_key, 8, key->data, 8, cut_message ("Wrong key"));
@ -58,7 +60,7 @@ test_mifare_desfire_des_send (void)
uint8_t expected_data[8] = { 0xd6, 0x59, 0xe1, 0x70, 0x43, 0xa8, 0x40, 0x68 };
uint8_t expected_key[8] = { 1, 1, 1, 1, 1, 1, 1, 1 };
mifare_cbc_des (key, data, 8, MD_SEND, 0);
mifare_cbc_des (key, null_ivect, data, 8, MD_SEND, 0);
cut_assert_equal_memory (&expected_data, 8, &data, 8, cut_message ("Wrong data"));
cut_assert_equal_memory (&expected_key, 8, key->data, 8, cut_message ("Wrong key"));