Cryptosystem Performance With Watermarking
Cryptosystem Performance With Watermarking
Algorithms
security level:
security level is usually expressed in "bits", where n-bit security
means that the attacker would have to perform 2 n operations to
break it
If the password is an “unsigned 32-bit integer”, there are
4,294,967,296 possible passwords from 0 to 4,294,967,295.
The video file contains number of frames each frame is
considered as RGB colored image each pixel of the frame is
combined from 3 values of 8-bit size where the range of each
value is 0-255.
Each value is encrypted and its size is increased and the
maximum size can be calculated by encrypting the maximum
value (255) using El-Gamal and RSA algorithms:
- El-Gamal Encryption
P=Pk;G=545;x=22;k=185;
Img= 255
M=double(Img);
Y=modexp(G,x,P);
a=modexp(G,k,P);
b=modexp(Y,k,P);
dd2=mod(b*M,P)
dd2 =
3761
And number of bits is
log2(dd2)
ans =
11. 8769
The estimated number of bits to encrypt the maximum pixel
value is 12 bits for each component and 12 3= 1728 for each
pixel, if the video file contains p frames of size m×n×3
Then the total number of possible combinations is
1728 (m×n×3×p)
-RSA Encryption
p=101;q=127;
[Pk,Phi,d,e] = intialize(p,q);
M=255
dd= modexp(M,e,Pk)
dd =
11304
And number of bits is
log2(dd)
ans =
13.4645
The estimated number of bits to encrypt the maximum pixel
value is 14 bits for each component and 14 3= 2744 for each
pixel, if the video file contains p frames of size m×n×3
Then the total number of possible combinations is
2744(m×n×3×p)
- El-Gamal Encryption
P=Pk;G=545;x=22;k=185;
Img= 256
M=double(Img);
Y=modexp(G,x,P);
a=modexp(G,k,P);
b=modexp(Y,k,P);
dd2=mod(b*M,P)
dd2 =
12644
And number of bits is
log2(dd2)
ans =
13.62616
The estimated number of bits to encrypt the maximum pixel
value is 14 bits for each component and 14 3= 2744 for each
pixel, if the video file contains p frames of size m×n×3
Then the total number of possible combinations is
2744 (m×n×3×p)
-RSA Encryption
p=109;q=127;
[Pk,Phi,d,e] = intialize(p,q);
M=256
dd= modexp(M,e,Pk)
dd =
12224
And number of bits is
log2(dd)
ans =
13.57742
The estimated number of bits to encrypt the maximum pixel
value is 14 bits for each component and 14 3= 2744 for each
pixel, if the video file contains p frames of size m×n×3
Then the total number of possible combinations is
2744(m×n×3×p)
Comparing both algorithms, the RSA has higher security level
than El-Gamal algorithm.
S=[1728 2197;2197 2744];
bar(S,.5)
set(gca,'XTickLabel',{'RSA';'El-Gamal'})
ylabel('Security Level')
legend('without watermarking','with watermarking')
3000
without watermarking
with watermarking
2500
2000
Security Level
1500
1000
500
0
RSA El-Gamal
Computation Time and Speed:
To compute the total time for encryption an decryption there two
MATLAB functions tic and toc used where the operation code
part for the algorithm is between these function.
So it can be used to compute the time for one frame:
- El-Gamal Algorithm
P=2083;G=545;x=22;k=185;
tic
mov = VideoReader('Taffic_br.3gp');
num_frames=1;
vin = read(mov,[1 num_frames]);
[mv nv pv qv]=size(vin);
for xx=1:num_frames
imwrite(uint8(vin(:,:,:,xx)),['IMAGE FILES/M1/M1' num2str(xx)
'.tif']);
disp(xx)
end
hh=zeros(2*mv,nv,pv);
for kk=1:num_frames
Img= double(imread(['IMAGE FILES\M1\M1' num2str(kk) '.tif']));
if kk==1%Watermarking
k_IM=Img(:,:,1);
x_IM=imread('njit_logo.jpg'); % image to be hidden
y_IM=imresize(x_IM,size(k_IM)); % resizing hidden image
z_IM=im2bw(y_IM); % converting rbg to binary
z_IM=double(z_IM); % increasing range to double
r_IM=double(k_IM-mod(k_IM,2)); % removal of LSB bits
l_IM=uint8(r_IM+z_IM); % adding LSB bit from image to be hidden
Img(:,:,1)=l_IM;
imshow(uint8(Img))
title('watermark is hidden in the first frame of video')
end
M=double(Img);
Y=modexp(G,x,P);
a=modexp(G,k,P);
b=modexp(Y,k,P);
dd=mod(b*M,P);
ee=dd/255;
ff=fix(ee);
gg=(ee-ff)*255;
hh(1:2:2*size(M,1)-1,:,:)=ff;
hh(2:2:2*size(M,1),:,:)=gg;
imwrite(uint8(hh),['IMAGE FILES\M2\M2' num2str(kk) '.tif']);
disp(kk)
end
[mv, nv, pv, qv]=size(vin);
hh2=zeros(2*mv,nv,pv);
for II=1:num_frames
hh2= double(imread(['IMAGE FILES/M2/M2' num2str(II) '.tif']));
ff2=hh2(1:2:2*size(M,1)-1,:,:);
gg2=hh2(2:2:2*size(M,1),:,:);
CC2=uint32(((gg2/255)+ff2)*255);
P=2083;G=545;x=22;
ax=modexp(a,x,P);
ax=mulinv(ax,P);
Vidr=mod(double(CC2)*ax,P);
if II==1%detection of watermark
l_IM=Vidr(:,:,1,1);
h_IM=mod(l_IM,2);p_IM=zeros(size(l_IM));
for x_IM=1:size(l_IM,1)
for y_IM=1:size(l_IM,2)
if(h_IM(x_IM,y_IM)==1)
p_IM(x_IM,y_IM)=255;
end
end
end
s_IM=im2bw(p_IM);
end
imwrite(uint8(Vidr),['IMAGE FILES\M4\M4' num2str(II) '.tif']);
disp(II)
end
t_total=toc
t_total =
3.3802
The computation time taken to apply the algorithm on one frame is
3.3802 seconds. The computation speed is estimated as a bit rate or the
number of bits processed in one second, the number of bits is calculated
using function fileinfo which finds the number of bit for the selected file.
InFInfo=imfinfo(['IMAGE FILES/M4/M4' num2str(II) '.tif']);
ISize=InFInfo.FileSize*8
ISize =
21891120
The frame file contains 21891120 bits and dividing by the total time to
get the speed
bit_speed=ISize/t_total
bit_speed =
6.4763e+06
The speed is 6.4763 Mb/s
- RSA Algorithm
p=101;%input('p= ');
q=127;%input('q= ');
[Pk,Phi,d,e] = intialize(p,q);
tic
mov = VideoReader('Taffic_br.3gp');
num_frames=1;
vin = read(mov,[1 num_frames]);
[mv nv pv qv]=size(vin);
for xx=1:num_frames
imwrite(uint8(vin(:,:,:,xx)),['IMAGE FILES/M1/M1' num2str(xx)
'.tif']);
disp(xx)
end
hh=zeros(2*mv,nv,pv);
for kk=1:num_frames
Img= double(imread(['IMAGE FILES\M1\M1' num2str(kk) '.tif']));
if kk==1%Watermarking
k_IM=Img(:,:,1);
% k_IM=rgb2gray(k_IM); % converting rgb image to gray image
x_IM=imread('njit_logo.jpg'); % image to be hidden
y_IM=imresize(x_IM,size(k_IM)); % resizing hidden image
z_IM=im2bw(y_IM); % converting rbg to binary
z_IM=double(z_IM); % increasing range to double
r_IM=double(k_IM-mod(k_IM,2)); % removal of LSB bits
l_IM=uint8(r_IM+z_IM); % adding LSB bit from image to be hidden
Img(:,:,1)=l_IM;
imshow(uint8(Img))
title('watermark is hidden in the first frame of video')
end
M=double(Img);
dd= modexp(M,e,Pk);
ee=dd/255;
ff=fix(ee);
gg=(ee-ff)*255;
hh(1:2:2*size(M,1)-1,:,:)=ff;
hh(2:2:2*size(M,1),:,:)=gg;
imwrite(uint8(hh),['IMAGE FILES\M2\M2' num2str(kk) '.tif']);
% imwrite(uint8(gg),['IMAGE FILES\M3\M3' num2str(kk) '.tif']);
disp(kk)
end
13.8902
The computation time taken to apply the algorithm on one frame is
13.8902 seconds.
InFInfo=imfinfo(['IMAGE FILES/M4/M4' num2str(II) '.tif']);
ISize=InFInfo.FileSize*8
ISize =
21891120
The frame file contains 21891120 bits and dividing by the total time to
get the speed
bit_speed=ISize/t_total
bit_speed =
1.5760e+06
The speed is 1.5760 Mb/s
Comparing both algorithms, El-Gamal algorithm is faster than
the RSA because RSA is more complicated.
S=[3.3802 13.8902;6.4763 1.5760];%e+06e+06
bar(S,'grouped')
set(gca,'XTickLabel',{'RSA';'El-Gamal'})
legend('computation Time (sec)','computation Speed
(Mb/s)')
Network overhead transmission time:
to calculate this time the tic and toc functions are applied in the period
from storing the encrypted video frame until reading it before the
encryption stage.
- El-Gamal Algorithm
imwrite(uint8(hh),['IMAGE FILES\M2\M2' num2str(kk)
'.tif']);
% imwrite(uint8(gg),['IMAGE FILES\M3\M3' num2str(kk)
'.tif']);
tic
disp(kk)
% end
t_net =
0.1755
The computation time taken to transmit one frame through the network
is 0.1755 seconds.
- RSA Algorithm
imwrite(uint8(hh),['IMAGE FILES\M2\M2' num2str(kk)
'.tif']);
% imwrite(uint8(gg),['IMAGE FILES\M3\M3' num2str(kk)
'.tif']);
tic
disp(kk)
% end
0.1376
The computation time taken to transmit one frame through the network
is 0.1376 seconds.
Comparing both algorithms, the RSA takes less time than El-
Gamal algorithm.
S=[0.1755;0.1376];
bar(S,.5)
set(gca,'XTickLabel',{'RSA';'El-Gamal'})
ylabel('Time (s)')
title('Network Overhead Transmission Time')
Frame size (image size) limitation:
The MATLAB software has limited available memory which depends
on the computer memory therefore there are limits for the image size.
Using the MATLAB command “help MEMORY” it displays
information showing how much memory is available and how much the
MATLAB software is currently using. The information displayed at
your computer screen includes the following items:
-Maximum Possible Array
-Memory Available for All Arrays
-Memory Used By MATLAB
-Total Physical Memory (RAM)
>> memory
Maximum possible array: 677 MB (7.101e+008
bytes) *
Memory available for all arrays: 1602 MB (1.680e+009
bytes) **
Memory used by MATLAB: 327 MB (3.425e+008
bytes)
Physical Memory (RAM): 3327 MB (3.489e+009
bytes)
And when using the huge size image (4320 ×7680 or greater) the
following error is displayed