Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > d1d38291248b5ff58339d3d2ddb22ecd > files > 1310

lib64beecrypt-devel-4.2.1-13.mga4.x86_64.rpm

\hypertarget{rsa_8h}{\section{include/beecrypt/rsa.h File Reference}
\label{rsa_8h}\index{include/beecrypt/rsa.\-h@{include/beecrypt/rsa.\-h}}
}


R\-S\-A algorithm.  


{\ttfamily \#include \char`\"{}beecrypt/rsakp.\-h\char`\"{}}\\*
Include dependency graph for rsa.\-h\-:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{rsa_8h__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{rsa_8h_a56d0efcbcd2a35d462b32760529fc72f}{rsapub} (const \hyperlink{structmpbarrett}{mpbarrett} $\ast$n, const \hyperlink{structmpnumber}{mpnumber} $\ast$e, const \hyperlink{structmpnumber}{mpnumber} $\ast$m, \hyperlink{structmpnumber}{mpnumber} $\ast$c)
\begin{DoxyCompactList}\small\item\em This function performs a raw R\-S\-A public key operation. \end{DoxyCompactList}\item 
int \hyperlink{rsa_8h_a98805e27f1b3f3d009547408b17c5dac}{rsapri} (const \hyperlink{structmpbarrett}{mpbarrett} $\ast$n, const \hyperlink{structmpnumber}{mpnumber} $\ast$d, const \hyperlink{structmpnumber}{mpnumber} $\ast$c, \hyperlink{structmpnumber}{mpnumber} $\ast$m)
\begin{DoxyCompactList}\small\item\em This function performs a raw R\-S\-A private key operation. \end{DoxyCompactList}\item 
int \hyperlink{rsa_8h_a9b9fc03593383e25bc06d8acab0a276a}{rsapricrt} (const \hyperlink{structmpbarrett}{mpbarrett} $\ast$n, const \hyperlink{structmpbarrett}{mpbarrett} $\ast$p, const \hyperlink{structmpbarrett}{mpbarrett} $\ast$q, const \hyperlink{structmpnumber}{mpnumber} $\ast$dp, const \hyperlink{structmpnumber}{mpnumber} $\ast$dq, const \hyperlink{structmpnumber}{mpnumber} $\ast$qi, const \hyperlink{structmpnumber}{mpnumber} $\ast$c, \hyperlink{structmpnumber}{mpnumber} $\ast$m)
\begin{DoxyCompactList}\small\item\em This function performs a raw R\-S\-A private key operation, with application of the Chinese Remainder Theorem. \end{DoxyCompactList}\item 
int \hyperlink{rsa_8h_aca849ebe0d68770764957907baf891b0}{rsavrfy} (const \hyperlink{structmpbarrett}{mpbarrett} $\ast$n, const \hyperlink{structmpnumber}{mpnumber} $\ast$e, const \hyperlink{structmpnumber}{mpnumber} $\ast$m, const \hyperlink{structmpnumber}{mpnumber} $\ast$c)
\begin{DoxyCompactList}\small\item\em This function performs a raw R\-S\-A verification. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
R\-S\-A algorithm. \begin{DoxyAuthor}{Author}
Bob Deblier \href{mailto:bob.deblier@telenet.be}{\tt bob.\-deblier@telenet.\-be} 
\end{DoxyAuthor}


\subsection{Function Documentation}
\hypertarget{rsa_8h_a98805e27f1b3f3d009547408b17c5dac}{\index{rsa.\-h@{rsa.\-h}!rsapri@{rsapri}}
\index{rsapri@{rsapri}!rsa.h@{rsa.\-h}}
\subsubsection[{rsapri}]{\setlength{\rightskip}{0pt plus 5cm}int rsapri (
\begin{DoxyParamCaption}
\item[{const {\bf mpbarrett} $\ast$}]{n, }
\item[{const {\bf mpnumber} $\ast$}]{d, }
\item[{const {\bf mpnumber} $\ast$}]{c, }
\item[{{\bf mpnumber} $\ast$}]{m}
\end{DoxyParamCaption}
)}}\label{rsa_8h_a98805e27f1b3f3d009547408b17c5dac}


This function performs a raw R\-S\-A private key operation. 

This function can be used for decryption and signing.

It performs the operation\-: \begin{DoxyItemize}
\item $m=c^{d}\ \textrm{mod}\ n$\end{DoxyItemize}

\begin{DoxyParams}{Parameters}
{\em n} & The modulus. \\
\hline
{\em d} & The private exponent. \\
\hline
{\em c} & The ciphertext. \\
\hline
{\em m} & The message. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & on success. \\
\hline
{\em -\/1} & on failure. \\
\hline
\end{DoxyRetVals}
\hypertarget{rsa_8h_a9b9fc03593383e25bc06d8acab0a276a}{\index{rsa.\-h@{rsa.\-h}!rsapricrt@{rsapricrt}}
\index{rsapricrt@{rsapricrt}!rsa.h@{rsa.\-h}}
\subsubsection[{rsapricrt}]{\setlength{\rightskip}{0pt plus 5cm}int rsapricrt (
\begin{DoxyParamCaption}
\item[{const {\bf mpbarrett} $\ast$}]{n, }
\item[{const {\bf mpbarrett} $\ast$}]{p, }
\item[{const {\bf mpbarrett} $\ast$}]{q, }
\item[{const {\bf mpnumber} $\ast$}]{dp, }
\item[{const {\bf mpnumber} $\ast$}]{dq, }
\item[{const {\bf mpnumber} $\ast$}]{qi, }
\item[{const {\bf mpnumber} $\ast$}]{c, }
\item[{{\bf mpnumber} $\ast$}]{m}
\end{DoxyParamCaption}
)}}\label{rsa_8h_a9b9fc03593383e25bc06d8acab0a276a}


This function performs a raw R\-S\-A private key operation, with application of the Chinese Remainder Theorem. 

It performs the operation\-: \begin{DoxyItemize}
\item $j_1=c^{dp}\ \textrm{mod}\ p$ \item $j_2=c^{dq}\ \textrm{mod}\ q$ \item $h=qi \cdot (j_1-j_2)\ \textrm{mod}\ p$ \item $m=j_2+hq$\end{DoxyItemize}

\begin{DoxyParams}{Parameters}
{\em n} & The modulus. \\
\hline
{\em p} & The first prime factor. \\
\hline
{\em q} & The second prime factor. \\
\hline
{\em dp} & The private exponent d mod (p-\/1). \\
\hline
{\em dq} & The private exponent d (q-\/1). \\
\hline
{\em qi} & The inverse of q mod p. \\
\hline
{\em c} & The ciphertext. \\
\hline
{\em m} & The message. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & on success. \\
\hline
{\em -\/1} & on failure. \\
\hline
\end{DoxyRetVals}
\hypertarget{rsa_8h_a56d0efcbcd2a35d462b32760529fc72f}{\index{rsa.\-h@{rsa.\-h}!rsapub@{rsapub}}
\index{rsapub@{rsapub}!rsa.h@{rsa.\-h}}
\subsubsection[{rsapub}]{\setlength{\rightskip}{0pt plus 5cm}int rsapub (
\begin{DoxyParamCaption}
\item[{const {\bf mpbarrett} $\ast$}]{n, }
\item[{const {\bf mpnumber} $\ast$}]{e, }
\item[{const {\bf mpnumber} $\ast$}]{m, }
\item[{{\bf mpnumber} $\ast$}]{c}
\end{DoxyParamCaption}
)}}\label{rsa_8h_a56d0efcbcd2a35d462b32760529fc72f}


This function performs a raw R\-S\-A public key operation. 

This function can be used for encryption and verifying.

It performs the following operation\-: \begin{DoxyItemize}
\item $c=m^{e}\ \textrm{mod}\ n$\end{DoxyItemize}

\begin{DoxyParams}{Parameters}
{\em n} & The R\-S\-A modulus. \\
\hline
{\em e} & The R\-S\-A public exponent. \\
\hline
{\em m} & The message. \\
\hline
{\em c} & The ciphertext. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & on success. \\
\hline
{\em -\/1} & on failure. \\
\hline
\end{DoxyRetVals}
\hypertarget{rsa_8h_aca849ebe0d68770764957907baf891b0}{\index{rsa.\-h@{rsa.\-h}!rsavrfy@{rsavrfy}}
\index{rsavrfy@{rsavrfy}!rsa.h@{rsa.\-h}}
\subsubsection[{rsavrfy}]{\setlength{\rightskip}{0pt plus 5cm}int rsavrfy (
\begin{DoxyParamCaption}
\item[{const {\bf mpbarrett} $\ast$}]{n, }
\item[{const {\bf mpnumber} $\ast$}]{e, }
\item[{const {\bf mpnumber} $\ast$}]{m, }
\item[{const {\bf mpnumber} $\ast$}]{c}
\end{DoxyParamCaption}
)}}\label{rsa_8h_aca849ebe0d68770764957907baf891b0}


This function performs a raw R\-S\-A verification. 

It verifies if ciphertext {\itshape c} was encrypted from cleartext {\itshape m} with the private key matching the given public key {\itshape }(n, e).


\begin{DoxyParams}{Parameters}
{\em n} & The modulus. \\
\hline
{\em e} & The public exponent. \\
\hline
{\em m} & The cleartext message. \\
\hline
{\em c} & The ciphertext message. \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 1} & on success. \\
\hline
{\em 0} & on failure. \\
\hline
\end{DoxyRetVals}