traceLen += iLen;
// parity bytes
- if (iLen != 0) {
+ if (num_paritybytes != 0) {
if (parity != NULL) {
memcpy(trace + traceLen, parity, num_paritybytes);
} else {
uint64_t data;
uint8_t *sbp; /* sboxpointer */
permute((uint8_t*)e_permtab, (uint8_t*)&r, (uint8_t*)&data);
- for(i=0; i<7; ++i)
+ for(i=0; i<6; ++i)
((uint8_t*)&data)[i] ^= kr[i];
/* Sbox substitution */
}
// print nonce
PrintAndLog("Length: %d, Nonce: %s", nonce_length, nonce);
+ free(nonce);
}
if (i < n - 1) {
sleep(d);
fclose(f);
saveFile(outfilename,"bin", decrypted, blocknum*8);
-
+ free(decrypted);
return 0;
}
}
cx += snprintf(output+cx,outsize-cx,"};");
prnlog(output);
+ free(output);
}
void printvar(char * name, uint8_t* arr, int len)
}
prnlog(output);
+ free(output);
}
void printarr_human_readable(char * title, uint8_t* arr, int len)
int32_t le24toh (uint8_t data[3]) {
return (data[2] << 16) | (data[1] << 8) | data[0];
}
+
+// RotateLeft - Ultralight, Desfire, works on byte level
+// 00-01-02 >> 01-02-00
+void rol(uint8_t *data, const size_t len){
+ uint8_t first = data[0];
+ for (size_t i = 0; i < len-1; i++) {
+ data[i] = data[i+1];
+ }
+ data[len-1] = first;
+}
#include <time.h>
#include "data.h"
+#ifndef ROTR
+# define ROTR(x,n) (((uintmax_t)(x) >> (n)) | ((uintmax_t)(x) << ((sizeof(x) * 8) - (n))))
+#endif
#ifndef MIN
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
void xor(unsigned char *dst, unsigned char *src, size_t len);
int32_t le24toh(uint8_t data[3]);
+void rol(uint8_t *data, const size_t len);