Notes on the tty handling changes: I didn't understand why you where doing open("/dev/tty", O_RDONLY), so the changes may be wrong.
The goal was to allow me to pipe a password into tcplay via standard in. isatty is used to determine whether to prompt the user or simply read from input. I suppose this could cause issues if the user (for some reason) lacks a tty. Let me know what you think.
In the makefile, I use variables in the test and clean target instead of hardcoded programs.
tcplay memcpy's to the same buffer when doing cipher chaning (in = out, in the cipher chaining loop). This eventually gets to a function which memcpy's in to out. memcpy is not technically allowed to do this (pointers must point to independed memory regions), so I check for that case and remove it.
Thoughts: It would probably be cleaner to remove the memcpy between buffers entirely by somehow hoisting it out of this function. I honestly didn't look to hard at this option yet.
Sorry - I haven't had time to review this yet. I'll hopefully have time this weekend.
The reason I am accessing /dev/tty instead of just relying on stdin is pretty much to avoid hijacking of stdin - someone putting a wrapper around tcplay that logs passphrases.
To pass in passphrases non-interactively the best thing to do would be to use the API, although I see how that is not convenient at all for a shell script or so.
If you separate out the changes to the tty business, I'll merge the rest straight ahead.
Support reading password for non-tty stdin
call isatty once instead of twice.
clear errno after it could be set to avoid confusing errors.
Wouldn't hijacking the controlling terminal also be possible in any case where hijacking stdin is possible?
Merge branch 'master' of https://github.com/bwalex/tc-play
After having another look at all of this, I've decided it's not really worth trying to handle weird cases when the advantages outweigh the disadvantages like they do in this case.
I've committed your code with some minor changes. Thanks, and sorry for the delay!