Exploring Privacy Techniques

 
This page is intended to provide C programmers with some ideas that may (or may not) be useful in maintaining privacy of digital information. It is not a how-to and does not even suggest an approach to robust data encryption.

Having said that, I’ll comment that I’ve used these routines to implement adjustable-length key encryption (I’ve only tested up to 8192-bit encryption) that appears fairly robust.

This first file is a normal C header file that provides information a C toolchain needs to make complete sense of my program code.

This next function is a debugging tool I wrote to allow capturing a snapshot of data during program execution. Your system may already provide such a tool and if so you won’t need this one.

The shuffle() function randomly reorders all n bytes in the memory area starting at b according to the value of a key parameter.

The unshuffle() function will un-do the byte shuffling work done by the function above, if provided with the exact same shuffled data and the exact same key:

The twinkle() function is similar to the shuffle() function except that it randomizes bits instead of bytes...

...and the untwinkle() function, like unshuffle(), uses the same key value to restore the original order of “twinkled” bits:

The sparkle() function randomly inverts bits according to the key value. When called again with the same key value, it restores previously “sparkled” data:

Here’s a short test program to illustrate using a 320-bit key with the functions above to encode and decode a text string...

...and here’s the console output for a session in which I compiled, linked, and executed this code:

The approach I’m thinking of taking involves using a graphic file (like this) as the data key:

Download

The next logical step is dispose of the hard-coded key and text data built into the program, and use data from files instead. To do that I coded separate encode and decode programs:

and the remarkably similar:

to do the actual work of encoding and decoding the file data. Both of these programs also need key data, so I wrote a routine that both could use to read a key file and produce an appropriate key:

Notice that the getkey function does not provide data extracted from the key file. Instead, it extracts data from the key file and scrambles it in such a way as to lose all resemblance to what the key file actually contains. It is this scrambled data that encode and decode use as keys.

With all that done, I brushed up on the ar and make utilities, moved the subfunctions into a library, and wrote makefile scripts to build the library and compile/link the encode and decode programs. With the debug code removed, the console output became a lot less interesting, but the privacy looks good:

I hope you’ve enjoyed this little exploration of privacy techniques. If you’d like to play with the code, click on the key image (above) to download the C source.

Copyright © 2013 Morris R Dovey

Home    Documents    Feedback?