📄 des_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Crypto++: des.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.2 --><div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Compound List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Compound Members</a> | <a class="qindex" href="globals.html">File Members</a></div><h1>des.h</h1><a href="des_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#ifndef CRYPTOPP_DES_H</span>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_DES_H</span>00003 <span class="preprocessor"></span><span class="comment"></span>00004 <span class="comment">/** \file</span>00005 <span class="comment">*/</span>00006 00007 <span class="preprocessor">#include "seckey.h"</span>00008 <span class="preprocessor">#include "secblock.h"</span>00009 00010 NAMESPACE_BEGIN(CryptoPP)00011 00012 <span class="keyword">class </span>CRYPTOPP_DLL RawDES00013 {00014 <span class="keyword">public</span>:00015 <span class="keywordtype">void</span> UncheckedSetKey(CipherDir direction, <span class="keyword">const</span> byte *userKey, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length = 8);00016 <span class="keywordtype">void</span> RawProcessBlock(word32 &l, word32 &r) <span class="keyword">const</span>;00017 00018 <span class="keyword">protected</span>:00019 <span class="keyword">static</span> <span class="keyword">const</span> word32 Spbox[8][64];00020 00021 FixedSizeSecBlock<word32, 32> k;00022 };00023 00024 <span class="keyword">struct </span>DES_Info : <span class="keyword">public</span> <a class="code" href="class_fixed_block_size.html">FixedBlockSize</a><8>, <span class="keyword">public</span> <a class="code" href="class_fixed_key_length.html">FixedKeyLength</a><8>00025 {00026 <span class="comment">// disable DES in DLL version by not exporting this function</span>00027 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"DES"</span>;}00028 };00029 <span class="comment"></span>00030 <span class="comment">/// <a href="http://www.weidai.com/scan-mirror/cs.html#DES">DES</a></span>00031 <span class="comment"></span><span class="comment">/*! The DES implementation in Crypto++ ignores the parity bits</span>00032 <span class="comment"> (the least significant bits of each byte) in the key. However</span>00033 <span class="comment"> you can use CheckKeyParityBits() and CorrectKeyParityBits() to</span>00034 <span class="comment"> check or correct the parity bits if you wish. */</span><a name="l00035"></a><a class="code" href="class_d_e_s.html">00035</a> <span class="keyword">class </span><a class="code" href="class_d_e_s.html">DES</a> : <span class="keyword">public</span> DES_Info, <span class="keyword">public</span> <a class="code" href="struct_block_cipher_documentation.html">BlockCipherDocumentation</a>00036 {00037 <span class="keyword">class </span>Base : <span class="keyword">public</span> BlockCipherBaseTemplate<DES_Info>, <span class="keyword">public</span> RawDES00038 {00039 <span class="keyword">public</span>:00040 <span class="keywordtype">void</span> ProcessAndXorBlock(<span class="keyword">const</span> byte *inBlock, <span class="keyword">const</span> byte *xorBlock, byte *outBlock) <span class="keyword">const</span>;00041 };00042 00043 <span class="keyword">public</span>:<span class="comment"></span>00044 <span class="comment"> //! check DES key parity bits</span>00045 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="class_d_e_s.html#_d_e_se0">CheckKeyParityBits</a>(<span class="keyword">const</span> byte *key);<span class="comment"></span>00046 <span class="comment"> //! correct DES key parity bits</span>00047 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="class_d_e_s.html#_d_e_se1">CorrectKeyParityBits</a>(byte *key);00048 <a name="l00049"></a><a class="code" href="class_d_e_s.html#_d_e_sw0">00049</a> <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate<ENCRYPTION, Base></a> <a class="code" href="class_block_cipher_template.html">Encryption</a>;<a name="l00050"></a><a class="code" href="class_d_e_s.html#_d_e_sw1">00050</a> <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate<DECRYPTION, Base></a> <a class="code" href="class_block_cipher_template.html">Decryption</a>;00051 };00052 00053 <span class="keyword">struct </span>DES_EDE2_Info : <span class="keyword">public</span> <a class="code" href="class_fixed_block_size.html">FixedBlockSize</a><8>, <span class="keyword">public</span> <a class="code" href="class_fixed_key_length.html">FixedKeyLength</a><16>00054 {00055 CRYPTOPP_DLL <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"DES-EDE2"</span>;}00056 };00057 <span class="comment"></span>00058 <span class="comment">/// <a href="http://www.weidai.com/scan-mirror/cs.html#DESede">DES-EDE2</a></span><a name="l00059"></a><a class="code" href="class_d_e_s___e_d_e2.html">00059</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_d_e_s___e_d_e2.html">DES_EDE2</a> : <span class="keyword">public</span> DES_EDE2_Info, <span class="keyword">public</span> <a class="code" href="struct_block_cipher_documentation.html">BlockCipherDocumentation</a>00060 {00061 <span class="keyword">class </span>CRYPTOPP_DLL Base : <span class="keyword">public</span> BlockCipherBaseTemplate<DES_EDE2_Info>00062 {00063 <span class="keyword">public</span>:00064 <span class="keywordtype">void</span> UncheckedSetKey(<a class="code" href="cryptlib_8h.html#a11">CipherDir</a> direction, <span class="keyword">const</span> byte *userKey, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length);00065 <span class="keywordtype">void</span> ProcessAndXorBlock(<span class="keyword">const</span> byte *inBlock, <span class="keyword">const</span> byte *xorBlock, byte *outBlock) <span class="keyword">const</span>;00066 00067 <span class="keyword">protected</span>:00068 RawDES m_des1, m_des2;00069 };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -