1 |
16 |
gajos |
\documentclass{gajewski}
|
2 |
|
|
|
3 |
|
|
\bibliographystyle{IEEEtran}
|
4 |
|
|
|
5 |
|
|
%%%%%%%%%%%%%%%%%
|
6 |
|
|
% Document variables
|
7 |
|
|
%%%%%%%%%%%%%%%%%
|
8 |
|
|
\docDate{ \today }
|
9 |
|
|
\docID{Present Decoder}
|
10 |
|
|
\docRevision{0.1}
|
11 |
|
|
\docStatus{Draft}
|
12 |
|
|
\docTitle{\mbox{Present Decoder}}
|
13 |
|
|
\authorName{\mbox{Krzysztof Gajewski} \\ and opencores.org}
|
14 |
|
|
\authorURL{www.opencores.org}
|
15 |
|
|
\authorAddress{\mbox{}}
|
16 |
|
|
\authorEmail{gajos@opencores.org}
|
17 |
|
|
|
18 |
|
|
\revisionList{
|
19 |
|
|
0.1 & all & 2014/05/25 & First draft & K. Gajewski \\
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
\begin{document}
|
23 |
|
|
|
24 |
|
|
\maketitle
|
25 |
|
|
|
26 |
|
|
\newpage
|
27 |
|
|
|
28 |
|
|
\revisionTable
|
29 |
|
|
|
30 |
|
|
\newpage
|
31 |
|
|
|
32 |
|
|
\tableofcontents
|
33 |
|
|
\newpage
|
34 |
|
|
|
35 |
|
|
\section{Introduction}
|
36 |
|
|
|
37 |
|
|
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.
|
38 |
|
|
This cipher consists of 32 rounds, during which:
|
39 |
|
|
\begin{itemize}
|
40 |
|
|
\item round key is added to plaintext
|
41 |
|
|
\item plaintext goes through sBoxes (substitution boxes)
|
42 |
|
|
\item plaintext after sBoxes goes through pLayer (permutation layer)
|
43 |
|
|
\item round key is updated
|
44 |
|
|
\end{itemize}
|
45 |
|
|
After that, ciphertext feeds out the output. Briefly algorithm was shown in Fig. \ref{pAlgorithm}.
|
46 |
|
|
\begin{figure}[!ht]%
|
47 |
|
|
\begin{center}
|
48 |
|
|
\includegraphics[width=0.66\textwidth]{img/presentAlgorithm.png}
|
49 |
|
|
\caption{%
|
50 |
|
|
Briefly block scheme of the PRESENT block cipher
|
51 |
|
|
}%
|
52 |
|
|
\label{pAlgorithm}
|
53 |
|
|
\end{center}
|
54 |
|
|
\end{figure}
|
55 |
|
|
In subprojects \texttt{Pure} and \texttt{PureTesting} Present coder components was presented. In this project Present decoder was presented. Decoding key is firstly generated, basing on the key used for data coding. Next, input data are decoded (taking into account "inverse" direction to the presented in Fig. \ref{pAlgorithm}), and at last feeds the output. This core works with 80 bit key. Target was Xilinx\textsuperscript{\textregistered} Spartan 3E XC3S500E \cite{Spartan} on Spartan 3E Starter Board \cite{Digilent} made by Digilent\textsuperscript{\textregistered}.
|
56 |
|
|
|
57 |
|
|
\newpage
|
58 |
|
|
|
59 |
|
|
\section{Interface}
|
60 |
|
|
|
61 |
|
|
Top level component of Present decoder was shown in Fig. \ref{pfdec}. All inputs and outputs are synchronous except \texttt{reset} signal and sampled at rising edge of the clock. Type for all signals is \texttt{STD\_LOGIC} or \texttt{STD\_LOGIC\_VECTOR}.
|
62 |
|
|
\begin{figure}[!ht]%
|
63 |
|
|
\begin{center}
|
64 |
|
|
\includegraphics[width=0.5\textwidth]{img/PresentFullDecoder.png}
|
65 |
|
|
\caption{%
|
66 |
|
|
Top level component of Present decoder
|
67 |
|
|
}%
|
68 |
|
|
\label{pfdec}
|
69 |
|
|
\end{center}
|
70 |
|
|
\end{figure}
|
71 |
|
|
|
72 |
|
|
\begin{tabularx}{\textwidth}{|p{30mm}|p{11mm}|p{11mm}|X|}
|
73 |
|
|
\hline \bf{Signal name} & \bf{Width} & \bf{In/Out} & \bf{Description}\\
|
74 |
|
|
\hline \texttt{ciphertext} & 64 & in & input data which have to be decoded. \\
|
75 |
|
|
\hline \texttt{key} & 80 & in & secret key used for input data decoding (the same which was used for data encoding). \\
|
76 |
|
|
\hline \texttt{clk} & 1 & in & clock signal for the component\\
|
77 |
|
|
\hline \texttt{reset} & 1 & in & \emph{Asynchronous} reset signal. \\
|
78 |
|
|
\hline \texttt{start} & 1 & in & signal which starts decoding process. \\
|
79 |
|
|
\hline \texttt{plaintext} & 64 & out & decoded text output. \\
|
80 |
|
|
\hline \texttt{ready} & 1 & out & signal informing about end of decoding process. \newline "0" - wait until end of data decoding. \newline "1" - data at the \texttt{ciphertext} output are valid, you can read them. \\
|
81 |
|
|
\hline
|
82 |
|
|
\end{tabularx}
|
83 |
|
|
\captionof{table}{Input/Output signals of Present Decoder component}
|
84 |
|
|
|
85 |
|
|
\newpage
|
86 |
|
|
|
87 |
|
|
\section{Internal structure and state machine workflow}
|
88 |
|
|
|
89 |
|
|
\begin{figure}[!ht]%
|
90 |
|
|
\begin{center}
|
91 |
|
|
\includegraphics[width=0.8\textwidth]{img/internalStructure.png}
|
92 |
|
|
\caption{%
|
93 |
|
|
Internal datapath between main components in Present decoder.
|
94 |
|
|
}%
|
95 |
|
|
\label{internalStructure}
|
96 |
|
|
\end{center}
|
97 |
|
|
\end{figure}
|
98 |
|
|
|
99 |
|
|
Internal datapath between main components was shown in Fig. \ref{internalStructure}. They are responsible for:
|
100 |
|
|
|
101 |
|
|
\begin{itemize}
|
102 |
|
|
\item \texttt{PresentEncKeyGen} - key generator for decoding process. Before decoding stage, key need to be prepared to the 'appropriate value'. This value is signalled by \texttt{ready = '1'}. It is almost the same core as in \texttt{Present} subproject, but truncated from text encoding part.
|
103 |
|
|
\item \texttt{PresentDec} - subcomponent responsible for ciphertext decoding. It is working in similar way as Present cipher, but is working in inverse way.
|
104 |
|
|
\item \texttt{FullDecoderSM} - State machine controlling overall decoding process.
|
105 |
|
|
\end{itemize}
|
106 |
|
|
|
107 |
|
|
More information about cipher core and key generation process can be found in \\ \texttt{./Present/doc/present\_pure.pdf} file ("Present" subproject documentation).
|
108 |
|
|
|
109 |
|
|
\begin{figure}[!ht]%
|
110 |
|
|
\begin{center}
|
111 |
|
|
\includegraphics[width=0.4\textwidth]{img/PresentDecStateMachine.jpg}
|
112 |
|
|
\caption{%
|
113 |
|
|
State machine of the Present component
|
114 |
|
|
}%
|
115 |
|
|
\label{presentDecSM}
|
116 |
|
|
\end{center}
|
117 |
|
|
\end{figure}
|
118 |
|
|
|
119 |
|
|
State machine of the \texttt{PresentDec} component was shown in Fig. \ref{presentDecSM}. It consist of three states \texttt{NOP}, \texttt{SM\_START} and \texttt{READY}. The way of work of this state machine is the same as in the \texttt{Present} subproject, but the counter is counting down instead of counting up.
|
120 |
|
|
|
121 |
|
|
\begin{figure}[!ht]%
|
122 |
|
|
\begin{center}
|
123 |
|
|
\includegraphics[width=0.5\textwidth]{img/FullDecoderSM.jpg}
|
124 |
|
|
\caption{%
|
125 |
|
|
State machine of the Present decoder in main component.
|
126 |
|
|
}%
|
127 |
|
|
\label{presentFullDecSM}
|
128 |
|
|
\end{center}
|
129 |
|
|
\end{figure}
|
130 |
|
|
|
131 |
|
|
State machine of the \texttt{FullDecoderSM} component was shown in Fig. \ref{presentFullDecSM}. It consist of four states \texttt{NOP}, \texttt{KG\_START}, \texttt{DEC\_START} and \texttt{READY}. \texttt{NOP} is default state after resetting the core. This state is active as long as \texttt{full\_decoder\_start} = '0'.
|
132 |
|
|
|
133 |
|
|
When \texttt{full\_decoder\_start} = '1' key generation for the decoding process starts. Proper \texttt{key} and \texttt{ciphertext} must feed the input before. \texttt{KG\_START} state is active as long \texttt{PresentEncKeyGen} is generating the key. Key generation ends, when \texttt{PresentEncKeyGen} sets the \texttt{ready} signal to '1'. When the \texttt{ready} signal is set to '1', the state is changing.
|
134 |
|
|
|
135 |
|
|
During \texttt{DEC\_START} state decoding process appears. State machine is in this state until \texttt{PresentDec} ends its works. The end of decoding is signalled by setting the \texttt{ready} signal to '1' by the \texttt{PresentDec} component. Then, the state is changing.
|
136 |
|
|
|
137 |
|
|
\texttt{READY} sets the \texttt{ready} signal of the \texttt{PresentFullDecoder} to '1'. It is idle-like state, when the user can reads the output of the Present decoder. The state machine is in this state until the user sets the \texttt{full\_decoder\_start} to '0'.
|
138 |
|
|
|
139 |
|
|
\newpage
|
140 |
|
|
|
141 |
|
|
\section{FPGA implementations}
|
142 |
|
|
|
143 |
|
|
The component has only been verified on a Xilinx\textsuperscript{\textregistered} Spartan 3E XC3S500E FPGA in FG320 package and synthesized with Xilinx ISE 14.2. Appropriate setup files was prepared with use of ISE Project Navigator, but Makefile scripts was also written. Suitable files was stored in \texttt{./Decode/syn/XC3ES500/} directory.
|
144 |
|
|
Implementation in FPGA device was done in another subproject called \texttt{DecodeTesting}.
|
145 |
|
|
Makefile was tested in Windows 8 with use of Cygwin for 64-bit Windows.
|
146 |
|
|
|
147 |
|
|
Synthesis results was given in Fig. \ref{SynResults}
|
148 |
|
|
|
149 |
|
|
\begin{tabularx}{\textwidth}{|p{45mm}|p{30mm}|p{30mm}|X|}
|
150 |
|
|
\hline \multicolumn{4}{|c|}{Xilinx \textregistered Spartan 3E XC3S500E FPGA in FG320 package} \\
|
151 |
|
|
\hline \bf{Parameter} & \bf{Used} & \bf{Available} & \bf{Utilisation}\\
|
152 |
|
|
\hline Number of Slices & 354 & 4656 & 7\% \\
|
153 |
|
|
\hline Number of Slice Flip Flops & 240 & 9312 & 2\% \\
|
154 |
|
|
\hline Number of 4 input LUTs & 402 & 9312 & 4\% \\
|
155 |
|
|
\hline Number of bonded IOBs & 212 & 232 & 91\% \\
|
156 |
|
|
\hline Number of GCLKs & 1 & 24 & 4\%\\
|
157 |
|
|
\hline Minimum period & 5.023ns & - & - \\
|
158 |
|
|
\hline Maximum Frequency & 199 MHz & - & - \\
|
159 |
|
|
\hline
|
160 |
|
|
\end{tabularx}
|
161 |
|
|
\label{SynResults}
|
162 |
|
|
\captionof{table}{Synthesis results for Spartan 3E XC3S500E}
|
163 |
|
|
|
164 |
|
|
Possible change in used FPGA device may be possible in steps given below\footnotemark[1]:
|
165 |
|
|
\begin{enumerate}
|
166 |
|
|
\item Copy \texttt{./Decode/syn/XC3ES500/} directory to another one like \texttt{./Decode/syn/YOUR\_FPGA\_SYMBOL/}
|
167 |
|
|
\item Go to \texttt{./Decode/syn/XC3ES500/} directory.
|
168 |
|
|
\item In \texttt{PresentEnc.xst} file modify the line \texttt{-p xc3s500e-5-fg320} to \texttt{-p YOUR\_FPGA\_SYMBOL}
|
169 |
|
|
\item In \texttt{Makefile} file modify the line \texttt{PLATFORM=xc3s500e-fg320-5} to \texttt{PLATFORM=YOUR\_FPGA\_SYMBOL}
|
170 |
|
|
\end{enumerate}
|
171 |
|
|
|
172 |
|
|
\footnotetext[1]{This solution was not tested and is based on my own observations. Additional care should be taken with *.UCF files. You can make this modifications on your own risk}
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
\newpage
|
176 |
|
|
|
177 |
|
|
\section{Simulation}
|
178 |
|
|
|
179 |
|
|
Self-checking test bench were provided to the components used for Present encoder. They are stored in \texttt{./Decode/bench/vhdl} directory. Suitable configuration files and Makefile used for running test bench was stored in
|
180 |
|
|
\texttt{./Decode/sim/rtl\_sim/bin} directory. Appropriate test vectors was taken from \cite{PRESENT}.
|
181 |
|
|
|
182 |
|
|
Makefile was prepared to make "manual run" of tests. If You want to perform it without gui, remove \texttt{-gui} option in Makefaile.
|
183 |
|
|
|
184 |
|
|
\newpage
|
185 |
|
|
|
186 |
|
|
\section{Troubleshooting}
|
187 |
|
|
|
188 |
|
|
During work with Windows 8 64-bit and and Xilinx\textsuperscript{\textregistered} ISE 64-bit some problems may occur:
|
189 |
|
|
|
190 |
|
|
\begin{enumerate}
|
191 |
|
|
\item Xilinx may be unable to open projects in Project Navigator.
|
192 |
|
|
\item When you run \texttt{make} in Cygwin and perform testbench it would be unable to open ISIM gui.
|
193 |
|
|
\item When you run ISIM gui (*.exe test bench file) it hangs out or anti virus protection opens.
|
194 |
|
|
\end{enumerate}
|
195 |
|
|
|
196 |
|
|
To solve problems listed above you have to perform steps listed below:
|
197 |
|
|
\begin{enumerate}
|
198 |
|
|
\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/})
|
199 |
|
|
\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})
|
200 |
|
|
\item Temporary switch off anti virus protection.
|
201 |
|
|
\end{enumerate}
|
202 |
|
|
|
203 |
|
|
\newpage
|
204 |
|
|
|
205 |
|
|
\section{License and Liability}
|
206 |
|
|
|
207 |
|
|
Copyright \textcopyright 2013 Authors and OPENCORES.ORG
|
208 |
|
|
|
209 |
|
|
This source file may be used and distributed without
|
210 |
|
|
restriction provided that this copyright statement is not
|
211 |
|
|
removed from the file and that any derivative work contains
|
212 |
|
|
the original copyright notice and the associated disclaimer.
|
213 |
|
|
|
214 |
|
|
This source file is free software; you can redistribute it
|
215 |
|
|
and-or modify it under the terms of the GNU Lesser General
|
216 |
|
|
Public License as published by the Free Software Foundation;
|
217 |
|
|
either version 2.1 of the License, or (at your option) any
|
218 |
|
|
later version.
|
219 |
|
|
|
220 |
|
|
This source is distributed in the hope that it will be
|
221 |
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied
|
222 |
|
|
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
223 |
|
|
PURPOSE. See the GNU Lesser General Public License for more
|
224 |
|
|
details.
|
225 |
|
|
|
226 |
|
|
You should have received a copy of the GNU Lesser General
|
227 |
|
|
Public License along with this source; if not, download it
|
228 |
|
|
from \href{http://www.opencores.org/lgpl.shtml}{http://www.opencores.org/lgpl.shtml}
|
229 |
|
|
|
230 |
|
|
Xilinx, Spartan3E is registered trademark of Xilinx Inc. 2100 Logic Drive, San Jose CA USA
|
231 |
|
|
|
232 |
|
|
\newpage
|
233 |
|
|
|
234 |
|
|
\bibliography{bibliography}
|
235 |
|
|
|
236 |
|
|
\end{document}
|