51 lines
10 KiB
HTML
51 lines
10 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 `aes` mod in crate `openssl`."><meta name="keywords" content="rust, rustlang, rust-lang, aes"><title>openssl::aes - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></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"><div class="sidebar-menu">☰</div><a href='../../openssl/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module aes</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#functions">Functions</a></li></ul></div><p class="location"><a href="../index.html">openssl</a></p><script>window.sidebarCurrent = {name: "aes", ty: "mod", relpath: "../"};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><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/openssl/aes.rs.html#1-292" title="goto source code">[src]</a></span><span class="in-band">Module <a href="../index.html">openssl</a>::<wbr><a class="mod" href="">aes</a></span></h1><div class="docblock"><p>Low level AES IGE and key wrapping functionality</p>
|
||
<p>AES ECB, CBC, XTS, CTR, CFB, GCM and other conventional symmetric encryption
|
||
modes are found in <a href="../symm/index.html"><code>symm</code></a>. This is the implementation of AES IGE and key wrapping</p>
|
||
<p>Advanced Encryption Standard (AES) provides symmetric key cipher that
|
||
the same key is used to encrypt and decrypt data. This implementation
|
||
uses 128, 192, or 256 bit keys. This module provides functions to
|
||
create a new key with <a href="struct.AesKey.html#method.new_encrypt"><code>new_encrypt</code></a> and perform an encryption/decryption
|
||
using that key with <a href="fn.aes_ige.html"><code>aes_ige</code></a>.</p>
|
||
<p>The <a href="../symm/index.html"><code>symm</code></a> module should be used in preference to this module in most cases.
|
||
The IGE block cypher is a non-traditional cipher mode. More traditional AES
|
||
encryption methods are found in the <a href="../symm/struct.Crypter.html"><code>Crypter</code></a> and <a href="../symm/struct.Cipher.html"><code>Cipher</code></a> structs.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1><h2 id="aes-ige" class="section-header"><a href="#aes-ige">AES IGE</a></h2>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">openssl</span>::<span class="ident">aes</span>::{<span class="ident">AesKey</span>, <span class="ident">aes_ige</span>};
|
||
<span class="kw">use</span> <span class="ident">openssl</span>::<span class="ident">symm</span>::<span class="ident">Mode</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">key</span> <span class="op">=</span> <span class="string">b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"</span>;
|
||
<span class="kw">let</span> <span class="ident">plaintext</span> <span class="op">=</span> <span class="string">b"\x12\x34\x56\x78\x90\x12\x34\x56\x12\x34\x56\x78\x90\x12\x34\x56"</span>;
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iv</span> <span class="op">=</span> <span class="kw-2">*</span><span class="string">b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\
|
||
\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">key</span> <span class="op">=</span> <span class="ident">AesKey</span>::<span class="ident">new_encrypt</span>(<span class="ident">key</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">output</span> <span class="op">=</span> [<span class="number">0u8</span>; <span class="number">16</span>];
|
||
<span class="ident">aes_ige</span>(<span class="ident">plaintext</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">output</span>, <span class="kw-2">&</span><span class="ident">key</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">iv</span>, <span class="ident">Mode</span>::<span class="ident">Encrypt</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">output</span>, <span class="kw-2">*</span><span class="string">b"\xa6\xad\x97\x4d\x5c\xea\x1d\x36\xd2\xf3\x67\x98\x09\x07\xed\x32"</span>);</pre></div>
|
||
<h2 id="key-wrapping" class="section-header"><a href="#key-wrapping">Key wrapping</a></h2>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">openssl</span>::<span class="ident">aes</span>::{<span class="ident">AesKey</span>, <span class="ident">unwrap_key</span>, <span class="ident">wrap_key</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">kek</span> <span class="op">=</span> <span class="string">b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"</span>;
|
||
<span class="kw">let</span> <span class="ident">key_to_wrap</span> <span class="op">=</span> <span class="string">b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF"</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">enc_key</span> <span class="op">=</span> <span class="ident">AesKey</span>::<span class="ident">new_encrypt</span>(<span class="ident">kek</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">ciphertext</span> <span class="op">=</span> [<span class="number">0u8</span>; <span class="number">24</span>];
|
||
<span class="ident">wrap_key</span>(<span class="kw-2">&</span><span class="ident">enc_key</span>, <span class="prelude-val">None</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">ciphertext</span>, <span class="kw-2">&</span><span class="ident">key_to_wrap</span>[..]).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="ident">dec_key</span> <span class="op">=</span> <span class="ident">AesKey</span>::<span class="ident">new_decrypt</span>(<span class="ident">kek</span>).<span class="ident">unwrap</span>();
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">orig_key</span> <span class="op">=</span> [<span class="number">0u8</span>; <span class="number">16</span>];
|
||
<span class="ident">unwrap_key</span>(<span class="kw-2">&</span><span class="ident">dec_key</span>, <span class="prelude-val">None</span>, <span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">orig_key</span>, <span class="kw-2">&</span><span class="ident">ciphertext</span>[..]).<span class="ident">unwrap</span>();
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&</span><span class="ident">orig_key</span>[..], <span class="kw-2">&</span><span class="ident">key_to_wrap</span>[..]);</pre></div>
|
||
</div><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||
<table><tr class="module-item"><td><a class="struct" href="struct.AesKey.html" title="openssl::aes::AesKey struct">AesKey</a></td><td class="docblock-short"><p>The key used to encrypt or decrypt cipher blocks.</p>
|
||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.KeyError.html" title="openssl::aes::KeyError struct">KeyError</a></td><td class="docblock-short"><p>Provides Error handling for parsing keys.</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.aes_ige.html" title="openssl::aes::aes_ige fn">aes_ige</a></td><td class="docblock-short"><p>Performs AES IGE encryption or decryption</p>
|
||
</td></tr><tr class="module-item"><td><a class="fn" href="fn.unwrap_key.html" title="openssl::aes::unwrap_key fn">unwrap_key</a></td><td class="docblock-short"><p>Unwrap a key, according to <a href="https://tools.ietf.org/html/rfc3394">RFC 3394</a></p>
|
||
</td></tr><tr class="module-item"><td><a class="fn" href="fn.wrap_key.html" title="openssl::aes::wrap_key fn">wrap_key</a></td><td class="docblock-short"><p>Wrap a key, according to <a href="https://tools.ietf.org/html/rfc3394">RFC 3394</a></p>
|
||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "openssl";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |