\hypertarget{elgamal_8h}{ \section{include/beecrypt/elgamal.h File Reference} \label{elgamal_8h}\index{include/beecrypt/elgamal.h@{include/beecrypt/elgamal.h}} } ElGamal algorithm. {\ttfamily \#include \char`\"{}beecrypt/mpbarrett.h\char`\"{}}\par Include dependency graph for elgamal.h: \nopagebreak \begin{figure}[H] \begin{center} \leavevmode \includegraphics[width=212pt]{elgamal_8h__incl} \end{center} \end{figure} \subsection*{Functions} \begin{DoxyCompactItemize} \item int \hyperlink{elgamal_8h_a71210da412fefa0f230a7f988eb83c31}{elgv1sign} (const \hyperlink{structmpbarrett}{mpbarrett} $\ast$p, const \hyperlink{structmpbarrett}{mpbarrett} $\ast$n, const \hyperlink{structmpnumber}{mpnumber} $\ast$g, \hyperlink{structrandomGeneratorContext}{randomGeneratorContext} $\ast$, const \hyperlink{structmpnumber}{mpnumber} $\ast$hm, const \hyperlink{structmpnumber}{mpnumber} $\ast$x, \hyperlink{structmpnumber}{mpnumber} $\ast$r, \hyperlink{structmpnumber}{mpnumber} $\ast$s) \begin{DoxyCompactList}\small\item\em This function performs raw ElGamal signing, variant 1. \item\end{DoxyCompactList}\item int \hyperlink{elgamal_8h_ab5a4857d59add82a522e0c08c83298f8}{elgv3sign} (const \hyperlink{structmpbarrett}{mpbarrett} $\ast$p, const \hyperlink{structmpbarrett}{mpbarrett} $\ast$n, const \hyperlink{structmpnumber}{mpnumber} $\ast$g, \hyperlink{structrandomGeneratorContext}{randomGeneratorContext} $\ast$, const \hyperlink{structmpnumber}{mpnumber} $\ast$hm, const \hyperlink{structmpnumber}{mpnumber} $\ast$x, \hyperlink{structmpnumber}{mpnumber} $\ast$r, \hyperlink{structmpnumber}{mpnumber} $\ast$s) \begin{DoxyCompactList}\small\item\em This function performs raw ElGamal signing, variant 3. \item\end{DoxyCompactList}\item int \hyperlink{elgamal_8h_ab91d86edb1453350a8e4023e694474ec}{elgv1vrfy} (const \hyperlink{structmpbarrett}{mpbarrett} $\ast$p, const \hyperlink{structmpbarrett}{mpbarrett} $\ast$n, const \hyperlink{structmpnumber}{mpnumber} $\ast$g, const \hyperlink{structmpnumber}{mpnumber} $\ast$hm, const \hyperlink{structmpnumber}{mpnumber} $\ast$y, const \hyperlink{structmpnumber}{mpnumber} $\ast$r, const \hyperlink{structmpnumber}{mpnumber} $\ast$s) \begin{DoxyCompactList}\small\item\em This function performs raw ElGamal verification, variant 1. \item\end{DoxyCompactList}\item int \hyperlink{elgamal_8h_aaa1c3bb1ca269e9b40ee8a561a3f78f6}{elgv3vrfy} (const \hyperlink{structmpbarrett}{mpbarrett} $\ast$p, const \hyperlink{structmpbarrett}{mpbarrett} $\ast$n, const \hyperlink{structmpnumber}{mpnumber} $\ast$g, const \hyperlink{structmpnumber}{mpnumber} $\ast$hm, const \hyperlink{structmpnumber}{mpnumber} $\ast$y, const \hyperlink{structmpnumber}{mpnumber} $\ast$r, const \hyperlink{structmpnumber}{mpnumber} $\ast$s) \begin{DoxyCompactList}\small\item\em This function performs raw ElGamal verification, variant 3. \item\end{DoxyCompactList}\end{DoxyCompactItemize} \subsection{Detailed Description} ElGamal algorithm. For more information on this algorithm, see: \char`\"{}Handbook of Applied Cryptography\char`\"{}, 11.5.2: \char`\"{}The ElGamal signature scheme\char`\"{}, p. 454-\/459 Two of the signature variants in Note 11.70 are implemented. \begin{Desc} \item[\hyperlink{todo__todo000002}{Todo}]Implement ElGamal encryption and decryption.\end{Desc} \begin{Desc} \item[\hyperlink{todo__todo000003}{Todo}]Explore the possibility of using simultaneous multiple exponentiation, as described in HAC, 14.87 (iii).\end{Desc} \begin{DoxyAuthor}{Author} Bob Deblier $<$\href{mailto:bob.deblier@telenet.be}{\tt bob.deblier@telenet.be}$>$ \end{DoxyAuthor} \subsection{Function Documentation} \hypertarget{elgamal_8h_a71210da412fefa0f230a7f988eb83c31}{ \index{elgamal.h@{elgamal.h}!elgv1sign@{elgv1sign}} \index{elgv1sign@{elgv1sign}!elgamal.h@{elgamal.h}} \subsubsection[{elgv1sign}]{\setlength{\rightskip}{0pt plus 5cm}int elgv1sign ( \begin{DoxyParamCaption} \item[{const {\bf mpbarrett} $\ast$}]{p, } \item[{const {\bf mpbarrett} $\ast$}]{n, } \item[{const {\bf mpnumber} $\ast$}]{g, } \item[{{\bf randomGeneratorContext} $\ast$}]{rgc, } \item[{const {\bf mpnumber} $\ast$}]{hm, } \item[{const {\bf mpnumber} $\ast$}]{x, } \item[{{\bf mpnumber} $\ast$}]{r, } \item[{{\bf mpnumber} $\ast$}]{s} \end{DoxyParamCaption} )}} \label{elgamal_8h_a71210da412fefa0f230a7f988eb83c31} This function performs raw ElGamal signing, variant 1. Signing equations: \begin{DoxyItemize} \item $r=g^{k}\ \textrm{mod}\ p$ \item $s=k^{-1}(h(m)-xr)\ \textrm{mod}\ (p-1)$\end{DoxyItemize} \begin{DoxyParams}{Parameters} {\em p} & The prime. \\ \hline {\em n} & The reducer mod (p-\/1). \\ \hline {\em g} & The generator. \\ \hline {\em rgc} & The pseudo-\/random generat \\ \hline {\em hm} & The hash to be signed. \\ \hline {\em x} & The private key value. \\ \hline {\em r} & The signature's {\itshape r\/} value. \\ \hline {\em s} & The signature's {\itshape s\/} value. \\ \hline \end{DoxyParams} \begin{DoxyRetVals}{Return values} {\em 0} & on success. \\ \hline {\em -\/1} & on failure. \\ \hline \end{DoxyRetVals} \hypertarget{elgamal_8h_ab91d86edb1453350a8e4023e694474ec}{ \index{elgamal.h@{elgamal.h}!elgv1vrfy@{elgv1vrfy}} \index{elgv1vrfy@{elgv1vrfy}!elgamal.h@{elgamal.h}} \subsubsection[{elgv1vrfy}]{\setlength{\rightskip}{0pt plus 5cm}int elgv1vrfy ( \begin{DoxyParamCaption} \item[{const {\bf mpbarrett} $\ast$}]{p, } \item[{const {\bf mpbarrett} $\ast$}]{n, } \item[{const {\bf mpnumber} $\ast$}]{g, } \item[{const {\bf mpnumber} $\ast$}]{hm, } \item[{const {\bf mpnumber} $\ast$}]{y, } \item[{const {\bf mpnumber} $\ast$}]{r, } \item[{const {\bf mpnumber} $\ast$}]{s} \end{DoxyParamCaption} )}} \label{elgamal_8h_ab91d86edb1453350a8e4023e694474ec} This function performs raw ElGamal verification, variant 1. Verifying equations: \begin{DoxyItemize} \item Check $0<r<p$ and $0<s<(p-1)$ \item $v_1=y^{r}r^{s}\ \textrm{mod}\ p$ \item $v_2=g^{h(m)}\ \textrm{mod}\ p$ \item Check $v_1=v_2$\end{DoxyItemize} \begin{DoxyParams}{Parameters} {\em p} & The prime. \\ \hline {\em n} & The reducer mod (p-\/1). \\ \hline {\em g} & The generator. \\ \hline {\em hm} & The hash to be signed. \\ \hline {\em y} & The public key value. \\ \hline {\em r} & The signature's {\itshape r\/} value. \\ \hline {\em s} & The signature's {\itshape s\/} value. \\ \hline \end{DoxyParams} \begin{DoxyRetVals}{Return values} {\em 1} & on success. \\ \hline {\em 0} & on failure. \\ \hline \end{DoxyRetVals} \hypertarget{elgamal_8h_ab5a4857d59add82a522e0c08c83298f8}{ \index{elgamal.h@{elgamal.h}!elgv3sign@{elgv3sign}} \index{elgv3sign@{elgv3sign}!elgamal.h@{elgamal.h}} \subsubsection[{elgv3sign}]{\setlength{\rightskip}{0pt plus 5cm}int elgv3sign ( \begin{DoxyParamCaption} \item[{const {\bf mpbarrett} $\ast$}]{p, } \item[{const {\bf mpbarrett} $\ast$}]{n, } \item[{const {\bf mpnumber} $\ast$}]{g, } \item[{{\bf randomGeneratorContext} $\ast$}]{rgc, } \item[{const {\bf mpnumber} $\ast$}]{hm, } \item[{const {\bf mpnumber} $\ast$}]{x, } \item[{{\bf mpnumber} $\ast$}]{r, } \item[{{\bf mpnumber} $\ast$}]{s} \end{DoxyParamCaption} )}} \label{elgamal_8h_ab5a4857d59add82a522e0c08c83298f8} This function performs raw ElGamal signing, variant 3. Signing equations: \begin{DoxyItemize} \item $r=g^{k}\ \textrm{mod}\ p$ \item $s=xr+kh(m)\ \textrm{mod}\ (p-1)$\end{DoxyItemize} \begin{DoxyParams}{Parameters} {\em p} & The prime. \\ \hline {\em n} & The reducer mod (p-\/1). \\ \hline {\em g} & The generator. \\ \hline {\em rgc} & The pseudo-\/random generat \\ \hline {\em hm} & The hash to be signed. \\ \hline {\em x} & The private key value. \\ \hline {\em r} & The signature's {\itshape r\/} value. \\ \hline {\em s} & The signature's {\itshape s\/} value. \\ \hline \end{DoxyParams} \begin{DoxyRetVals}{Return values} {\em 0} & on success. \\ \hline {\em -\/1} & on failure. \\ \hline \end{DoxyRetVals} \hypertarget{elgamal_8h_aaa1c3bb1ca269e9b40ee8a561a3f78f6}{ \index{elgamal.h@{elgamal.h}!elgv3vrfy@{elgv3vrfy}} \index{elgv3vrfy@{elgv3vrfy}!elgamal.h@{elgamal.h}} \subsubsection[{elgv3vrfy}]{\setlength{\rightskip}{0pt plus 5cm}int elgv3vrfy ( \begin{DoxyParamCaption} \item[{const {\bf mpbarrett} $\ast$}]{p, } \item[{const {\bf mpbarrett} $\ast$}]{n, } \item[{const {\bf mpnumber} $\ast$}]{g, } \item[{const {\bf mpnumber} $\ast$}]{hm, } \item[{const {\bf mpnumber} $\ast$}]{y, } \item[{const {\bf mpnumber} $\ast$}]{r, } \item[{const {\bf mpnumber} $\ast$}]{s} \end{DoxyParamCaption} )}} \label{elgamal_8h_aaa1c3bb1ca269e9b40ee8a561a3f78f6} This function performs raw ElGamal verification, variant 3. Verifying equations: \begin{DoxyItemize} \item Check $0<r<p$ and $0<s<(p-1)$ \item $v_1=g^{s}\ \textrm{mod}\ p$ \item $v_2=y^{r}r^{h(m)}\ \textrm{mod}\ p$ \item Check $v_1=v_2$\end{DoxyItemize} \begin{DoxyParams}{Parameters} {\em p} & The prime. \\ \hline {\em n} & The reducer mod (p-\/1). \\ \hline {\em g} & The generator. \\ \hline {\em hm} & The hash to be signed. \\ \hline {\em y} & The public key value. \\ \hline {\em r} & The signature's {\itshape r\/} value. \\ \hline {\em s} & The signature's {\itshape s\/} value. \\ \hline \end{DoxyParams} \begin{DoxyRetVals}{Return values} {\em 1} & on success. \\ \hline {\em 0} & on failure. \\ \hline \end{DoxyRetVals}