Memory-based side-channel attacks and countermeasures