crypto: handle more error cases