The government will announce that it is rushing through emergency legislation underpinning the state's right to keep personal data held by internet and phone companies.