diff --git a/libfreefare/mifare_desfire_crypto.c b/libfreefare/mifare_desfire_crypto.c index de2ff16..3d56699 100644 --- a/libfreefare/mifare_desfire_crypto.c +++ b/libfreefare/mifare_desfire_crypto.c @@ -69,6 +69,9 @@ xor(const uint8_t *ivect, uint8_t *data, const size_t len) void rol(uint8_t *data, const size_t len) { + if (len == 0) + return; + uint8_t first = data[0]; for (size_t i = 0; i < len - 1; i++) { data[i] = data[i + 1]; @@ -79,6 +82,9 @@ rol(uint8_t *data, const size_t len) void lsl(uint8_t *data, size_t len) { + if (len == 0) + return; + for (size_t n = 0; n < len - 1; n++) { data[n] = (data[n] << 1) | (data[n + 1] >> 7); }