<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.5"/> <title>BeeCrypt: include/beecrypt/blowfish.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">BeeCrypt  <span id="projectnumber">4.2.1</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.5 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_7519372152c32ce484a8cde0fb6b8cd0.html">beecrypt</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#nested-classes">Data Structures</a> | <a href="#define-members">Macros</a> | <a href="#func-members">Functions</a> | <a href="#var-members">Variables</a> </div> <div class="headertitle"> <div class="title">blowfish.h File Reference<div class="ingroups"><a class="el" href="group__BC__m.html">Block ciphers</a> | <a class="el" href="group__BC__blowfish__m.html">Block ciphers: Blowfish</a></div></div> </div> </div><!--header--> <div class="contents"> <p>Blowfish block cipher. <a href="#details">More...</a></p> <div class="textblock"><code>#include "<a class="el" href="beecrypt_8h_source.html">beecrypt/beecrypt.h</a>"</code><br/> <code>#include "<a class="el" href="blowfishopt_8h_source.html">beecrypt/blowfishopt.h</a>"</code><br/> </div><div class="textblock"><div class="dynheader"> Include dependency graph for blowfish.h:</div> <div class="dyncontent"> <div class="center"><img src="blowfish_8h__incl.png" border="0" usemap="#include_2beecrypt_2blowfish_8h" alt=""/></div> <map name="include_2beecrypt_2blowfish_8h" id="include_2beecrypt_2blowfish_8h"> <area shape="rect" id="node2" href="beecrypt_8h.html" title="BeeCrypt API, headers. " alt="" coords="467,155,604,181"/><area shape="rect" id="node20" href="blowfishopt_8h.html" title="Blowfish block cipher, assembler-optimized routines, headers. " alt="" coords="517,80,669,107"/><area shape="rect" id="node3" href="api_8h.html" title="BeeCrypt API, portability headers. " alt="" coords="444,379,548,405"/><area shape="rect" id="node15" href="memchunk_8h.html" title="beecrypt/memchunk.h" alt="" coords="461,229,611,256"/><area shape="rect" id="node16" href="mpnumber_8h.html" title="Multi-precision numbers, headers. " alt="" coords="635,229,783,256"/><area shape="rect" id="node4" href="gnu_8h.html" title="beecrypt/gnu.h" alt="" coords="442,453,549,480"/><area shape="rect" id="node17" href="mp_8h.html" title="Multi-precision integer routines. " alt="" coords="566,304,671,331"/><area shape="rect" id="node18" href="mpopt_8h.html" title="Multi-precision integer optimization definitions. " alt="" coords="572,379,695,405"/></map> </div> </div><div class="textblock"><div class="dynheader"> This graph shows which files directly or indirectly include this file:</div> <div class="dyncontent"> <div class="center"><img src="blowfish_8h__dep__incl.png" border="0" usemap="#include_2beecrypt_2blowfish_8hdep" alt=""/></div> <map name="include_2beecrypt_2blowfish_8hdep" id="include_2beecrypt_2blowfish_8hdep"> <area shape="rect" id="node2" href="blowfishopt_8h.html" title="Blowfish block cipher, assembler-optimized routines, headers. " alt="" coords="5,80,203,107"/></map> </div> </div> <p><a href="blowfish_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a> Data Structures</h2></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structblowfishParam.html">blowfishParam</a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight">Holds all the parameters necessary for the Blowfish cipher. <a href="structblowfishParam.html#details">More...</a><br/></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> Macros</h2></td></tr> <tr class="memitem:a320de9881e6c7560cd5b13828c420d5a"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#a320de9881e6c7560cd5b13828c420d5a">BLOWFISHROUNDS</a>   16</td></tr> <tr class="separator:a320de9881e6c7560cd5b13828c420d5a"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:aa638e9cb3cbf0ad5b94a25fdb9eb64c6"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#aa638e9cb3cbf0ad5b94a25fdb9eb64c6">BLOWFISHPSIZE</a>   (<a class="el" href="blowfish_8h.html#a320de9881e6c7560cd5b13828c420d5a">BLOWFISHROUNDS</a>+2)</td></tr> <tr class="separator:aa638e9cb3cbf0ad5b94a25fdb9eb64c6"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:acce3d0c95c67c98202e851063604819e"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#acce3d0c95c67c98202e851063604819e">blowfishSetup</a> (<a class="el" href="structblowfishParam.html">blowfishParam</a> *, const <a class="el" href="api_8h.html#ab8ef12fab634c171394422d0ee8baf94">byte</a> *, size_t, <a class="el" href="group__BC__m.html#gace10d4c0b0409d35c6a703d6445fc558">cipherOperation</a>)</td></tr> <tr class="memdesc:acce3d0c95c67c98202e851063604819e"><td class="mdescLeft"> </td><td class="mdescRight">The function performs the cipher's key expansion. <a href="#acce3d0c95c67c98202e851063604819e">More...</a><br/></td></tr> <tr class="separator:acce3d0c95c67c98202e851063604819e"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a56566a49f33043d7a443a7bbbcd7bd5f"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#a56566a49f33043d7a443a7bbbcd7bd5f">blowfishSetIV</a> (<a class="el" href="structblowfishParam.html">blowfishParam</a> *, const <a class="el" href="api_8h.html#ab8ef12fab634c171394422d0ee8baf94">byte</a> *iv)</td></tr> <tr class="memdesc:a56566a49f33043d7a443a7bbbcd7bd5f"><td class="mdescLeft"> </td><td class="mdescRight">This function sets the Initialization Vector. <a href="#a56566a49f33043d7a443a7bbbcd7bd5f">More...</a><br/></td></tr> <tr class="separator:a56566a49f33043d7a443a7bbbcd7bd5f"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a8bd243fafbf7c52359f19ab04de13c42"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#a8bd243fafbf7c52359f19ab04de13c42">blowfishSetCTR</a> (<a class="el" href="structblowfishParam.html">blowfishParam</a> *, const <a class="el" href="api_8h.html#ab8ef12fab634c171394422d0ee8baf94">byte</a> *nivz, size_t counter)</td></tr> <tr class="separator:a8bd243fafbf7c52359f19ab04de13c42"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a2b48ab4a1793739d266308d1033aee70"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#a2b48ab4a1793739d266308d1033aee70">blowfishEncrypt</a> (<a class="el" href="structblowfishParam.html">blowfishParam</a> *, uint32_t *, const uint32_t *)</td></tr> <tr class="memdesc:a2b48ab4a1793739d266308d1033aee70"><td class="mdescLeft"> </td><td class="mdescRight">This function performs the Blowfish encryption; it encrypts one block of 64 bits. <a href="#a2b48ab4a1793739d266308d1033aee70">More...</a><br/></td></tr> <tr class="separator:a2b48ab4a1793739d266308d1033aee70"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a6339ebc5b30a93680c152076ddd5f033"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#a6339ebc5b30a93680c152076ddd5f033">blowfishDecrypt</a> (<a class="el" href="structblowfishParam.html">blowfishParam</a> *, uint32_t *, const uint32_t *)</td></tr> <tr class="memdesc:a6339ebc5b30a93680c152076ddd5f033"><td class="mdescLeft"> </td><td class="mdescRight">This function performs the Blowfish decryption; it Rderypts one block of 64 bits. <a href="#a6339ebc5b30a93680c152076ddd5f033">More...</a><br/></td></tr> <tr class="separator:a6339ebc5b30a93680c152076ddd5f033"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ae2137286429679c247215465d99342c5"><td class="memItemLeft" align="right" valign="top">uint32_t * </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#ae2137286429679c247215465d99342c5">blowfishFeedback</a> (<a class="el" href="structblowfishParam.html">blowfishParam</a> *)</td></tr> <tr class="separator:ae2137286429679c247215465d99342c5"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a> Variables</h2></td></tr> <tr class="memitem:a58839854cfc0f9bcafd4b79ffd8e9d91"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="structblockCipher.html">blockCipher</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="blowfish_8h.html#a58839854cfc0f9bcafd4b79ffd8e9d91">blowfish</a></td></tr> <tr class="memdesc:a58839854cfc0f9bcafd4b79ffd8e9d91"><td class="mdescLeft"> </td><td class="mdescRight">Holds the full API description of the Blowfish algorithm. <a href="#a58839854cfc0f9bcafd4b79ffd8e9d91">More...</a><br/></td></tr> <tr class="separator:a58839854cfc0f9bcafd4b79ffd8e9d91"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Blowfish block cipher. </p> <p>For more information on this blockcipher, see: "Applied Cryptography", second edition Bruce Schneier Wiley & Sons</p> <p>Also see <a href="http://www.counterpane.com/blowfish.html">http://www.counterpane.com/blowfish.html</a></p> <dl class="section author"><dt>Author</dt><dd>Bob Deblier <a href="#" onclick="location.href='mai'+'lto:'+'bob'+'.d'+'ebl'+'ie'+'r@t'+'el'+'ene'+'t.'+'be'; return false;">bob.d<span style="display: none;">.nosp@m.</span>ebli<span style="display: none;">.nosp@m.</span>er@te<span style="display: none;">.nosp@m.</span>lene<span style="display: none;">.nosp@m.</span>t.be</a> </dd></dl> </div><h2 class="groupheader">Macro Definition Documentation</h2> <a class="anchor" id="aa638e9cb3cbf0ad5b94a25fdb9eb64c6"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define BLOWFISHPSIZE   (<a class="el" href="blowfish_8h.html#a320de9881e6c7560cd5b13828c420d5a">BLOWFISHROUNDS</a>+2)</td> </tr> </table> </div><div class="memdoc"> </div> </div> <a class="anchor" id="a320de9881e6c7560cd5b13828c420d5a"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define BLOWFISHROUNDS   16</td> </tr> </table> </div><div class="memdoc"> </div> </div> <h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="a6339ebc5b30a93680c152076ddd5f033"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">blowfishDecrypt </td> <td>(</td> <td class="paramtype"><a class="el" href="structblowfishParam.html">blowfishParam</a> * </td> <td class="paramname"><em>bp</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">uint32_t * </td> <td class="paramname"><em>dst</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const uint32_t * </td> <td class="paramname"><em>src</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>This function performs the Blowfish decryption; it Rderypts one block of 64 bits. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">bp</td><td>The cipher's parameter block. </td></tr> <tr><td class="paramname">dst</td><td>The cleartext; should be aligned on 32-bit boundary. </td></tr> <tr><td class="paramname">src</td><td>The ciphertext; should be aligned on 32-bit boundary. </td></tr> </table> </dd> </dl> <dl class="retval"><dt>Return values</dt><dd> <table class="retval"> <tr><td class="paramname">0</td><td>on success. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a2b48ab4a1793739d266308d1033aee70"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">blowfishEncrypt </td> <td>(</td> <td class="paramtype"><a class="el" href="structblowfishParam.html">blowfishParam</a> * </td> <td class="paramname"><em>bp</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">uint32_t * </td> <td class="paramname"><em>dst</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const uint32_t * </td> <td class="paramname"><em>src</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>This function performs the Blowfish encryption; it encrypts one block of 64 bits. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">bp</td><td>The cipher's parameter block. </td></tr> <tr><td class="paramname">dst</td><td>The ciphertext; should be aligned on 32-bit boundary. </td></tr> <tr><td class="paramname">src</td><td>The cleartext; should be aligned on 32-bit boundary. </td></tr> </table> </dd> </dl> <dl class="retval"><dt>Return values</dt><dd> <table class="retval"> <tr><td class="paramname">0</td><td>on success. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="ae2137286429679c247215465d99342c5"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">uint32_t* blowfishFeedback </td> <td>(</td> <td class="paramtype"><a class="el" href="structblowfishParam.html">blowfishParam</a> * </td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> </div> </div> <a class="anchor" id="a8bd243fafbf7c52359f19ab04de13c42"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int blowfishSetCTR </td> <td>(</td> <td class="paramtype"><a class="el" href="structblowfishParam.html">blowfishParam</a> * </td> <td class="paramname">, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="api_8h.html#ab8ef12fab634c171394422d0ee8baf94">byte</a> * </td> <td class="paramname"><em>nivz</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t </td> <td class="paramname"><em>counter</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> </div> </div> <a class="anchor" id="a56566a49f33043d7a443a7bbbcd7bd5f"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int blowfishSetIV </td> <td>(</td> <td class="paramtype"><a class="el" href="structblowfishParam.html">blowfishParam</a> * </td> <td class="paramname"><em>bp</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="api_8h.html#ab8ef12fab634c171394422d0ee8baf94">byte</a> * </td> <td class="paramname"><em>iv</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>This function sets the Initialization Vector. </p> <dl class="section note"><dt>Note</dt><dd>This function is only useful in block chaining or feedback modes. </dd></dl> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">bp</td><td>The cipher's parameter block. </td></tr> <tr><td class="paramname">iv</td><td>The initialization vector; may be null. </td></tr> </table> </dd> </dl> <dl class="retval"><dt>Return values</dt><dd> <table class="retval"> <tr><td class="paramname">0</td><td>on success. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="acce3d0c95c67c98202e851063604819e"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int blowfishSetup </td> <td>(</td> <td class="paramtype"><a class="el" href="structblowfishParam.html">blowfishParam</a> * </td> <td class="paramname"><em>bp</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="api_8h.html#ab8ef12fab634c171394422d0ee8baf94">byte</a> * </td> <td class="paramname"><em>key</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t </td> <td class="paramname"><em>keybits</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="group__BC__m.html#gace10d4c0b0409d35c6a703d6445fc558">cipherOperation</a> </td> <td class="paramname"><em>op</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>The function performs the cipher's key expansion. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">bp</td><td>The cipher's parameter block. </td></tr> <tr><td class="paramname">key</td><td>The key value. </td></tr> <tr><td class="paramname">keybits</td><td>The number of bits in the key; legal values are: 32 to 448, in multiples of 8. </td></tr> <tr><td class="paramname">op</td><td>ENCRYPT or DECRYPT. </td></tr> </table> </dd> </dl> <dl class="retval"><dt>Return values</dt><dd> <table class="retval"> <tr><td class="paramname">0</td><td>on success. </td></tr> <tr><td class="paramname">-1</td><td>on failure. </td></tr> </table> </dd> </dl> </div> </div> <h2 class="groupheader">Variable Documentation</h2> <a class="anchor" id="a58839854cfc0f9bcafd4b79ffd8e9d91"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">blowfish</td> </tr> </table> </div><div class="memdoc"> <p>Holds the full API description of the Blowfish algorithm. </p> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Fri Sep 27 2013 02:36:25 for BeeCrypt by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.5 </small></address> </body> </html>