Documentation for 0931d530ae

This commit is contained in:
github-actions
2023-01-22 19:44:10 +00:00
parent a448f64699
commit b48f6e8671
2457 changed files with 9513 additions and 8691 deletions

View File

@@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: hashing/sha1.cpp File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.5 -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
@@ -132,35 +132,35 @@ Namespaces</h2></td></tr>
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:acf6bd970f29a68702bdbdfe8338e45e0"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d7a/sha1_8cpp.html#acf6bd970f29a68702bdbdfe8338e45e0">hashing::sha1::leftRotate32bits</a> (uint32_t n, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a> rotate)</td></tr>
<tr class="memdesc:acf6bd970f29a68702bdbdfe8338e45e0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Rotates the bits of a 32-bit unsigned integer. <a href="../../d8/d7a/sha1_8cpp.html#acf6bd970f29a68702bdbdfe8338e45e0">More...</a><br /></td></tr>
<tr class="memdesc:acf6bd970f29a68702bdbdfe8338e45e0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Rotates the bits of a 32-bit unsigned integer. <br /></td></tr>
<tr class="separator:acf6bd970f29a68702bdbdfe8338e45e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aada0803ef851d831b7a290a924e3c228"><td class="memItemLeft" align="right" valign="top"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d7a/sha1_8cpp.html#aada0803ef851d831b7a290a924e3c228">hashing::sha1::sig2hex</a> (void *sig)</td></tr>
<tr class="memdesc:aada0803ef851d831b7a290a924e3c228"><td class="mdescLeft">&#160;</td><td class="mdescRight">Transforms the 160-bit SHA-1 signature into a 40 char hex string. <a href="../../d8/d7a/sha1_8cpp.html#aada0803ef851d831b7a290a924e3c228">More...</a><br /></td></tr>
<tr class="memdesc:aada0803ef851d831b7a290a924e3c228"><td class="mdescLeft">&#160;</td><td class="mdescRight">Transforms the 160-bit SHA-1 signature into a 40 char hex string. <br /></td></tr>
<tr class="separator:aada0803ef851d831b7a290a924e3c228"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7be3471f7e489d7d0df42b97a48bf141"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d7a/sha1_8cpp.html#a7be3471f7e489d7d0df42b97a48bf141">hashing::sha1::hash_bs</a> (const void *input_bs, uint64_t input_size)</td></tr>
<tr class="memdesc:a7be3471f7e489d7d0df42b97a48bf141"><td class="mdescLeft">&#160;</td><td class="mdescRight">The SHA-1 algorithm itself, taking in a bytestring. <a href="../../d8/d7a/sha1_8cpp.html#a7be3471f7e489d7d0df42b97a48bf141">More...</a><br /></td></tr>
<tr class="memdesc:a7be3471f7e489d7d0df42b97a48bf141"><td class="mdescLeft">&#160;</td><td class="mdescRight">The SHA-1 algorithm itself, taking in a bytestring. <br /></td></tr>
<tr class="separator:a7be3471f7e489d7d0df42b97a48bf141"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2397f2444a05e4d1487c67e215410d3c"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d7a/sha1_8cpp.html#a2397f2444a05e4d1487c67e215410d3c">hashing::sha1::hash</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> &amp;message)</td></tr>
<tr class="memdesc:a2397f2444a05e4d1487c67e215410d3c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Converts the string to bytestring and calls the main algorithm. <a href="../../d8/d7a/sha1_8cpp.html#a2397f2444a05e4d1487c67e215410d3c">More...</a><br /></td></tr>
<tr class="memdesc:a2397f2444a05e4d1487c67e215410d3c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Converts the string to bytestring and calls the main algorithm. <br /></td></tr>
<tr class="separator:a2397f2444a05e4d1487c67e215410d3c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d7a/sha1_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Self-test implementations of well-known SHA-1 hashes. <a href="../../d8/d7a/sha1_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">More...</a><br /></td></tr>
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Self-test implementations of well-known SHA-1 hashes. <br /></td></tr>
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac9e1a11f44135b890dd10a00e73b5661"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d7a/sha1_8cpp.html#ac9e1a11f44135b890dd10a00e73b5661">interactive</a> ()</td></tr>
<tr class="memdesc:ac9e1a11f44135b890dd10a00e73b5661"><td class="mdescLeft">&#160;</td><td class="mdescRight">Puts user in a loop where inputs can be given and SHA-1 hash will be computed and printed. <a href="../../d8/d7a/sha1_8cpp.html#ac9e1a11f44135b890dd10a00e73b5661">More...</a><br /></td></tr>
<tr class="memdesc:ac9e1a11f44135b890dd10a00e73b5661"><td class="mdescLeft">&#160;</td><td class="mdescRight">Puts user in a loop where inputs can be given and SHA-1 hash will be computed and printed. <br /></td></tr>
<tr class="separator:ac9e1a11f44135b890dd10a00e73b5661"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d8/d7a/sha1_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <a href="../../d8/d7a/sha1_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">More...</a><br /></td></tr>
<tr class="memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function. <br /></td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Simple C++ implementation of the <a href="https://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA-1 Hashing Algorithm</a> </p>
<div class="textblock"><p>Simple C++ implementation of the <a href="https://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA-1 Hashing Algorithm</a> </p>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/tGautot" target="_blank">tGautot</a> </dd></dl>
<p><a href="https://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA-1</a> is a cryptographic hash function that was developped by the <a href="https://en.wikipedia.org/wiki/National_Security_Agency" target="_blank">NSA</a> 1995. SHA-1 is not considered secure since around 2010.</p>
<h3><a class="anchor" id="autotoc_md83"></a>
Algorithm</h3>
<p >The first step of the algorithm is to pad the message for its length to be a multiple of 64 (bytes). This is done by first adding 0x80 (10000000) and then only zeroes until the last 8 bytes must be filled, where then the 64 bit size of the input will be added</p>
<p >Once this is done, the algo breaks down this padded message into 64 bytes chunks. Each chunk is used for one <em>round</em>, a round breaks the chunk into 16 blocks of 4 bytes. These 16 blocks are then extended to 80 blocks using <a class="el" href="../../d7/d47/namespace_x_o_r.html" title="Functions for XOR cipher algorithm.">XOR</a> operations on existing blocks (see code for more details). The algorithm will then update its 160-bit state (here represented used 5 32-bits integer) using partial hashes computed using special functions on the blocks previously built. Please take a look at the <a href="https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode" target="_blank">wikipedia article</a> for more precision on these operations </p><dl class="section note"><dt>Note</dt><dd>This is a simple implementation for a byte string but some implmenetations can work on bytestream, messages of unknown length. </dd></dl>
<p>The first step of the algorithm is to pad the message for its length to be a multiple of 64 (bytes). This is done by first adding 0x80 (10000000) and then only zeroes until the last 8 bytes must be filled, where then the 64 bit size of the input will be added</p>
<p>Once this is done, the algo breaks down this padded message into 64 bytes chunks. Each chunk is used for one <em>round</em>, a round breaks the chunk into 16 blocks of 4 bytes. These 16 blocks are then extended to 80 blocks using <a class="el" href="../../d7/d47/namespace_x_o_r.html" title="Functions for XOR cipher algorithm.">XOR</a> operations on existing blocks (see code for more details). The algorithm will then update its 160-bit state (here represented used 5 32-bits integer) using partial hashes computed using special functions on the blocks previously built. Please take a look at the <a href="https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode" target="_blank">wikipedia article</a> for more precision on these operations </p><dl class="section note"><dt>Note</dt><dd>This is a simple implementation for a byte string but some implmenetations can work on bytestream, messages of unknown length. </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a2397f2444a05e4d1487c67e215410d3c" name="a2397f2444a05e4d1487c67e215410d3c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2397f2444a05e4d1487c67e215410d3c">&#9670;&#160;</a></span>hash()</h2>
@@ -638,7 +638,7 @@ Here is the call graph for this function:</div>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_ece9b94c107bbaa1dd68197a8c9983b9.html">hashing</a></li><li class="navelem"><a class="el" href="../../d8/d7a/sha1_8cpp.html">sha1.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5 </li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6 </li>
</ul>
</div>
</body>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
-->
<!-- Title: hashing::sha1::hash Pages: 1 -->
<svg width="232pt" height="27pt"

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
-->
<!-- Title: hashing::sha1::hash_bs Pages: 1 -->
<svg width="256pt" height="64pt"

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
-->
<!-- Title: test Pages: 1 -->
<svg width="131pt" height="27pt"

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
-->
<!-- Title: interactive Pages: 1 -->
<svg width="210pt" height="101pt"

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
-->
<!-- Title: main Pages: 1 -->
<svg width="284pt" height="101pt"

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB