crypto: fix crash with invalid hex strings