Some changes in crypto.lib. Added tests.