<!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>Crypto++: salsa.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</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> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>salsa.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// salsa.h - written and placed in the public domain by Wei Dai</span> <a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="preprocessor">#ifndef CRYPTOPP_SALSA_H</span> <a name="l00004"></a>00004 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_SALSA_H</span> <a name="l00005"></a>00005 <span class="preprocessor"></span> <a name="l00006"></a>00006 <span class="preprocessor">#include "<a class="code" href="strciphr_8h.html">strciphr.h</a>"</span> <a name="l00007"></a>00007 <a name="l00008"></a>00008 NAMESPACE_BEGIN(CryptoPP) <a name="l00009"></a>00009 <a name="l00010"></a>00010 <span class="comment">//! _</span> <a name="l00011"></a><a class="code" href="struct_salsa20___info.html">00011</a> <span class="comment"></span>struct <a class="code" href="struct_salsa20___info.html" title="_">Salsa20_Info</a> : public <a class="code" href="class_variable_key_length.html" title="support query of variable key length, template parameters are default, min, max,...">VariableKeyLength</a><32, 16, 32, 16, <a class="code" href="class_simple_keying_interface.html" title="keying interface for crypto algorithms that take byte strings as keys">SimpleKeyingInterface</a>::UNIQUE_IV, 8> <a name="l00012"></a>00012 { <a name="l00013"></a>00013 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"Salsa20"</span>;} <a name="l00014"></a>00014 }; <a name="l00015"></a>00015 <a name="l00016"></a><a class="code" href="class_salsa20___policy.html">00016</a> <span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_salsa20___policy.html">Salsa20_Policy</a> : <span class="keyword">public</span> <a class="code" href="struct_additive_cipher_concrete_policy.html">AdditiveCipherConcretePolicy</a><word32, 16> <a name="l00017"></a>00017 { <a name="l00018"></a>00018 <span class="keyword">protected</span>: <a name="l00019"></a>00019 <span class="keywordtype">void</span> CipherSetKey(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &params, <span class="keyword">const</span> byte *key, <span class="keywordtype">size_t</span> length); <a name="l00020"></a>00020 <span class="keywordtype">void</span> OperateKeystream(KeystreamOperation operation, byte *output, <span class="keyword">const</span> byte *input, <span class="keywordtype">size_t</span> iterationCount); <a name="l00021"></a>00021 <span class="keywordtype">void</span> CipherResynchronize(byte *keystreamBuffer, <span class="keyword">const</span> byte *IV, <span class="keywordtype">size_t</span> length); <a name="l00022"></a>00022 <span class="keywordtype">bool</span> CipherIsRandomAccess()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">true</span>;} <a name="l00023"></a>00023 <span class="keywordtype">void</span> SeekToIteration(lword iterationCount); <a name="l00024"></a>00024 <span class="preprocessor">#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64</span> <a name="l00025"></a>00025 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetAlignment() <span class="keyword">const</span>; <a name="l00026"></a>00026 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetOptimalBlockSize() <span class="keyword">const</span>; <a name="l00027"></a>00027 <span class="preprocessor">#endif</span> <a name="l00028"></a>00028 <span class="preprocessor"></span> <a name="l00029"></a>00029 <a class="code" href="class_fixed_size_aligned_sec_block.html">FixedSizeAlignedSecBlock<word32, 16></a> m_state; <a name="l00030"></a>00030 <span class="keywordtype">int</span> m_rounds; <a name="l00031"></a>00031 }; <a name="l00032"></a>00032 <span class="comment"></span> <a name="l00033"></a>00033 <span class="comment">/// <a href="http://www.cryptolounge.org/wiki/Salsa20">Salsa20</a>, variable rounds: 8, 12 or 20 (default 20)</span> <a name="l00034"></a><a class="code" href="struct_salsa20.html">00034</a> <span class="comment"></span><span class="keyword">struct </span><a class="code" href="struct_salsa20.html" title="Salsa20, variable rounds: 8, 12 or 20 (default 20)">Salsa20</a> : <span class="keyword">public</span> <a class="code" href="struct_salsa20___info.html" title="_">Salsa20_Info</a>, <span class="keyword">public</span> <a class="code" href="struct_symmetric_cipher_documentation.html" title="Each class derived from this one defines two types, Encryption and Decryption, both...">SymmetricCipherDocumentation</a> <a name="l00035"></a>00035 { <a name="l00036"></a><a class="code" href="struct_salsa20.html#afd19ece998349d70ad9a9dfc31bf2718">00036</a> <span class="keyword">typedef</span> <a class="code" href="class_symmetric_cipher_final.html" title="_">SymmetricCipherFinal<ConcretePolicyHolder<Salsa20_Policy, AdditiveCipherTemplate<></a> >, <a class="code" href="struct_salsa20___info.html" title="_">Salsa20_Info</a>> <a class="code" href="class_symmetric_cipher_final.html" title="_">Encryption</a>; <a name="l00037"></a><a class="code" href="struct_salsa20.html#a2daea7c39af63c821da7d3a5caca7ae0">00037</a> <span class="keyword">typedef</span> <a class="code" href="class_symmetric_cipher_final.html" title="_">Encryption</a> <a class="code" href="class_symmetric_cipher_final.html" title="_">Decryption</a>; <a name="l00038"></a>00038 }; <a name="l00039"></a>00039 <span class="comment"></span> <a name="l00040"></a>00040 <span class="comment">//! _</span> <a name="l00041"></a><a class="code" href="struct_x_salsa20___info.html">00041</a> <span class="comment"></span><span class="keyword">struct </span><a class="code" href="struct_x_salsa20___info.html" title="_">XSalsa20_Info</a> : <span class="keyword">public</span> <a class="code" href="class_fixed_key_length.html" title="to be inherited by keyed algorithms with fixed key length">FixedKeyLength</a><32, SimpleKeyingInterface::UNIQUE_IV, 24> <a name="l00042"></a>00042 { <a name="l00043"></a>00043 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"XSalsa20"</span>;} <a name="l00044"></a>00044 }; <a name="l00045"></a>00045 <a name="l00046"></a><a class="code" href="class_x_salsa20___policy.html">00046</a> <span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_x_salsa20___policy.html">XSalsa20_Policy</a> : <span class="keyword">public</span> <a class="code" href="class_salsa20___policy.html">Salsa20_Policy</a> <a name="l00047"></a>00047 { <a name="l00048"></a>00048 <span class="keyword">public</span>: <a name="l00049"></a>00049 <span class="keywordtype">void</span> CipherSetKey(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &params, <span class="keyword">const</span> byte *key, <span class="keywordtype">size_t</span> length); <a name="l00050"></a>00050 <span class="keywordtype">void</span> CipherResynchronize(byte *keystreamBuffer, <span class="keyword">const</span> byte *IV, <span class="keywordtype">size_t</span> length); <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keyword">protected</span>: <a name="l00053"></a>00053 <a class="code" href="class_fixed_size_sec_block.html">FixedSizeSecBlock<word32, 8></a> m_key; <a name="l00054"></a>00054 }; <a name="l00055"></a>00055 <span class="comment"></span> <a name="l00056"></a>00056 <span class="comment">/// <a href="http://www.cryptolounge.org/wiki/XSalsa20">XSalsa20</a>, variable rounds: 8, 12 or 20 (default 20)</span> <a name="l00057"></a><a class="code" href="struct_x_salsa20.html">00057</a> <span class="comment"></span><span class="keyword">struct </span><a class="code" href="struct_x_salsa20.html" title="XSalsa20, variable rounds: 8, 12 or 20 (default 20)">XSalsa20</a> : <span class="keyword">public</span> <a class="code" href="struct_x_salsa20___info.html" title="_">XSalsa20_Info</a>, <span class="keyword">public</span> <a class="code" href="struct_symmetric_cipher_documentation.html" title="Each class derived from this one defines two types, Encryption and Decryption, both...">SymmetricCipherDocumentation</a> <a name="l00058"></a>00058 { <a name="l00059"></a><a class="code" href="struct_x_salsa20.html#a85227819eec510aeda514425e87243e1">00059</a> <span class="keyword">typedef</span> <a class="code" href="class_symmetric_cipher_final.html" title="_">SymmetricCipherFinal<ConcretePolicyHolder<XSalsa20_Policy, AdditiveCipherTemplate<></a> >, <a class="code" href="struct_x_salsa20___info.html" title="_">XSalsa20_Info</a>> <a class="code" href="class_symmetric_cipher_final.html" title="_">Encryption</a>; <a name="l00060"></a><a class="code" href="struct_x_salsa20.html#afb1d31b7cf5663762c3093bbbd4ff18a">00060</a> <span class="keyword">typedef</span> <a class="code" href="class_symmetric_cipher_final.html" title="_">Encryption</a> <a class="code" href="class_symmetric_cipher_final.html" title="_">Decryption</a>; <a name="l00061"></a>00061 }; <a name="l00062"></a>00062 <a name="l00063"></a>00063 NAMESPACE_END <a name="l00064"></a>00064 <a name="l00065"></a>00065 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on 9 Dec 2009 for Crypto++ by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>