⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emsa2_8cpp-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Crypto++: emsa2.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.2 --><div class="tabs">  <ul>    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>    <li><a href="namespaces.html"><span>Namespaces</span></a></li>    <li><a href="classes.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&nbsp;List</span></a></li>    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>  </ul></div><h1>emsa2.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// emsa2.cpp - written and placed in the public domain by Wei Dai</span><a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="preprocessor">#include "pch.h"</span><a name="l00004"></a>00004 <span class="preprocessor">#include "<a class="code" href="emsa2_8h.html" title="This file contains various padding schemes for public key algorithms.">emsa2.h</a>"</span><a name="l00005"></a>00005 <a name="l00006"></a>00006 <span class="preprocessor">#ifndef CRYPTOPP_IMPORTS</span><a name="l00007"></a>00007 <span class="preprocessor"></span><a name="l00008"></a>00008 NAMESPACE_BEGIN(CryptoPP)<a name="l00009"></a>00009 <a name="l00010"></a><a class="code" href="class_e_m_s_a2_pad.html#1e5129986bcf985f6482832afdb34fff">00010</a> void <a class="code" href="class_e_m_s_a2_pad.html" title="_">EMSA2Pad</a>::ComputeMessageRepresentative(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &amp;rng, <a name="l00011"></a>00011         const byte *recoverableMessage, <span class="keywordtype">size_t</span> recoverableMessageLength,<a name="l00012"></a>00012         <a class="code" href="class_hash_transformation.html" title="interface for hash functions and data processing part of MACs">HashTransformation</a> &amp;hash, <a class="code" href="pubkey_8h.html#ef874ed3f2d212ac4629255c8ef86dd0">HashIdentifier</a> hashIdentifier, <span class="keywordtype">bool</span> messageEmpty,<a name="l00013"></a>00013         byte *representative, <span class="keywordtype">size_t</span> representativeBitLength)<span class="keyword"> const</span><a name="l00014"></a>00014 <span class="keyword"></span>{<a name="l00015"></a>00015         assert(representativeBitLength &gt;= MinRepresentativeBitLength(hashIdentifier.second, hash.DigestSize()));<a name="l00016"></a>00016 <a name="l00017"></a>00017         <span class="keywordflow">if</span> (representativeBitLength % 8 != 7)<a name="l00018"></a>00018                 <span class="keywordflow">throw</span> <a class="code" href="class_p_k___signature_scheme_1_1_invalid_key_length.html" title="invalid key exception, may be thrown by any function in this class if the private...">PK_SignatureScheme::InvalidKeyLength</a>(<span class="stringliteral">"EMSA2: EMSA2 requires a key length that is a multiple of 8"</span>);<a name="l00019"></a>00019 <a name="l00020"></a>00020         <span class="keywordtype">size_t</span> digestSize = hash.DigestSize();<a name="l00021"></a>00021         <span class="keywordtype">size_t</span> representativeByteLength = BitsToBytes(representativeBitLength);<a name="l00022"></a>00022 <a name="l00023"></a>00023         representative[0] = messageEmpty ? 0x4b : 0x6b;<a name="l00024"></a>00024         memset(representative+1, 0xbb, representativeByteLength-digestSize-4);  <span class="comment">// pad with 0xbb</span><a name="l00025"></a>00025         byte *afterP2 = representative+representativeByteLength-digestSize-3;<a name="l00026"></a>00026         afterP2[0] = 0xba;<a name="l00027"></a>00027         hash.Final(afterP2+1);<a name="l00028"></a>00028         representative[representativeByteLength-2] = *hashIdentifier.first;<a name="l00029"></a>00029         representative[representativeByteLength-1] = 0xcc;<a name="l00030"></a>00030 }<a name="l00031"></a>00031 <a name="l00032"></a>00032 NAMESPACE_END<a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Fri Jun 1 11:11:20 2007 for Crypto++ by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -