mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-17 16:29:50 +00:00
deploy: de38ae62916547ad097c066f94a32e9ba7790eeb
This commit is contained in:
commit
9a86359447
28502 changed files with 1261284 additions and 0 deletions
16
openssl/symm/enum.Mode.html
Normal file
16
openssl/symm/enum.Mode.html
Normal file
File diff suppressed because one or more lines are too long
30
openssl/symm/fn.decrypt.html
Normal file
30
openssl/symm/fn.decrypt.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!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="Decrypts data in one go, and returns the decrypted data."><title>decrypt in openssl::symm - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="openssl" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../openssl/index.html">openssl</a><span class="version">0.10.68</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">decrypt</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In openssl::<wbr>symm</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">openssl</a>::<wbr><a href="index.html">symm</a></span><h1>Function <span class="fn">decrypt</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/openssl/symm.rs.html#812-819">Source</a> </span></div><pre class="rust item-decl"><code>pub fn decrypt(
|
||||
t: <a class="struct" href="struct.Cipher.html" title="struct openssl::symm::Cipher">Cipher</a>,
|
||||
key: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
iv: <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]>,
|
||||
data: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>>, <a class="struct" href="../error/struct.ErrorStack.html" title="struct openssl::error::ErrorStack">ErrorStack</a>></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Decrypts data in one go, and returns the decrypted data.</p>
|
||||
<p>Data is decrypted using the specified cipher type <code>t</code> in decrypt mode with the specified <code>key</code>
|
||||
and initialization vector <code>iv</code>. Padding is enabled.</p>
|
||||
<p>This is a convenient interface to <code>Crypter</code> to decrypt all data in one go. To decrypt a stream
|
||||
of data incrementally , use <code>Crypter</code> instead.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>Decrypt data in AES128 CBC mode</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::symm::{decrypt, Cipher};
|
||||
|
||||
<span class="kw">let </span>cipher = Cipher::aes_128_cbc();
|
||||
<span class="kw">let </span>data = <span class="string">b"\xB4\xB9\xE7\x30\xD6\xD6\xF7\xDE\x77\x3F\x1C\xFF\xB3\x3E\x44\x5A\x91\xD7\x27\x62\
|
||||
\x87\x4D\xFB\x3C\x5E\xC4\x59\x72\x4A\xF4\x7C\xA1"</span>;
|
||||
<span class="kw">let </span>key = <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>iv = <span class="string">b"\x00\x01\x02\x03\x04\x05\x06\x07\x00\x01\x02\x03\x04\x05\x06\x07"</span>;
|
||||
<span class="kw">let </span>ciphertext = decrypt(
|
||||
cipher,
|
||||
key,
|
||||
<span class="prelude-val">Some</span>(iv),
|
||||
data).unwrap();
|
||||
|
||||
<span class="macro">assert_eq!</span>(
|
||||
<span class="string">b"Some Crypto Text"</span>,
|
||||
<span class="kw-2">&</span>ciphertext[..]);</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
11
openssl/symm/fn.decrypt_aead.html
Normal file
11
openssl/symm/fn.decrypt_aead.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!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="Like `decrypt`, but for AEAD ciphers such as AES GCM."><title>decrypt_aead in openssl::symm - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="openssl" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../openssl/index.html">openssl</a><span class="version">0.10.68</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In openssl::<wbr>symm</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">openssl</a>::<wbr><a href="index.html">symm</a></span><h1>Function <span class="fn">decrypt_aead</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/openssl/symm.rs.html#875-906">Source</a> </span></div><pre class="rust item-decl"><code>pub fn decrypt_aead(
|
||||
t: <a class="struct" href="struct.Cipher.html" title="struct openssl::symm::Cipher">Cipher</a>,
|
||||
key: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
iv: <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]>,
|
||||
aad: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
data: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
tag: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>>, <a class="struct" href="../error/struct.ErrorStack.html" title="struct openssl::error::ErrorStack">ErrorStack</a>></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Like <code>decrypt</code>, but for AEAD ciphers such as AES GCM.</p>
|
||||
<p>Additional Authenticated Data can be provided in the <code>aad</code> field, and the authentication tag
|
||||
should be provided in the <code>tag</code> field.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
30
openssl/symm/fn.encrypt.html
Normal file
30
openssl/symm/fn.encrypt.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!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="Encrypts data in one go, and returns the encrypted data."><title>encrypt in openssl::symm - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="openssl" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../openssl/index.html">openssl</a><span class="version">0.10.68</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">encrypt</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In openssl::<wbr>symm</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">openssl</a>::<wbr><a href="index.html">symm</a></span><h1>Function <span class="fn">encrypt</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/openssl/symm.rs.html#773-780">Source</a> </span></div><pre class="rust item-decl"><code>pub fn encrypt(
|
||||
t: <a class="struct" href="struct.Cipher.html" title="struct openssl::symm::Cipher">Cipher</a>,
|
||||
key: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
iv: <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]>,
|
||||
data: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>>, <a class="struct" href="../error/struct.ErrorStack.html" title="struct openssl::error::ErrorStack">ErrorStack</a>></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Encrypts data in one go, and returns the encrypted data.</p>
|
||||
<p>Data is encrypted using the specified cipher type <code>t</code> in encrypt mode with the specified <code>key</code>
|
||||
and initialization vector <code>iv</code>. Padding is enabled.</p>
|
||||
<p>This is a convenient interface to <code>Crypter</code> to encrypt all data in one go. To encrypt a stream
|
||||
of data incrementally , use <code>Crypter</code> instead.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>Encrypt data in AES128 CBC mode</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::symm::{encrypt, Cipher};
|
||||
|
||||
<span class="kw">let </span>cipher = Cipher::aes_128_cbc();
|
||||
<span class="kw">let </span>data = <span class="string">b"Some Crypto Text"</span>;
|
||||
<span class="kw">let </span>key = <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>iv = <span class="string">b"\x00\x01\x02\x03\x04\x05\x06\x07\x00\x01\x02\x03\x04\x05\x06\x07"</span>;
|
||||
<span class="kw">let </span>ciphertext = encrypt(
|
||||
cipher,
|
||||
key,
|
||||
<span class="prelude-val">Some</span>(iv),
|
||||
data).unwrap();
|
||||
|
||||
<span class="macro">assert_eq!</span>(
|
||||
<span class="string">b"\xB4\xB9\xE7\x30\xD6\xD6\xF7\xDE\x77\x3F\x1C\xFF\xB3\x3E\x44\x5A\x91\xD7\x27\x62\x87\x4D\
|
||||
\xFB\x3C\x5E\xC4\x59\x72\x4A\xF4\x7C\xA1"</span>,
|
||||
<span class="kw-2">&</span>ciphertext[..]);</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
14
openssl/symm/fn.encrypt_aead.html
Normal file
14
openssl/symm/fn.encrypt_aead.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<!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="Like `encrypt`, but for AEAD ciphers such as AES GCM."><title>encrypt_aead in openssl::symm - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="openssl" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../openssl/index.html">openssl</a><span class="version">0.10.68</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In openssl::<wbr>symm</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">openssl</a>::<wbr><a href="index.html">symm</a></span><h1>Function <span class="fn">encrypt_aead</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/openssl/symm.rs.html#844-869">Source</a> </span></div><pre class="rust item-decl"><code>pub fn encrypt_aead(
|
||||
t: <a class="struct" href="struct.Cipher.html" title="struct openssl::symm::Cipher">Cipher</a>,
|
||||
key: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
iv: <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]>,
|
||||
aad: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
data: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
tag: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>],
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>>, <a class="struct" href="../error/struct.ErrorStack.html" title="struct openssl::error::ErrorStack">ErrorStack</a>></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Like <code>encrypt</code>, but for AEAD ciphers such as AES GCM.</p>
|
||||
<p>Additional Authenticated Data can be provided in the <code>aad</code> field, and the authentication tag
|
||||
will be copied into the <code>tag</code> field.</p>
|
||||
<p>The size of the <code>tag</code> buffer indicates the required size of the tag. While some ciphers support
|
||||
a range of tag sizes, it is recommended to pick the maximum size. For AES GCM, this is 16 bytes,
|
||||
for example.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
47
openssl/symm/index.html
Normal file
47
openssl/symm/index.html
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<!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="High level interface to certain symmetric ciphers."><title>openssl::symm - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="openssl" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../openssl/index.html">openssl</a><span class="version">0.10.68</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module symm</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate openssl</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">openssl</a></span><h1>Module <span>symm</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/openssl/symm.rs.html#1-1763">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>High level interface to certain symmetric ciphers.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>Encrypt data in AES128 CBC mode</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::symm::{encrypt, Cipher};
|
||||
|
||||
<span class="kw">let </span>cipher = Cipher::aes_128_cbc();
|
||||
<span class="kw">let </span>data = <span class="string">b"Some Crypto Text"</span>;
|
||||
<span class="kw">let </span>key = <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>iv = <span class="string">b"\x00\x01\x02\x03\x04\x05\x06\x07\x00\x01\x02\x03\x04\x05\x06\x07"</span>;
|
||||
<span class="kw">let </span>ciphertext = encrypt(
|
||||
cipher,
|
||||
key,
|
||||
<span class="prelude-val">Some</span>(iv),
|
||||
data).unwrap();
|
||||
|
||||
<span class="macro">assert_eq!</span>(
|
||||
<span class="string">b"\xB4\xB9\xE7\x30\xD6\xD6\xF7\xDE\x77\x3F\x1C\xFF\xB3\x3E\x44\x5A\x91\xD7\x27\x62\x87\x4D\
|
||||
\xFB\x3C\x5E\xC4\x59\x72\x4A\xF4\x7C\xA1"</span>,
|
||||
<span class="kw-2">&</span>ciphertext[..]);</code></pre></div>
|
||||
<p>Encrypting an asymmetric key with a symmetric cipher</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::rsa::{Padding, Rsa};
|
||||
<span class="kw">use </span>openssl::symm::Cipher;
|
||||
|
||||
<span class="comment">// Generate keypair and encrypt private key:
|
||||
</span><span class="kw">let </span>keypair = Rsa::generate(<span class="number">2048</span>).unwrap();
|
||||
<span class="kw">let </span>cipher = Cipher::aes_256_cbc();
|
||||
<span class="kw">let </span>pubkey_pem = keypair.public_key_to_pem_pkcs1().unwrap();
|
||||
<span class="kw">let </span>privkey_pem = keypair.private_key_to_pem_passphrase(cipher, <span class="string">b"Rust"</span>).unwrap();
|
||||
<span class="comment">// pubkey_pem and privkey_pem could be written to file here.
|
||||
|
||||
// Load private and public key from string:
|
||||
</span><span class="kw">let </span>pubkey = Rsa::public_key_from_pem_pkcs1(<span class="kw-2">&</span>pubkey_pem).unwrap();
|
||||
<span class="kw">let </span>privkey = Rsa::private_key_from_pem_passphrase(<span class="kw-2">&</span>privkey_pem, <span class="string">b"Rust"</span>).unwrap();
|
||||
|
||||
<span class="comment">// Use the asymmetric keys to encrypt and decrypt a short message:
|
||||
</span><span class="kw">let </span>msg = <span class="string">b"Foo bar"</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>encrypted = <span class="macro">vec!</span>[<span class="number">0</span>; pubkey.size() <span class="kw">as </span>usize];
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>decrypted = <span class="macro">vec!</span>[<span class="number">0</span>; privkey.size() <span class="kw">as </span>usize];
|
||||
<span class="kw">let </span>len = pubkey.public_encrypt(msg, <span class="kw-2">&mut </span>encrypted, Padding::PKCS1).unwrap();
|
||||
<span class="macro">assert!</span>(len > msg.len());
|
||||
<span class="kw">let </span>len = privkey.private_decrypt(<span class="kw-2">&</span>encrypted, <span class="kw-2">&mut </span>decrypted, Padding::PKCS1).unwrap();
|
||||
<span class="kw">let </span>output_string = String::from_utf8(decrypted[..len].to_vec()).unwrap();
|
||||
<span class="macro">assert_eq!</span>(<span class="string">"Foo bar"</span>, output_string);
|
||||
<span class="macro">println!</span>(<span class="string">"Decrypted: '{}'"</span>, output_string);</code></pre></div>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Cipher.html" title="struct openssl::symm::Cipher">Cipher</a></div><div class="desc docblock-short">Represents a particular cipher algorithm.</div></li><li><div class="item-name"><a class="struct" href="struct.Crypter.html" title="struct openssl::symm::Crypter">Crypter</a></div><div class="desc docblock-short">Represents a symmetric cipher context.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.Mode.html" title="enum openssl::symm::Mode">Mode</a></div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.decrypt.html" title="fn openssl::symm::decrypt">decrypt</a></div><div class="desc docblock-short">Decrypts data in one go, and returns the decrypted data.</div></li><li><div class="item-name"><a class="fn" href="fn.decrypt_aead.html" title="fn openssl::symm::decrypt_aead">decrypt_<wbr>aead</a></div><div class="desc docblock-short">Like <code>decrypt</code>, but for AEAD ciphers such as AES GCM.</div></li><li><div class="item-name"><a class="fn" href="fn.encrypt.html" title="fn openssl::symm::encrypt">encrypt</a></div><div class="desc docblock-short">Encrypts data in one go, and returns the encrypted data.</div></li><li><div class="item-name"><a class="fn" href="fn.encrypt_aead.html" title="fn openssl::symm::encrypt_aead">encrypt_<wbr>aead</a></div><div class="desc docblock-short">Like <code>encrypt</code>, but for AEAD ciphers such as AES GCM.</div></li></ul></section></div></main></body></html>
|
||||
1
openssl/symm/sidebar-items.js
Normal file
1
openssl/symm/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["Mode"],"fn":["decrypt","decrypt_aead","encrypt","encrypt_aead"],"struct":["Cipher","Crypter"]};
|
||||
34
openssl/symm/struct.Cipher.html
Normal file
34
openssl/symm/struct.Cipher.html
Normal file
File diff suppressed because one or more lines are too long
131
openssl/symm/struct.Crypter.html
Normal file
131
openssl/symm/struct.Crypter.html
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue