mirror of
https://gitlab.redox-os.org/CoffeeCode/redox-ssh.git
synced 2025-12-29 00:02:18 +01:00
298 lines
No EOL
16 KiB
HTML
298 lines
No EOL
16 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="generator" content="rustdoc">
|
||
<meta name="description" content="API documentation for the Rust `sha2` mod in crate `crypto`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, sha2">
|
||
|
||
<title>crypto::sha2 - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../../normalize.css">
|
||
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
|
||
<link rel="stylesheet" type="text/css" href="../../main.css">
|
||
|
||
|
||
|
||
|
||
</head>
|
||
<body class="rustdoc mod">
|
||
<!--[if lte IE 8]>
|
||
<div class="warning">
|
||
This old browser is unsupported and will most likely display funky
|
||
things.
|
||
</div>
|
||
<![endif]-->
|
||
|
||
|
||
|
||
<nav class="sidebar">
|
||
|
||
<p class='location'>Module sha2</p><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#constants">Constants</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'><a href='../index.html'>crypto</a></p><script>window.sidebarCurrent = {name: 'sha2', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script>
|
||
</nav>
|
||
|
||
<nav class="sub">
|
||
<form class="search-form js-only">
|
||
<div class="search-container">
|
||
<input class="search-input" name="search"
|
||
autocomplete="off"
|
||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
||
type="search">
|
||
</div>
|
||
</form>
|
||
</nav>
|
||
|
||
<section id='main' class="content">
|
||
<h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>crypto</a>::<wbr><a class="mod" href=''>sha2</a></span><span class='out-of-band'><span id='render-detail'>
|
||
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
|
||
[<span class='inner'>−</span>]
|
||
</a>
|
||
</span><a class='srclink' href='../../src/crypto/sha2.rs.html#11-1496' title='goto source code'>[src]</a></span></h1>
|
||
<div class='docblock'><p>An implementation of the SHA-2 cryptographic hash algorithms.</p>
|
||
|
||
<p>There are 6 standard algorithms specified in the SHA-2 standard:</p>
|
||
|
||
<ul>
|
||
<li><code>Sha224</code>, which is the 32-bit <code>Sha256</code> algorithm with the result truncated to 224 bits.</li>
|
||
<li><code>Sha256</code>, which is the 32-bit <code>Sha256</code> algorithm.</li>
|
||
<li><code>Sha384</code>, which is the 64-bit <code>Sha512</code> algorithm with the result truncated to 384 bits.</li>
|
||
<li><code>Sha512</code>, which is the 64-bit <code>Sha512</code> algorithm.</li>
|
||
<li><code>Sha512Trunc224</code>, which is the 64-bit <code>Sha512</code> algorithm with the result truncated to 224 bits.</li>
|
||
<li><code>Sha512Trunc256</code>, which is the 64-bit <code>Sha512</code> algorithm with the result truncated to 256 bits.</li>
|
||
</ul>
|
||
|
||
<p>Algorithmically, there are only 2 core algorithms: <code>Sha256</code> and <code>Sha512</code>.
|
||
All other algorithms are just applications of these with different initial hash
|
||
values, and truncated to different digest bit lengths.</p>
|
||
|
||
<h1 id='usage' class='section-header'><a href='#usage'>Usage</a></h1>
|
||
<p>An example of using <code>Sha256</code> is:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="self">self</span>::<span class="ident">crypto</span>::<span class="ident">digest</span>::<span class="ident">Digest</span>;
|
||
<span class="kw">use</span> <span class="self">self</span>::<span class="ident">crypto</span>::<span class="ident">sha2</span>::<span class="ident">Sha256</span>;
|
||
|
||
<span class="comment">// create a Sha256 object</span>
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">hasher</span> <span class="op">=</span> <span class="ident">Sha256</span>::<span class="ident">new</span>();
|
||
|
||
<span class="comment">// write input message</span>
|
||
<span class="ident">hasher</span>.<span class="ident">input_str</span>(<span class="string">"hello world"</span>);
|
||
|
||
<span class="comment">// read hash digest</span>
|
||
<span class="kw">let</span> <span class="ident">hex</span> <span class="op">=</span> <span class="ident">hasher</span>.<span class="ident">result_str</span>();
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">hex</span>,
|
||
<span class="macro">concat</span><span class="macro">!</span>(<span class="string">"b94d27b9934d3e08a52e52d7da7dabfa"</span>,
|
||
<span class="string">"c484efe37a5380ee9088f7ace2efcde9"</span>));</pre>
|
||
|
||
<p>An example of using <code>Sha512</code> is:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="self">self</span>::<span class="ident">crypto</span>::<span class="ident">digest</span>::<span class="ident">Digest</span>;
|
||
<span class="kw">use</span> <span class="self">self</span>::<span class="ident">crypto</span>::<span class="ident">sha2</span>::<span class="ident">Sha512</span>;
|
||
|
||
<span class="comment">// create a Sha512 object</span>
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">hasher</span> <span class="op">=</span> <span class="ident">Sha512</span>::<span class="ident">new</span>();
|
||
|
||
<span class="comment">// write input message</span>
|
||
<span class="ident">hasher</span>.<span class="ident">input_str</span>(<span class="string">"hello world"</span>);
|
||
|
||
<span class="comment">// read hash digest</span>
|
||
<span class="kw">let</span> <span class="ident">hex</span> <span class="op">=</span> <span class="ident">hasher</span>.<span class="ident">result_str</span>();
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">hex</span>,
|
||
<span class="macro">concat</span><span class="macro">!</span>(<span class="string">"309ecc489c12d6eb4cc40f50c902f2b4"</span>,
|
||
<span class="string">"d0ed77ee511a7c7a9bcd3ca86d4cd86f"</span>,
|
||
<span class="string">"989dd35bc5ff499670da34255b45b0cf"</span>,
|
||
<span class="string">"d830e81f605dcf7dc5542e93ae9cd76f"</span>));</pre>
|
||
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
||
<table>
|
||
<tr class=' module-item'>
|
||
<td><a class="struct" href="struct.Sha224.html"
|
||
title='struct crypto::sha2::Sha224'>Sha224</a></td>
|
||
<td class='docblock-short'>
|
||
<p>The SHA-256 hash algorithm with the SHA-224 initial hash value. The result is truncated to 224 bits.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="struct" href="struct.Sha256.html"
|
||
title='struct crypto::sha2::Sha256'>Sha256</a></td>
|
||
<td class='docblock-short'>
|
||
<p>The SHA-256 hash algorithm with the SHA-256 initial hash value.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="struct" href="struct.Sha384.html"
|
||
title='struct crypto::sha2::Sha384'>Sha384</a></td>
|
||
<td class='docblock-short'>
|
||
<p>The SHA-512 hash algorithm with the SHA-384 initial hash value. The result is truncated to 384 bits.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="struct" href="struct.Sha512.html"
|
||
title='struct crypto::sha2::Sha512'>Sha512</a></td>
|
||
<td class='docblock-short'>
|
||
<p>The SHA-512 hash algorithm with the SHA-512 initial hash value.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="struct" href="struct.Sha512Trunc224.html"
|
||
title='struct crypto::sha2::Sha512Trunc224'>Sha512Trunc224</a></td>
|
||
<td class='docblock-short'>
|
||
<p>The SHA-512 hash algorithm with the SHA-512/224 initial hash value. The result is truncated to 224 bits.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="struct" href="struct.Sha512Trunc256.html"
|
||
title='struct crypto::sha2::Sha512Trunc256'>Sha512Trunc256</a></td>
|
||
<td class='docblock-short'>
|
||
<p>The SHA-512 hash algorithm with the SHA-512/256 initial hash value. The result is truncated to 256 bits.</p>
|
||
</td>
|
||
</tr></table><h2 id='constants' class='section-header'><a href="#constants">Constants</a></h2>
|
||
<table>
|
||
<tr class=' module-item'>
|
||
<td><a class="constant" href="constant.K32.html"
|
||
title='constant crypto::sha2::K32'>K32</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Constants necessary for SHA-256 family of digests.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="constant" href="constant.K64.html"
|
||
title='constant crypto::sha2::K64'>K64</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Constants necessary for SHA-512 family of digests.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="constant" href="constant.K32X4.html"
|
||
title='constant crypto::sha2::K32X4'>K32X4</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Constants necessary for SHA-256 family of digests.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="constant" href="constant.K64X2.html"
|
||
title='constant crypto::sha2::K64X2'>K64X2</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Constants necessary for SHA-512 family of digests.</p>
|
||
</td>
|
||
</tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
|
||
<table>
|
||
<tr class=' module-item'>
|
||
<td><a class="fn" href="fn.sha256_digest_block.html"
|
||
title='fn crypto::sha2::sha256_digest_block'>sha256_digest_block</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Process a block with the SHA-256 algorithm. (See more...)</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="fn" href="fn.sha256_digest_block_u32.html"
|
||
title='fn crypto::sha2::sha256_digest_block_u32'>sha256_digest_block_u32</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Process a block with the SHA-256 algorithm.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="fn" href="fn.sha256_digest_round_x2.html"
|
||
title='fn crypto::sha2::sha256_digest_round_x2'>sha256_digest_round_x2</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Emulates <code>llvm.x86.sha256rnds2</code> intrinsic.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="fn" href="fn.sha256_schedule_x4.html"
|
||
title='fn crypto::sha2::sha256_schedule_x4'>sha256_schedule_x4</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Performs 4 rounds of the SHA-256 message schedule update.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="fn" href="fn.sha512_digest_block.html"
|
||
title='fn crypto::sha2::sha512_digest_block'>sha512_digest_block</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Process a block with the SHA-512 algorithm. (See more...)</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="fn" href="fn.sha512_digest_block_u64.html"
|
||
title='fn crypto::sha2::sha512_digest_block_u64'>sha512_digest_block_u64</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Process a block with the SHA-512 algorithm.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="fn" href="fn.sha512_digest_round.html"
|
||
title='fn crypto::sha2::sha512_digest_round'>sha512_digest_round</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Performs one round of the SHA-512 message block digest.</p>
|
||
</td>
|
||
</tr>
|
||
<tr class=' module-item'>
|
||
<td><a class="fn" href="fn.sha512_schedule_x2.html"
|
||
title='fn crypto::sha2::sha512_schedule_x2'>sha512_schedule_x2</a></td>
|
||
<td class='docblock-short'>
|
||
<p>Performs 2 rounds of the SHA-512 message schedule update.</p>
|
||
</td>
|
||
</tr></table></section>
|
||
<section id='search' class="content hidden"></section>
|
||
|
||
<section class="footer"></section>
|
||
|
||
<aside id="help" class="hidden">
|
||
<div>
|
||
<h1 class="hidden">Help</h1>
|
||
|
||
<div class="shortcuts">
|
||
<h2>Keyboard Shortcuts</h2>
|
||
|
||
<dl>
|
||
<dt>?</dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt>S</dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt>⇤</dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt>⇥</dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt>⏎</dt>
|
||
<dd>Go to active search result</dd>
|
||
<dt>+</dt>
|
||
<dd>Collapse/expand all sections</dd>
|
||
</dl>
|
||
</div>
|
||
|
||
<div class="infos">
|
||
<h2>Search Tricks</h2>
|
||
|
||
<p>
|
||
Prefix searches with a type followed by a colon (e.g.
|
||
<code>fn:</code>) to restrict the search to a given type.
|
||
</p>
|
||
|
||
<p>
|
||
Accepted types are: <code>fn</code>, <code>mod</code>,
|
||
<code>struct</code>, <code>enum</code>,
|
||
<code>trait</code>, <code>type</code>, <code>macro</code>,
|
||
and <code>const</code>.
|
||
</p>
|
||
|
||
<p>
|
||
Search functions by type signature (e.g.
|
||
<code>vec -> usize</code> or <code>* -> vec</code>)
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
|
||
|
||
<script>
|
||
window.rootPath = "../../";
|
||
window.currentCrate = "crypto";
|
||
</script>
|
||
<script src="../../main.js"></script>
|
||
<script defer src="../../search-index.js"></script>
|
||
</body>
|
||
</html> |