Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 0a67b807a02637f2cae68649d519a89d > files > 2504

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Crypto++: pssr.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.14 -->
<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">pssr.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">// pssr.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="pssr_8h.html">pssr.h</a>&quot;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</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="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="ripemd_8h.html">ripemd.h</a>&quot;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="whrlpool_8h.html">whrlpool.h</a>&quot;</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="misc_8h.html">misc.h</a>&quot;</span></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="preprocessor">#include &lt;functional&gt;</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;NAMESPACE_BEGIN(<a class="code" href="namespace_crypto_p_p.html">CryptoPP</a>)</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;</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> byte <a class="code" href="class_e_m_s_a2_hash_id.html">EMSA2HashId&lt;RIPEMD160&gt;::id</a> = 0x31;</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> byte <a class="code" href="class_e_m_s_a2_hash_id.html">EMSA2HashId&lt;RIPEMD128&gt;::id</a> = 0x32;</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> byte <a class="code" href="class_e_m_s_a2_hash_id.html">EMSA2HashId&lt;Whirlpool&gt;::id</a> = 0x37;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor">#ifndef CRYPTOPP_IMPORTS</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="keywordtype">size_t</span> PSSR_MEM_Base::MinRepresentativeBitLength(<span class="keywordtype">size_t</span> hashIdentifierLength, <span class="keywordtype">size_t</span> digestLength)<span class="keyword"> const</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="keyword"></span>{</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="keywordtype">size_t</span> saltLen = SaltLen(digestLength);</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    <span class="keywordtype">size_t</span> minPadLen = MinPadLen(digestLength);</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <span class="keywordflow">return</span> 9 + 8*(minPadLen + saltLen + digestLength + hashIdentifierLength);</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;}</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="keywordtype">size_t</span> PSSR_MEM_Base::MaxRecoverableLength(<span class="keywordtype">size_t</span> representativeBitLength, <span class="keywordtype">size_t</span> hashIdentifierLength, <span class="keywordtype">size_t</span> digestLength)<span class="keyword"> const</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="keyword"></span>{</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    <span class="keywordflow">if</span> (AllowRecovery())</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="misc_8h.html#a30712a90999ad9d9152975f2e92d46b8">SaturatingSubtract</a>(representativeBitLength, MinRepresentativeBitLength(hashIdentifierLength, digestLength)) / 8;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    <span class="keywordflow">return</span> 0;</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;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="keywordtype">bool</span> PSSR_MEM_Base::IsProbabilistic()<span class="keyword"> const</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="keyword"></span>{</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    <span class="keywordflow">return</span> SaltLen(1) &gt; 0;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;}</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="keywordtype">bool</span> PSSR_MEM_Base::AllowNonrecoverablePart()<span class="keyword"> const</span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="keyword"></span>{</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;}</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="keywordtype">bool</span> PSSR_MEM_Base::RecoverablePartFirst()<span class="keyword"> const</span></div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="keyword"></span>{</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;}</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="keywordtype">void</span> PSSR_MEM_Base::ComputeMessageRepresentative(<a class="code" href="class_random_number_generator.html">RandomNumberGenerator</a> &amp;rng,</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    <span class="keyword">const</span> byte *recoverableMessage, <span class="keywordtype">size_t</span> recoverableMessageLength,</div><div class="line"><a name="l00051"></a><span class="lineno">   51</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="l00052"></a><span class="lineno">   52</span>&#160;    byte *representative, <span class="keywordtype">size_t</span> representativeBitLength)<span class="keyword"> const</span></div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="keyword"></span>{</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(recoverableMessageLength);</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    CRYPTOPP_UNUSED(messageEmpty), CRYPTOPP_UNUSED(hashIdentifier);</div><div class="line"><a name="l00056"></a><span class="lineno">   56</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="l00057"></a><span class="lineno">   57</span>&#160;</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> u = hashIdentifier.second + 1;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> representativeByteLength = <a class="code" href="misc_8h.html#a7c5d30b17c9d4869fdc3458dd05c500d">BitsToBytes</a>(representativeBitLength);</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="keyword">const</span> <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="l00061"></a><span class="lineno">   61</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> saltSize = SaltLen(digestSize);</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    byte *<span class="keyword">const</span> h = representative + representativeByteLength - u - digestSize;</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    <a class="code" href="class_sec_byte_block.html">SecByteBlock</a> digest(digestSize), salt(saltSize);</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aa0b8c7a110d8968268fd02ec32b9a8e8">Final</a>(digest);</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    rng.<a class="code" href="class_random_number_generator.html#a497145546d24e6d4abaf10b7e0f1ba17">GenerateBlock</a>(salt, saltSize);</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="comment">// compute H = hash of M&#39;</span></div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    byte c[8];</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <a class="code" href="misc_8h.html#aef6a8d35198f71ff68811bacd599c664">PutWord</a>(<span class="keyword">false</span>, <a class="code" href="cryptlib_8h.html#aaeb92d42f5a6e27b8ba19f18d69d142baf0c3bb6c718cc7ff0bffef4e8f178c57">BIG_ENDIAN_ORDER</a>, c, (word32)SafeRightShift&lt;29&gt;(recoverableMessageLength));</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    <a class="code" href="misc_8h.html#aef6a8d35198f71ff68811bacd599c664">PutWord</a>(<span class="keyword">false</span>, <a class="code" href="cryptlib_8h.html#aaeb92d42f5a6e27b8ba19f18d69d142baf0c3bb6c718cc7ff0bffef4e8f178c57">BIG_ENDIAN_ORDER</a>, c+4, word32(recoverableMessageLength &lt;&lt; 3));</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">Update</a>(c, 8);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">Update</a>(recoverableMessage, recoverableMessageLength);</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">Update</a>(digest, digestSize);</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">Update</a>(salt, saltSize);</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aa0b8c7a110d8968268fd02ec32b9a8e8">Final</a>(h);</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="comment">// compute representative</span></div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    GetMGF().<a class="code" href="class_mask_generating_function.html#a7ef49cae6b047a6be64909d63cfa41ba">GenerateAndMask</a>(hash, representative, representativeByteLength - u - digestSize, h, digestSize, <span class="keyword">false</span>);</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    byte *xorStart = representative + representativeByteLength - u - digestSize - salt.size() - recoverableMessageLength - 1;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    xorStart[0] ^= 1;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    <span class="keywordflow">if</span> (recoverableMessage &amp;&amp; recoverableMessageLength)</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        <a class="code" href="misc_8h.html#a6aaae7768600b9d735a5e1b8192035f8">xorbuf</a>(xorStart + 1, recoverableMessage, recoverableMessageLength);</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <a class="code" href="misc_8h.html#a6aaae7768600b9d735a5e1b8192035f8">xorbuf</a>(xorStart + 1 + recoverableMessageLength, salt, salt.size());</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    <span class="keywordflow">if</span> (hashIdentifier.first &amp;&amp; hashIdentifier.second)</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    {</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;        memcpy(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second);</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;        representative[representativeByteLength - 1] = 0xcc;</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    }</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keywordflow">else</span></div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    {</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;        representative[representativeByteLength - 1] = 0xbc;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    }</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    <span class="keywordflow">if</span> (representativeBitLength % 8 != 0)</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;        representative[0] = (byte)<a class="code" href="misc_8h.html#a616a7f0365c4947b0c8a44606c525a62">Crop</a>(representative[0], representativeBitLength % 8);</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;}</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;<a class="code" href="struct_decoding_result.html">DecodingResult</a> PSSR_MEM_Base::RecoverMessageFromRepresentative(</div><div class="line"><a name="l00099"></a><span class="lineno">   99</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="l00100"></a><span class="lineno">  100</span>&#160;    byte *representative, <span class="keywordtype">size_t</span> representativeBitLength,</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    byte *recoverableMessage)<span class="keyword"> const</span></div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;<span class="keyword"></span>{</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(messageEmpty), CRYPTOPP_UNUSED(hashIdentifier);</div><div class="line"><a name="l00104"></a><span class="lineno">  104</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="l00105"></a><span class="lineno">  105</span>&#160;</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> u = hashIdentifier.second + 1;</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> representativeByteLength = <a class="code" href="misc_8h.html#a7c5d30b17c9d4869fdc3458dd05c500d">BitsToBytes</a>(representativeBitLength);</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <span class="keyword">const</span> <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="l00109"></a><span class="lineno">  109</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">size_t</span> saltSize = SaltLen(digestSize);</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    <span class="keyword">const</span> byte *<span class="keyword">const</span> h = representative + representativeByteLength - u - digestSize;</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;    <a class="code" href="class_sec_byte_block.html">SecByteBlock</a> digest(digestSize);</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aa0b8c7a110d8968268fd02ec32b9a8e8">Final</a>(digest);</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <a class="code" href="struct_decoding_result.html">DecodingResult</a> result(0);</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    <span class="keywordtype">bool</span> &amp;valid = result.isValidCoding;</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    <span class="keywordtype">size_t</span> &amp;recoverableMessageLength = result.messageLength;</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    valid = (representative[representativeByteLength - 1] == (hashIdentifier.second ? 0xcc : 0xbc)) &amp;&amp; valid;</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    <span class="keywordflow">if</span> (hashIdentifier.first &amp;&amp; hashIdentifier.second)</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        valid = <a class="code" href="misc_8h.html#a8e14b85d64aa63e5ba80471716837c74">VerifyBufsEqual</a>(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second) &amp;&amp; valid;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    GetMGF().<a class="code" href="class_mask_generating_function.html#a7ef49cae6b047a6be64909d63cfa41ba">GenerateAndMask</a>(hash, representative, representativeByteLength - u - digestSize, h, digestSize);</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    <span class="keywordflow">if</span> (representativeBitLength % 8 != 0)</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;        representative[0] = (byte)<a class="code" href="misc_8h.html#a616a7f0365c4947b0c8a44606c525a62">Crop</a>(representative[0], representativeBitLength % 8);</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    <span class="comment">// extract salt and recoverableMessage from DB = 00 ... || 01 || M || salt</span></div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    byte *salt = representative + representativeByteLength - u - digestSize - saltSize;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    byte *M = <a class="code" href="misc_8h.html#ab29e4cf4553b1ff9f884df223a2abd6a">FindIfNot</a>(representative, salt-1, byte(0));</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;    recoverableMessageLength = salt-M-1;</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    <span class="keywordflow">if</span> (*M == 0x01 &amp;&amp;</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;       (<span class="keywordtype">size_t</span>)(M - representative - (representativeBitLength % 8 != 0)) &gt;= MinPadLen(digestSize) &amp;&amp;</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;       recoverableMessageLength &lt;= MaxRecoverableLength(representativeBitLength, hashIdentifier.second, digestSize))</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    {</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;        <span class="keywordflow">if</span> (recoverableMessage)</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;            memcpy(recoverableMessage, M+1, recoverableMessageLength);</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    }</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    <span class="keywordflow">else</span></div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    {</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;        recoverableMessageLength = 0;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;        valid = <span class="keyword">false</span>;</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    }</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    <span class="comment">// verify H = hash of M&#39;</span></div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    byte c[8];</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    <a class="code" href="misc_8h.html#aef6a8d35198f71ff68811bacd599c664">PutWord</a>(<span class="keyword">false</span>, <a class="code" href="cryptlib_8h.html#aaeb92d42f5a6e27b8ba19f18d69d142baf0c3bb6c718cc7ff0bffef4e8f178c57">BIG_ENDIAN_ORDER</a>, c, (word32)SafeRightShift&lt;29&gt;(recoverableMessageLength));</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <a class="code" href="misc_8h.html#aef6a8d35198f71ff68811bacd599c664">PutWord</a>(<span class="keyword">false</span>, <a class="code" href="cryptlib_8h.html#aaeb92d42f5a6e27b8ba19f18d69d142baf0c3bb6c718cc7ff0bffef4e8f178c57">BIG_ENDIAN_ORDER</a>, c+4, word32(recoverableMessageLength &lt;&lt; 3));</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">Update</a>(c, 8);</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">Update</a>(recoverableMessage, recoverableMessageLength);</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">Update</a>(digest, digestSize);</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    hash.<a class="code" href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">Update</a>(salt, saltSize);</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;    valid = hash.<a class="code" href="class_hash_transformation.html#a16c4aecd047015d513feef4ed5b929ba">Verify</a>(h) &amp;&amp; valid;</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    <span class="keywordflow">if</span> (!AllowRecovery() &amp;&amp; valid &amp;&amp; recoverableMessageLength != 0)</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;        {<span class="keywordflow">throw</span> <a class="code" href="class_not_implemented.html">NotImplemented</a>(<span class="stringliteral">&quot;PSSR_MEM: message recovery disabled&quot;</span>);}</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    <span class="keywordflow">return</span> result;</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;}</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;NAMESPACE_END</div><div class="ttc" id="misc_8h_html_ab29e4cf4553b1ff9f884df223a2abd6a"><div class="ttname"><a href="misc_8h.html#ab29e4cf4553b1ff9f884df223a2abd6a">FindIfNot</a></div><div class="ttdeci">InputIt FindIfNot(InputIt first, InputIt last, const T &amp;value)</div><div class="ttdoc">Finds first element not in a range. </div><div class="ttdef"><b>Definition:</b> <a href="misc_8h_source.html#l02540">misc.h:2540</a></div></div>
<div class="ttc" id="misc_8h_html"><div class="ttname"><a href="misc_8h.html">misc.h</a></div><div class="ttdoc">Utility functions for the Crypto++ library. </div></div>
<div class="ttc" id="ripemd_8h_html"><div class="ttname"><a href="ripemd_8h.html">ripemd.h</a></div><div class="ttdoc">Classes for RIPEMD message digest. </div></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="class_random_number_generator_html_a497145546d24e6d4abaf10b7e0f1ba17"><div class="ttname"><a href="class_random_number_generator.html#a497145546d24e6d4abaf10b7e0f1ba17">RandomNumberGenerator::GenerateBlock</a></div><div class="ttdeci">virtual void GenerateBlock(byte *output, size_t size)</div><div class="ttdoc">Generate random array of bytes. </div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8cpp_source.html#l00317">cryptlib.cpp:317</a></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="misc_8h_html_aef6a8d35198f71ff68811bacd599c664"><div class="ttname"><a href="misc_8h.html#aef6a8d35198f71ff68811bacd599c664">PutWord</a></div><div class="ttdeci">void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, const byte *xorBlock=NULL)</div><div class="ttdoc">Access a block of memory. </div><div class="ttdef"><b>Definition:</b> <a href="misc_8h_source.html#l02295">misc.h:2295</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_sec_byte_block_html"><div class="ttname"><a href="class_sec_byte_block.html">SecByteBlock</a></div><div class="ttdoc">SecBlock&lt;byte&gt; typedef. </div><div class="ttdef"><b>Definition:</b> <a href="secblock_8h_source.html#l00822">secblock.h:822</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="struct_decoding_result_html"><div class="ttname"><a href="struct_decoding_result.html">DecodingResult</a></div><div class="ttdoc">Returns a decoding results. </div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8h_source.html#l00252">cryptlib.h:252</a></div></div>
<div class="ttc" id="class_mask_generating_function_html_a7ef49cae6b047a6be64909d63cfa41ba"><div class="ttname"><a href="class_mask_generating_function.html#a7ef49cae6b047a6be64909d63cfa41ba">MaskGeneratingFunction::GenerateAndMask</a></div><div class="ttdeci">virtual void GenerateAndMask(HashTransformation &amp;hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, bool mask=true) const =0</div><div class="ttdoc">Generate and apply mask. </div></div>
<div class="ttc" id="class_not_implemented_html"><div class="ttname"><a href="class_not_implemented.html">NotImplemented</a></div><div class="ttdoc">A method was called which was not implemented. </div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8h_source.html#l00220">cryptlib.h:220</a></div></div>
<div class="ttc" id="misc_8h_html_a616a7f0365c4947b0c8a44606c525a62"><div class="ttname"><a href="misc_8h.html#a616a7f0365c4947b0c8a44606c525a62">Crop</a></div><div class="ttdeci">T Crop(T value, size_t bits)</div><div class="ttdoc">Truncates the value to the specified number of bits. </div><div class="ttdef"><b>Definition:</b> <a href="misc_8h_source.html#l00778">misc.h:778</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="misc_8h_html_a30712a90999ad9d9152975f2e92d46b8"><div class="ttname"><a href="misc_8h.html#a30712a90999ad9d9152975f2e92d46b8">SaturatingSubtract</a></div><div class="ttdeci">T1 SaturatingSubtract(const T1 &amp;a, const T2 &amp;b)</div><div class="ttdoc">Performs a saturating subtract clamped at 0. </div><div class="ttdef"><b>Definition:</b> <a href="misc_8h_source.html#l00890">misc.h:890</a></div></div>
<div class="ttc" id="cryptlib_8h_html_aaeb92d42f5a6e27b8ba19f18d69d142baf0c3bb6c718cc7ff0bffef4e8f178c57"><div class="ttname"><a href="cryptlib_8h.html#aaeb92d42f5a6e27b8ba19f18d69d142baf0c3bb6c718cc7ff0bffef4e8f178c57">BIG_ENDIAN_ORDER</a></div><div class="ttdoc">byte order is big-endian </div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8h_source.html#l00144">cryptlib.h:144</a></div></div>
<div class="ttc" id="class_hash_transformation_html_a16c4aecd047015d513feef4ed5b929ba"><div class="ttname"><a href="class_hash_transformation.html#a16c4aecd047015d513feef4ed5b929ba">HashTransformation::Verify</a></div><div class="ttdeci">virtual bool Verify(const byte *digest)</div><div class="ttdoc">Verifies the hash of the current message. </div><div class="ttdef"><b>Definition:</b> <a href="cryptlib_8h_source.html#l01151">cryptlib.h:1151</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="whrlpool_8h_html"><div class="ttname"><a href="whrlpool_8h.html">whrlpool.h</a></div><div class="ttdoc">Classes for the Whirlpool message digest. </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="misc_8h_html_a6aaae7768600b9d735a5e1b8192035f8"><div class="ttname"><a href="misc_8h.html#a6aaae7768600b9d735a5e1b8192035f8">xorbuf</a></div><div class="ttdeci">void xorbuf(byte *buf, const byte *mask, size_t count)</div><div class="ttdoc">Performs an XOR of a buffer with a mask. </div><div class="ttdef"><b>Definition:</b> <a href="misc_8cpp_source.html#l00032">misc.cpp:32</a></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="misc_8h_html_a8e14b85d64aa63e5ba80471716837c74"><div class="ttname"><a href="misc_8h.html#a8e14b85d64aa63e5ba80471716837c74">VerifyBufsEqual</a></div><div class="ttdeci">bool VerifyBufsEqual(const byte *buf1, const byte *buf2, size_t count)</div><div class="ttdoc">Performs a near constant-time comparison of two equally sized buffers. </div><div class="ttdef"><b>Definition:</b> <a href="misc_8cpp_source.html#l00100">misc.cpp:100</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 class="ttc" id="pssr_8h_html"><div class="ttname"><a href="pssr_8h.html">pssr.h</a></div><div class="ttdoc">Classes for probablistic signature schemes. </div></div>
<div class="ttc" id="class_hash_transformation_html_aafabefaf445b65d3ba0d8e1c0294afe5"><div class="ttname"><a href="class_hash_transformation.html#aafabefaf445b65d3ba0d8e1c0294afe5">HashTransformation::Update</a></div><div class="ttdeci">virtual void Update(const byte *input, size_t length)=0</div><div class="ttdoc">Updates a hash with additional input. </div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Sep 16 2018 07:57:59 for Crypto++ by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>