Refactor crypto error handling to be more like TLS error handling: