📄 modes_8h-source.html
字号:
<a name="l00126"></a><a class="code" href="class_o_f_b___mode_policy.html#506ca773e274a1e502e817ab16be4655">00126</a> <span class="keywordtype">bool</span> <a class="code" href="class_stream_transformation.html#c97d3fcac9b9f596ac8a7c69b69524cf" title="returns whether this cipher supports random access">IsRandomAccess</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">false</span>;}<a name="l00127"></a><a class="code" href="class_o_f_b___mode_policy.html#f8594eed79fc66094f525df05f5eba74">00127</a> <a class="code" href="class_simple_keying_interface.html#88201c180fbfaa9fef2715252546ad6e">IV_Requirement</a> <a class="code" href="class_cipher_mode_base.html#a46eb377a83a479ee66ea044f845bf50" title="returns the minimal requirement for secure IVs">IVRequirement</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_simple_keying_interface.html#88201c180fbfaa9fef2715252546ad6e1cc32e69fe4f385e54d9d482a2ab5a56">UNIQUE_IV</a>;}<a name="l00128"></a><a class="code" href="class_o_f_b___mode_policy.html#20ee768bb4173bc4fb3f3659519d7113">00128</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * CRYPTOPP_API StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"OFB"</span>;}<a name="l00129"></a>00129 <a name="l00130"></a>00130 <span class="keyword">private</span>:<a name="l00131"></a>00131 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetBytesPerIteration()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_cipher_mode_base.html#6d0a5b8deef965aa690441541c5a7aa7">BlockSize</a>();}<a name="l00132"></a>00132 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetIterationsToBuffer()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 1;}<a name="l00133"></a>00133 <span class="keywordtype">void</span> WriteKeystream(byte *keystreamBuffer, <span class="keywordtype">size_t</span> iterationCount)<a name="l00134"></a>00134 {<a name="l00135"></a>00135 assert(iterationCount == 1);<a name="l00136"></a>00136 assert(<a class="code" href="class_cipher_mode_base.html#b6c63ae5b5521b462912b1bb2d766989">m_cipher</a>-><a class="code" href="class_block_transformation.html#924da616b7ba966704fb67e2b852fd2e" title="returns true if this is an encryption object">IsForwardTransformation</a>()); <span class="comment">// OFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt</span><a name="l00137"></a>00137 <a class="code" href="class_cipher_mode_base.html#b6c63ae5b5521b462912b1bb2d766989">m_cipher</a>-><a class="code" href="class_block_transformation.html#2fefb3f4c6c6297c0c91fcbba9e4f4f3" title="encrypt or decrypt one block">ProcessBlock</a>(keystreamBuffer);<a name="l00138"></a>00138 }<a name="l00139"></a>00139 <span class="keywordtype">void</span> CipherResynchronize(byte *keystreamBuffer, <span class="keyword">const</span> byte *iv)<a name="l00140"></a>00140 {<a name="l00141"></a>00141 <a class="code" href="modes_8h.html#0c35d7771f5bc9ace517ebdf23338b92">CopyOrZero</a>(keystreamBuffer, iv, <a class="code" href="class_cipher_mode_base.html#6d0a5b8deef965aa690441541c5a7aa7">BlockSize</a>());<a name="l00142"></a>00142 }<a name="l00143"></a>00143 };<a name="l00144"></a>00144 <a name="l00145"></a><a class="code" href="class_c_t_r___mode_policy.html">00145</a> <span class="keyword">class </span>CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : <span class="keyword">public</span> <a class="code" href="class_mode_policy_common_template.html">ModePolicyCommonTemplate</a><AdditiveCipherAbstractPolicy><a name="l00146"></a>00146 {<a name="l00147"></a>00147 <span class="keyword">public</span>:<a name="l00148"></a><a class="code" href="class_c_t_r___mode_policy.html#341dc9e7473b2df15050df5a586a7ecd">00148</a> <span class="keywordtype">bool</span> <a class="code" href="class_stream_transformation.html#c97d3fcac9b9f596ac8a7c69b69524cf" title="returns whether this cipher supports random access">IsRandomAccess</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">true</span>;}<a name="l00149"></a><a class="code" href="class_c_t_r___mode_policy.html#a35bece1189c9827e9a1ae577bedf8a8">00149</a> <a class="code" href="class_simple_keying_interface.html#88201c180fbfaa9fef2715252546ad6e">IV_Requirement</a> <a class="code" href="class_cipher_mode_base.html#a46eb377a83a479ee66ea044f845bf50" title="returns the minimal requirement for secure IVs">IVRequirement</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_simple_keying_interface.html#88201c180fbfaa9fef2715252546ad6e1cc32e69fe4f385e54d9d482a2ab5a56">UNIQUE_IV</a>;}<a name="l00150"></a><a class="code" href="class_c_t_r___mode_policy.html#92512c120b1c6091ac2ebc5ac93aafc3">00150</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * CRYPTOPP_API StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"CTR"</span>;}<a name="l00151"></a>00151 <a name="l00152"></a>00152 <span class="keyword">private</span>:<a name="l00153"></a>00153 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetAlignment()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_cipher_mode_base.html#b6c63ae5b5521b462912b1bb2d766989">m_cipher</a>-><a class="code" href="class_block_transformation.html#f2da7e22f6b6ddda72bc7db2aceaa67a" title="block pointers must be divisible by this">BlockAlignment</a>();}<a name="l00154"></a>00154 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetBytesPerIteration()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_cipher_mode_base.html#6d0a5b8deef965aa690441541c5a7aa7">BlockSize</a>();}<a name="l00155"></a>00155 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetIterationsToBuffer()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_cipher_mode_base.html#b6c63ae5b5521b462912b1bb2d766989">m_cipher</a>-><a class="code" href="class_block_transformation.html#9ee1da34a4c957d4be87d2b0469806b0" title="return number of blocks that can be processed in parallel, for bit-slicing implementations...">OptimalNumberOfParallelBlocks</a>();}<a name="l00156"></a>00156 <span class="keywordtype">void</span> WriteKeystream(byte *buffer, <span class="keywordtype">size_t</span> iterationCount)<a name="l00157"></a>00157 {OperateKeystream(<a class="code" href="strciphr_8h.html#b4a226527d2bd01ff19bfa14d09742276ab40a8f816d015407f61839c60b9a4e">WRITE_KEYSTREAM</a>, buffer, NULL, iterationCount);}<a name="l00158"></a>00158 <span class="keywordtype">bool</span> CanOperateKeystream()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">true</span>;}<a name="l00159"></a>00159 <span class="keywordtype">void</span> OperateKeystream(<a class="code" href="strciphr_8h.html#b4a226527d2bd01ff19bfa14d0974227">KeystreamOperation</a> operation, byte *output, <span class="keyword">const</span> byte *input, <span class="keywordtype">size_t</span> iterationCount);<a name="l00160"></a>00160 <span class="keywordtype">void</span> CipherResynchronize(byte *keystreamBuffer, <span class="keyword">const</span> byte *iv);<a name="l00161"></a>00161 <span class="keywordtype">void</span> SeekToIteration(lword iterationCount);<a name="l00162"></a>00162 <a name="l00163"></a>00163 <span class="keyword">inline</span> <span class="keywordtype">void</span> ProcessMultipleBlocks(byte *output, <span class="keyword">const</span> byte *input, <span class="keywordtype">size_t</span> n);<a name="l00164"></a>00164 <a name="l00165"></a>00165 <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> m_counterArray;<a name="l00166"></a>00166 };<a name="l00167"></a>00167 <a name="l00168"></a><a class="code" href="class_block_oriented_cipher_mode_base.html">00168</a> <span class="keyword">class </span>CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockOrientedCipherModeBase : <span class="keyword">public</span> <a class="code" href="class_cipher_mode_base.html">CipherModeBase</a><a name="l00169"></a>00169 {<a name="l00170"></a>00170 <span class="keyword">public</span>:<a name="l00171"></a>00171 <span class="keywordtype">void</span> UncheckedSetKey(<span class="keyword">const</span> byte *key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length, <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);<a name="l00172"></a><a class="code" href="class_block_oriented_cipher_mode_base.html#de6a00d82e063bcee5d1db3cd294751c">00172</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_stream_transformation.html#e224d250f716e82c54bc4e4c8930d188" title="returns block size, if input must be processed in blocks, otherwise 1">MandatoryBlockSize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_cipher_mode_base.html#6d0a5b8deef965aa690441541c5a7aa7">BlockSize</a>();}<a name="l00173"></a><a class="code" href="class_block_oriented_cipher_mode_base.html#7721eef9f8c5c0c4ca16048c41feed8f">00173</a> <span class="keywordtype">bool</span> <a class="code" href="class_stream_transformation.html#c97d3fcac9b9f596ac8a7c69b69524cf" title="returns whether this cipher supports random access">IsRandomAccess</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">false</span>;}<a name="l00174"></a><a class="code" href="class_block_oriented_cipher_mode_base.html#503746952c074403bf2d72374f3d6672">00174</a> <span class="keywordtype">bool</span> <a class="code" href="class_stream_transformation.html#aad9b1fd9cceaf3641f03452da29534b" title="returns whether this transformation is self-inverting (e.g. xor with a keystream)...">IsSelfInverting</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">false</span>;}<a name="l00175"></a><a class="code" href="class_block_oriented_cipher_mode_base.html#3f08ba1e5fe34ab0cd379a54da828938">00175</a> <span class="keywordtype">bool</span> <a class="code" href="class_stream_transformation.html#548b24c9354ebda5cdd06ef1cd79667b" title="returns whether this is an encryption object">IsForwardTransformation</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_cipher_mode_base.html#b6c63ae5b5521b462912b1bb2d766989">m_cipher</a>-><a class="code" href="class_block_transformation.html#924da616b7ba966704fb67e2b852fd2e" title="returns true if this is an encryption object">IsForwardTransformation</a>();}<a name="l00176"></a><a class="code" href="class_block_oriented_cipher_mode_base.html#f1afe72ca94c6e1c3889e785ae3bd770">00176</a> <span class="keywordtype">void</span> <a class="code" href="class_simple_keying_interface.html#8ee3f5f9c00d193bf9d8fd8aa46ccbb2" title="resynchronize with an IV">Resynchronize</a>(<span class="keyword">const</span> byte *iv) {memcpy_s(<a class="code" href="class_cipher_mode_base.html#5d4cdcf2a0a4f5c52115fa622eebc10a">m_register</a>, <a class="code" href="class_cipher_mode_base.html#5d4cdcf2a0a4f5c52115fa622eebc10a">m_register</a>.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>(), iv, <a class="code" href="class_cipher_mode_base.html#6d0a5b8deef965aa690441541c5a7aa7">BlockSize</a>());}<a name="l00177"></a>00177 <span class="keywordtype">void</span> <a class="code" href="class_stream_transformation.html#26feabde21bc4d1783195969733e3bb0" title="encrypt or decrypt an array of bytes of specified length">ProcessData</a>(byte *outString, <span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length);<a name="l00178"></a>00178 <a name="l00179"></a>00179 <span class="keyword">protected</span>:<a name="l00180"></a><a class="code" href="class_block_oriented_cipher_mode_base.html#e4b779c42aaf33255f70c5723c0f40aa">00180</a> <span class="keywordtype">bool</span> RequireAlignedInput()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">true</span>;}<a name="l00181"></a>00181 <span class="keyword">virtual</span> <span class="keywordtype">void</span> ProcessBlocks(byte *outString, <span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> numberOfBlocks) =0;<a name="l00182"></a><a class="code" href="class_block_oriented_cipher_mode_base.html#4e567f03f82e6108065a1316de50e1cf">00182</a> <span class="keywordtype">void</span> <a class="code" href="class_cipher_mode_base.html#8c864c16ce0eb014699c0a61adcc6836">ResizeBuffers</a>()<a name="l00183"></a>00183 {<a name="l00184"></a>00184 <a class="code" href="class_cipher_mode_base.html#8c864c16ce0eb014699c0a61adcc6836">CipherModeBase::ResizeBuffers</a>();<a name="l00185"></a>00185 m_buffer.New(<a class="code" href="class_cipher_mode_base.html#6d0a5b8deef965aa690441541c5a7aa7">BlockSize</a>());<a name="l00186"></a>00186 }<a name="l00187"></a>00187 <a name="l00188"></a><a class="code" href="class_block_oriented_cipher_mode_base.html#4c6c74ef76c66ac97ec7f3409dde8f28">00188</a> <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> m_buffer;<a name="l00189"></a>00189 };<a name="l00190"></a>00190 <a name="l00191"></a><a class="code" href="class_e_c_b___one_way.html">00191</a> <span class="keyword">class </span>CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : <span class="keyword">public</span> BlockOrientedCipherModeBase<a name="l00192"></a>00192 {<a name="l00193"></a>00193 <span class="keyword">public</span>:<a name="l00194"></a><a class="code" href="class_e_c_b___one_way.html#ea389c964114b73390dd81d836124461">00194</a> <span class="keywordtype">void</span> <a class="code" href="class_simple_keying_interface.html#df3c29b3ef3af74788a58c7c49887fd7" title="set or reset the key of this object">SetKey</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">size_t</span> length, <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 = g_nullNameValuePairs)<a name="l00195"></a>00195 {<a class="code" href="class_cipher_mode_base.html#b6c63ae5b5521b462912b1bb2d766989">m_cipher</a>-><a class="code" href="class_simple_keying_interface.html#df3c29b3ef3af74788a58c7c49887fd7" title="set or reset the key of this object">SetKey</a>(key, length, params); <a class="code" href="class_block_oriented_cipher_mode_base.html#4e567f03f82e6108065a1316de50e1cf">BlockOrientedCipherModeBase::ResizeBuffers</a>();}<a name="l00196"></a><a class="code" href="class_e_c_b___one_way.html#ebf9c2099287d5545af4501d650a15c5">00196</a> <a class="code" href="class_simple_keying_interface.html#88201c180fbfaa9fef2715252546ad6e">IV_Requirement</a> <a class="code" href="class_cipher_mode_base.html#a46eb377a83a479ee66ea044f845bf50" title="returns the minimal requirement for secure IVs">IVRequirement</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_simple_keying_interface.html#88201c180fbfaa9fef2715252546ad6ec1d24de3dedd05c28516f452d3ace417">NOT_RESYNCHRONIZABLE</a>;}<a name="l00197"></a><a class="code" href="class_e_c_b___one_way.html#697d02a4fbec48b4accec6ce4226e083">00197</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_stream_transformation.html#f66ef64545279c01310718af3d627534" title="returns the input block size that is most efficient for this cipher">OptimalBlockSize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_cipher_mode_base.html#6d0a5b8deef965aa690441541c5a7aa7">BlockSize</a>() * <a class="code" href="class_cipher_mode_base.html#b6c63ae5b5521b462912b1bb2d766989">m_cipher</a>-><a class="code" href="class_block_transformation.html#9ee1da34a4c957d4be87d2b0469806b0" title="return number of blocks that can be processed in parallel, for bit-slicing implementations...">OptimalNumberOfParallelBlocks</a>();}<a name="l00198"></a><a class="code" href="class_e_c_b___one_way.html#c210a643327cfc7f3b031be3e6d64731">00198</a> <span class="keywordtype">void</span> ProcessBlocks(byte *outString, <span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> numberOfBlocks)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -