OpenCores
URL https://opencores.org/ocsvn/present/present/trunk

Subversion Repositories present

[/] [present/] [trunk/] [PureTesting/] [doc/] [src/] [present_pure_testing.tex] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 gajos
\documentclass{gajewski}
2
 
3
\bibliographystyle{IEEEtran}
4
 
5
%%%%%%%%%%%%%%%%%
6
% Document variables
7
%%%%%%%%%%%%%%%%%
8
\docDate{ \today }
9
\docID{Present Cipher ("Pure Testing") - with communication channel with PC}
10 20 gajos
\docRevision{0.2}
11 15 gajos
\docStatus{Draft}
12
\docTitle{\mbox{Present Cipher ("Pure Testing") -} \mbox{with communication channel with PC}}
13
\docTitleShort{Present Cipher ("Pure Testing")...}
14
\authorName{\mbox{Krzysztof Gajewski} \\ and opencores.org}
15
\authorURL{www.opencores.org}
16
\authorAddress{\mbox{}}
17
\authorEmail{gajos@opencores.org}
18
 
19
\revisionList{
20
0.1 & all & 2014/05/01 & First draft & K. Gajewski \\
21 20 gajos
0.2 & all & 2014/09/16 & Some small corrections with the text, typos, etc. & K. Gajewski \\
22 15 gajos
}
23
 
24
\begin{document}
25
 
26
\maketitle
27
 
28
\newpage
29
 
30
\revisionTable
31
 
32
\newpage
33
 
34
\tableofcontents
35
\newpage
36
 
37
\section{Introduction}
38
 
39
Present is "ultra-lightweight" block cipher developed by A. Bogdanov et al. and proposed in 2007 \cite{PRESENT}. It uses 64 bit data block and 80 bit or 128 bit key.
40
This cipher consists of 32 rounds, during which:
41
\begin{itemize}
42
    \item round key is added to plaintext
43
    \item plaintext goues through sBoxes (substitution boxes)
44
    \item plaintext after sBoxes goes through pLayer (permutation layer)
45
    \item round key is updated
46
\end{itemize}
47 20 gajos
After that, ciphertext feeds out the output. Briefly algorithm was shown in Fig. \ref{pAlgorithm}.
48 15 gajos
\begin{figure}[!ht]%
49
    \begin{center}
50
    \includegraphics[width=0.66\textwidth]{img/presentAlgorithm.png}
51
    \caption{%
52
        Briefly block scheme of the PRESENT block cipher
53
     }%
54
    \label{pAlgorithm}
55
    \end{center}
56
 \end{figure}
57
More informations about FPGA Present core can be found in "Pure" subfolder.
58
In this project Present block cipher works with 80 bit key. It was attached by shifting registers to RS-232 core developed by Digilent\textsuperscript{\textregistered} to enable communication with PC. Target was Xilinx\textsuperscript{\textregistered} Spartan 3E XC3S500E \cite{Spartan} on Spartan 3E  Starter Board \cite{Digilent} made by Digilent\textsuperscript{\textregistered}.
59
 
60
\newpage
61
 
62
\section{Interface}
63
 
64 20 gajos
Top level component of the Present Pure Testing was shown in Fig. \ref{ptest}. The number of inputs and outputs was limited due to RS-232 component in communication interface. All inputs and outputs are synchronous except \texttt{reset} signal and sampled at rising edge of clock. All signals are \texttt{STD\_LOGIC}.
65 15 gajos
\begin{figure}[!ht]%
66
    \begin{center}
67
    \includegraphics[width=0.5\textwidth]{img/PresentPureTesting.png}
68
    \caption{%
69 20 gajos
        Top level component of the Present Pure Testing
70 15 gajos
     }%
71
    \label{ptest}
72
    \end{center}
73
 \end{figure}
74
 
75
\begin{tabularx}{\textwidth}{|p{30mm}|p{11mm}|p{11mm}|X|}
76
  \hline \bf{Signal name} & \bf{Width} & \bf{In/Out} & \bf{Description}\\
77 20 gajos
  \hline \texttt{clk} & 1  &  in  & clock signal for the component. \\
78
  \hline \texttt{DATA\_RXD} & 1 & in & input data signal. \\
79
  \hline \texttt{reset} & 1  &  in  &  \emph{asynchronous} reset signal.\\
80
  \hline \texttt{DATA\_TXD} & 1 &  out  & output data signal.   \\
81 15 gajos
  \hline
82
\end{tabularx}
83 20 gajos
\captionof{table}{Input/Output signals of the Present component}
84 15 gajos
 
85
\newpage
86
 
87
\section{Internal structure and state machine workflow}
88
 
89 20 gajos
Internal datapath between components was shown in fig. \ref{pinside}. All control signals, \texttt{clk} and \texttt{reset} was omitted for clearance. In these schamatic \texttt{keyReg}, \texttt{textReg} and \texttt{outReg} are shift registers enabling conversion of the serial input/output data into parallel data. They are respectively:
90 15 gajos
\begin{itemize}
91
    \item \texttt{keyReg} - shift register for the key,
92
    \item \texttt{textReg} - shift register for the text to be encoded,
93
    \item \texttt{outReg} - shift register for the output data to be sendend by RS232.
94
\end{itemize}
95
\texttt{present} - is the crypto core. It was described in \texttt{./Present/doc/present\_pure.pdf} file ("Present" subproject documentation). \texttt{RS232} is the serial communication core developed by Digilent\textsuperscript{\textregistered} responsible for the communication with PC computer.
96
\texttt{SM} is state machine which manage communication with PC and data conversion before and after data encoding in \texttt{present} component.
97
 
98
\begin{figure}[!ht]%
99
    \begin{center}
100
    \includegraphics[width=0.95\textwidth]{img/PresentCommInside.png}
101
    \caption{%
102 20 gajos
        Internal structure of the Present core with communication environment.
103 15 gajos
     }%
104
    \label{pinside}
105
    \end{center}
106
 \end{figure}
107
 
108
State machine states and transition between them was shown in fig. \ref{presentCommSM}.
109
 
110
\begin{figure}[!ht]%
111
    \begin{center}
112
    \includegraphics[width=0.95\textwidth]{img/PresentCommSM.png}
113
    \caption{%
114
        State machine of the Present cipher with added communication component
115
     }%
116
    \label{presentCommSM}
117
    \end{center}
118
 \end{figure}
119
 
120
 
121
State machine consist of following states, which are briefly explained:
122
 
123
\begin{itemize}
124 20 gajos
    \item \texttt{NOP} - this is the initial state of the state machine. It is set up after resetting the system. If any data appear in the RS-232 input (\texttt{RDAsig = '1'}), this state will be changed.
125
    \item \texttt{READ\_DATA\_TEXT} / \texttt{READ\_DATA\_KEY} - These states inform the RS-232 component that input data was read (by write enable in \texttt{keyReg} register).
126
    \item \texttt{DECODE\_READ\_TEXT} / \texttt{DECODE\_READ\_KEY}- In these states the number of performed data reading iterations are checked. Because one RS-232 packet was set to 8 bytes - 8 iterations need to be ferformed for reading full 64 bit text data input (10 iterations for reading full 80 bit key data input).
127 15 gajos
    \item \texttt{TEMP\_STATE} / \texttt{TEMP2\_STATE} / \texttt{TEMP\_OUT} - Here the counter is prepared for key reading / encoding / next "encoding session".
128
    \item \texttt{MOVE\_TEXT} / \texttt{MOVE\_KEY} / - Due to serial data in RS-232 component are stored in 8 bit register, they need to be shifted in appropriate place in given shift registers. It is performed by 8 shifts made in 8 clock cycles.
129
    \item \texttt{NOP\_FOR\_KEY} - Kind of \texttt{NOP} or wait state until 'key' data will arrive.
130
    \item \texttt{PRESENT\_ENCODE} - In this state Present encoding is performed. This state is active until Present component informs about ending of the encoding process (\texttt{readySig = '1'}).
131 20 gajos
    \item \texttt{WRITE\_OUT} - state responsible for immediate sending encoded data. It is performed as many number as 64 bits of encoded data will be sent by the RS-232 component to the PC (similarly to "\texttt{DECODE...}" states).
132 15 gajos
    \item \texttt{MOVE\_OUT} - it is similar state to the previous \texttt{MOVE...} states, but here additionally state machine must wait until output data buffer will be prepared for next data which have to be sended.
133
\end{itemize}
134
No "lost data" checking, and data correction protocol was performed. It was assumed "ideal channel" for communication. Some states could be "merged" into one state but it will involve more expanded control logic.
135
 
136
\newpage
137
 
138
\section{FPGA implementations}
139
 
140 20 gajos
The  component  has been verified on a Xilinx\textsuperscript{\textregistered} Spartan 3E XC3S500E FPGA in FG320 package and synthesized  with  Xilinx  ISE  14.2. It was also implemented and practically tested on Spartan 3E Starter Board made by Digilent\textsuperscript{\textregistered}. Appropriate setup files was prepared with the use of ISE Project Navigator, but Makefile scripts was also written. Suitable files was stored in \texttt{./PureTesting/syn/XC3ES500/}  directory.
141 15 gajos
Makefile was tested in Windows 8 with use of Cygwin for 64-bit Windows.
142
 
143
Synthesis results was given in Fig. \ref{SynResults}
144
 
145
\begin{tabularx}{\textwidth}{|p{45mm}|p{30mm}|p{30mm}|X|}
146
  \hline \multicolumn{4}{|c|}{Xilinx\textsuperscript{\textregistered} Spartan 3E XC3S500E FPGA in FG320 package} \\
147
  \hline \bf{Parameter} & \bf{Used} & \bf{Available} & \bf{Utilization}\\
148
  \hline Number of Slices & 426 & 4656 & 9\% \\
149
  \hline Number of Slice Flip Flops & 441 & 9312 & 4\% \\
150
  \hline Number of 4 input LUTs & 474 & 9312 & 5\% \\
151
  \hline Number of bonded IOBs & 4 & 232 & 1\% \\
152
  \hline Number of GCLKs & 2 & 24 & 8\%\\
153
  \hline Minimum period & 5.283ns & - & - \\
154
  \hline Maximum Frequency & 189 MHz & - & - \\
155
  \hline
156
\end{tabularx}
157
\label{SynResults}
158
\captionof{table}{Synthesis results for Spartan 3E XC3S500E}
159
 
160
Possible change in used FPGA device may be possible in steps given below\footnotemark[1]:
161
\begin{enumerate}
162
    \item Copy \texttt{./PureTesting/syn/XC3ES500/} directory to another one like \\ \texttt{./PureTesting/syn/YOUR\_FPGA\_SYMBOL/}
163 20 gajos
    \item Go to \texttt{./PureTesting/syn/YOUR\_FPGA\_SYMBOL/}  directory.
164
    \item In \texttt{PresentComm.xst} file modify the line \texttt{-p xc3s500e-5-fg320} to \texttt{-p YOUR\_FPGA\_CODE}
165
    \item In \texttt{Makefile} file modify the line \texttt{PLATFORM=xc3s500e-fg320-5} to \texttt{PLATFORM=YOUR\_FPGA\_CODE}
166 15 gajos
\end{enumerate}
167
 
168
\footnotetext[1]{This solution was not tested and is based on my own observations. Additional care should be taken with *.UCF files - this supplied with this project should be appropriate only for Spartan 3E Starter Board made by Digilent\textsuperscript{\textregistered}. You can make this modifications on your own risk}
169
 
170
\newpage
171
 
172
\section{Simulation and software}
173
 
174
\subsection{Simulation}
175
 
176
Self-checking test bench were provided to the components used for Present encoder with RS-232 communication. They are stored in \texttt{./PureTesting/bench/vhdl} directory. Suitable configuration files and Makefile used for running test bench was stored in
177
\texttt{./PureTesting/sim/rtl\_sim/bin} directory. Appropriate test vectors was taken from \cite{PRESENT}. In \texttt{PresentCommTB.vhd} file with suitable test files stored in \texttt{./PureTesting/sim/rtl\_sim/bin/test} directory simulation of RS-232 communication was prepared. Due to that only this one test bench is not self checking. Observation and testing of the communication in this case will be most comfortable using isim gui.
178
 
179
Makefile was prepared to make "manual run" of tests. If You want to perform it without gui, remove \texttt{-gui} option in Makefaile.
180
 
181
\subsection{Software}
182
 
183
With this project two tool programs written in Java was included:
184
\begin{itemize}
185
    \item \texttt{PresentDataGenerator} (class with the same file name)
186
    \item "GUI Application" which consist of two classes (Communication.java and Window.java)
187
\end{itemize}
188
They were brought into Eclipse project, which can be easy imported. It was tested with Eclipse Indigo version.
189
 
190
First of them is used to prepare data for \texttt{PresentCommTB}. It can be used by:
191
\begin{itemize}
192
    \item Setting \texttt{drive}, \texttt{data} and \texttt{key} variables with hexadecimal values as it is desired.
193
    \item Running the compiler and running program.
194
\end{itemize}
195
 
196
On its output it sends set of bits which are sequently sent to the PresentComm component during test bench.
197
 
198
"GUI application" enables communication with PC by use of RS-232 connection. RS-232 communication in Java is delivered by  \texttt{rxtx} library. It was partly based on tutorial which can be found at \cite{GUIComm}.
199
This program can be used as follow:
200
\begin{itemize}
201
    \item After connecting FPGA board to the RS-232 port click the "Connect" button.
202
    \item To the "Data" and "Key" write suitable hexadecimal data used for encoding.
203
    \item Press "Send" button.
204
    \item Answer should appear in "Log" box in hexadecimal values.
205
\end{itemize}
206
These programs were not prepared for unusual cases, so entering intended inappropriate values (like non hexadecimal values) are not recommended.
207
 
208
\newpage
209
 
210
\section{Troubleshooting}
211
 
212
During work with Windows 8 64-bit and and Xilinx\textsuperscript{\textregistered} ISE 64-bit some problems may occur:
213
 
214
\begin{enumerate}
215
    \item Xilinx may be unable to open projects in Project Navigator.
216
    \item When you run \texttt{make} in Cygwin and perform testbench it would be unable to open ISIM gui.
217
    \item When you run ISIM gui  (*.exe test bench file) it hangs out or anti virus protection opens.
218
\end{enumerate}
219
 
220
To solve problems listed above you have to perform steps listed below:
221
\begin{enumerate}
222
    \item You have to rename libraries \texttt{libPortabilityNOSH.dll} to \texttt{libPortability.dll} from \texttt{nt64} directories (\href{http://www.gadgetfactory.net/2013/09/having-problems-installing-xilinx-ise-on-windows-8-64bit-here-is-a-fix-video-included/}{http://www.gadgetfactory.net/2013/09/having-problems-installing-xilinx-ise-on-windows-8-64bit-here-is-a-fix-video-included/})
223
    \item Firstly, install Cygwin X11 (\href{http://stackoverflow.com/questions/9393462/cannot-launch-git-gui-using-cygwin-on-windows}{http://stackoverflow.com/questions/9393462/cannot-launch-git-gui-using-cygwin-on-windows})
224
    \item Temporary switch off anti virus protection.
225
\end{enumerate}
226
 
227
\newpage
228
 
229
\section{License and Liability}
230
Copyright\textcopyright \space 2013 Authors and OPENCORES.ORG
231
 
232
This source file may be used and distributed without
233
restriction provided that this copyright statement is not
234
removed from the file and that any derivative work contains
235
the original copyright notice and the associated disclaimer.
236
 
237
This source file is free software; you can redistribute it
238
and-or modify it under the terms of the GNU Lesser General
239
Public License as published by the Free Software Foundation;
240
either version 2.1 of the License, or (at your option) any
241
later version.
242
 
243
This source is distributed in the hope that it will be
244
useful, but WITHOUT ANY WARRANTY; without even the implied
245
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
246
PURPOSE. See the GNU Lesser General Public License for more
247
details.
248
 
249
You should have received a copy of the GNU Lesser General
250
Public License along with this source; if not, download it
251
from \href{http://www.opencores.org/lgpl.shtml}{http://www.opencores.org/lgpl.shtml}
252
 
253
Xilinx, Spartan3E is registered trademark of Xilinx Inc. 2100 Logic Drive, San Jose CA USA
254
 
255
\newpage
256
 
257
\bibliography{bibliography}
258
 
259
\end{document}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.