Simulation of Image Encryption
Simulation of Image Encryption
With the fast progression of data exchange in electronic way, information security is
becoming more important in data storage and transmission. Because of widely using images in
industrial process, it is important to protect the confidential image data from unauthorized
access. This paper presents the design of a 128 bit encoder using AES Rijndael Algorithm for
image encryption.
The AES algorithm defined by the National Institute of Standard and Technology(NIST)
of United States has been widely accepted. Optimized and Synthesizable VHDL code is
developed for the implementation of 128- bit data encryption and process. Xilinx ISE9.2i
software is used for synthesis.
Timing simulation is performed to verify the functionality of the designed circuit.
Transmission of sensitive data over the communication channel have emphasized the need for
fast and secure digital communication networks to achieve the requirements for secrecy, integrity
and non reproduction of exchanged information. Cryptography provides a method for securing
and authenticating the transmission of information over insecure channels.
INTRODUCTION
Transmission of sensitive data over the communication channel have emphasized the
need for fast and secure digital communication networks to achieve the requirements for secrecy,
integrity and non reproduction of exchanged information. Cryptography provides a method for
securing and authenticating the transmission of information over insecure channels. It enables
us to store sensitive information or transmit it across insecure networks so that unauthorized
persons cannot read it.
The urgency for secure exchange of digital data resulted in large quantities of different
encryption algorithms which are evaluated on the basis of throughput ,speed of operation and
area requirements. There are mainly two types of cryptographic algorithms: symmetric and
asymmetric algorithms. Symmetric systems such as Data Encryption Standard(DES),3DES, and
Advanced Encryption Standard(AES) uses an identical key for the sender and receiver; both to
encrypt the message text and decrypt the cipher text. Asymmetric systems such as Rivest-
Shamir- Adelman(RSA) & Elliptic Curve Cryptosystem(ECC) uses different keys for encryption
and decryption. Symmetric cryptosystems is more suitable to encrypt large amount of data with
high speed.
To replace the old Data Encryption Standard ,in September 12 of 1997,the National
Institute of Standard and Technology(NIST) required proposals to what was called Advanced
Encryption Standard (AES).Many algorithms were presented originally with researches from 12
different nations. On October 2nd 2000,NIST has announced the Rijndael Algorithm is the best
in security, performance, efficiency, implement ability & flexibility. The Rijndael algorithm was
developed by Joan Daemen of Proton World International and Vincent Rijmen of Katholieke
University at Leuven.
AES encryption is an efficient scheme for both hardware and software implementation.
As compare to software implementation, hardware implementation provides greater physical
security and higher speed. Hardware implementation is useful in wireless security like military
communication and mobile telephony where there is a greater emphasis on the speed of
communication. Most of the work has been presented on hardware implementation of AES using
FPGA.
AES has been adopted by the U.S. government and is now used worldwide. It supersedes
the Data Encryption Standard (DES). The algorithm described by AES is a symmetric-key
algorithm, meaning the same key is used for both encrypting and decrypting the data.
In the United States, AES was announced by the NIST as U.S. FIPS PUB 197 (FIPS 197)
on November 26, 2001. This announcement followed a five-year standardization process in
which fifteen competing designs were presented and evaluated, before the Rijndael cipher was
selected as the most suitable (see Advanced Encryption Standard process for more details). It
became effective as a federal government standard on May 26, 2002 after approval by
the Secretary of Commerce. AES is included in the ISO/IEC 18033-3 standard. AES is available
in many different encryption packages, and is the first publicly accessible and
open cipher approved by the National Security Agency (NSA) for top secret information when
used in an NSA approved cryptographic module.
The name plays on the names of the two inventors. Strictly speaking, the AES standard
is a variant of Rijndael where the block size is restricted to 128 bits.
The key size used for an AES cipher specifies the number of repetitions of transformation
rounds that convert the input, called the plaintext, into the final output, called the ciphertext. The
number of cycles of repetition are as follows:
Each round consists of several processing steps, including one that depends on the
encryption key itself. A set of reverse rounds are applied to transform cipher text back into the
original plaintext using the same encryption key.
1. Key Expansion—round keys are derived from the cipher key using Rijndael's key
schedule
2. Initial Round
1. Add Round Key—each byte of the state is combined with the round key using
bitwise xor
3. Rounds
1. Sub Bytes—a non-linear substitution step where each byte is replaced with
another according to a lookup table.
2. Shift Rows—a transposition step where each row of the state is shifted cyclically
a certain number of steps.
3. Mix Columns—a mixing operation which operates on the columns of the state,
combining the four bytes in each column.
4. Add Round Key
4. Final Round (no Mix Columns)
1. Sub Bytes
2. Shift Rows
3. Add Round Key
SUB BYTES STEP
The Shift Rows step operates on the rows of the state; it cyclically shifts the bytes in each
row by a certain offset. For AES, the first row is left unchanged. Each byte of the second row is
shifted one to the left. Similarly, the third and fourth rows are shifted by offsets of two and three
respectively. For blocks of sizes 128 bits and 192 bits, the shifting pattern is the same. Row n is
shifted left circular by n-1 bytes. In this way, each column of the output state of the Shift
Rows step is composed of bytes from each column of the input state. (Rijndael variants with a
larger block size have slightly different offsets). For a 256-bit block, the first row is unchanged
and the shifting for the second, third and fourth row is 1 byte, 3 bytes and 4 bytes respectively—
this change only applies for the Rijndael cipher when used with a 256-bit block, as AES does not
use 256-bit blocks.
MIX COLUMNS STEP
In the Mix Columns step, the four bytes of each column of the state are combined using
an invertible linear transformation. The Mix Columns function takes four bytes as input and
outputs four bytes, where each input byte affects all four output bytes. Together with Shift
Rows, Mix Columns provides diffusion in the cipher.
During this operation, each column is multiplied by the known matrix that for the 128 bit
key is
The multiplication operation is defined as: multiplication by 1 means no change,
multiplication by 2 means shifting to the left, and multiplication by 3 means shifting to the left
and then performing xor with the initial unshifted value. After shifting, a conditional xorwith
0x1B should be performed if the shifted value is larger than 0xFF.
In more general sense, each column is treated as a polynomial over GF(28) and is then
multiplied modulo x4+1 with a fixed polynomial c(x) = 0x03 · x3 + x2 + x + 0x02. The
coefficients are displayed in their hexadecimal equivalent of the binary representation of bit
polynomials from GF(2)[x]. The MixColumns step can also be viewed as a multiplication by a
particular MDS matrix in a finite field. This process is described further in the article Rijndael
mix columns.
ADD ROUND KEY STEP
In the Add Round Key step, the sub key is combined with the state. For each round, a sub
key is derived from the main key using Rijndael's key schedule; each sub key is the same size as
the state. The sub key is added by combining each byte of the state with the corresponding byte
of the sub key using bitwise XOR.
On systems with 32-bit or larger words, it is possible to speed up execution of this cipher
by combining the SubBytes andShiftRows steps with the MixColumns step by transforming
them into a sequence of table lookups. This requires four 256-entry 32-bit tables, and utilizes a
total of four kilobytes (4096 bytes) of memory — one kilobyte for each table. A round then be
done with 16 table lookups and 12 32-bit exclusive-or operations, followed by four 32-bit
exclusive-or operations in the AddRoundKey step.
If the resulting four kilobyte table size is too large for a given target platform, the table
lookup operation can be performed with a single 256-entry 32-bit (i.e. 1 kilobyte) table by the
use of circular rotates.
Security
Until May 2009, the only successful published attacks against the full AES were side-
channel attacks on some specific implementations. The National Security Agency (NSA)
reviewed all the AES finalists, including Rijndael, and stated that all of them were secure enough
for U.S. Government non-classified data. In June 2003, the U.S. Government announced that
AES could be used to protect classified information:
The design and strength of all key lengths of the AES algorithm (i.e., 128, 192 and 256)
are sufficient to protect classified information up to the SECRET level. TOP SECRET
information will require use of either the 192 or 256 key lengths. The implementation of AES in
products intended to protect national security systems and/or information must be reviewed and
certified by NSA prior to their acquisition and use."
AES has 10 rounds for 128-bit keys, 12 rounds for 192-bit keys, and 14 rounds for 256-
bit keys. By 2006, the best known attacks were on 7 rounds for 128-bit keys, 8 rounds for 192-bit
keys, and 9 rounds for 256-bit keys.
ATTACKS
AES has a fairly simple algebraic description. In 2002, a theoretical attack, termed the
"XSL attack", was announced by Nicolas Courtois and Josef Pieprzyk, purporting to show a
weakness in the AES algorithm due to its simple description. Since then, other papers have
shown that the attack as originally presented is unworkable; see XSL attack on block ciphers.
During the AES process, developers of competing algorithms wrote of Rijndael, "...we
are concerned about [its] use...in security-critical applications." [13] However, in October 2000 at
the end of the AES selection process in, Bruce Schneier, a developer of the competing
algorithm Twofish, wrote that while he thought successful academic attacks on Rijndael would
be developed someday, "I do not believe that anyone will ever discover an attack that will allow
someone to read Rijndael traffic."
On July 1, 2009, Bruce Schneier blogged about a related-key attack on the 192-bit and
256-bit versions of AES, discovered by Alex Biryukov and Dmitry Khovratovich, which exploits
AES's somewhat simple key schedule and has a complexity of 2 119. In December 2009 it was
improved to 299.5. This is a follow-up to an attack discovered earlier in 2009 by Alex Biryukov,
Dmitry Khovratovich, and Ivica Nikolić, with a complexity of 296 for one out of every 235 keys.
Another attack was blogged by Bruce Schneier on July 30, 2009 and released as a
preprint[19] on August 3, 2009. This new attack, by Alex Biryukov, Orr Dunkelman, Nathan
Keller, Dmitry Khovratovich, and Adi Shamir, is against AES-256 that uses only two related
keys and 239 time to recover the complete 256-bit key of a 9-round version, or 245 time for a 10-
round version with a stronger type of related subkey attack, or 2 70 time for an 11-round version.
256-bit AES uses 14 rounds, so these attacks aren't effective against full AES.
In November 2009, the first known-key distinguishing attack against a reduced 8-round
version of AES-128 was released as a preprint. [20] This known-key distinguishing attack is an
improvement of the rebound or the start-from-the-middle attacks for AES-like permutations,
which view two consecutive rounds of permutation as the application of a so-called Super-Sbox.
It works on the 8-round version of AES-128, with a time complexity of 2 48, and a memory
complexity of 232.
The first key-recovery attacks on full AES were due to Andrey Bogdanov, Dmitry
Khovratovich, and Christian Rechberger, and were published in 2011. [22] The attack is based on
bicliques and is faster than brute force by a factor of about four. It requires 2 126.1 operations to
recover an AES-128 key. For AES-192 and AES-256, 2189.7 and 2254.4 operations are needed,
respectively.
Side-channel attacks
Side-channel attacks do not attack the underlying cipher and so have nothing to do with
its security as described here, but attack implementations of the cipher on systems which
inadvertently leak data. There are several such known attacks on certain implementations of
AES.
In November 2010 Endre Bangerter, David Gullasch and Stephan Krenn published a
paper which described a practical approach to a "near real time" recovery of secret keys from
AES-128 without the need for either cipher text or plaintext. The approach also works on AES-
128 implementations that use compression tables, such as OpenSSL.[27] Like some earlier attacks
this one requires the ability to run unprivileged code on the system performing the AES
encryption, which may be achieved by malware infection far more easily than commandeering
the root account.
BACKGROUND:
What is DIP?
An image may be defined as a two-dimensional function f(x, y), where x & y are
spatial coordinates, & the amplitude of f at any pair of coordinates (x, y) is called the intensity
or gray level of the image at that point. When x, y & the amplitude values of f are all finite
discrete quantities, we call the image a digital image. The field of DIP refers to processing digital
image by means of digital computer. Digital image is composed of a finite number of elements,
each of which has a particular location & value. The elements are called pixels.
Vision is the most advanced of our sensor, so it is not surprising that image play the single
most important role in human perception. However, unlike humans, who are limited to the visual
band of the EM spectrum imaging machines cover almost the entire EM spectrum, ranging from
gamma to radio waves. They can operate also on images generated by sources that humans are
not accustomed to associating with image.
There is no general agreement among authors regarding where image processing stops &
other related areas such as image analysis& computer vision start. Sometimes a distinction is
made by defining image processing as a discipline in which both the input & output at a process
are images. This is limiting & somewhat artificial boundary. The area of image analysis (image
understanding) is in between image processing & computer vision.
There are no clear-cut boundaries in the continuum from image processing at one end to
complete vision at the other. However, one useful paradigm is to consider three types of
computerized processes in this continuum: low-, mid-, & high-level processes. Low-level
process involves primitive operations such as image processing to reduce noise, contrast
enhancement & image sharpening. A low- level process is characterized by the fact that both its
inputs & outputs are images. Mid-level process on images involves tasks such as segmentation,
description of that object to reduce them to a form suitable for computer processing &
classification of individual objects. A mid-level process is characterized by the fact that its inputs
generally are images but its outputs are attributes extracted from those images. Finally higher-
level processing involves “Making sense” of an ensemble of recognized objects, as in image
analysis & at the far end of the continuum performing the cognitive functions normally
associated with human vision.
Digital image processing, as already defined is used successfully in a broad range of areas
of exceptional social & economic value.
What is an image?
An image is represented as a two dimensional function f(x, y) where x and y are spatial co-
ordinates and the amplitude of ‘f’ at any pair of coordinates (x, y) is called the intensity of the
image at that point.
Gray scale image:
A grayscale image is a function I (xylem) of the two spatial coordinates of the image
plane. I(x, y) is the intensity of the image at the point (x, y) on the image plane. I (xylem) takes
non-negative values assume the image is bounded by a rectangle [0, a] ´[0, b]I: [0, a] ´ [0, b] ®
[0, info)
Color image:
It can be represented by three functions, R (xylem) for red, G (xylem) for green and
B (xylem) for blue.
An image may be continuous with respect to the x and y coordinates and also in
amplitude. Converting such an image to digital form requires that the coordinates as well as the
amplitude to be digitized. Digitizing the coordinate’s values is called sampling. Digitizing the
amplitude values is called quantization.
Coordinate convention:
The result of sampling and quantization is a matrix of real numbers. We use two principal
ways to represent digital images. Assume that an image f(x, y) is sampled so that the resulting
image has M rows and N columns. We say that the image is of size M X N. The values of the
coordinates (xylem) are discrete quantities. For notational clarity and convenience, we use
integer values for these discrete coordinates. In many image processing books, the image origin
is defined to be at (xylem)=(0,0).The next coordinate values along the first row of the image are
(xylem)=(0,1).It is important to keep in mind that the notation (0,1) is used to signify the second
sample along the first row. It does not mean that these are the actual values of physical
coordinates when the image was sampled. Following figure shows the coordinate convention.
Note that x ranges from 0 to M-1 and y from 0 to N-1 in integer increments.
The coordinate convention used in the toolbox to denote arrays is different from the
preceding paragraph in two minor ways. First, instead of using (xylem) the toolbox uses the
notation (race) to indicate rows and columns. Note, however, that the order of coordinates is the
same as the order discussed in the previous paragraph, in the sense that the first element of a
coordinate topples, (alb), refers to a row and the second to a column. The other difference is that
the origin of the coordinate system is at (r, c) = (1, 1); thus, r ranges from 1 to M and c from 1 to
N in integer increments. IPT documentation refers to the coordinates. Less frequently the toolbox
also employs another coordinate convention called spatial coordinates which uses x to refer to
columns and y to refers to rows. This is the opposite of our use of variables x and y.
Image as Matrices:
The preceding discussion leads to the following representation for a digitized image
function:
f(xylem)= . . .
. . .
The right side of this equation is a digital image by definition. Each element of this
array is called an image element, picture element, pixel or pel. The terms image and pixel are
used throughout the rest of our discussions to denote a digital image and its elements.
. . .
f= . . .
Matrices in MATLAB are stored in variables with names such as A, a, RGB, real array and
so on. Variables must begin with a letter and contain only letters, numerals and underscores. As
noted in the previous paragraph, all MATLAB quantities are written using mono-scope
characters. We use conventional Roman, italic notation such as f(x ,y), for mathematical
expressions
Reading Images:
Images are read into the MATLAB environment using function imread whose syntax is
imread(‘filename’)
Format name Description recognized extension
Here filename is a spring containing the complete of the image file(including any
applicable extension).For example the command line
reads the JPEG (above table) image chestxray into image array f. Note the use of single quotes
(‘) to delimit the string filename. The semicolon at the end of a command line is used by
MATLAB for suppressing output. If a semicolon is not included. MATLAB displays the results
of the operation(s) specified in that line. The prompt symbol(>>) designates the beginning of a
command line, as it appears in the MATLAB command window.
When as in the preceding command line no path is included in filename, imread reads the
file from the current directory and if that fails it tries to find the file in the MATLAB search path.
The simplest way to read an image from a specified directory is to include a full or relative path
to that directory in filename.
For example,
reads the image from a folder called my images on the D: drive, whereas
reads the image from the my images subdirectory of the current of the current working
directory. The current directory window on the MATLAB desktop toolbar displays MATLAB’s
current working directory and provides a simple, manual way to change it. Above table lists
some of the most of the popular image/graphics formats supported by imread and imwrite.
This function is particularly useful in programming when used in the following form to
determine automatically the size of an image:
>>[M,N]=size(f);
This syntax returns the number of rows(M) and columns(N) in the image.
The whole function displays additional information about an array. For instance ,the
statement
>> whos f
gives
Name size Bytes Class
The unit8 entry shown refers to one of several MATLAB data classes. A semicolon at the
end of a whose line has no effect ,so normally one is not used.
Displaying Images:
Images are displayed on the MATLAB desktop using function imshow, which has the basic
syntax:
imshow(f,g)
Where f is an image array, and g is the number of intensity levels used to display it.
If g is omitted ,it defaults to 256 levels .using the syntax
imshow(f,{low high})
Displays as black all values less than or equal to low and as white all values greater
than or equal to high. The values in between are displayed as intermediate intensity values using
the default number of levels .Finally the syntax
Imshow(f,[ ])
Sets variable low to the minimum value of array f and high to its maximum value.
This form of imshow is useful for displaying images that have a low dynamic range or that have
positive and negative values.
Function pixval is used frequently to display the intensity values of individual pixels
interactively. This function displays a cursor overlaid on an image. As the cursor is moved over
the image with the mouse the coordinates of the cursor position and the corresponding intensity
values are shown on a display that appears below the figure window .When working with color
images, the coordinates as well as the red, green and blue components are displayed. If the left
button on the mouse is clicked and then held pressed, pixval displays the Euclidean distance
between the initial and current cursor locations.
The syntax form of interest here is Pixval which shows the cursor on the last image
displayed. Clicking the X button on the cursor window turns it off.
The following statements read from disk an image called rose_512.tif extract basic
information about the image and display it using imshow :
>>f=imread(‘rose_512.tif’);
>>whos f
>>imshow(f)
A semicolon at the end of an imshow line has no effect, so normally one is not used.
If another image,g, is displayed using imshow, MATLAB replaces the image in the screen with
the new image. To keep the first image and output a second image, we use function figure as
follows:
>>figure ,imshow(g)
Suppose that we have just read an image h and find that using imshow produces the image.
It is clear that this image has a low dynamic range, which can be remedied for display purposes
by using the statement.
>>imshow(h,[ ])
WRITING IMAGES:
Images are written to disk using function imwrite, which has the following basic syntax:
Imwrite (f,’filename’)
With this syntax, the string contained in filename must include a recognized file format
extension .Alternatively, the desired format can be specified explicitly with a third input
argument. >>imwrite(f,’patient10_run1’,’tif’)
Or alternatively
For example the following command writes f to a TIFF file named patient10_run1:
>>imwrite(f,’patient10_run1.tif’)
If filename contains no path information, then imwrite saves the file in the current working
directory.
The imwrite function can have other parameters depending on e file format selected. Most
of the work in the following deals either with JPEG or TIFF images ,so we focus attention here
on these two formats.
More general imwrite syntax applicable only to JPEG images is
imwrite(f,’filename.jpg,,’quality’,q)
where q is an integer between 0 and 100(the lower number the higher the degradation due to
JPEG compression).
>> imwrite(f,’bubbles25.jpg’,’quality’,25)
The image for q=15 has false contouring that is barely visible, but this effect becomes quite
pronounced for q=5 and q=0.Thus, an expectable solution with some margin for error is to
compress the images with q=25.In order to get an idea of the compression achieved and to obtain
other image file details, we can use function imfinfo which has syntax.
Imfinfo filename
Here filename is the complete file name of the image stored in disk.
For example,
outputs the following information(note that some fields contain no information in this case):
Filename: ‘bubbles25.jpg’
FileSize: 13849
Format: ‘jpg’
Format Version: ‘‘
Width: 714
Height: 682
Bit Depth: 8
Format Signature: ‘‘
Comment: {}
Where file size is in bytes. The number of bytes in the original image is corrupted simply
by multiplying width by height by bit depth and dividing the result by 8. The result is
486948.Dividing this file size gives the compression ratio:(486948/13849)=35.16.This
compression ratio was achieved. While maintaining image quality consistent with the
requirements of the appearance. In addition to the obvious advantages in storage space, this
reduction allows the transmission of approximately 35 times the amount of un compressed data
per unit time.
>> K=imfinfo(‘bubbles25.jpg’);
>> image_ bytes =K.Width* K.Height* K.Bit Depth /8;
Note that iminfo was used in two different ways. The first was t type imfinfo bubbles25.jpg
at the prompt, which resulted in the information being displayed on the screen. The second was
to type K=imfinfo (‘bubbles25.jpg’),which resulted in the information generated by imfinfo
being stored in K. These two different ways of calling imfinfo are an example of command_
function duality, an important concept that is explained in more detail in the MATLAB online
documentation.
More general imwrite syntax applicable only to tif images has the form
Imwrite(g,’filename.tif’,’compression’,’parameter’,….’resloution’,[colres rowers] )
Where ‘parameter’ can have one of the following principal values: ‘none’ indicates no
compression, ‘pack bits’ indicates pack bits compression (the default for non ‘binary images’)
and ‘ccitt’ indicates ccitt compression. (the default for binary images).The 1*2 array [colres
rowers]
Contains two integers that give the column resolution and row resolution in dot per_ unit
(the default values). For example, if the image dimensions are in inches, colres is in the number
of dots(pixels)per inch (dpi) in the vertical direction and similarly for rowers in the horizontal
direction. Specifying the resolution by single scalar, res is equivalent to writing [res res].
>>imwrite(f,’sf.tif’,’compression’,’none’,’resolution’,……………..[300 300])
the values of the vector[colures rows] were determined by multiplying 200 dpi by the ratio
2.25/1.5, which gives 30 dpi. Rather than do the computation manually, we could write
>> res=round(200*2.25/1.5);
>>imwrite(f,’sf.tif’,’compression’,’none’,’resolution’,res)
where its argument to the nearest integer.It function round rounds is important to note that
the number of pixels was not changed by these commands. Only the scale of the image changed.
The original 450*450 image at 200 dpi is of size 2.25*2.25 inches. The new 300_dpi image is
identical, except that is 450*450 pixels are distributed over a 1.5*1.5_inch area. Processes such
as this are useful for controlling the size of an image in a printed document with out sacrificing
resolution.
Often it is necessary to export images to disk the way they appear on the MATLAB
desktop. This is especially true with plots .The contents of a figure window can be exported to
disk in two ways. The first is to use the file pull-down menu is in the figure window and then
choose export. With this option the user can select a location, filename, and format. More control
over export parameters is obtained by using print command:
Print-fno-dfileformat-rresno filename
Where no refers to the figure number in the figure window interest, file format refers
one of the file formats in table above. ‘resno’ is the resolution in dpi, and filename is the name
we wish to assign the file.
If we simply type print at the prompt, MATLAB prints (to the default printer) the contents
of the last figure window displayed. It is possible also to specify other options with print, such as
specific printing device.
Data Classes:
Although we work with integers coordinates the values of pixels themselves are not
restricted to be integers in MATLAB. Table above list various data classes supported by
MATLAB and IPT are representing pixels values. The first eight entries in the table are refers to
as numeric data classes. The ninth entry is the char class and, as shown, the last entry is referred
to as logical data class.
All numeric computations in MATLAB are done in double quantities, so this is also a
frequent data class encounter in image processing applications. Class unit 8 also is encountered
frequently, especially when reading data from storages devices, as 8 bit images are most
common representations found in practice. These two data classes, classes logical, and, to a
lesser degree, class unit 16 constitute the primary data classes on which we focus. Many ipt
functions however support all the data classes listed in table. Data class double requires 8 bytes
to represent a number uint8 and int 8 require one byte each, uint16 and int16 requires 2bytes and
unit 32.
Name Description
Per element).
[-2147483648, 21474833647]
(4 byte per element).
int 32 and single, required 4 bytes each. The char data class holds characters in Unicode
representation. A character string is merely a 1*n array of characters logical array contains only
the values 0 to 1,with each element being stored in memory using function logical or by using
relational operators.
Image Types:
1 .Intensity images
2. Binary images
3. Indexed images
4. R G B images
Most monochrome image processing operations are carried out using binary or intensity
images, so our initial focus is on these two image types. Indexed and RGB colour images.
Intensity Images:
An intensity image is a data matrix whose values have been scaled to represent intentions.
When the elements of an intensity image are of class unit8, or class unit 16, they have integer
values in the range [0,255] and [0, 65535], respectively. If the image is of class double, the
values are floating _point numbers. Values of scaled, double intensity images are in the range [0,
1] by convention.
Binary Images:
Binary images have a very specific meaning in MATLAB.A binary image is a logical array
0s and1s.Thus, an array of 0s and 1s whose values are of data class, say unit8, is not considered
as a binary image in MATLAB .A numeric array is converted to binary using function logical.
Thus, if A is a numeric array consisting of 0s and 1s, we create an array B using the statement.
B=logical (A)
If A contains elements other than 0s and 1s.Use of the logical function converts all
nonzero quantities to logical 1s and all entries with value 0 to logical 0s.
islogical(c)
If c is a logical array, this function returns a 1.Otherwise returns a 0. Logical array can be
converted to numeric arrays using the data class conversion functions.
Indexed Images:
Matrix map is an m*3 arrays of class double containing floating_ point values in the range
[0, 1].The length m of the map are equal to the number of colors it defines. Each row of map
specifies the red, green and blue components of a single color. An indexed images uses “direct
mapping” of pixel intensity values color map values. The color of each pixel is determined by
using the corresponding value the integer matrix x as a pointer in to map. If x is of class double
,then all of its components with values less than or equal to 1 point to the first row in map, all
components with value 2 point to the second row and so on. If x is of class units or unit 16, then
all components value 0 point to the first row in map, all components with value 1 point to the
second and so on.
RGB Image:
An RGB color image is an M*N*3 array of color pixels where each color pixel is triplet
corresponding to the red, green and blue components of an RGB image, at a specific spatial
location. An RGB image may be viewed as “stack” of three gray scale images that when fed in to
the red, green and blue inputs of a color monitor
Produce a color image on the screen. Convention the three images forming an RGB color
image are referred to as the red, green and blue components images. The data class of the
components images determines their range of values. If an RGB image is of class double the
range of values is [0, 1].
Similarly the range of values is [0,255] or [0, 65535].For RGB images of class units or unit
16 respectively. The number of bits use to represents the pixel values of the component images
determines the bit depth of an RGB image. For example, if each component image is an 8bit
image, the corresponding RGB image is said to be 24 bits deep.
Generally, the number of bits in all component images is the same. In this case the number
of possible color in an RGB image is (2^b) ^3, where b is a number of bits in each component
image. For the 8bit case the number is 16,777,216 colors.
AES
A new standard was needed primarily because DES has a relatively small 56-
bit key which was becoming vulnerable to brute force attacks. In addition, the DES was designed
primarily for hardware and is relatively slow when implemented in software. [1] While Triple-
DES avoids the problem of a small key size, it is very slow even in software; is unsuitable for
limited-resource platforms, and may be affected by potential security issues connected with the
(today comparatively small) block size of 64 bits.
On January 2, 1997, NIST announced that they wished to choose a successor to DES to
be known as AES. Like DES, this was to be "an unclassified, publicly disclosed encryption
algorithm capable of protecting sensitive government information well into the next
century." However, rather than simply publishing a successor, NIST asked for input from
interested parties on how the successor should be chosen. Interest from the
open cryptographic community was immediately intense, and NIST received a great many
submissions during the three month comment period.
The result of this feedback was a call for new algorithms on September 12, 1997. The
algorithms were all to be block ciphers, supporting a block size of 128 bits and key sizes of 128,
192, and 256 bits. Such ciphers were rare at the time of the announcement; the best known was
probably Square.
Start and stop rounds
In the nine months that followed, fifteen different designs were created and submitted
from several different countries. They were, in alphabetical order: CAST-
256, CRYPTON, DEAL, DFC, E2,FROG, HPC, LOKI97, MAGENTA, MARS, RC6, Rijndael,
SAFER+, Serpent, and Two fish.
In the ensuing debate, many advantages and disadvantages of the different candidates
were investigated by cryptographers; they were assessed not only on security, but also on
performance in a variety of settings (PCs of various architectures, smart cards, hardware
implementations) and on their feasibility in limited environments (smart cards with very limited
memory, low gate count implementations, FPGAs).
Some designs fell due to cryptanalysis that ranged from minor flaws to significant attacks,
while others lost favour due to poor performance in various environments or through having little
to offer over other candidates. NIST held two conferences to discuss the submissions (AES1,
August 1998 and AES2, March 1999), and in August 1999 they announced [4] that they were
narrowing the field from fifteen to five: MARS, RC6, Rijndael, Serpent, and Twofish. All five
algorithms, commonly referred to as "AES finalists", were designed by cryptographers
considered well-known and respected in the community. The AES2 conference votes were as
follows:
A further round of intense analysis and cryptanalysis followed, culminating in the AES3
conference in April 2000, at which a representative of each of the final five teams made a
presentation arguing why their design should be chosen as the AES.
Implementations
Rijndael is free for any use public or private, commercial or non-commercial. The
authors of Rijndael used to provide a home page for the algorithm. Care should be taken when
implementing AES in software. Like most encryption algorithms, Rijndael was designed on big-
endian systems. For this reason, little-endian systems return correct test vector results only
through swapping bytes of the input and output words.
Careful choice must be made in selecting the mode of operation of the cipher. The simplest
mode encrypts and decrypts each 128-bit block separately. In this mode, called "electronic code
book (ECB)", blocks that are identical will be encrypted identically, which is entirely insecure.
This will make some of the plaintext structure visible in the cipher text. Selecting other modes,
such as empressing a sequential counter over the block prior to encryption (CTR mode) and
removing it after decryption avoids this problem.
C/ASM library
AES Crypt
Bee Crypt
c crypt
Open SSL
Gnu TLS
A portable byte-oriented AES-256 implementation in C
Polar SSL (single header and source file implementation Source Code)
Reference implementation and derived code
Brian Glad man
lib tom crypt used in Drop bear SSH client and server
m crypt
n crypt
Matrix SSL, Embedded SSL library.
Microsoft CryptoAPI uses Cryptographic Service Providers to offer encryption
implementations. The Microsoft AES Cryptographic Provider was introduced in Windows
XP and can be used with any version of the Microsoft Crypto API .
C++ library
C# /.NET
Java
Java script
Python
Py Crypto
M2Crypto, a Python wrapper for Open SSL
Python AES
N Crypt, a Python wrapper for Open SSL built using Pyrex
alo- aes
py crypt opp, a set of Python wrappers for a few of the best crypto algorithms from the
Crypto++ library
Slow AES, slow but still useful when faster ones are not available
py crypt, a small Python program that encrypts or decrypts files using AES
crypto_ example, Set of example code that wraps around PyCrypto and demonstrates
best-practises symmetric encryption, as per Cryptographic Right Answers by Colin Percival.
AES (Rijndael) uses a key schedule to expand a short key into a number of separate
round keys. This is known as the Rijndael key schedule.
Operators
Rijndael's key schedule utilizes a number of operations, which will be described before
describing the key schedule.
Rotate
The rotate operation takes a 32-bit word like this (in hexadecimal):
1D 2C 3A 4F
and rotates it eight bits to the left such that the high eight bits "wrap around" and become the low
eight bits of the result.
2C 3A 4F 1D
Rcon
is , and we
compute
in .
For example, the rcon(1) = 1, the rcon(2) = 2, the rcon(3) = 4, and the rcon(9) is
the hexadecimal number 0x1b (27 in decimal).
Rcon[256] = {
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab,
0x4d, 0x9a,
0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5,
0x91, 0x39,
0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83,
0x1d, 0x3a,
0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36,
0x6c, 0xd8,
0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d,
0xfa, 0xef,
0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33,
0x66, 0xcc,
0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40,
0x80, 0x1b,
0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
0xd4, 0xb3,
0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25,
0x4a, 0x94,
0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08,
0x10, 0x20,
0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6,
0x97, 0x35,
0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61,
0xc2, 0x9f,
0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01,
0x02, 0x04,
0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e,
0xbc, 0x63,
0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4,
0xd3, 0xbd,
0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8,
0xcb, 0x8d}
S-box
This operation is used as an inner loop in the key schedule, and is done thus:
The input is a 32-bit word and at an iteration number i. The output is a 32-bit word.
Copy the input over to the output.
Use the above described rotate operation to rotate the output eight bits to the left
Apply Rijndael's S-box on all four individual bytes in the output word
On just the first (leftmost) byte of the output word, exclusive or the byte with 2 to the
power of (i-1). In other words, perform the rcon operation with i as the input, and exclusive
or the rcon output with the first byte of the output word
Key schedule
Constants
Since the key schedule for 128-bit, 192-bit, and 256-bit encryption are very similar, with
only some constants changed, the following keysize constants are defined here:
n has a value of 16 for 128-bit keys, 24 for 192-bit keys, and 32 for 256-bit keys
b has a value of 176 for 128-bit keys, 208 for 192-bit keys, and 240 for 256-bit keys
1. The first n bytes of the expanded key are simply the encryption key.
2. The rcon iteration value i is set to 1
3. Until we have b bytes of expanded key, we do the following to generate n more bytes of
expanded key:
We do the following to create 4 bytes of expanded key:
1. We create a 4-byte temporary variable, t
2. We assign the value of the previous four bytes in the expanded key to t
3. We perform the key schedule core (see above) on t, with i as the rcon
iteration value
4. We increment i by 1
5. We exclusive-or t with the four-byte block n bytes before the new
expanded key. This becomes the next 4 bytes in the expanded key
We then do the following three times to create the next twelve bytes of expanded
key:
1. We assign the value of the previous 4 bytes in the expanded key to t
2. We exclusive-or t with the four-byte block n bytes before the new
expanded key. This becomes the next 4 bytes in the expanded key
If we are generating a 256-bit key, we do the following to generate the next 4
bytes of expanded key:
1. We assign the value of the previous 4 bytes in the expanded key to t
2. We run each of the 4 bytes in t through Rijndael's S-box
3. We exclusive-or t with the 4-byte block n bytes before the new expanded
key. This becomes the next 4 bytes in the expanded key.
If we are generating a 128-bit key, we do not perform the following steps. If we
are generating a 192-bit key, we run the following steps twice. If we are generating a
256-bit key, we run the following steps three times:
1. We assign the value of the previous 4 bytes in the expanded key to t
2. We exclusive-or t with the four-byte block n bytes before the new
expanded key. This becomes the next 4 bytes in the expanded key
Rjindael s box
Forward s box
This affine transformation is the sum of multiple rotations of the byte as a vector, where
addition is the XOR operation. For example, the multiplicative inverse of 0x11 is 0xb4. The
affine transformation is defined as:
1. Store the multiplicative inverse of the input number in two 8-bit unsigned
temporary variables: s and x.
2. Rotate the value s one bit to the left; if the value of s had a high bit (eighth
bit from the right) of one, make the low bit of s one; otherwise the low bit
of s is zero.
3. Exclusive or the value of x with the value of s, storing the value in x
4. For three more iterations, repeat steps two and three; steps two and three are
done a total of four times.
5. The value of x will now have the result of the multiplication.
After the matrix multiplication is done, exclusive or the value by the decimal number 99
(the hexadecimal number 0x63, the binary number 1100011, and the bit string 11000110
representing the number in LSb first notation).
|0 1 2 3 4 5 6 7 8 9 a b c d e f
---|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|
00 |63 7c 77 7b f2 6b 6f c5 30 01 67 2b fe d7 ab 76
10 |ca 82 c9 7d fa 59 47 f0 ad d4 a2 af 9c a4 72 c0
20 |b7 fd 93 26 36 3f f7 cc 34 a5 e5 f1 71 d8 31 15
30 |04 c7 23 c3 18 96 05 9a 07 12 80 e2 eb 27 b2 75
40 |09 83 2c 1a 1b 6e 5a a0 52 3b d6 b3 29 e3 2f 84
50 |53 d1 00 ed 20 fc b1 5b 6a cb be 39 4a 4c 58 cf
60 |d0 ef aa fb 43 4d 33 85 45 f9 02 7f 50 3c 9f a8
70 |51 a3 40 8f 92 9d 38 f5 bc b6 da 21 10 ff f3 d2
80 |cd 0c 13 ec 5f 97 44 17 c4 a7 7e 3d 64 5d 19 73
90 |60 81 4f dc 22 2a 90 88 46 ee b8 14 de 5e 0b db
a0 |e0 32 3a 0a 49 06 24 5c c2 d3 ac 62 91 95 e4 79
b0 |e7 c8 37 6d 8d d5 4e a9 6c 56 f4 ea 65 7a ae 08
c0 |ba 78 25 2e 1c a6 b4 c6 e8 dd 74 1f 4b bd 8b 8a
d0 |70 3e b5 66 48 03 f6 0e 61 35 57 b9 86 c1 1d 9e
e0 |e1 f8 98 11 69 d9 8e 94 9b 1e 87 e9 ce 55 28 df
f0 |8c a1 89 0d bf e6 42 68 41 99 2d 0f b0 54 bb 16
Here the column is determined by the least significant nibble, and the row is
determined by the most significant nibble. For example, the value 0x9a is converted
in to 0xb8 by Rijndael's S-box. Note that the multiplicative inverse of 0x00 is
defined as itself.
Inverse s box
The inverse S-box is simply the S-box run in reverse. For example, the inverse S-box
of 0xdb is 0x9f. It is calculated by first calculating the inverse affine transformation of the input
value, followed by the multiplicative inverse. The inverse affine transformation is as follows:
The following table represents Rijndael's inverse S-box:
|0 1 2 3 4 5 6 7 8 9 a b c d e f
---|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|
00 |52 09 6a d5 30 36 a5 38 bf 40 a3 9e 81 f3 d7 fb
10 |7c e3 39 82 9b 2f ff 87 34 8e 43 44 c4 de e9 cb
20 |54 7b 94 32 a6 c2 23 3d ee 4c 95 0b 42 fa c3 4e
30 |08 2e a1 66 28 d9 24 b2 76 5b a2 49 6d 8b d1 25
40 |72 f8 f6 64 86 68 98 16 d4 a4 5c cc 5d 65 b6 92
50 |6c 70 48 50 fd ed b9 da 5e 15 46 57 a7 8d 9d 84
60 |90 d8 ab 00 8c bc d3 0a f7 e4 58 05 b8 b3 45 06
70 |d0 2c 1e 8f ca 3f 0f 02 c1 af bd 03 01 13 8a 6b
80 |3a 91 11 41 4f 67 dc ea 97 f2 cf ce f0 b4 e6 73
90 |96 ac 74 22 e7 ad 35 85 e2 f9 37 e8 1c 75 df 6e
a0 |47 f1 1a 71 1d 29 c5 89 6f b7 62 0e aa 18 be 1b
b0 |fc 56 3e 4b c6 d2 79 20 9a db c0 fe 78 cd 5a f4
c0 |1f dd a8 33 88 07 c7 31 b1 12 10 59 27 80 ec 5f
d0 |60 51 7f a9 19 b5 4a 0d 2d e5 7a 9f 93 c9 9c ef
e0 |a0 e0 3b 4d ae 2a f5 b0 c8 eb bb 3c 83 53 99 61
f0 |17 2b 04 7e ba 77 d6 26 e1 69 14 63 55 21 0c 7d
design criteria
In addition, to strengthen the S-Box against algebraic attacks, the affine transformation
was added. In the case of suspicion of a trapdoor being built into the cipher, the current S-box
might be replaced by another one. The authors claim that the Rijndael cipher structure should
provide enough resistance against differential and linear cryptanalysis, even if an S-Box with
"average" correlation / difference propagation properties is used.
General
Designers IBM
Cipher detail
Rounds 16
Best public cryptanalysis
The origins of DES go back to the early 1970s. In 1972, after concluding a study on the
US government's computer security needs, the US standards body NBS (National Bureau of
Standards) now named NIST (National Institute of Standards and Technology) identified a need
for a government-wide standard for encrypting unclassified, sensitive information. Accordingly,
on 15 May 1973, after consulting with the NSA, NBS solicited proposals for a cipher that would
meet rigorous design criteria. None of the submissions, however, turned out to be suitable. A
second request was issued on 27 August 1974. This time, IBM submitted a candidate which was
deemed acceptable — a cipher developed during the period 1973–1974 based on an earlier
algorithm, Horst Feistel's Lucifer cipher. The team at IBM involved in cipher design and analysis
included Feistel, Walter Tuchman, Don Coppersmith, Alan Konheim, Carl Meyer, Mike Matyas,
Roy Adler, Edna Grossman, Bill Notz, Lynn Smith, and Bryant Tuckerman.
On 17 March 1975, the proposed DES was published in the Federal Register. Public
comments were requested, and in the following year two open workshops were held to discuss
the proposed standard. There was some criticism from various parties, including from public-key
cryptography pioneers Martin Hellman and Whitfield Diffie, citing a shortened key length and
the mysterious "S-boxes" as evidence of improper interference from the NSA. The suspicion was
that the algorithm had been covertly weakened by the intelligence agency so that they but no-
one else could easily read encrypted messages. Alan Konheim (one of the designers of DES)
commented, "We sent the S-boxes off to Washington. They came back and were all
different." The United States Senate Select Committee on Intelligence reviewed the NSA's
actions to determine whether there had been any improper involvement. In the unclassified
summary of their findings, published in 1978, the Committee wrote:
In the development of DES, NSA convinced IBM that a reduced key size was sufficient;
indirectly assisted in the development of the S-box structures; and certified that the final DES
algorithm was, to the best of their knowledge, free from any statistical or mathematical
weakness.
However, it also found that NSA did not tamper with the design of the algorithm in any
way. IBM invented and designed the algorithm, made all pertinent decisions regarding it, and
concurred that the agreed upon key size was more than adequate for all commercial applications
for which the DES was intended.
Another member of the DES team, Walter Tuchman, stated "We developed the DES
algorithm entirely within IBM using IBMers. The NSA did not dictate a single wire!" In contrast,
a declassified NSA book on cryptologic history states:
In 1973 NBS solicited private industry for a data encryption standard (DES). The first
offerings were disappointing, so NSA began working on its own algorithm. Then Howard
Rosenblum, deputy director for research and engineering, discovered that Walter Tuchman of
IBM was working on a modification to Lucifer for general use. NSA gave Tuchman a clearance
and brought him in to work jointly with the Agency on his Lucifer modification." and NSA
worked closely with IBM to strengthen the algorithm against all except brute force attacks and to
strengthen substitution tables, called S-boxes. Conversely, NSA tried to convince IBM to reduce
the length of the key from 64 to 48 bits. Ultimately they compromised on a 56-bit key.
Some of the suspicions about hidden weaknesses in the S-boxes were allayed in 1990,
with the independent discovery and open publication by Eli Biham and Adi
Shamir of differential cryptanalysis, a general method for breaking block ciphers. The S-boxes of
DES were much more resistant to the attack than if they had been chosen at random, strongly
suggesting that IBM knew about the technique in the 1970s. This was indeed the case; in 1994,
Don Coppersmith published some of the original design criteria for the S-boxes. According
to Steven Levy, IBM Watson researchers discovered differential cryptanalytic attacks in 1974
and were asked by the NSA to keep the technique secret. Coppersmith explains IBM's secrecy
decision by saying, "that was because [differential cryptanalysis] can be a very powerful tool,
used against many schemes, and there was concern that such information in the public domain
could adversely affect national security." Levy quotes Walter Tuchman: "they asked us to stamp
all our documents confidential... We actually put a number on each one and locked them up in
safes, because they were considered U.S. government classified. They said do it. So I did
it". Bruce Schneier observed that "It took the academic community two decades to figure out that
the NSA 'tweaks' actually improved the security of DES."
Despite the criticisms, DES was approved as a federal standard in November 1976, and
published on 15 January 1977 as FIPS PUB 46, authorized for use on all unclassified data. It was
subsequently reaffirmed as the standard in 1983, 1988 (revised as FIPS-46-1), 1993 (FIPS-46-2),
and again in 1999 (FIPS-46-3), the latter prescribing "Triple DES" (see below). On 26 May
2002, DES was finally superseded by the Advanced Encryption Standard (AES), following a
public competition. On 19 May 2005, FIPS 46-3 was officially withdrawn, but NIST has
approved Triple DESthrough the year 2030 for sensitive government information.
The algorithm is also specified in ANSI X3.92, [14] NIST SP 800-67 and ISO/IEC 18033-
3 (as a component of TDEA). Another theoretical attack, linear cryptanalysis, was published in
1994, but it was a brute force attack in 1998 that demonstrated that DES could be attacked very
practically, and highlighted the need for a replacement algorithm. These and other methods
of cryptanalysis are discussed in more detail later in this article.
The introduction of DES is considered to have been a catalyst for the academic study of
cryptography, particularly of methods to crack block ciphers. According to a NIST retrospective
about DES,
The DES can be said to have "jump started" the nonmilitary study and development of
encryption algorithms. In the 1970s there were very few cryptographers, except for those in
military or intelligence organizations, and little academic study of cryptography. There are now
many active academic cryptologists, mathematics departments with strong programs in
cryptography, and commercial information security companies and consultants. A generation of
cryptanalysts has cut its teeth analyzing (that is trying to "crack") the DES algorithm. In the
words of cryptographer Bruce Schneier, "DES did more to galvanize the field of cryptanalysis
than anything else. Now there was an algorithm to study." An astonishing share of the open
literature in cryptography in the 1970s and 1980s dealt with the DES, and the DES is the
standard against which every symmetric key algorithm since has been compared.
Figure illustrates the key schedule for encryption — the algorithm which generates the
subkeys. Initially, 56 bits of the key are selected from the initial 64 by Permuted Choice 1 (PC-
1) — the remaining eight bits are either discarded or used as parity check bits. The 56 bits are
then divided into two 28-bit halves; each half is thereafter treated separately. In successive
rounds, both halves are rotated left by one or two bits (specified for each round), and then 48
subkey bits are selected by Permuted Choice 2 (PC-2) — 24 bits from the left half, and 24 from
the right. The rotations (denoted by "<<<" in the diagram) mean that a different set of bits is used
in each subkey; each bit is used in approximately 14 out of the 16 subkeys.
The key schedule for decryption is similar — the subkeys are in reverse order compared
to encryption. Apart from that change, the process is the same as for encryption. The same 28
bits are passed to all rotation boxes.
Although more information has been published on the cryptanalysis of DES than any
other block cipher, the most practical attack to date is still a brute force approach. Various minor
cryptanalytic properties are known, and three theoretical attacks are possible which, while having
a theoretical complexity less than a brute force attack, require an unrealistic number
of known or chosen plaintexts to carry out, and are not a concern in practice.
For any cipher, the most basic method of attack is brute force — trying every possible
key in turn. The length of the key determines the number of possible keys, and hence the
feasibility of this approach. For DES, questions were raised about the adequacy of its key size
early on, even before it was adopted as a standard, and it was the small key size, rather than
theoretical cryptanalysis, which dictated a need for a replacement algorithm. As a result of
discussions involving external consultants including the NSA, the key size was reduced from 128
bits to 56 bits to fit on a single chip.
The EFF's US$250,000 DES cracking machine contained 1,856 custom chips and could
brute force a DES key in a matter of days — the photo shows a DES Cracker circuit board fitted
with several Deep Crack chips.
There are three attacks known that can break the full 16 rounds of DES with less complexity
than a brute-force search: differential cryptanalysis (DC), linear cryptanalysis (LC), and Davies'
attack. However, the attacks are theoretical and are unfeasible to mount in practice; these types
of attack are sometimes termed certificational weaknesses.
There have also been attacks proposed against reduced-round versions of the cipher, that is,
versions of DES with fewer than 16 rounds. Such analysis gives an insight into how many
rounds are needed for safety, and how much of a "security margin" the full version
retains. Differential-linear cryptanalysis was proposed by Langford and Hellman in 1994, and
combines differential and linear cryptanalysis into a single attack. An enhanced version of the
attack can break 9-round DES with 215.8 known plaintexts and has a 229.2 time complexity.
Disk encryption
Disk encryption does not replace file or directory encryption in all situations. Disk
encryption is sometimes used in conjunction with file system-level encryption with the intention
of providing a more secure implementation. Since disk encryption generally uses the
same key for encrypting the whole volume, all data is de cryptable when the system runs.
However, some disk encryption solutions use multiple keys for encrypting different partitions. If
an attacker gains access to the computer at run-time, the attacker has access to all files.
Conventional file and folder encryption instead allows different keys for different portions of the
disk. Thus an attacker cannot extract information from still-encrypted files and folders.
Unlike disk encryption, file system-level encryption does not typically encrypt file
system metadata, such as the directory structure, file names, modification timestamps or sizes.
A limited number of disk encryption solutions have support for TPM. These
implementations can wrap the decryption key using the TPM, thus tying the hard disk
drive (HDD) to a particular device. If the HDD is removed from that particular device and placed
in another, the decryption process will fail. Recovery is possible with the
decryption password or token.
Although this has the advantage that the disk cannot be removed from the device, it might
create a single point of failure in the encryption. For example, if something happens to the TPM
or the mother board, a user would not be able to access the data by connecting the hard drive to
another computer, unless that user has a separate recovery key.
Multi scale Electrophysiology Format (MEF) was developed to handle the large amounts
of data produced by large-scale electrophysiology in human and animal subjects. MEF can store
any time series data up to 24 bits in length, and employs lossless range encoded difference
compression. Subject identifying information in the file header can be encrypted using 128-bit
AES encryption in order to comply with HIPAA requirements for patient privacy when
transmitting data across an open network.
Compressed data is stored in independent blocks to allow direct access to the data,
facilitate parallel processing and limit the effects of potential damage to files. Data fidelity is
ensured by a 32-bit cyclic redundancy check in each compressed data block using the Koopman
polynomial (0xEB31D82E), which has a Hamming distance of from 4 to 114 kbits.
Triple des
The original DES cipher's key size of 56 bits was generally sufficient when that
algorithm was designed, but the availability of increasing computational power made brute-force
attacks feasible. Triple DES provides a relatively simple method of increasing the key size of
DES to protect against such attacks, without the need to design a completely new block cipher
algorithm.
The earliest standard that defines the algorithm (ANS X9.52, published in 1998)
describes it as the "Triple Data Encryption Algorithm (TDEA)" — i.e. three operations of the
Data Encryption Algorithm specified in ANSI X3.92 — and does not use the terms "Triple DES"
or "DES" at all. FIPS PUB 46-3 (1999) defines the "Triple Data Encryption Algorithm (TDEA)",
but also uses the terms "DES" and "Triple DES". It uses the terms "Data Encryption Algorithm"
and "DES" interchangeably, including starting the specification with:
The Data Encryption Standard (DES) shall consist of the following Data Encryption
Algorithm (DES) [sic] and Triple Data Encryption Algorithm (TDEA, as described in ANSI
X9.52).
NIST SP 800-67 (2004, 2008, 2012) primarily uses the term TDEA, but also refers to
"Triple DES (TDEA)". ISO/IEC 18033-3 (2005) uses "TDEA", but mentions that:
None of the standards that define the algorithm use the term "3DES".
Triple DES uses a "key bundle" which comprises three DES keys, K1, K2 and K3, each of
56 bits (excluding parity bits). The encryption algorithm is:
I.e., DES encrypt with K1, DES decrypt with K2, then DES encrypt with K3.
plaintext = DK1(EK2(DK3(ciphertext)))
Key option
Keying option 2 provides less security, with 2 × 56 = 112 key bits. This option is stronger than
simply DES encrypting twice, e.g. with K1 and K2, because it protects against meet-in-the-middle
attacks.
Keying option 3 is equivalent to DES, with only 56 key bits. This option provides
backward compatibility with DES, because the first and second DES operations cancel out. It is
no longer recommended by the National Institute of Standards and Technology (NIST), and is
not supported by ISO/IEC 18033-3.
Block diagram
A symmetric cryptosystem is shown in figure and has five ingredients:
i. Plain text: this is the original message or data that fed into the algorithm as input.
ii. Encryption algorithm: the algorithm performs various substitutions and transformations on the
plaintext.
iii. Secret key: this is also an input to the algorithm and its value is independent of the plaintext.
The algorithm will produce a different output depending on the specific key.
iv. Cipher text: this is the scrambled message produced as output. It depends on the plaintext and
the secret key.
v. Decryption algorithm: this is essentially the encryption algorithm run in reverse. It takes the
cipher text and the secret key and produces the original plaintext.
AES Algorithm
The AES Algorithm is a symmetric-key cipher, in which both the sender and the receiver
use a single key for encryption and decryption. The data block length is fixed to be 128 bits,
while the length can be 128,192,or 256 bits. In addition, the AES algorithm is an iterative
algorithm. Each iteration can be called a round, and the total number of rounds is 10,12, or 14,
when key length is 128,192, or 256, respectively. The 128 bit data block is divided into 16 bytes.
These bytes are mapped to a 4x4 array called the State, and all the internal operations of the AES
algorithm are performed on the State.
ALGORITHM
The encryption process is iterative in nature. Each iterations are known as rounds. For
each round 128 bit input data and 128 bit key is required. That is, need 4 words of key in one
round. So the input key must be expanded to the required number of words, which depends upon
the number of rounds. The output of each round serves as input of next stage. In AES system,
same secret key is used for both encryption and decryption. So it provides simplicity in design.
Figure shows the following image encryption
In the encryption of the AES algorithm(Figure), each round except the final round
consists of four transformations:
i. Sub Bytes: Operates in each byte of the State independently. Each byte is substituted by
corresponding byte in the S-box.
ii. Shift Row: Cyclically shifts the rows of the State over different offsets.
iii. Mix Column: In this operation the column of the State are considered as polynomials over
GF(2⁸) and are multiplied with a fixed polynomial. The Mix Column component Does not
operate in the last round of the algorithm.
iv. Add Round Key: Involves bit-wise XOR operation.
State array
The input to the encryption algorithm is a single 128-bit block .This block is copied into
the State array, which is a square matrix of bytes. State array is modified at each stage of
encryption. Similarly, the 128 bit key is depicted as a square matrix of bytes. The ordering of
bytes within a matrix is by column.
Key expansion
The key is copied into the first 4 words of the expanded key. The reminder of the
expanded key is filled in 4 words at a time. Each added word w[i] depends on the immediately
preceding word, w[i-1] and the word four positions back, w[i-4]. In three out of four cases, a
simple XOR is used. For a word whose position in the w array is a multiple of 4, a more complex
function g is used.
1. Rot Word performs a one-byte circular left shift on a word. This means that an input word
[b0,b1,b2,b3] is transformed into [b1,b2,b3,b0].
2. Sub Word performs a byte substitution on each byte of its input word, using the S-box.
3. The result of step 1 and step2 is XOR ed with a round constant R con[j].
The round constant is a word in which the three rightmost bytes are always 0.Thus the
effect of XOR of a word with Rcon is to only perform an XOR on the left byte of the word. The
round constant is for each round and is defined as Rcon[j] = ( RC[j],0,0,0), with RC[1]=1;
RC[j]=2*RC[j-1] and with multiplication over the field GF(2^8).
The 128 bits of State array are bitwise XOR ed with the 128 bits of the round key(4
words of the expanded key).The operation is viewed as a column wise operation between the 4
bytes of the State array column and one word of the round key.
Figure shows the xor operation between key and state word
Substitute Bytes
AES defines a 16 x 16 matrix of byte values, called an S-box, that contains a permutation
of all possible 256 8-bit values. Each byte of State array is mapped into a new byte in the
following way: The leftmost 4 bits of the byte are used as a row value and the leftmost 4 bits are
used as a column value. These row and column values serve as indexes into the S-box to select a
unique
Figure shows the sub byte operation
Shift Rows
The first row of State array is not altered. For the second row , a 1-byte circular left shift
is performed. For the third row,a 2- byte circular left shift is performed. For the third row, a 3-
byte circular left shift is performed.
Figure shows the shifting operation
Mix Column
It operates on each column individually. Each byte of a column is mapped into a new
value that is a function of all four bytes in the column. The transformation can be defined by
following matrix multiplication on State array.
Each element in the product matrix is the sum of products of elements of one row and
one column. In this case, individual additions and multiplications are performed in GF(2^8).The
Mix Column transformation on a single column j(0 <= j <= 3) of State array can be expressed as
An image can be encrypted by combining MATLAB with the encoder. Each pixel in an
image is represented by 8 bits, ie 1 byte. Using MATLAB convert the pixel values into bytes.
These byte values are then used as input to the encoder. The 128 bit encoder then convert this
byte into corresponding encoded byte. The encoded bit values are then converted into decimal
values for pixels. Repeat this operation for each pixels
REFERENCES
2. William stallings “Cryptography and Network Security” 3rd Edition published by Pearson
Education Inc and Dorling Kindersley Publishing Inc.
5. Xinmiao Zhang, Student Member,IEEE, and Keshab K. Parthi, Fellow, IEEE “High-Speed
VLSI Architecture for AES Algorithm” IEEE Transactions on VLSI, Vol.12, No.19, September
2004
6. Alireza Hodjat, Student Member, IEEE, and Ingrid Verbauwhede, Senior Member, IEEE
“Area- Throughput Trade-Offs for Fully Pipelined30 to 70 Gbits/s AES Processors” IEEE
Transactions on Computers, Vol.55, no.4, April2006
7. Pawel Chodowiec and Kris Gaj “Very compact FPGA implementation of the AES
Algorithm”,in Proc. Of Cryptographic hardware and embedded system workshop,pp.319-
333,2003
10.J.Bhasker “ A VHDL Primer”.3rd Edition published by Pearson Education Inc and Dorling
Kindersley Publishing Inc.
11.J. Elbirt, W. Yip, B. Chetwynd, and C. Paar. An FPGA implementation and performance
evaluation of the AES block cipher candidate algorithm finalist. presented at Proc.3rdAESConf.
(AES3).[Online].Available:http://cs rc.nist.gov/encryption/aes/round2/conf3/aes3papers.ht ml.
13.H. Kuo and I. Verbauwhede, “Architectural optimization for a 1.82 Gbits/sec VLSI
implementation of the AES Rijndael algorithm,” in Proc. CHES 2001, pp. 51–64, Paris, France,
May 2001.
14.M. McLoone and J. V. McCanny, “Rijndael FPGA implementation utilizing look-up tables,”
in IEEEWorkshop on Signal Processing Systems, pp.349–360, Sept. 2001.
Appendix
INTRODUCTION TO MATLAB
Matlab Introduction
1. Advance algorithm for high performance numerical computation ,especially in the Field
matrix algebra
2. A large collection of predefined mathematical functions and the ability to define one’s own
functions.
3. Two-and three dimensional graphics for plotting and displaying data
4. A complete online help system
5. Powerful, matrix or vector oriented high level programming language for individual
applications.
6. Toolboxes available for solving advanced problems in several application areas
MATLAB
MATLAB
Programming language
Tool boxes
Signal processing
Image processing
Control systems
Neural Networks
Communications
Robust control
Statistics
Development Environment.
This is the set of tools and facilities that help you use
MATLAB functions and files. Many of these tools are graphical user interfaces. It includes the
MATLAB desktop and Command Window, a command history, an editor and debugger, and
browsers for viewing help, the workspace, files, and the search path.
Graphics.
Starting MATLAB
MATLAB Desktop
1. Arithmetic operations
Entering Matrices
The best way for you to get started with MATLAB is to learn how to handle matrices. Start
MATLAB and follow along with each example.
Start by entering Dürer’s matrix as a list of its elements. You only have to follow a few basic
conventions:
A=
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
You are probably already aware that the special properties of a magic square have to do with the
various ways of summing its elements. If you take the sum along any row or column, or along
either of the two main diagonals, you will always get the same number. Let us verify that using
MATLAB.
The first statement to try is
sum(A)
ans =
34 34 34 34
So A' produces
ans =
16 5 9 4
3 10 6 15
2 11 7 14
13 8 12 1
And sum(A')' produces a column vector containing the row sums
ans =
34
34
34
34
The sum of the elements on the main diagonal is obtained with the sum and the diag
functions:
diag(A) produces
ans =
16
10
1 and
sum(diag(A)) produces
ans =
34
But a function originally intended for use in graphics, fliplr, flips a matrix From left to right:
Sum (diag(fliplr(A)))
ans =
34
You have verified that the matrix in Dürer’s engraving is indeed a magic Square and, in the
process, have sampled a few MATLAB matrix operations.
Operators
+ Addition
- Subtraction
* Multiplication
/ Division
MATLAB documentation)
. ^ Power
Generating Matrices
Z = zeros(2,4)
Z=
0000
0000
F = 5*ones(3,3)
F=
555
555
555
N = fix(10*rand(1,10))
N=
9264874084
R = randn(4,4)
R=
M-Files
A = [...
Store the file under the name magik.m. Then the statement
Magik reads the file and creates a variable, A, containing our example matrix.
Graph Components