+ uint8_t buf[32] = {0};
+ struct Crypto1State *pcs;
+
+ pcs = crypto1_create(key);
+ uint32_t nt1 = crypto1_word(pcs, ad->nt_enc ^ ad->uid, 1) ^ ad->nt_enc;
+ uint32_t ar = prng_successor(nt1, 64);
+ uint32_t at = prng_successor(nt1, 96);
+ printf("key> nested auth uid: %08x nt: %08x nt_parity: %s ar: %08x at: %08x\n", ad->uid, nt1, printBitsPar(&ad->nt_enc_par, 4), ar, at);
+ uint32_t nr1 = crypto1_word(pcs, ad->nr_enc, 1) ^ ad->nr_enc;
+ uint32_t ar1 = crypto1_word(pcs, 0, 0) ^ ad->ar_enc;
+ uint32_t at1 = crypto1_word(pcs, 0, 0) ^ ad->at_enc;
+ printf("key> the same key test. nr1: %08x ar1: %08x at1: %08x \n", nr1, ar1, at1);
+
+ if (NTParityChk(ad, nt1))
+ printf("key> the same key test OK. key=%x%x\n", (unsigned int)((key & 0xFFFFFFFF00000000) >> 32), (unsigned int)(key & 0xFFFFFFFF));
+ else {
+ printf("key> the same key test. check nt parity error.\n");
+ return false;
+ }
+
+ memcpy(buf, cmd, cmdsize);
+ mf_crypto1_decrypt(pcs, buf, cmdsize, 0);
+
+ return CheckCrc14443(CRC_14443_A, buf, cmdsize);