mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-22 14:22:36 +00:00
EMVToken::EMVCards keeps every EMV card that was read, together with the ICC and issuer public key certificates and the CPLC data that make up its keyfile, and keeps the card connected. Closing all security token sessions, the option to close them after mounting and wiping the cache on auto-dismount only closed PKCS#11 sessions, so this data stayed in memory until VeraCrypt exited. Add Token::CloseAllSessions, which also releases the cached cards so that their data is erased and their connection closed, and use it wherever all sessions are closed. This resolves the "TODO Use Token" notes at these call sites on Windows. Keep the EMV cache private and serialize reader enumeration, card reads, and cache cleanup with the same mutex. Closing sessions waits for active reads to release their local card references before erasing the cache, so a read cannot race destruction or insert its card after cleanup.