|
Boost Users : |
Subject: Re: [Boost-users] boost.Iostream OpenSSL Filter
From: Neil Nelson (nnelson_at_[hidden])
Date: 2012-08-06 17:40:33
exocoder,
Upon just reading the docs at
http://www.boost.org/doc/libs/1_50_0/libs/iostreams/doc/index.html
and particularly
2.2.8. Multi-Character Filters
It looks like you could take the code from the following page
http://stackoverflow.com/questions/1007337/encrypting-and-decrypting-a-small-file-using-openssl
with the critical line being
AES_cfb128_encrypt(indata, outdata, bytes_read, &key, ivec, &num,
AES_ENCRYPT);
that reads and writes to memory buffers. Two other aspects are: (1)
software using encryption is export restricted and you can research that
if needed for your application, (2) key management is likely the more
complicated part, and (3) use of initialization vectors (added random
bytes at the beginning of the input data).
Neil Nelson
> I am currently looking at using OpenSSL to write information to an
> encrypted file on-the-fly so to speak. I have been researching my
> options for doing this, and have come across the Boost.Iostream library,
> which promises to be a very elegant solution (The documentation even
> suggests that filters can be written to provide encryption/decryption
> using OpenSSL).
> It would seem that my best approach would be to use the BIO_f* interface
> to encrypt a memory buffer, which could be written by overloading
> write(). However the OpenSSL documentation is particularly sparse when
> it comes to file/memory encryption and I would appreciate any advice on
> how to do this.
> Thank you in advance for any help proffered.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net