properly use unsigned char casts for ctype functions.
missing errno check
better response
fix regression introduced when plugged the passphrase-protected key support