Boost logo

Boost Users :

Subject: [Boost-users] Fwd: [MPL] How can I make this occupy less space on disk?
From: Pedro d'Aquino (pedro.daquino_at_[hidden])
Date: 2011-05-17 11:52:59


Hello,

I'm using Boost.MPL to obfuscate sensitive strings during compilation.
I wrote a class called obf_string which can be used in the following
way:

obf_string<'my_d','atab','ase_','pass','word'> password;
connect_to_db( password.unobfuscate() );

If someone runs strings.exe on this executable, they will not see
"my_database_password" listed there, because it has been XORed with a
binary mask. This approach has several benefits over e.g.
preprocessing all the source files with a tool that encrypts all
strings. The most significant is that I can easily see and change the
string.

The problem is that my implementation of obf_string is occupying too
much space on disk. I have devised a test to compare it with a normal
std::string. The test files, which are attached (test_stdstring.cpp
and test_obfstring.cpp), contain 50 different strings each. In one
file they are used to construct std::strings, in the other one they
are obfuscated through obf_string.

On average, each new std::string added 188 bytes, while each
obf_string occupied 690 bytes. Here's a plot that shows the
difference:

http://img59.imageshack.us/img59/6417/obfstring.png.

Everything was compiled on VC++10 with /O1 (minimize size). I'm using
Boost 1.46.1.

I would like to understand why obf_strings take up so much space, and
figure out ways I can minimize this. This is really important to me -
our application currently instantiates obf_string over 600 times, so
the overhead is starting to add up.

Naturally, I have also attached the full source code of obf_string.

Any help would be greatly appreciated!

Thanks,

Pedro d'Aquino






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