> From: [email protected] On Behalf Of Ger Hobbelt
> Sent: Wednesday, 08 April, 2009 19:06

> On Tue, Apr 7, 2009 at 8:17 PM, Charles <[email protected]> wrote:
> > Doh!  Thanks guys.  I try and use std::strings where 
> possible to keep 
> > me out of trouble.  Stupid.  So I should be padding my key? 
>  I guess 
> > this threw me off:
> 
> Trouble with string<> is (and with anything that thinks 'string'
> instead of 'binary blob', to ab/re-use a database term) that 
> any NUL bytes within your key would make any 
> assignment/copy-ing in your code dangerous as strings stop 
> copying when they hit the NUL sentinel.
> 
That's a problem for C-style strings (in C or C++), but not 
for C++ std::string which is counted and allows all chars.

It is more descriptive to use uchar[N] or vector<uchar>(N),
and avoids the danger of some operations that (can) treat 
it as printable/text -- which keys and ciphertext aren't,
unless encoded e.g. base64. But NUL is OK in std::string.

BTW, std::basic_string<> is the template; 
std::string and std::wstring are specifics.



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [email protected]

Reply via email to