The story takes place in March 1943 with the Second World War at its height and is loosely based on actual events. The cryptanalysts at Bletchley Park, Buckinghamshire, England, have a problem: the Nazi U-boats have increased the security of key-changing of their Enigma machine ciphers, leading to a blackout in the flow of naval vital signals intelligence. This could spell disaster in the critical Battle of the Atlantic, on whose outcome Britain's survival depends. The British cryptanalysts have cracked the "shark" cipher before, and they need to do it again in order to keep track of U-boat locations and steer shipping convoys out of their way. The plot follows the fictional character of the brilliant but maverick working class mathematician Tom Jericho (played by Dougray Scott). He is returned to Bletchley Park from Cambridge to assist with the crisis after a period of recuperation bought on by overwork earlier in the war combined with an unhappy love affair with Claire Romilly (Saffron Burrows), which led to his having a nervous breakdown. Jericho immediately tries to see Claire again and finds she has mysteriously disappeared. He enlists the help of Claire's blue stocking housemate Hester Wallace (Kate Winslet) to follow the trail of clues and learn what has happened to her. Mr. Jericho and Miss Wallace, as they coldly call each other, repeatedly break the rules of the Bletchley Park establishment and the law as their hunt gets more intense. Jericho is closely watched by MI5 agent Wigram (Jeremy Northam), who plays cat and mouse with him throughout the film. Jericho is tolerated at the Park, despite his transgressions, because of the brilliant plan he invents for uncovering the new key. The plan may unfortunately mean sacrificing at least one Allied convoy to the U-boats. The film follows events as signals intelligence see a convoy spotted and then hunted down by the U-boats, but this gives enough information for the new key to be analysed using electro mechanical Bombe devices. Tom and Hester at the same time in their unofficial research uncover a British government plot to bury the intelligence information of the Katyn massacre for fear it might weaken American willingness to remain in the war on the same side as Stalin. This in turn leads to their suspicion that a Polish cryptanalyst, Jozef 'Puck' Pukowski (Nikolaj Coster Waldau) at the park may have been so incensed by his own learning of the massacre which claimed the life of his brother that he is prepared to betray Bletchley's secrets to the Nazis in order to take revenge on Stalin.