+ if (conf_block[5] & 0x80) {
+ page_size = 256 * 8;
+ }
+
+ // From PicoPass DS:
+ // When the page is in personalization mode this bit is equal to 1.
+ // Once the application issuer has personalized and coded its dedicated areas, this bit must be set to 0:
+ // the page is then "in application mode".
+ bool personalization_mode = conf_block[7] & 0x80;
+
+ // chip memory may be divided in 8 pages
+ uint8_t max_page = conf_block[4] & 0x10 ? 0 : 7;
+
+ // Precalculate the cipher states, feeding it the CC
+ cipher_state_KD[0] = opt_doTagMAC_1(card_challenge_data, diversified_key_d);
+ cipher_state_KC[0] = opt_doTagMAC_1(card_challenge_data, diversified_key_c);
+ if (simulationMode == ICLASS_SIM_MODE_FULL) {
+ for (int i = 1; i < max_page; i++) {
+ uint8_t *epurse = emulator + i*page_size + 8*2;
+ uint8_t *Kd = emulator + i*page_size + 8*3;
+ uint8_t *Kc = emulator + i*page_size + 8*4;
+ cipher_state_KD[i] = opt_doTagMAC_1(epurse, Kd);
+ cipher_state_KC[i] = opt_doTagMAC_1(epurse, Kc);
+ }
+ }
+