4
$\begingroup$

I am reading a paper on security analysis of a cipher image using the paper at the following URL:

https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8306512&tag=1

It indicates some test that a cipher image should pass for successful encryption. One of the simple test is to count the number of ones and number of zeros in the BINARY SEQUENCE of the image, and they should be equal, i.e 0.5 roughly of the total:

enter image description here

How is it possible to get a proper binary sequence representation of the image? Do I just convert each bit into its binary representation and form a binary sequence, do I have to do something else?

$\endgroup$
  • $\begingroup$ What does it mean to convert a bit into a binary representation? Bits are already a binary representation. Was that by any chance supposed to read "...convert a byte into a binary representation"? $\endgroup$ – Ella Rose Sep 5 '18 at 16:44
  • $\begingroup$ i meant conversion each pixel into it's eight bit reprsentation $\endgroup$ – user311790 Sep 5 '18 at 16:47
2
$\begingroup$

It's simple. Lena is 512 x 512 pixels with a bit depth of 8. So you simply export the raw image to a file that will be exactly 262,144 bytes long. It's critical that you export or save the image as a raw binary file, not one of those JPEGey things. That won't work.

To determine the two chi values, you then consider the file as a series of consecutive individual bits, or as pairs of bits. This will entail a load of bit shifting /masking operations in your favourite programming language.

A tip. Install ent, and just run it twice against the encrypted Lena file. Run one, use the -b option which will treat the file as a series of bits. The output will produce a chi and p value. Run again without the b option. This will process the file as a series of 8 bit values. If the encryption produces independent (non correlated) bits, they can be lumped into four pair groups and treated as octets. Assume the same 5% confidence value, and look at the returned chi value to see if it's acceptable. You'd expect $219 \leq \chi^2 \leq 293$ for randomly distributed octets.

ent will also give you the Shannon entropy of the images for comparison with those in the paper.

Another tip. Do not assume that a chi failure means the encryption fails. Randomness is pesky and you have to try the test several times on repetitive images or keys.

$\endgroup$
  • 1
    $\begingroup$ How exactly do you get the Shannon entropy from a single image? Entropy is a property of a method of generating data, not of the raw data itself. $\endgroup$ – forest Sep 10 '18 at 1:57
  • $\begingroup$ @forest Arrrrgh! $\endgroup$ – Paul Uszak Sep 10 '18 at 3:17
  • 2
    $\begingroup$ Care to elaborate? It seems like you are misunderstanding the definition of entropy again. $\endgroup$ – forest Sep 10 '18 at 3:18
  • $\begingroup$ @forest I think that I've solved your problem, but it's going to require you accepting a paradigm shift. I suggest we call it known entropy and unknown entropy. Do you concur? $\endgroup$ – Paul Uszak Sep 10 '18 at 3:27
  • 1
    $\begingroup$ Are you perhaps talking about, Information entropy vs Kolmogorov complexity? $\endgroup$ – forest Sep 10 '18 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.