Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 17f48c047155a7d4c992d6a672acd57f > files > 2228

libcryptopp-devel-7.0.0-1.1.mga7.armv7hl.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Crypto++: emsa2.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Crypto++
   &#160;<span id="projectnumber">7.0</span>
   </div>
   <div id="projectbrief">Free&nbsp;C&#43;&#43;&nbsp;class&nbsp;library&nbsp;of&nbsp;cryptographic&nbsp;schemes</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">emsa2.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">// emsa2.cpp - originally written and placed in the public domain by Wei Dai</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="pch_8h.html">pch.h</a>&quot;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="emsa2_8h.html">emsa2.h</a>&quot;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#ifndef CRYPTOPP_IMPORTS</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;NAMESPACE_BEGIN(<a class="code" href="namespace_crypto_p_p.html">CryptoPP</a>)</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment">// Inclusion based on DLL due to Clang, http://github.com/weidai11/cryptopp/issues/300</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#ifndef CRYPTOPP_IS_DLL</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="keyword">template</span>&lt;&gt; <span class="keyword">const</span> <span class="keywordtype">byte</span> <a class="code" href="class_e_m_s_a2_hash_id.html">EMSA2HashId&lt;SHA1&gt;::id</a> = 0x33;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="keyword">template</span>&lt;&gt; <span class="keyword">const</span> <span class="keywordtype">byte</span> <a class="code" href="class_e_m_s_a2_hash_id.html">EMSA2HashId&lt;SHA224&gt;::id</a> = 0x38;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="keyword">template</span>&lt;&gt; <span class="keyword">const</span> <span class="keywordtype">byte</span> <a class="code" href="class_e_m_s_a2_hash_id.html">EMSA2HashId&lt;SHA256&gt;::id</a> = 0x34;</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="keyword">template</span>&lt;&gt; <span class="keyword">const</span> <span class="keywordtype">byte</span> <a class="code" href="class_e_m_s_a2_hash_id.html">EMSA2HashId&lt;SHA384&gt;::id</a> = 0x36;</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">template</span>&lt;&gt; <span class="keyword">const</span> <span class="keywordtype">byte</span> <a class="code" href="class_e_m_s_a2_hash_id.html">EMSA2HashId&lt;SHA512&gt;::id</a> = 0x35;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="keywordtype">void</span> EMSA2Pad::ComputeMessageRepresentative(<a class="code" href="class_random_number_generator.html">RandomNumberGenerator</a>&amp; <span class="comment">/*rng*/</span>,</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">byte</span>* recoverableMessage, <span class="keywordtype">size_t</span> recoverableMessageLength,</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    <a class="code" href="class_hash_transformation.html">HashTransformation</a> &amp;hash, HashIdentifier hashIdentifier, <span class="keywordtype">bool</span> messageEmpty,</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="keywordtype">byte</span> *representative, <span class="keywordtype">size_t</span> representativeBitLength)<span class="keyword"> const</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="keyword"></span>{</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(recoverableMessageLength), CRYPTOPP_UNUSED(representativeBitLength);</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;    <a class="code" href="trap_8h.html#adf3b392588bc94cbeae9f415a78c7b95">CRYPTOPP_ASSERT</a>(representativeBitLength &gt;= MinRepresentativeBitLength(hashIdentifier.second, hash.<a class="code" href="class_hash_transformation.html#a9f42cc280bac76b884ad12615c0dabb5">DigestSize</a>()));</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <span class="keywordflow">if</span> (representativeBitLength % 8 != 7)</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        <span class="keywordflow">throw</span> <a class="code" href="class_p_k___signature_scheme_1_1_invalid_key_length.html">PK_SignatureScheme::InvalidKeyLength</a>(<span class="stringliteral">&quot;EMSA2: EMSA2 requires a key length that is a multiple of 8&quot;</span>);</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;    <span class="keywordtype">size_t</span> digestSize = hash.<a class="code" href="class_hash_transformation.html#a9f42cc280bac76b884ad12615c0dabb5">DigestSize</a>();</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    <span class="keywordtype">size_t</span> representativeByteLength = <a class="code" href="misc_8h.html#a7c5d30b17c9d4869fdc3458dd05c500d">BitsToBytes</a>(representativeBitLength);</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    representative[0] = messageEmpty ? 0x4b : 0x6b;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    memset(representative+1, 0xbb, representativeByteLength-digestSize-4);  <span class="comment">// pad with 0xbb</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <span class="keywordtype">byte</span> *afterP2 = representative+representativeByteLength-digestSize-3;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    afterP2[0] = 0xba;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aa0b8c7a110d8968268fd02ec32b9a8e8">Final</a>(afterP2+1);</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    representative[representativeByteLength-2] = *hashIdentifier.first;</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    representative[representativeByteLength-1] = 0xcc;</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;}</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;NAMESPACE_END</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="preprocessor">#endif</span></div><div class="ttc" id="emsa2_8h_html"><div class="ttname"><a href="emsa2_8h.html">emsa2.h</a></div><div class="ttdoc">Classes and functions for various padding schemes used in public key algorithms.</div></div>
<div class="ttc" id="misc_8h_html_a7c5d30b17c9d4869fdc3458dd05c500d"><div class="ttname"><a href="misc_8h.html#a7c5d30b17c9d4869fdc3458dd05c500d">BitsToBytes</a></div><div class="ttdeci">size_t BitsToBytes(size_t bitCount)</div><div class="ttdoc">Returns the number of 8-bit bytes or octets required for the specified number of bits.</div><div class="ttdef"><b>Definition:</b> <a href="misc_8h_source.html#l00790">misc.h:790</a></div></div>
<div class="ttc" id="class_random_number_generator_html"><div class="ttname"><a href="class_random_number_generator.html">RandomNumberGenerator</a></div><div class="ttdoc">Interface for random number generators.</div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8h_source.html#l01330">cryptlib.h:1330</a></div></div>
<div class="ttc" id="class_e_m_s_a2_hash_id_html"><div class="ttname"><a href="class_e_m_s_a2_hash_id.html">EMSA2HashId</a></div><div class="ttdoc">EMSA2 hash identifier.</div><div class="ttdef"><b>Definition:</b> <a href="emsa2_8h_source.html#l00023">emsa2.h:23</a></div></div>
<div class="ttc" id="pch_8h_html"><div class="ttname"><a href="pch_8h.html">pch.h</a></div><div class="ttdoc">Precompiled header file.</div></div>
<div class="ttc" id="class_p_k___signature_scheme_1_1_invalid_key_length_html"><div class="ttname"><a href="class_p_k___signature_scheme_1_1_invalid_key_length.html">PK_SignatureScheme::InvalidKeyLength</a></div><div class="ttdoc">Exception throw when the private or public key has a length that can't be used.</div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8h_source.html#l02619">cryptlib.h:2619</a></div></div>
<div class="ttc" id="trap_8h_html_adf3b392588bc94cbeae9f415a78c7b95"><div class="ttname"><a href="trap_8h.html#adf3b392588bc94cbeae9f415a78c7b95">CRYPTOPP_ASSERT</a></div><div class="ttdeci">#define CRYPTOPP_ASSERT(exp)</div><div class="ttdoc">Debugging and diagnostic assertion.</div><div class="ttdef"><b>Definition:</b> <a href="trap_8h_source.html#l00060">trap.h:60</a></div></div>
<div class="ttc" id="class_hash_transformation_html_a9f42cc280bac76b884ad12615c0dabb5"><div class="ttname"><a href="class_hash_transformation.html#a9f42cc280bac76b884ad12615c0dabb5">HashTransformation::DigestSize</a></div><div class="ttdeci">virtual unsigned int DigestSize() const =0</div><div class="ttdoc">Provides the digest size of the hash.</div></div>
<div class="ttc" id="class_hash_transformation_html"><div class="ttname"><a href="class_hash_transformation.html">HashTransformation</a></div><div class="ttdoc">Interface for hash functions and data processing part of MACs.</div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8h_source.html#l01065">cryptlib.h:1065</a></div></div>
<div class="ttc" id="namespace_crypto_p_p_html"><div class="ttname"><a href="namespace_crypto_p_p.html">CryptoPP</a></div><div class="ttdoc">Crypto++ library namespace.</div></div>
<div class="ttc" id="class_hash_transformation_html_aa0b8c7a110d8968268fd02ec32b9a8e8"><div class="ttname"><a href="class_hash_transformation.html#aa0b8c7a110d8968268fd02ec32b9a8e8">HashTransformation::Final</a></div><div class="ttdeci">virtual void Final(byte *digest)</div><div class="ttdoc">Computes the hash of the current message.</div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8h_source.html#l01095">cryptlib.h:1095</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Nov 27 2019 15:03:30 for Crypto++ by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>