mifare_desfire_key: fix get/set_version for AES keys
This commit is contained in:
parent
2514cde675
commit
eea8b7b51e
1 changed files with 8 additions and 0 deletions
|
@ -114,6 +114,9 @@ mifare_desfire_key_get_version(MifareDESFireKey key)
|
||||||
{
|
{
|
||||||
uint8_t version = 0;
|
uint8_t version = 0;
|
||||||
|
|
||||||
|
if (key->type == T_AES)
|
||||||
|
return key->aes_version;
|
||||||
|
|
||||||
for (int n = 0; n < 8; n++) {
|
for (int n = 0; n < 8; n++) {
|
||||||
version |= ((key->data[n] & 1) << (7 - n));
|
version |= ((key->data[n] & 1) << (7 - n));
|
||||||
}
|
}
|
||||||
|
@ -124,6 +127,11 @@ mifare_desfire_key_get_version(MifareDESFireKey key)
|
||||||
void
|
void
|
||||||
mifare_desfire_key_set_version(MifareDESFireKey key, uint8_t version)
|
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++) {
|
for (int n = 0; n < 8; n++) {
|
||||||
uint8_t version_bit = ((version & (1 << (7 - n))) >> (7 - n));
|
uint8_t version_bit = ((version & (1 << (7 - n))) >> (7 - n));
|
||||||
key->data[n] &= 0xfe;
|
key->data[n] &= 0xfe;
|
||||||
|
|
Loading…
Reference in a new issue