From eea8b7b51ecb91652bb53c2c875ea6c503ed5328 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Wed, 30 Aug 2017 23:06:58 +0200 Subject: [PATCH] mifare_desfire_key: fix get/set_version for AES keys --- libfreefare/mifare_desfire_key.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libfreefare/mifare_desfire_key.c b/libfreefare/mifare_desfire_key.c index 00e542c..3968cd9 100644 --- a/libfreefare/mifare_desfire_key.c +++ b/libfreefare/mifare_desfire_key.c @@ -114,6 +114,9 @@ mifare_desfire_key_get_version(MifareDESFireKey key) { uint8_t version = 0; + if (key->type == T_AES) + return key->aes_version; + for (int n = 0; n < 8; n++) { version |= ((key->data[n] & 1) << (7 - n)); } @@ -124,6 +127,11 @@ mifare_desfire_key_get_version(MifareDESFireKey key) void mifare_desfire_key_set_version(MifareDESFireKey key, uint8_t version) { + if (key->type == T_AES) { + key->aes_version = version; + return; + } + for (int n = 0; n < 8; n++) { uint8_t version_bit = ((version & (1 << (7 - n))) >> (7 - n)); key->data[n] &= 0xfe;