Proceedings of APSIPA Annual Summit and Conference 201712 - 15 December 2017, Malaysia

Cube-based Encryption Connected Prior to
Motion JPEG Standard
Kosuke Shimizu∗ and Taizo Suzuki†∗ Department of Computer Science, University of Tsukuba, Japan

E-mail: shimizu@adapt.cs.tsukuba.ac.jp† Faculty of Engineering, Information and Systems, University of Tsukuba, Japan

E-mail: taizo@cs.tsukuba.ac.jp

Abstract—We propose a cube-based encryption-thencompression (ETC) system for the Motion JPEG standard.
ETC systems reduce the visibility of multimedia content, suchas a video sequence, to provide a high level of security at thesame time as compressing it efficiently. The conventional ETC
system for Motion JPEG applies block-based encryption toeach frame of a sequence. However, although the quality of theencrypted and compressed frames is comparable to that of theunencrypted frames, any third party may decrypt the content
from a frame without a decryption key because the blocks
cannot be moved from one frame to another. To enhance thesecurity of the ETC system, we propose a cube-based encryption
by extending the block-based encryption. Experiments showthat the proposed encryption method affects the Motion JPEG
in quality, whereas that the level of encryption is high bothobjectively and subjectively.

I. I NTRODUCTION
Telecommunications of multimedia content on bandwidthconstrained and unsecured channels of, e.g., cloud computing
or social networking services (SNSs), face two problems: thesender Alice may have difficulty sending large amounts ofcontent to a receiver Bob, and a third party may be able to lookat and/or modify the sent content illegally. To send content
securely and efficiently, the content should be encrypted before
or after compression. Here, the compression-then-encryption(CTE) system (Fig. 1(a)) encrypts the content after it has
been compressed [1]–[4]. However, since the file format of
the encrypted content is restricted to .aes (the Advanced
Encryption Standard (AES) [5]), the encrypted content cannot
be compressed efficiently and is inapplicable to services thatcannot handle AES files.
The encryption-then-compression (ETC) system, which encrypts the content before it is compressed (Fig. 1(b)), has beensuggested as a better means of privacy protection comparedwith CTE system [6]–[9]. The ETC system usually uses a “perceptual” encryption, which encrypts the content visually while
keeping its file format unaltered. Therefore, content encryptedby ETC system can be compressed with high compression
technology such as the JPEG standard and is applicable tomany services offered today. Kurihara et al. proposed a blockbased encryption for the Motion JPEG standard (Fig. 2(a)). A
bitstream, consisting of content encrypted and compressed by
Alice, is sent to Bob. Bob obtains the processed content bydecompressing and decrypting the bitstream. The system can

978-1-5386-1542-3@2017 APSIPA

compress each encrypted frame with the same compression
ratio as the unencrypted one. However, a frame may beillegally decrypted from each frame without any encryption
key; i.e., the security of ETC system is insufficient.
To enhance the security of ETC system, we propose a cubebased encryption for Motion JPEG. The system, shown in
Fig. 2(b), encrypts each frame not only spatially but also
temporally and guards against illegal decryption from only
one frame. To this end, we consider a video sequence to bea large cuboid and divide it up into smaller cubes that do
not overlap. Since several blocks in the each encrypted frame
have spatiotemporal sections obtained by arranging the frames
temporally, illegal decryption from a single frame is clearly
impossible. Experiments show that the proposed encryption
method affects the Motion JPEG in quality, whereas the levelof encryption is high both objectively and subjectively.
II. B LOCK - BASED ETC S YSTEM FOR M OTION JPEG
A. Block-based Encryption
A block-based encryption [9] is shown in Fig. 2(a). The
block scrambling randomly permutes the blocks, into whicha frame has been divided such that they do not overlap. The
block rotation and inversion randomly rotates and inverts theblocks. The directions of block rotation and block inversion are{0◦ , 90◦ , 180◦ , 270◦ } and {non inversion, horizontal inversion,
vertical inversion, horizontal+vertical inversion}, respectively.
The block negative/positive transformation randomly inverts
each color of the blocks. Let Ci , Ci′ , and rand(i) be eitherof {Ri , Gi , Bi }, which are the pixel values of ith block, theencrypted values based on Ci , i.e.,{
255 − Ci (rand(i) = 0)
Ci′ =
,
Ci
(otherwise)
and a binary random value calculated at the block. The blockcolor component shuffling rearranges the order of the color
components in each block randomly; e.g., the pixel values{Ri , Gi , Bi } may be rearranged into {Gi , Bi , Ri }.
B. Weak Point of Block Rotation/Inversion
A weak point of block rotation/inversion is that all blocks
must remain in the same frame. This means that a third party
may be able to decrypt the all encrypted blocks in the same

1811

APSIPA ASC 2017

AliceBob

Multimedia
Content

Bitstream

Bob

Multimedia
Content
Perceptual
Encryption

Decompression

Compression

Encryption

Alice

Processed
Content

Decryption

Processed
Content
Decryption

Existing
Compression
Framework
Bitstream

Compression(a)Decompression(b)Fig. 1. Procedure of encryption and compression: (a) CTE system, (b) ETC system.
Block
Rotation/
Inversion

Block
Scrambling

Block Negative/
Positive
Transformation

Block Color
Component
Shuffling

Cube
Rotation

Encrypted
image

Plain
image

Cube Negative/
Positive
Transformation

Cube
Scrambling

Cube Color
Component
ShufflingPlain
sequence

Encrypted
sequence(b)(a)
Fig. 2. Block/cube-based encryption: (a) block case, (b) cube case.

frame illegally by using a jigsaw puzzle solver [10] and abrute-force attack, even if it does not have the decryption key
or infinite computational power. To solve this problem, at least
one encrypted block must not remain in the original frame.
III. C UBE - BASED ETC S YSTEM FOR M OTION JPEG
A. Cube-based Encryption
The cube-based ETC system consists of four encryption
methods: which are called cube rotation, cube scrambling,
cube negative/positive transformation, and cube color component shuffling. Regarding the new methods, we consider avideo sequence to be a large cuboid and divide it into smaller
cubes that do not to overlap each other. The sequence isencrypted by the new methods.
In the cube rotation shown in Fig. 3, each cube is rotatedin a random direction and through a random angle. The directions and angles are {vertically, horizontally, depth-wise} and{0◦ , 90◦ , 180◦ ,270◦ }, respectively. The details are describedin Algorithm 1. Bv , Bh , and Bd are the height, width, anddepth of a small cube, respectively. Nv , Nh , Nd , Ns , and N
are values derived from Bv , Bh , and Bd . A is the set of
random numbers generated from a pseudo random number
generator (P RN G) initialized with a seed δ. The starting pointof the rotation (D, Y, X) is calculated from each number of
A at t. The rotation direction Dir and rotation angle Ang
are obtained from the random number at the time. % is theremainder operator; e.g., num1 % num2 means num1 modulo
num2 . According to Dir, the cube is rotated (⟲) depth-wise(Dir = 0), horizontally (Dir = 1), and vertically (Dir = 2).
The cube scrambling is illustrated in Fig. 4. It exchanges
the positions of pairs of cubes corresponding to each random
number. The operation is applied to all cubes. The details
are described in Algorithm 2. The first step is initializationof Nv , Nh , Nd , Ns , N, P RN G, and A. The function derive(·)

Video
Sequence
Horizontally
VerticallyDepth-wiserotate each cube randomly

Fig. 3. Cube rotation.

2
1

4
3

1
6

5

3

2

5
4

6

Fig. 4. Cube scrambling.

means that the variables are calculated by using Algorithm 1
and a random number A(t) (t = 0, 1, · · · , N −1). The operator⇆ means the exchange of two cubes.
The cube negative/positive transformation and cube color
component shuffling are almost the same as conventional
block-based case. To facilitate the discussion, we omit the
explanation here and will not mention the two methods further.
B. Robustness against Illegal Decryption
The cube-based ETC system is more robust against illegal
decryption than the block-based ETC system. In contrast with

APSIPA ASC 2017

Proceedings of APSIPA Annual Summit and Conference 201712 - 15 December 2017, Malaysia

Algorithm 1 Cube rotation
Input: Video sequence Vin
Output: Vin encrypted by rotating each small cube
1: Nv ← height of each frame/Bv
2: Nh ← width of each frame/Bh
3: Nd ← number of frames/Bd
4: Ns ← Nv × Nh
5: N ← Nv × Nh × Nd //Number of cubes
6: P RN G ← δ
7: A ← arrange{a0 , · · · , aN −1 ; ai ∈ [0, 1, · · · , N − 1]}
8: for t = 0 to N − 1 do
9:X ← (A(t)%Ns )%Nh × Bh
10:Y ← (A(t)%Ns )/Nh × Bv
11:D ← ⌊A(t)/Ns ⌋ × Bd
12:
Dir ← rand()%3 //horizontally, vertically, or depthwise13:
Ang ← rand()%4 //0◦ , 90◦ , 180◦ , 270◦
14:
if Dir = 0 then15:// Depth-wise rotate
16:
for v = Y to Y + Bv do
17:
Vin (D : D + Bd , v, X : X + Bh , :) ⟲ 90 × Ang ◦18:
end for19:
else if Dir = 1 then20:// Horizontally rotate
21:
for d = D to D + Bd do
22:
Vin (d, Y : Y + Bv , X : X + Bh , :) ⟲ 90 × Ang ◦23:
end for24:
else if Dir = 2 then25:// Vertically rotate
26:
for h = X to X + Bh do
27:
Vin (D : D + Bd , Y : Y + Bv , h, :) ⟲ 90 × Ang ◦28:
end for29:
end if
30: end for

Algorithm 2 Cube scrambling
Input: Video sequence Vin
Output: Vin encrypted by scrambling small cubes composing
the video sequence
1: {Nv , Nh , Nd , Ns , N, P RN G, A}←derive(Algorithm 1)
2: t ← 0
3: while t ≤ N − 1 do
4:
(D1 , Y1 , X1 )←derive(Algorithm 1, A(t))
5:(D2 , Y2 , X2 )←derive(Algorithm 1, A(t + 1))
6:
Vin (D1 : D1 + Bd , Y1 : Y1 + Bv , X1 : X1 + Bh , :) ⇆Vin (D2 : D2 + Bd , Y2 : Y2 + Bv , X2 : X2 + Bh , :)7:t←t+2
8: end while

978-1-5386-1542-3@2017 APSIPA

the block-based case, the cube-based case, which utilizes multiple frames simultaneously, can exchange the blocks of eachframe with the blocks of the other frames or spatiotemporalslices. This means that the illegal decryption from only eachframe is clearly impossible.
However, new methods of decrypting encrypted frames
illegally may be developed someday, e.g., a brute-force attack
using each cube as a unit. Here, we can evaluate new methods
by calculating the total number of brute-force attacks. The
cube rotation is decrypted by rotating each cube in all directions and angles. Since there are three directions and fourangles, each cube produces a total of twelve rotation variations.
The maximum number of brute-force attacks against cube
rotation for N cubes is
Ncr = 12N .
The cube scrambling is decrypted by moving each cube backto its proper position. The probability that the third party canmove one in N cubes back to its proper position is N1 andthe probability of it moving back one more cube properly is
1
N (N −1) . Viewed in this way, the probability of it moving all
cubes properly is
Pcs =

N
−1
∏

1
1
=
.
N −i
N!
i=0

The maximum number of brute-force attacks against cube
scrambling is
Ncs = N !.
Consequently, the total number of brute-force attacks against
the two cube-based methods is
Nct = Ncr × Ncs = 12N × N !.
For example, when the cube rotation and cube scrambling
are applied to a 288 × 352 × 256 video sequence, Nct is126336 ×6336! in the case of 16×16×16 cube. This number ismuch bigger than the 2256 of the brute-force attacks against the
SHA-256 hash digest [11], and it is clear that attacks against
these methods in real time are difficult.
IV. E XPERIMENTAL R ESULTS
We compared the compression quality of frames encryptedby the ETC systems with that of the unencrypted frames. Threeraw video sequences Akiyo, Bowing, and Coastguard [12] wereused. Each video sequence had a size of 288 × 352 × 256 and8-bit RGB full color space. The size of the divided small cubes
was 16 × 16 × 16 pixels in accordance with the conventional
block-based case. We experimented as follows:
1) Encrypt the frames of a raw video sequence.
2) Compress the encrypted frames with libjpeg [13], whose
compression qualities are Q = {10, 20, · · · , 100}.
3) Calculate mean bitrates of the compressed frames.
4) Decompress the compressed frames.
5) Decrypt the decompressed frames.
6) Calculate mean PSNRs of the decrypted frames.

1813

APSIPA ASC 2017

Proceedings of APSIPA Annual Summit and Conference 201712 - 15 December 2017, Malaysia

Fig. S. Ra1e-distortion ClIne (mean of 2S6 frames): (a) Al:i)YJ. (b) Bowing. (c) Coa&tgwmJ.

Fig. 6. Visibility comparison of 140th frame of Coa&tguorrl. (Ieft-to-rigbt) original, only cube rotation. only cube scrambling. and cube rotation and saambling.

The experimental results are shown in Fig. 5. The quality
in encrypted Akiyo became better than the unencrypted one.
The quality in encrypted Bowing was almost same as the
unencrypted one except for Q = 100. The quality in encrypted
Coastguard became worse than the unencrypted one. Thesemean that the proposed encryption influences Motion JPEG
algorithm. We consider the reason is that the encrypted frame
containing many almost invariant textures in ditJerent frames
can be compressed efficiently by JPEG, whereas one containing other textures cannot be compressed so efficiently.
We also confirmed that the visibilities of the encrypted
frames were reduced to enhance security. A visibility comparison of the 140th frame of Coastguard is shown in Fig. 6. In
the case of only cube rotation, some of the blocks are not in theoriginal frame. In the case of only cube scrambling and cube
rotation and scrambling, the blocks are at ditJerent positions
from those of the original frame. It is clear that we cannot
recognize the original frames in the case of cube rotation andscrambling.

v. CONCLUSION
We proposed a cube-based ETC system for Motion JPEG.

The cube-based encryption makes the illegal decryption fromonly each frame of a video sequence impossible and isrobust against a brute-force attack. Experiments showed thatthe proposed encryption method affected the Motion JPEG
in quality, whereas the level of encryption was high bothobjectively and subjectively.

REFERENCES(I) N. G. Bourbakis, "Image data compression-encryptioo using G-scan
pal1ems." in Proc. of ICSMC'W. Orlando. FL, Oct. 1997, JIll. 1117-

1120.
(2) H. (])eng and X. Li, "Partial encryption of compressed images andvideos." IEEE Tnuu. Signal Proau.. vol. 48. DO. 8. JIll. 2439-24SI.
Aug. 2000.
(3) M. Ito, N. Obnisbi, A. A1fa1ou, and A. Mansour. "New illlllF encryption
and compression method balled on independent component analysis," inProc. ofICTTA'08. Damascus, Syria. AIX'. 2008, JIll. I~.
(4) D. Mabeswari and V. Radha, "Secure layer based compound image c0mpression using XML compressioo." in Proc. ofICCIC'IO. Coimbatore.
India, Dec. 2010, JIll. 494-498.
(S) Advanced Encryption StanJanl (AES), FIPS Pub. 197. Nov. 2001.
(6) A. Kingston. S. Colosimo, P. Campisi. and F. Autrusseau, "LossIessimage compression and selective encryption using a disaete Radontransfonn," in Proc. oflarUl, San Antonio, TIC, Sep. 2007. JIll. 46S468.
1.7) F. Ahmed, M. Y. Slyal, and V. U. Abbas. "A perceptually scalable
and JPEG compession tolerant image encryption scbeme; in Proc. of
PRIVI"IO. Singapore, Nov. 2010. JIll. 232-238(8) O. Watanabe, T. Fukubarai. and H. Kiya, "A perceptua1 encryption
scheme f(X' Motion JPEG 2000 standard," in Proc. of ISC/T'15, Nara,
Japan. Oct. 201S. JIll. 12S-128.
(9) K. Kurihara, M. Kikucbi, S. Imaizumi, S. Sbiota, and H. Kiya, "An
encryptioo-tben-compression system for JPEG'Motion JPEG standard."
IEICE Tnuu. FIllldDmnrtal8, vol. E98-A, DO. II, JIll. 2238-224S. Nov.
201S.
(10) T. Chuman, K. Kurihara, and H Kiya, "On tbe security of block-based
ETC systems against jigsaw puzzle solver," in Proc. oflCASSr 17, New
Orleans, LA, Mar. 2017, JIll. 2157-2161.
(II) Secure Hash StanJanl (SHS). FIPS Pub. 180-4. Mat 2012.
(12) "Xipb.org video test media (derf's collection)."Avai1able:bttps:llmediLxipb.orrJvidln'derfi.
(13) "JPEG software." Available: bUps:lljpeg.orwjpegisoftware.btm1.

ACKNOWLEDGMENT

This work was supported by a JSPS Grant-in-Aid for Young
Scientists (8), Grant Number 16KI8100.

978-1-5386-1542-3@2017 APSIPA1814

APSIPA ASC 2017