On Sun, Apr 3, 2011 at 15:39, avejidah <[email protected]> wrote: > Is there a way to safely read a password into a SecByteBlock from > stdin? > > const unsigned maxLen = 100; > SecByteBlock password(maxLen+1); > cin.getline(reinterpret_cast<char*>(password.BytePtr()), maxLen+1); > > ^^ cin may do some buffering behind the scenes, correct?
I think it does. Terminal IO details at any lower level than what you just wrote get a bit hairy and can vary from platform to platform. It's probably instructive to look at how NSS handles it for Linux and Windows, though I should caveat this by saying that I haven't scrutinized their code very carefully. Here's the NSS password reading function: http://mxr.mozilla.org/security/source/security/nss/cmd/lib/secpwd.c#88 It should give you a good idea anyway. HTH, Geoff -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com.
