Change rol8() to rol() to work with buffers of any length.
This commit is contained in:
parent
7278740a03
commit
13f03a60bb
4 changed files with 9 additions and 9 deletions
|
@ -117,7 +117,7 @@ typedef enum {
|
|||
void *mifare_cryto_preprocess_data (MifareTag tag, void *data, size_t *nbytes, int communication_settings);
|
||||
void *mifare_cryto_postprocess_data (MifareTag tag, void *data, ssize_t *nbytes, int communication_settings);
|
||||
void mifare_cbc_des (MifareDESFireKey key, uint8_t *data, size_t data_size, MifareDirection direction, int mac);
|
||||
void rol8(uint8_t *data);
|
||||
void rol (uint8_t *data, const size_t len);
|
||||
void *assert_crypto_buffer_size (MifareTag tag, size_t nbytes);
|
||||
|
||||
#define MIFARE_ULTRALIGHT_PAGE_COUNT 16
|
||||
|
|
|
@ -354,7 +354,7 @@ mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key
|
|||
|
||||
uint8_t PCD_r_RndB[8];
|
||||
memcpy (PCD_r_RndB, PICC_RndB, 8);
|
||||
rol8 (PCD_r_RndB);
|
||||
rol (PCD_r_RndB, 8);
|
||||
|
||||
uint8_t token[16];
|
||||
memcpy (token, PCD_RndA, 8);
|
||||
|
@ -378,7 +378,7 @@ mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key
|
|||
|
||||
uint8_t PCD_RndA_s[8];
|
||||
memcpy (PCD_RndA_s, PCD_RndA, 8);
|
||||
rol8 (PCD_RndA_s);
|
||||
rol (PCD_RndA_s, 8);
|
||||
|
||||
|
||||
if (0 != memcmp (PCD_RndA_s, PICC_RndA_s, 8)) {
|
||||
|
|
|
@ -43,13 +43,13 @@ xor8 (uint8_t *ivect, uint8_t *data)
|
|||
}
|
||||
|
||||
void
|
||||
rol8(uint8_t *data)
|
||||
rol(uint8_t *data, const size_t len)
|
||||
{
|
||||
uint8_t first = data[0];
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (size_t i = 0; i < len-1; i++) {
|
||||
data[i] = data[i+1];
|
||||
}
|
||||
data[7] = first;
|
||||
data[len-1] = first;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
#include "freefare_internal.h"
|
||||
|
||||
void
|
||||
test_mifare_rol8 (void)
|
||||
test_mifare_rol (void)
|
||||
{
|
||||
uint8_t data[8] = "01234567";
|
||||
rol8 (data);
|
||||
cut_assert_equal_memory ("12345670", 8, data, 8, cut_message ("Wrong data"));
|
||||
rol (data, sizeof (data));
|
||||
cut_assert_equal_memory ("12345670", 8, data, sizeof (data), cut_message ("Wrong data"));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue