<!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++: default.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>default.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_DEFAULT_H</span> <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_DEFAULT_H</span> <a name="l00003"></a>00003 <span class="preprocessor"></span> <a name="l00004"></a>00004 <span class="preprocessor">#include "sha.h"</span> <a name="l00005"></a>00005 <span class="preprocessor">#include "hmac.h"</span> <a name="l00006"></a>00006 <span class="preprocessor">#include "<a class="code" href="des_8h.html">des.h</a>"</span> <a name="l00007"></a>00007 <span class="preprocessor">#include "filters.h"</span> <a name="l00008"></a>00008 <span class="preprocessor">#include "<a class="code" href="modes_8h.html">modes.h</a>"</span> <a name="l00009"></a>00009 <a name="l00010"></a>00010 NAMESPACE_BEGIN(CryptoPP) <a name="l00011"></a>00011 <a name="l00012"></a>00012 typedef <a class="code" href="class_d_e_s___e_d_e2.html" title="DES-EDE2">DES_EDE2</a> <a class="code" href="class_d_e_s___e_d_e2.html" title="DES-EDE2">Default_BlockCipher</a>; <a name="l00013"></a>00013 typedef <a class="code" href="class_s_h_a1.html" title="SHA-1">SHA</a> <a class="code" href="class_s_h_a1.html" title="SHA-1">DefaultHashModule</a>; <a name="l00014"></a>00014 typedef <a class="code" href="class_h_m_a_c.html" title="HMAC">HMAC</a><DefaultHashModule> <a class="code" href="class_h_m_a_c.html" title="HMAC">DefaultMAC</a>; <a name="l00015"></a>00015 <span class="comment"></span> <a name="l00016"></a>00016 <span class="comment">//! Password-Based Encryptor using DES-EDE2</span> <a name="l00017"></a><a class="code" href="class_default_encryptor.html">00017</a> <span class="comment"></span>class <a class="code" href="class_default_encryptor.html" title="Password-Based Encryptor using DES-EDE2.">DefaultEncryptor</a> : public <a class="code" href="class_proxy_filter.html" title="Base class for Filter classes that are proxies for a chain of other filters.">ProxyFilter</a> <a name="l00018"></a>00018 { <a name="l00019"></a>00019 <span class="keyword">public</span>: <a name="l00020"></a>00020 <a class="code" href="class_default_encryptor.html" title="Password-Based Encryptor using DES-EDE2.">DefaultEncryptor</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *passphrase, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL); <a name="l00021"></a>00021 <a class="code" href="class_default_encryptor.html" title="Password-Based Encryptor using DES-EDE2.">DefaultEncryptor</a>(<span class="keyword">const</span> byte *passphrase, <span class="keywordtype">size_t</span> passphraseLength, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL); <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="keyword">protected</span>: <a name="l00024"></a>00024 <span class="keywordtype">void</span> FirstPut(<span class="keyword">const</span> byte *); <a name="l00025"></a>00025 <span class="keywordtype">void</span> LastPut(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length); <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="keyword">private</span>: <a name="l00028"></a>00028 <a class="code" href="class_sec_block.html">SecByteBlock</a> m_passphrase; <a name="l00029"></a>00029 <a class="code" href="struct_c_b_c___mode.html" title="CBC mode.">CBC_Mode<Default_BlockCipher>::Encryption</a> m_cipher; <a name="l00030"></a>00030 }; <a name="l00031"></a>00031 <span class="comment"></span> <a name="l00032"></a>00032 <span class="comment">//! Password-Based Decryptor using DES-EDE2</span> <a name="l00033"></a><a class="code" href="class_default_decryptor.html">00033</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_default_decryptor.html" title="Password-Based Decryptor using DES-EDE2.">DefaultDecryptor</a> : <span class="keyword">public</span> <a class="code" href="class_proxy_filter.html" title="Base class for Filter classes that are proxies for a chain of other filters.">ProxyFilter</a> <a name="l00034"></a>00034 { <a name="l00035"></a>00035 <span class="keyword">public</span>: <a name="l00036"></a>00036 <a class="code" href="class_default_decryptor.html" title="Password-Based Decryptor using DES-EDE2.">DefaultDecryptor</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *passphrase, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL, <span class="keywordtype">bool</span> throwException=<span class="keyword">true</span>); <a name="l00037"></a>00037 <a class="code" href="class_default_decryptor.html" title="Password-Based Decryptor using DES-EDE2.">DefaultDecryptor</a>(<span class="keyword">const</span> byte *passphrase, <span class="keywordtype">size_t</span> passphraseLength, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL, <span class="keywordtype">bool</span> throwException=<span class="keyword">true</span>); <a name="l00038"></a>00038 <a name="l00039"></a><a class="code" href="class_default_decryptor_1_1_err.html">00039</a> <span class="keyword">class </span><a class="code" href="class_default_decryptor_1_1_err.html">Err</a> : <span class="keyword">public</span> <a class="code" href="class_exception.html" title="base class for all exceptions thrown by Crypto++">Exception</a> <a name="l00040"></a>00040 { <a name="l00041"></a>00041 <span class="keyword">public</span>: <a name="l00042"></a>00042 <a class="code" href="class_default_decryptor_1_1_err.html">Err</a>(<span class="keyword">const</span> std::string &s) <a name="l00043"></a>00043 : <a class="code" href="class_exception.html" title="base class for all exceptions thrown by Crypto++">Exception</a>(<a class="code" href="class_exception.html#a8e53909d979479380e0274807c074c0aa77a639a803cf53052f9c76a0354247e6" title="data integerity check (such as CRC or MAC) failed">DATA_INTEGRITY_CHECK_FAILED</a>, s) {} <a name="l00044"></a>00044 }; <a name="l00045"></a><a class="code" href="class_default_decryptor_1_1_key_bad_err.html">00045</a> <span class="keyword">class </span><a class="code" href="class_default_decryptor_1_1_key_bad_err.html">KeyBadErr</a> : <span class="keyword">public</span> <a class="code" href="class_default_decryptor_1_1_err.html">Err</a> {<span class="keyword">public</span>: <a class="code" href="class_default_decryptor_1_1_key_bad_err.html">KeyBadErr</a>() : <a class="code" href="class_default_decryptor_1_1_err.html">Err</a>(<span class="stringliteral">"DefaultDecryptor: cannot decrypt message with this passphrase"</span>) {}}; <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="keyword">enum</span> State {WAITING_FOR_KEYCHECK, KEY_GOOD, KEY_BAD}; <a name="l00048"></a>00048 State CurrentState()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_state;} <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keyword">protected</span>: <a name="l00051"></a>00051 <span class="keywordtype">void</span> FirstPut(<span class="keyword">const</span> byte *inString); <a name="l00052"></a>00052 <span class="keywordtype">void</span> LastPut(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length); <a name="l00053"></a>00053 <a name="l00054"></a>00054 State m_state; <a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="keyword">private</span>: <a name="l00057"></a>00057 <span class="keywordtype">void</span> CheckKey(<span class="keyword">const</span> byte *salt, <span class="keyword">const</span> byte *keyCheck); <a name="l00058"></a>00058 <a name="l00059"></a>00059 <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> m_passphrase; <a name="l00060"></a>00060 <a class="code" href="struct_c_b_c___mode.html" title="CBC mode.">CBC_Mode<Default_BlockCipher>::Decryption</a> m_cipher; <a name="l00061"></a>00061 <a class="code" href="classmember__ptr.html">member_ptr<FilterWithBufferedInput></a> m_decryptor; <a name="l00062"></a>00062 <span class="keywordtype">bool</span> m_throwException; <a name="l00063"></a>00063 }; <a name="l00064"></a>00064 <span class="comment"></span> <a name="l00065"></a>00065 <span class="comment">//! Password-Based Encryptor using DES-EDE2 and HMAC/SHA-1</span> <a name="l00066"></a><a class="code" href="class_default_encryptor_with_m_a_c.html">00066</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_default_encryptor_with_m_a_c.html" title="Password-Based Encryptor using DES-EDE2 and HMAC/SHA-1.">DefaultEncryptorWithMAC</a> : <span class="keyword">public</span> <a class="code" href="class_proxy_filter.html" title="Base class for Filter classes that are proxies for a chain of other filters.">ProxyFilter</a> <a name="l00067"></a>00067 { <a name="l00068"></a>00068 <span class="keyword">public</span>: <a name="l00069"></a>00069 <a class="code" href="class_default_encryptor_with_m_a_c.html" title="Password-Based Encryptor using DES-EDE2 and HMAC/SHA-1.">DefaultEncryptorWithMAC</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *passphrase, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL); <a name="l00070"></a>00070 <a class="code" href="class_default_encryptor_with_m_a_c.html" title="Password-Based Encryptor using DES-EDE2 and HMAC/SHA-1.">DefaultEncryptorWithMAC</a>(<span class="keyword">const</span> byte *passphrase, <span class="keywordtype">size_t</span> passphraseLength, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL); <a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="keyword">protected</span>: <a name="l00073"></a>00073 <span class="keywordtype">void</span> FirstPut(<span class="keyword">const</span> byte *inString) {} <a name="l00074"></a>00074 <span class="keywordtype">void</span> LastPut(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length); <a name="l00075"></a>00075 <a name="l00076"></a>00076 <span class="keyword">private</span>: <a name="l00077"></a>00077 <a class="code" href="classmember__ptr.html">member_ptr<DefaultMAC></a> m_mac; <a name="l00078"></a>00078 }; <a name="l00079"></a>00079 <span class="comment"></span> <a name="l00080"></a>00080 <span class="comment">//! Password-Based Decryptor using DES-EDE2 and HMAC/SHA-1</span> <a name="l00081"></a><a class="code" href="class_default_decryptor_with_m_a_c.html">00081</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_default_decryptor_with_m_a_c.html" title="Password-Based Decryptor using DES-EDE2 and HMAC/SHA-1.">DefaultDecryptorWithMAC</a> : <span class="keyword">public</span> <a class="code" href="class_proxy_filter.html" title="Base class for Filter classes that are proxies for a chain of other filters.">ProxyFilter</a> <a name="l00082"></a>00082 { <a name="l00083"></a>00083 <span class="keyword">public</span>: <a name="l00084"></a><a class="code" href="class_default_decryptor_with_m_a_c_1_1_m_a_c_bad_err.html">00084</a> <span class="keyword">class </span><a class="code" href="class_default_decryptor_with_m_a_c_1_1_m_a_c_bad_err.html">MACBadErr</a> : <span class="keyword">public</span> <a class="code" href="class_default_decryptor.html" title="Password-Based Decryptor using DES-EDE2.">DefaultDecryptor</a>::Err {<span class="keyword">public</span>: <a class="code" href="class_default_decryptor_with_m_a_c_1_1_m_a_c_bad_err.html">MACBadErr</a>() : <a class="code" href="class_default_decryptor_1_1_err.html">DefaultDecryptor::Err</a>(<span class="stringliteral">"DefaultDecryptorWithMAC: MAC check failed"</span>) {}}; <a name="l00085"></a>00085 <a name="l00086"></a>00086 <a class="code" href="class_default_decryptor_with_m_a_c.html" title="Password-Based Decryptor using DES-EDE2 and HMAC/SHA-1.">DefaultDecryptorWithMAC</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *passphrase, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL, <span class="keywordtype">bool</span> throwException=<span class="keyword">true</span>); <a name="l00087"></a>00087 <a class="code" href="class_default_decryptor_with_m_a_c.html" title="Password-Based Decryptor using DES-EDE2 and HMAC/SHA-1.">DefaultDecryptorWithMAC</a>(<span class="keyword">const</span> byte *passphrase, <span class="keywordtype">size_t</span> passphraseLength, <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *attachment = NULL, <span class="keywordtype">bool</span> throwException=<span class="keyword">true</span>); <a name="l00088"></a>00088 <a name="l00089"></a>00089 DefaultDecryptor::State CurrentState() <span class="keyword">const</span>; <a name="l00090"></a>00090 <span class="keywordtype">bool</span> CheckLastMAC() <span class="keyword">const</span>; <a name="l00091"></a>00091 <a name="l00092"></a>00092 <span class="keyword">protected</span>: <a name="l00093"></a>00093 <span class="keywordtype">void</span> FirstPut(<span class="keyword">const</span> byte *inString) {} <a name="l00094"></a>00094 <span class="keywordtype">void</span> LastPut(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length); <a name="l00095"></a>00095 <a name="l00096"></a>00096 <span class="keyword">private</span>: <a name="l00097"></a>00097 <a class="code" href="classmember__ptr.html">member_ptr<DefaultMAC></a> m_mac; <a name="l00098"></a>00098 <a class="code" href="class_hash_verification_filter.html" title="Filter Wrapper for HashTransformation.">HashVerifier</a> *m_hashVerifier; <a name="l00099"></a>00099 <span class="keywordtype">bool</span> m_throwException; <a name="l00100"></a>00100 }; <a name="l00101"></a>00101 <a name="l00102"></a>00102 NAMESPACE_END <a name="l00103"></a>00103 <a name="l00104"></a>00104 <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>