removed asserts and did proper error handling in crypto.c