소스 검색

MFkey: Use union for MfClassicNonce, save some ram

Willy-JL 1 년 전
부모
커밋
5890d08342
1개의 변경된 파일20개의 추가작업 그리고 14개의 파일을 삭제
  1. 20 14
      mfkey/mfkey.h

+ 20 - 14
mfkey/mfkey.h

@@ -74,20 +74,26 @@ typedef struct {
     uint32_t nt1; // tag challenge second
     uint32_t uid_xor_nt0; // uid ^ nt0
     uint32_t uid_xor_nt1; // uid ^ nt1
-    // Mfkey32
-    uint32_t p64; // 64th successor of nt0
-    uint32_t p64b; // 64th successor of nt1
-    uint32_t nr0_enc; // first encrypted reader challenge
-    uint32_t ar0_enc; // first encrypted reader response
-    uint32_t nr1_enc; // second encrypted reader challenge
-    uint32_t ar1_enc; // second encrypted reader response
-    // Nested
-    uint32_t ks1_1_enc; // first encrypted keystream
-    uint32_t ks1_2_enc; // second encrypted keystream
-    char par_1_str[5]; // first parity bits (string representation)
-    char par_2_str[5]; // second parity bits (string representation)
-    uint8_t par_1; // first parity bits
-    uint8_t par_2; // second parity bits
+    union {
+        // Mfkey32
+        struct {
+            uint32_t p64; // 64th successor of nt0
+            uint32_t p64b; // 64th successor of nt1
+            uint32_t nr0_enc; // first encrypted reader challenge
+            uint32_t ar0_enc; // first encrypted reader response
+            uint32_t nr1_enc; // second encrypted reader challenge
+            uint32_t ar1_enc; // second encrypted reader response
+        };
+        // Nested
+        struct {
+            uint32_t ks1_1_enc; // first encrypted keystream
+            uint32_t ks1_2_enc; // second encrypted keystream
+            char par_1_str[5]; // first parity bits (string representation)
+            char par_2_str[5]; // second parity bits (string representation)
+            uint8_t par_1; // first parity bits
+            uint8_t par_2; // second parity bits
+        };
+    };
 } MfClassicNonce;
 
 typedef struct {