--- tags: 46-MSDF --- # 2: Steganography ## Cryptography vs. Steganograhy - Ciphertext looks like noises. - Stegotext looks like **normal** text - encipher<->decipher - embed<->extract ## Concept of Steganography ## Textual Steganography ## Image Steganography ```shell= $ cat file1 file2 > file3 # This prints file1 and file2 to file3, truncating file3 # if already exitsted. ``` ### LSB Steganography - Pros - Simple/Fast/High Capacity: mnl bits? - Cons - Less secure when embedded bits are too many - fragile to image processing #### i-th bitplane #### RC4 stream cipher for random path generation ### Transform domain (e.g. DCT) Steganography #### Method 1. OutGuess OutGuess is a steganographic software for hiding data in the most redundant content data bits of existing (media) files. https://github.com/resurrecting-open-source-projects/outguess.git # Lab 2 ## 2 Crytography ### a) Use the “General Test Pattern.tif” gray-scale image. #### i) gray_scale_img -> Enc(AES, ECB/CBC) -> ```= % AES / ECB vs. CBC mode cipher_ecb = Encipher(plaintext, 'password', 'AES', 'ECB'); cipher_cbc = Encipher(plaintext, 'password', 'AES', 'CBC'); figure, imshow(cipher_ecb) figure, imshow(cipher_cbc) ``` (Left) ECB : (Right) CBC <img src='https://i.imgur.com/zTPe4lJ.jpg' width='50%'><img src='https://i.imgur.com/S2KhGbL.jpg' width='50%'> #### ii) Decrypt the CBC encrypted image and show the plaintext image. Use the function isequal() to check whether the original and the decrypted image are identical. ```= plaintext_true = Decipher(cipher_cbc, 'password', 'AES', 'CBC'); if (isequal(plaintext, plaintext_true)) disp('The recovered plaintext is identical with the original plaintext!'); else disp('The recovered plaintext does not match the original plaintext!'); end plaintext_false = Decipher(cipher_cbc, 'not_the_password', 'AES', 'CBC'); if (isequal(plaintext, plaintext_false)) disp('The recovered plaintext is identical with the original plaintext!'); else disp('The recovered plaintext does not match the original plaintext!'); end >> lab2 The recovered plaintext is identical with the original plaintext! The recovered plaintext does not match the original plaintext! ``` #### iii) Compute the histograms of the plaintext, the ECB and the CBC encrypted images and show the three histograms in the same figure. Are the histograms different from each other? Why or why not? ## 3 LSB Steganography > a) > - Use the bitget() function to get your image’s 8 bitplanes and display them in one 3x3 figure together with the original gray-scale image. > - Repeat the task for a the test image “windmill.png” from the “more images.zip” archive. > - Explain why the windmill image’s LSB bitplanes do not look as random as the other test images. <img src='https://i.imgur.com/SAjd8Xo.jpg' width='50%'><img src='https://i.imgur.com/rVsVZ9u.jpg' width='50%'> ```matlab= % a) 23.png img = rgb2gray(imread('23.png')); subplot(3,3,1),imshow(img),title('Original'); for i=1:8 subplot(3,3,i+1),imshow(double(bitget(img,i))); % The following should work as well. % subplot(3,3,i+1),imshow(bitget(img,i), [0 1]); title(['Bitplane ' num2str(i)]); end % a) windmill.png img = imread('windmill.png'); subplot(3,3,1),imshow(img),title('Original'); for i=1:8 subplot(3,3,i+1),imshow(double(bitget(img,i))); % The following should work as well. % subplot(3,3,i+1),imshow(bitget(img,i), [0 1]); title(['Bitplane ' num2str(i)]); end ``` > b) > - Reproduce the results of Slide 36 (of Lecture 2) with your chosen gray-scale image. Use PSNR() to calculate the objective quality of each image when i LSBs are set to zeros. > - Observe how the PSNR values change w.r.t. the value of i and explain why. <img src='https://i.imgur.com/qbrhcG8.jpg' width='50%'><img src='https://i.imgur.com/wEIQAJ0.jpg' width='50%'> ```matlab= % b) PSNR() img = imread('windmill.png'); imgs = cell(1,9); imgs{1} = img; subplot(3,3,1), imshow(imgs{1}), title('Original'); for i=2:9 imgs{i} = bitset(imgs{i-1},i-1,0); subplot(3,3,i),imshow(imgs{i}); title(['Bitplanes 1-' num2str(i) ' = 0']); end pause; close all; PSNR_values = zeros(1,8); for i=1:8 % "PSNR(A, B)" is a MATLAB function that calculates the % PSNR between two images A and B. PSNR_values(i) = PSNR(imgs{i+1},imgs{1}); fprintf('PSNR value of the image when %d bitplane(s) is/are set to zeros: %g dB.\n', i, PSNR_values(i)); end plot(1:8, PSNR_values, '-*'); axis tight; xlabel('Number of bitplane(s) setting to zeros'); ylabel('PSNR (dB)'); ``` > c)