<!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"/> <title>PolarSSL: polarssl/des.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body onload='searchBox.OnSelectItem(0);'> <!-- Generated by Doxygen 1.7.4 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">PolarSSL</div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li id="searchli"> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </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>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">polarssl/des.h</div> </div> </div> <div class="contents"> <a href="des_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00025"></a>00025 <span class="preprocessor">#ifndef POLARSSL_DES_H</span> <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define POLARSSL_DES_H</span> <a name="l00027"></a>00027 <span class="preprocessor"></span> <a name="l00028"></a>00028 <span class="preprocessor">#define DES_ENCRYPT 1</span> <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define DES_DECRYPT 0</span> <a name="l00030"></a>00030 <span class="preprocessor"></span> <a name="l00031"></a>00031 <span class="preprocessor">#define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH -0x0C00</span> <a name="l00032"></a>00032 <span class="preprocessor"></span> <a name="l00036"></a><a class="code" href="structdes__context.html">00036</a> <span class="keyword">typedef</span> <span class="keyword">struct</span> <a name="l00037"></a>00037 { <a name="l00038"></a><a class="code" href="structdes__context.html#ad74deaba449f48518e3610d89bc04bbd">00038</a> <span class="keywordtype">int</span> <a class="code" href="structdes__context.html#ad74deaba449f48518e3610d89bc04bbd">mode</a>; <a name="l00039"></a><a class="code" href="structdes__context.html#a288e79d9700956e804b8ed7a140e4d6e">00039</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> sk[32]; <a name="l00040"></a>00040 } <a name="l00041"></a>00041 <a class="code" href="structdes__context.html" title="DES context structure.">des_context</a>; <a name="l00042"></a>00042 <a name="l00046"></a><a class="code" href="structdes3__context.html">00046</a> <span class="keyword">typedef</span> <span class="keyword">struct</span> <a name="l00047"></a>00047 { <a name="l00048"></a><a class="code" href="structdes3__context.html#a609e7e53195aded2a1fd72201322becf">00048</a> <span class="keywordtype">int</span> <a class="code" href="structdes3__context.html#a609e7e53195aded2a1fd72201322becf">mode</a>; <a name="l00049"></a><a class="code" href="structdes3__context.html#a1f2e45ce7a0e9b8d733f6c56307aa388">00049</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> sk[96]; <a name="l00050"></a>00050 } <a name="l00051"></a>00051 <a class="code" href="structdes3__context.html" title="Triple-DES context structure.">des3_context</a>; <a name="l00052"></a>00052 <a name="l00053"></a>00053 <span class="preprocessor">#ifdef __cplusplus</span> <a name="l00054"></a>00054 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> { <a name="l00055"></a>00055 <span class="preprocessor">#endif</span> <a name="l00056"></a>00056 <span class="preprocessor"></span> <a name="l00063"></a>00063 <span class="keywordtype">void</span> <a class="code" href="des_8h.html#aee64993375c58c97b3fc965f76645232" title="DES key schedule (56-bit, encryption)">des_setkey_enc</a>( <a class="code" href="structdes__context.html" title="DES context structure.">des_context</a> *ctx, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> key[8] ); <a name="l00064"></a>00064 <a name="l00071"></a>00071 <span class="keywordtype">void</span> <a class="code" href="des_8h.html#a7dffe952ce9419e747d0a4633946eabd" title="DES key schedule (56-bit, decryption)">des_setkey_dec</a>( <a class="code" href="structdes__context.html" title="DES context structure.">des_context</a> *ctx, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> key[8] ); <a name="l00072"></a>00072 <a name="l00079"></a>00079 <span class="keywordtype">void</span> <a class="code" href="des_8h.html#a8cf7aa7333feb45e083f3f4ffe32ab74" title="Triple-DES key schedule (112-bit, encryption)">des3_set2key_enc</a>( <a class="code" href="structdes3__context.html" title="Triple-DES context structure.">des3_context</a> *ctx, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> key[16] ); <a name="l00080"></a>00080 <a name="l00087"></a>00087 <span class="keywordtype">void</span> <a class="code" href="des_8h.html#a29a04fcca2236e62a119381645b65782" title="Triple-DES key schedule (112-bit, decryption)">des3_set2key_dec</a>( <a class="code" href="structdes3__context.html" title="Triple-DES context structure.">des3_context</a> *ctx, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> key[16] ); <a name="l00088"></a>00088 <a name="l00095"></a>00095 <span class="keywordtype">void</span> <a class="code" href="des_8h.html#a6aba8975626002db39adaa92a1d1ed90" title="Triple-DES key schedule (168-bit, encryption)">des3_set3key_enc</a>( <a class="code" href="structdes3__context.html" title="Triple-DES context structure.">des3_context</a> *ctx, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> key[24] ); <a name="l00096"></a>00096 <a name="l00103"></a>00103 <span class="keywordtype">void</span> <a class="code" href="des_8h.html#ada6d7a926e262017c012a5e160b6f26e" title="Triple-DES key schedule (168-bit, decryption)">des3_set3key_dec</a>( <a class="code" href="structdes3__context.html" title="Triple-DES context structure.">des3_context</a> *ctx, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> key[24] ); <a name="l00104"></a>00104 <a name="l00114"></a>00114 <span class="keywordtype">int</span> <a class="code" href="des_8h.html#a92ee6c66c1fd47cd3eba61736d0478b1" title="DES-ECB block encryption/decryption.">des_crypt_ecb</a>( <a class="code" href="structdes__context.html" title="DES context structure.">des_context</a> *ctx, <a name="l00115"></a>00115 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> input[8], <a name="l00116"></a>00116 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> output[8] ); <a name="l00117"></a>00117 <a name="l00128"></a>00128 <span class="keywordtype">int</span> <a class="code" href="des_8h.html#aa1da20413e9e803a8fcf9011643dcdaf" title="DES-CBC buffer encryption/decryption.">des_crypt_cbc</a>( <a class="code" href="structdes__context.html" title="DES context structure.">des_context</a> *ctx, <a name="l00129"></a>00129 <span class="keywordtype">int</span> mode, <a name="l00130"></a>00130 <span class="keywordtype">int</span> length, <a name="l00131"></a>00131 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> iv[8], <a name="l00132"></a>00132 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *input, <a name="l00133"></a>00133 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *output ); <a name="l00134"></a>00134 <a name="l00144"></a>00144 <span class="keywordtype">int</span> <a class="code" href="des_8h.html#ac404a5ef3c0602cdc31c9e0e74530b0a" title="3DES-ECB block encryption/decryption">des3_crypt_ecb</a>( <a class="code" href="structdes3__context.html" title="Triple-DES context structure.">des3_context</a> *ctx, <a name="l00145"></a>00145 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> input[8], <a name="l00146"></a>00146 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> output[8] ); <a name="l00147"></a>00147 <a name="l00160"></a>00160 <span class="keywordtype">int</span> <a class="code" href="des_8h.html#a16ce54d365b8f1a963518bf6c9a24521" title="3DES-CBC buffer encryption/decryption">des3_crypt_cbc</a>( <a class="code" href="structdes3__context.html" title="Triple-DES context structure.">des3_context</a> *ctx, <a name="l00161"></a>00161 <span class="keywordtype">int</span> mode, <a name="l00162"></a>00162 <span class="keywordtype">int</span> length, <a name="l00163"></a>00163 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> iv[8], <a name="l00164"></a>00164 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *input, <a name="l00165"></a>00165 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *output ); <a name="l00166"></a>00166 <a name="l00167"></a>00167 <span class="comment">/*</span> <a name="l00168"></a>00168 <span class="comment"> * \brief Checkup routine</span> <a name="l00169"></a>00169 <span class="comment"> *</span> <a name="l00170"></a>00170 <span class="comment"> * \return 0 if successful, or 1 if the test failed</span> <a name="l00171"></a>00171 <span class="comment"> */</span> <a name="l00172"></a>00172 <span class="keywordtype">int</span> des_self_test( <span class="keywordtype">int</span> verbose ); <a name="l00173"></a>00173 <a name="l00174"></a>00174 <span class="preprocessor">#ifdef __cplusplus</span> <a name="l00175"></a>00175 <span class="preprocessor"></span>} <a name="l00176"></a>00176 <span class="preprocessor">#endif</span> <a name="l00177"></a>00177 <span class="preprocessor"></span> <a name="l00178"></a>00178 <span class="preprocessor">#endif </span><span class="comment">/* des.h */</span> </pre></div></div> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Defines</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr class="footer"/><address class="footer"><small>Generated on Mon May 16 2011 for PolarSSL by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>