📄 strciphr_8h-source.html
字号:
<a name="l00148"></a>00148 <a name="l00149"></a>00149 <span class="keyword">protected</span>:<a name="l00150"></a>00150 <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="l00151"></a>00151 <a name="l00152"></a><a class="code" href="class_additive_cipher_template.html#2b8c6e4e11ac35c6f267991d0b62f84c">00152</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetBufferByteSize(<span class="keyword">const</span> PolicyInterface &policy)<span class="keyword"> const </span>{<span class="keywordflow">return</span> policy.GetBytesPerIteration() * policy.GetIterationsToBuffer();}<a name="l00153"></a>00153 <a name="l00154"></a><a class="code" href="class_additive_cipher_template.html#a0b80a8012abd9061b9522102737069b">00154</a> <span class="keyword">inline</span> byte * KeystreamBufferBegin() {<span class="keywordflow">return</span> this->m_buffer.data();}<a name="l00155"></a><a class="code" href="class_additive_cipher_template.html#99f88c7364a00f78d4afe44f4c962e9e">00155</a> <span class="keyword">inline</span> byte * KeystreamBufferEnd() {<span class="keywordflow">return</span> (this->m_buffer.data() + this->m_buffer.size());}<a name="l00156"></a>00156 <a name="l00157"></a><a class="code" href="class_additive_cipher_template.html#dc071d835c1113d83a98ca62b09f0904">00157</a> <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> m_buffer;<a name="l00158"></a><a class="code" href="class_additive_cipher_template.html#0c2f1c9e2245bff40739170769ea39c4">00158</a> <span class="keywordtype">size_t</span> m_leftOver;<a name="l00159"></a>00159 };<a name="l00160"></a>00160 <a name="l00161"></a><a class="code" href="class_c_f_b___cipher_abstract_policy.html">00161</a> <span class="keyword">class </span>CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CFB_CipherAbstractPolicy<a name="l00162"></a>00162 {<a name="l00163"></a>00163 <span class="keyword">public</span>:<a name="l00164"></a><a class="code" href="class_c_f_b___cipher_abstract_policy.html#9b92dca4aee385aa7bfa76e2ee8bfad5">00164</a> <span class="keyword">virtual</span> ~CFB_CipherAbstractPolicy() {}<a name="l00165"></a>00165 <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetAlignment() <span class="keyword">const</span> =0;<a name="l00166"></a>00166 <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetBytesPerIteration() <span class="keyword">const</span> =0;<a name="l00167"></a>00167 <span class="keyword">virtual</span> byte * GetRegisterBegin() =0;<a name="l00168"></a>00168 <span class="keyword">virtual</span> <span class="keywordtype">void</span> TransformRegister() =0;<a name="l00169"></a><a class="code" href="class_c_f_b___cipher_abstract_policy.html#d3cf5f1f95bc71115bc9cddf91821886">00169</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> CanIterate()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">false</span>;}<a name="l00170"></a><a class="code" href="class_c_f_b___cipher_abstract_policy.html#021f82d6099659217e92aabb222200d4">00170</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> Iterate(byte *output, <span class="keyword">const</span> byte *input, <a class="code" href="cryptlib_8h.html#353ccabf5ddc119a6a33e92f7b9961c7" title="used to specify a direction for a cipher to operate in (encrypt or decrypt)">CipherDir</a> dir, <span class="keywordtype">size_t</span> iterationCount) {assert(<span class="keyword">false</span>);}<a name="l00171"></a>00171 <span class="keyword">virtual</span> <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) =0;<a name="l00172"></a><a class="code" href="class_c_f_b___cipher_abstract_policy.html#08bdf72613d15644bcd8b2ac3e17dd7c">00172</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> CipherResynchronize(<span class="keyword">const</span> byte *iv) {<span class="keywordflow">throw</span> <a class="code" href="class_not_implemented.html" title="exception thrown by a class if a non-implemented method is called">NotImplemented</a>(<span class="stringliteral">"SimpleKeyingInterface: this object doesn't support resynchronization"</span>);}<a name="l00173"></a>00173 };<a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="keyword">template</span> <<span class="keyword">typename</span> WT, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> W, <span class="keyword">class</span> BASE = CFB_CipherAbstractPolicy><a name="l00176"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy.html">00176</a> <span class="keyword">struct </span>CRYPTOPP_NO_VTABLE CFB_CipherConcretePolicy : <span class="keyword">public</span> BASE<a name="l00177"></a>00177 {<a name="l00178"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy.html#d2553cceef6af4437f6930ec3af95bf7">00178</a> <span class="keyword">typedef</span> WT WordType;<a name="l00179"></a>00179 <a name="l00180"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy.html#01045749031b5ba60cb7123762c23070">00180</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetAlignment()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">sizeof</span>(WordType);}<a name="l00181"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy.html#a7b2e21cf767f6f2a4ec03a7d128b692">00181</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetBytesPerIteration()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">sizeof</span>(WordType) * W;}<a name="l00182"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy.html#128bb497623a649723aa1e2e42eb0233">00182</a> <span class="keywordtype">bool</span> CanIterate()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">true</span>;}<a name="l00183"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy.html#620b544b8ec71768e9872315c82ed206">00183</a> <span class="keywordtype">void</span> TransformRegister() {this->Iterate(NULL, NULL, <a class="code" href="cryptlib_8h.html#353ccabf5ddc119a6a33e92f7b9961c7244e5e74f856cdd5aafc1005877a2f61">ENCRYPTION</a>, 1);}<a name="l00184"></a>00184 <a name="l00185"></a>00185 <span class="keyword">template</span> <<span class="keyword">class</span> B><a name="l00186"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html">00186</a> <span class="keyword">struct </span><a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html">RegisterOutput</a><a name="l00187"></a>00187 {<a name="l00188"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html#220fb3f949134ff82c40d18115a495ef">00188</a> <a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html">RegisterOutput</a>(byte *output, <span class="keyword">const</span> byte *input, <a class="code" href="cryptlib_8h.html#353ccabf5ddc119a6a33e92f7b9961c7" title="used to specify a direction for a cipher to operate in (encrypt or decrypt)">CipherDir</a> dir)<a name="l00189"></a>00189 : m_output(output), m_input(input), m_dir(dir) {}<a name="l00190"></a>00190 <a name="l00191"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html#82f4011e9652312a0216345186fa3ada">00191</a> <span class="keyword">inline</span> <a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html">RegisterOutput</a>& operator()(WordType &registerWord)<a name="l00192"></a>00192 {<a name="l00193"></a>00193 assert(IsAligned<WordType>(m_output));<a name="l00194"></a>00194 assert(IsAligned<WordType>(m_input));<a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="keywordflow">if</span> (!NativeByteOrderIs(B::ToEnum()))<a name="l00197"></a>00197 registerWord = ByteReverse(registerWord);<a name="l00198"></a>00198 <a name="l00199"></a>00199 <span class="keywordflow">if</span> (m_dir == <a class="code" href="cryptlib_8h.html#353ccabf5ddc119a6a33e92f7b9961c7244e5e74f856cdd5aafc1005877a2f61">ENCRYPTION</a>)<a name="l00200"></a>00200 {<a name="l00201"></a>00201 <span class="keywordflow">if</span> (m_input == NULL)<a name="l00202"></a>00202 assert(m_output == NULL);<a name="l00203"></a>00203 <span class="keywordflow">else</span><a name="l00204"></a>00204 {<a name="l00205"></a>00205 WordType ct = *(<span class="keyword">const</span> WordType *)m_input ^ registerWord;<a name="l00206"></a>00206 registerWord = ct;<a name="l00207"></a>00207 *(WordType*)m_output = ct;<a name="l00208"></a>00208 m_input += <span class="keyword">sizeof</span>(WordType);<a name="l00209"></a>00209 m_output += <span class="keyword">sizeof</span>(WordType);<a name="l00210"></a>00210 }<a name="l00211"></a>00211 }<a name="l00212"></a>00212 <span class="keywordflow">else</span><a name="l00213"></a>00213 {<a name="l00214"></a>00214 WordType ct = *(<span class="keyword">const</span> WordType *)m_input;<a name="l00215"></a>00215 *(WordType*)m_output = registerWord ^ ct;<a name="l00216"></a>00216 registerWord = ct;<a name="l00217"></a>00217 m_input += <span class="keyword">sizeof</span>(WordType);<a name="l00218"></a>00218 m_output += <span class="keyword">sizeof</span>(WordType);<a name="l00219"></a>00219 }<a name="l00220"></a>00220 <a name="l00221"></a>00221 <span class="comment">// registerWord is left unreversed so it can be xor-ed with further input</span><a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keywordflow">return</span> *<span class="keyword">this</span>;<a name="l00224"></a>00224 }<a name="l00225"></a>00225 <a name="l00226"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html#9e0b19b991f7ea809fdacf4160301ad6">00226</a> byte *m_output;<a name="l00227"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html#dee6a78dc75f70c6b3f485720a2e9448">00227</a> <span class="keyword">const</span> byte *m_input;<a name="l00228"></a><a class="code" href="struct_c_f_b___cipher_concrete_policy_1_1_register_output.html#818280855d8986219a63d7890626c220">00228</a> <a class="code" href="cryptlib_8h.html#353ccabf5ddc119a6a33e92f7b9961c7" title="used to specify a direction for a cipher to operate in (encrypt or decrypt)">CipherDir</a> m_dir;<a name="l00229"></a>00229 };<a name="l00230"></a>00230 };<a name="l00231"></a>00231
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -