Media playback is unsupported on your device Media caption David Cameron: "We must not allow terrorists safe space to communicate with each other"

David Cameron has promised a "comprehensive piece of legislation" to close the "safe spaces" used by suspected terrorists to communicate online with each other.

If he wins the election, Mr Cameron said he would increase the authorities' power to access both the details of communications and their content.

Mr Cameron said the recent attacks in Paris showed the need for such a move.

He was "comfortable" it was appropriate in a "modern liberal democracy".

Speaking at an event in the East Midlands, Mr Cameron said he recognised such powers were "very intrusive" but he believed that they were justified to counter the growing threat to the UK, as long as proper legal safeguards were in place.

The coalition introduced emergency legislation last year to maintain internet and phone companies' obligation to store their customers' personal communications data and to give access to the police.

'In extremis'

But an attempt to extend these powers to include internet browsing history and social media sites were dropped following opposition from the Liberal Democrats.

Mr Cameron said the government had acted to safeguard powers for so-called communications data, which refers to the details of when and how people have contacted each other but not the content of messages.

He said legislation would be needed to allow for "more modern forms of communication".

He went on to say he would also legislate in the "more contentious" area of the content of these online communications.

There should be no "means of communication" which "we cannot read", he said.

Data laws

Image copyright Thinkstock

Draft Communications Data Bill 2012 - Would have extended the range of data communications companies have to store for 12 months. It would have included, for the first time, details of messages sent on social media, webmail, voice calls over the internet and gaming, in addition to emails and phone calls. Officials would not have been able to see the content of the messages without a warrant. The bill, dubbed the "snooper's charter" by critics, was blocked by the Lib Dems.

- Would have extended the range of data communications companies have to store for 12 months. It would have included, for the first time, details of messages sent on social media, webmail, voice calls over the internet and gaming, in addition to emails and phone calls. Officials would not have been able to see the content of the messages without a warrant. The bill, dubbed the "snooper's charter" by critics, was blocked by the Lib Dems. Data Retention and Investigatory Powers Act 2014-15 - Introduced as emergency legislation to maintain the requirement for phone and internet companies to log records (but not content) of calls, texts and internet use.

- Introduced as emergency legislation to maintain the requirement for phone and internet companies to log records (but not content) of calls, texts and internet use. Counter-Terrorism and Security Bill 2014-15 - Part of the bill going through Parliament would add to the Data Retention and Investigatory Powers Act to allow internet protocol (IP) address matching. This would identify the individual or the device that was using a particular IP address at any given time.

Previous governments had backed away from going down such a route, Mr Cameron said, but he believed this would have to change so that, "in extremis", such material could be obtained with a signed warrant from the home secretary.

He said this would mirror existing powers enabling the police to get hold of conventional forms of communications, such as letters and other correspondence, in criminal investigations if legally sanctioned.

Existing legislation will have to be renewed after May's general election because a "sunset clause" (which gives the law a limited time life span) was added to the Data Retention and Investigatory Powers Act last year, meaning the measures will expire in 2016.

'Blanket powers'

Mr Cameron added: "If I am prime minister, I will make sure it is a comprehensive piece of legislation that makes sure we do not allow terrorist safe spaces to communicate with each other.

"That is the key principle. Do we allow terrorists the safe spaces to talk to each other? I say 'no we don't".

He added: "I am confident the powers we need, whether it is on communications data or the content of communications, I am very comfortable they are absolutely right for a modern liberal democracy."

Labour leader Ed Miliband said it was important for security services to "keep up to date with technology" but said it had to be "done in the right way", with "basic liberties" protected.

"That's why we said there needs to be an independent look at these issues, to make recommendations about what needs to be changed for the future," he added.

Explaining his party's opposition to the draft Communications Data Bill in 2013, Lib Dem leader Nick Clegg said a "law which means there will be a record kept of every website you visit, who you communicate with on social media sites" would not happen when his party was in government.

Speaking on BBC Radio 4's The World at One, David Anderson QC, the government's independent reviewer of terror legislation, said the "real issue" was that people were communicating not over the telephone, but over the internet, using service providers based in the United States.

Liberal Democrat Civil Liberties Minister Simon Hughes said he would not support "blanket powers" that would take away the liberties of "innocent civilians".