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 15

Go to most recent revision | 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
\docRevision{0.1}
11
\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
}
22
 
23
\begin{document}
24
 
25
\maketitle
26
 
27
\newpage
28
 
29
\revisionTable
30
 
31
\newpage
32
 
33
\tableofcontents
34
\newpage
35
 
36
\section{Introduction}
37
 
38
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.
39
This cipher consists of 32 rounds, during which:
40
\begin{itemize}
41
    \item round key is added to plaintext
42
    \item plaintext goues through sBoxes (substitution boxes)
43
    \item plaintext after sBoxes goes through pLayer (permutation layer)
44
    \item round key is updated
45
\end{itemize}
46
After that, ciphertext feeds out the output. Briefly algorithm was shown in Fig. \ref{pAlgorithm}
47
\begin{figure}[!ht]%
48
    \begin{center}
49
    \includegraphics[width=0.66\textwidth]{img/presentAlgorithm.png}
50
    \caption{%
51
        Briefly block scheme of the PRESENT block cipher
52
     }%
53
    \label{pAlgorithm}
54
    \end{center}
55
 \end{figure}
56
More informations about FPGA Present core can be found in "Pure" subfolder.
57
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}.
58
 
59
\newpage
60
 
61
\section{Interface}
62
 
63
Top level component of 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 in Present State Machine ("internal" part of the core) and sampled at rising edge of clock. All signals are \texttt{STD\_LOGIC}.
64
\begin{figure}[!ht]%
65
    \begin{center}
66
    \includegraphics[width=0.5\textwidth]{img/PresentPureTesting.png}
67
    \caption{%
68
        Top level component of Present Pure Testing
69
     }%
70
    \label{ptest}
71
    \end{center}
72
 \end{figure}
73
 
74
\begin{tabularx}{\textwidth}{|p{30mm}|p{11mm}|p{11mm}|X|}
75
  \hline \bf{Signal name} & \bf{Width} & \bf{In/Out} & \bf{Description}\\
76
  \hline \texttt{clk} & 1  &  in  & Clock signal for the component. \\
77
  \hline \texttt{DATA\_RXD} & 1 & in & Input data signal. \\
78
  \hline \texttt{reset} & 1  &  in  &  \emph{Asynchronous} / \emph{Synchronous} reset signal.\\
79
  \hline \texttt{DATA\_TXD} & 1 &  out  & Output data signal.   \\
80
  \hline
81
\end{tabularx}
82
\captionof{table}{Input/Output signals of Present component}
83
 
84
\newpage
85
 
86
\section{Internal structure and state machine workflow}
87
 
88
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 input/output serial data into parallel data. They are respectively:
89
\begin{itemize}
90
    \item \texttt{keyReg} - shift register for the key,
91
    \item \texttt{textReg} - shift register for the text to be encoded,
92
    \item \texttt{outReg} - shift register for the output data to be sendend by RS232.
93
\end{itemize}
94
\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.
95
\texttt{SM} is state machine which manage communication with PC and data conversion before and after data encoding in \texttt{present} component.
96
 
97
\begin{figure}[!ht]%
98
    \begin{center}
99
    \includegraphics[width=0.95\textwidth]{img/PresentCommInside.png}
100
    \caption{%
101
        Internal structure of Present core with communication environment.
102
     }%
103
    \label{pinside}
104
    \end{center}
105
 \end{figure}
106
 
107
State machine states and transition between them was shown in fig. \ref{presentCommSM}.
108
 
109
\begin{figure}[!ht]%
110
    \begin{center}
111
    \includegraphics[width=0.95\textwidth]{img/PresentCommSM.png}
112
    \caption{%
113
        State machine of the Present cipher with added communication component
114
     }%
115
    \label{presentCommSM}
116
    \end{center}
117
 \end{figure}
118
 
119
 
120
State machine consist of following states, which are briefly explained:
121
 
122
\begin{itemize}
123
    \item \texttt{NOP} - this is 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.
124
    \item \texttt{READ\_DATA\_TEXT} / \texttt{READ\_DATA\_KEY} - This state informs the RS-232 component that input data was readed (by write enable in \texttt{keyReg} register).
125
    \item \texttt{DECODE\_READ\_TEXT} / \texttt{DECODE\_READ\_KEY}- In this state 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).
126
    \item \texttt{TEMP\_STATE} / \texttt{TEMP2\_STATE} / \texttt{TEMP\_OUT} - Here the counter is prepared for key reading / encoding / next "encoding session".
127
    \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.
128
    \item \texttt{NOP\_FOR\_KEY} - Kind of \texttt{NOP} or wait state until 'key' data will arrive.
129
    \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'}).
130
    \item \texttt{WRITE\_OUT} - state responsible for immediate sending encoded data. It is performed as many number as 64 bits of encoded data wil be sended by the RS-232 component to the PC (similarly to "\texttt{DECODE...}" states).
131
    \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.
132
\end{itemize}
133
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.
134
 
135
\newpage
136
 
137
\section{FPGA implementations}
138
 
139
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 use of ISE Project Navigator, but Makefile scripts was also written. Suitable files was stored in \texttt{./PureTesting/syn/XC3ES500/}  directory.
140
Makefile was tested in Windows 8 with use of Cygwin for 64-bit Windows.
141
 
142
Synthesis results was given in Fig. \ref{SynResults}
143
 
144
\begin{tabularx}{\textwidth}{|p{45mm}|p{30mm}|p{30mm}|X|}
145
  \hline \multicolumn{4}{|c|}{Xilinx\textsuperscript{\textregistered} Spartan 3E XC3S500E FPGA in FG320 package} \\
146
  \hline \bf{Parameter} & \bf{Used} & \bf{Available} & \bf{Utilization}\\
147
  \hline Number of Slices & 426 & 4656 & 9\% \\
148
  \hline Number of Slice Flip Flops & 441 & 9312 & 4\% \\
149
  \hline Number of 4 input LUTs & 474 & 9312 & 5\% \\
150
  \hline Number of bonded IOBs & 4 & 232 & 1\% \\
151
  \hline Number of GCLKs & 2 & 24 & 8\%\\
152
  \hline Minimum period & 5.283ns & - & - \\
153
  \hline Maximum Frequency & 189 MHz & - & - \\
154
  \hline
155
\end{tabularx}
156
\label{SynResults}
157
\captionof{table}{Synthesis results for Spartan 3E XC3S500E}
158
 
159
Possible change in used FPGA device may be possible in steps given below\footnotemark[1]:
160
\begin{enumerate}
161
    \item Copy \texttt{./PureTesting/syn/XC3ES500/} directory to another one like \\ \texttt{./PureTesting/syn/YOUR\_FPGA\_SYMBOL/}
162
    \item Go to \texttt{./PureTesting/syn/XC3ES500/}  directory.
163
    \item In \texttt{PresentEnc.xst} file modify the line \texttt{-p xc3s500e-5-fg320} to \texttt{-p YOUR\_FPGA\_SYMBOL}
164
    \item In \texttt{Makefile} file modify the line \texttt{PLATFORM=xc3s500e-fg320-5} to \texttt{PLATFORM=YOUR\_FPGA\_SYMBOL}
165
\end{enumerate}
166
 
167
\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}
168
 
169
\newpage
170
 
171
\section{Simulation and software}
172
 
173
\subsection{Simulation}
174
 
175
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
176
\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.
177
 
178
Makefile was prepared to make "manual run" of tests. If You want to perform it without gui, remove \texttt{-gui} option in Makefaile.
179
 
180
\subsection{Software}
181
 
182
With this project two tool programs written in Java was included:
183
\begin{itemize}
184
    \item \texttt{PresentDataGenerator} (class with the same file name)
185
    \item "GUI Application" which consist of two classes (Communication.java and Window.java)
186
\end{itemize}
187
They were brought into Eclipse project, which can be easy imported. It was tested with Eclipse Indigo version.
188
 
189
First of them is used to prepare data for \texttt{PresentCommTB}. It can be used by:
190
\begin{itemize}
191
    \item Setting \texttt{drive}, \texttt{data} and \texttt{key} variables with hexadecimal values as it is desired.
192
    \item Running the compiler and running program.
193
\end{itemize}
194
 
195
On its output it sends set of bits which are sequently sent to the PresentComm component during test bench.
196
 
197
"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}.
198
This program can be used as follow:
199
\begin{itemize}
200
    \item After connecting FPGA board to the RS-232 port click the "Connect" button.
201
    \item To the "Data" and "Key" write suitable hexadecimal data used for encoding.
202
    \item Press "Send" button.
203
    \item Answer should appear in "Log" box in hexadecimal values.
204
\end{itemize}
205
These programs were not prepared for unusual cases, so entering intended inappropriate values (like non hexadecimal values) are not recommended.
206
 
207
\newpage
208
 
209
\section{Troubleshooting}
210
 
211
During work with Windows 8 64-bit and and Xilinx\textsuperscript{\textregistered} ISE 64-bit some problems may occur:
212
 
213
\begin{enumerate}
214
    \item Xilinx may be unable to open projects in Project Navigator.
215
    \item When you run \texttt{make} in Cygwin and perform testbench it would be unable to open ISIM gui.
216
    \item When you run ISIM gui  (*.exe test bench file) it hangs out or anti virus protection opens.
217
\end{enumerate}
218
 
219
To solve problems listed above you have to perform steps listed below:
220
\begin{enumerate}
221
    \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/})
222
    \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})
223
    \item Temporary switch off anti virus protection.
224
\end{enumerate}
225
 
226
\newpage
227
 
228
\section{License and Liability}
229
Copyright\textcopyright \space 2013 Authors and OPENCORES.ORG
230
 
231
This source file may be used and distributed without
232
restriction provided that this copyright statement is not
233
removed from the file and that any derivative work contains
234
the original copyright notice and the associated disclaimer.
235
 
236
This source file is free software; you can redistribute it
237
and-or modify it under the terms of the GNU Lesser General
238
Public License as published by the Free Software Foundation;
239
either version 2.1 of the License, or (at your option) any
240
later version.
241
 
242
This source is distributed in the hope that it will be
243
useful, but WITHOUT ANY WARRANTY; without even the implied
244
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
245
PURPOSE. See the GNU Lesser General Public License for more
246
details.
247
 
248
You should have received a copy of the GNU Lesser General
249
Public License along with this source; if not, download it
250
from \href{http://www.opencores.org/lgpl.shtml}{http://www.opencores.org/lgpl.shtml}
251
 
252
Xilinx, Spartan3E is registered trademark of Xilinx Inc. 2100 Logic Drive, San Jose CA USA
253
 
254
\newpage
255
 
256
\bibliography{bibliography}
257
 
258
\end{document}

powered by: WebSVN 2.1.0

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