mpvrc/openssl/index.html

99 lines
No EOL
17 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="Bindings to OpenSSL"><title>openssl - 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="../crates.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 crate"><!--[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"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#building" title="Building">Building</a><ul><li><a href="#vendored" title="Vendored">Vendored</a></li><li><a href="#automatic" title="Automatic">Automatic</a></li><li><a href="#manual" title="Manual">Manual</a></li></ul></li><li><a href="#feature-detection" title="Feature Detection">Feature Detection</a></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></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"><h1>Crate <span>openssl</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/lib.rs.html#1-257">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Bindings to OpenSSL</p>
<p>This crate provides a safe interface to the popular OpenSSL cryptography library. OpenSSL versions 1.0.1 through
3.x.x and LibreSSL versions 2.5 through 3.7.x are supported.</p>
<h2 id="building"><a class="doc-anchor" href="#building">§</a>Building</h2>
<p>Both OpenSSL libraries and headers are required to build this crate. There are multiple options available to locate
OpenSSL.</p>
<h3 id="vendored"><a class="doc-anchor" href="#vendored">§</a>Vendored</h3>
<p>If the <code>vendored</code> Cargo feature is enabled, the <code>openssl-src</code> crate will be used to compile and statically link to
a copy of OpenSSL. The build process requires a C compiler, perl (and perl-core), and make. The OpenSSL version will generally track
the newest OpenSSL release, and changes to the version are <em>not</em> considered breaking changes.</p>
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
openssl = { version = &quot;0.10&quot;, features = [&quot;vendored&quot;] }</code></pre></div>
<p>The vendored copy will be configured to automatically find a configuration and root certificates at <code>/usr/local/ssl</code>.
This path can be overridden with an environment variable (see the manual section below).
Alternatively, the <code>openssl-probe</code> crate can be used to find root certificates at runtime.</p>
<h3 id="automatic"><a class="doc-anchor" href="#automatic">§</a>Automatic</h3>
<p>The <code>openssl-sys</code> crate will automatically detect OpenSSL installations via Homebrew on macOS and vcpkg on Windows.
Additionally, it will use <code>pkg-config</code> on Unix-like systems to find the system installation.</p>
<div class="example-wrap"><pre class="language-not_rust"><code># macOS (Homebrew)
$ brew install openssl@3
# macOS (MacPorts)
$ sudo port install openssl
# macOS (pkgsrc)
$ sudo pkgin install openssl
# Arch Linux
$ sudo pacman -S pkgconf openssl
# Debian and Ubuntu
$ sudo apt-get install pkg-config libssl-dev
# Fedora
$ sudo dnf install pkgconf perl-FindBin perl-IPC-Cmd openssl-devel
# Alpine Linux
$ apk add pkgconf openssl-dev
# openSUSE
$ sudo zypper in libopenssl-devel</code></pre></div><h3 id="manual"><a class="doc-anchor" href="#manual">§</a>Manual</h3>
<p>A set of environment variables can be used to point <code>openssl-sys</code> towards an OpenSSL installation. They will
override the automatic detection logic.</p>
<ul>
<li><code>OPENSSL_DIR</code> - If specified, the directory of an OpenSSL installation. The directory should contain <code>lib</code> and
<code>include</code> subdirectories containing the libraries and headers respectively.</li>
<li><code>OPENSSL_LIB_DIR</code> and <code>OPENSSL_INCLUDE_DIR</code> - If specified, the directories containing the OpenSSL libraries and
headers respectively. This can be used if the OpenSSL installation is split in a nonstandard directory layout.</li>
<li><code>OPENSSL_STATIC</code> - If set, the crate will statically link to OpenSSL rather than dynamically link.</li>
<li><code>OPENSSL_LIBS</code> - If set, a <code>:</code>-separated list of library names to link to (e.g. <code>ssl:crypto</code>). This can be used
if nonstandard library names were used for whatever reason.</li>
<li><code>OPENSSL_NO_VENDOR</code> - If set, always find OpenSSL in the system, even if the <code>vendored</code> feature is enabled.</li>
</ul>
<p>If the <code>vendored</code> Cargo feature is enabled, the following environment variable can also be used to further configure
the OpenSSL build.</p>
<ul>
<li><code>OPENSSL_CONFIG_DIR</code> - If set, the copy of OpenSSL built by the <code>openssl-src</code> crate will be configured to look for
configuration files and root certificates in this directory.</li>
</ul>
<p>Additionally, these variables can be prefixed with the upper-cased target architecture (e.g.
<code>X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR</code>), which can be useful when cross compiling.</p>
<h2 id="feature-detection"><a class="doc-anchor" href="#feature-detection">§</a>Feature Detection</h2>
<p>APIs have been added to and removed from the various supported OpenSSL versions, and this library exposes the
functionality available in the version being linked against. This means that methods, constants, and even modules
will be present when building against one version of OpenSSL but not when building against another! APIs will
document any version-specific availability restrictions.</p>
<p>A build script can be used to detect the OpenSSL or LibreSSL version at compile time if needed. The <code>openssl-sys</code>
crate propagates the version via the <code>DEP_OPENSSL_VERSION_NUMBER</code> and <code>DEP_OPENSSL_LIBRESSL_VERSION_NUMBER</code>
environment variables to build scripts. The version format is a hex-encoding of the OpenSSL release version:
<code>0xMNNFFPPS</code>. For example, version 1.0.2gs encoding is <code>0x1_00_02_07_0</code>.</p>
<p>For example, lets say we want to adjust the TLSv1.3 cipher suites used by a client, but also want to compile
against OpenSSL versions that dont support TLSv1.3:</p>
<p>Cargo.toml:</p>
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
openssl-sys = &quot;0.9&quot;
openssl = &quot;0.10&quot;</code></pre></div>
<p>build.rs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::env;
<span class="kw">fn </span>main() {
<span class="kw">if let </span><span class="prelude-val">Ok</span>(v) = env::var(<span class="string">"DEP_OPENSSL_VERSION_NUMBER"</span>) {
<span class="kw">let </span>version = u64::from_str_radix(<span class="kw-2">&amp;</span>v, <span class="number">16</span>).unwrap();
<span class="kw">if </span>version &gt;= <span class="number">0x1_01_01_00_0 </span>{
<span class="macro">println!</span>(<span class="string">"cargo:rustc-cfg=openssl111"</span>);
}
}
}</code></pre></div>
<p>lib.rs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>openssl::ssl::{SslConnector, SslMethod};
<span class="kw">let </span><span class="kw-2">mut </span>ctx = SslConnector::builder(SslMethod::tls()).unwrap();
<span class="comment">// set_ciphersuites was added in OpenSSL 1.1.1, so we can only call it when linking against that version
</span><span class="attr">#[cfg(openssl111)]
</span>ctx.set_ciphersuites(<span class="string">"TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256"</span>).unwrap();</code></pre></div>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="aes/index.html" title="mod openssl::aes">aes</a></div><div class="desc docblock-short">Low level AES IGE and key wrapping functionality</div></li><li><div class="item-name"><a class="mod" href="asn1/index.html" title="mod openssl::asn1">asn1</a></div><div class="desc docblock-short">Defines the format of certificates</div></li><li><div class="item-name"><a class="mod" href="base64/index.html" title="mod openssl::base64">base64</a></div><div class="desc docblock-short">Base64 encoding support.</div></li><li><div class="item-name"><a class="mod" href="bn/index.html" title="mod openssl::bn">bn</a></div><div class="desc docblock-short">BigNum implementation</div></li><li><div class="item-name"><a class="mod" href="cipher/index.html" title="mod openssl::cipher">cipher</a></div><div class="desc docblock-short">Symmetric ciphers.</div></li><li><div class="item-name"><a class="mod" href="cipher_ctx/index.html" title="mod openssl::cipher_ctx">cipher_<wbr>ctx</a></div><div class="desc docblock-short">The symmetric encryption context.</div></li><li><div class="item-name"><a class="mod" href="cms/index.html" title="mod openssl::cms">cms</a></div><div class="desc docblock-short">SMIME implementation using CMS</div></li><li><div class="item-name"><a class="mod" href="conf/index.html" title="mod openssl::conf">conf</a></div><div class="desc docblock-short">Interface for processing OpenSSL configuration files.</div></li><li><div class="item-name"><a class="mod" href="derive/index.html" title="mod openssl::derive">derive</a></div><div class="desc docblock-short">Shared secret derivation.</div></li><li><div class="item-name"><a class="mod" href="dh/index.html" title="mod openssl::dh">dh</a></div><div class="desc docblock-short">Diffie-Hellman key agreement.</div></li><li><div class="item-name"><a class="mod" href="dsa/index.html" title="mod openssl::dsa">dsa</a></div><div class="desc docblock-short">Digital Signatures</div></li><li><div class="item-name"><a class="mod" href="ec/index.html" title="mod openssl::ec">ec</a></div><div class="desc docblock-short">Elliptic Curve</div></li><li><div class="item-name"><a class="mod" href="ecdsa/index.html" title="mod openssl::ecdsa">ecdsa</a></div><div class="desc docblock-short">Low level Elliptic Curve Digital Signature Algorithm (ECDSA) functions.</div></li><li><div class="item-name"><a class="mod" href="encrypt/index.html" title="mod openssl::encrypt">encrypt</a></div><div class="desc docblock-short">Message encryption.</div></li><li><div class="item-name"><a class="mod" href="envelope/index.html" title="mod openssl::envelope">envelope</a></div><div class="desc docblock-short">Envelope encryption.</div></li><li><div class="item-name"><a class="mod" href="error/index.html" title="mod openssl::error">error</a></div><div class="desc docblock-short">Errors returned by OpenSSL library.</div></li><li><div class="item-name"><a class="mod" href="ex_data/index.html" title="mod openssl::ex_data">ex_data</a></div></li><li><div class="item-name"><a class="mod" href="hash/index.html" title="mod openssl::hash">hash</a></div><div class="desc docblock-short">Message digest (hash) computation support.</div></li><li><div class="item-name"><a class="mod" href="kdf/index.html" title="mod openssl::kdf">kdf</a></div></li><li><div class="item-name"><a class="mod" href="lib_ctx/index.html" title="mod openssl::lib_ctx">lib_ctx</a></div></li><li><div class="item-name"><a class="mod" href="md/index.html" title="mod openssl::md">md</a></div><div class="desc docblock-short">Message digest algorithms.</div></li><li><div class="item-name"><a class="mod" href="md_ctx/index.html" title="mod openssl::md_ctx">md_ctx</a></div><div class="desc docblock-short">The message digest context.</div></li><li><div class="item-name"><a class="mod" href="memcmp/index.html" title="mod openssl::memcmp">memcmp</a></div><div class="desc docblock-short">Utilities to safely compare cryptographic values.</div></li><li><div class="item-name"><a class="mod" href="nid/index.html" title="mod openssl::nid">nid</a></div><div class="desc docblock-short">A collection of numerical identifiers for OpenSSL objects.</div></li><li><div class="item-name"><a class="mod" href="ocsp/index.html" title="mod openssl::ocsp">ocsp</a></div></li><li><div class="item-name"><a class="mod" href="pkcs5/index.html" title="mod openssl::pkcs5">pkcs5</a></div></li><li><div class="item-name"><a class="mod" href="pkcs7/index.html" title="mod openssl::pkcs7">pkcs7</a></div></li><li><div class="item-name"><a class="mod" href="pkcs12/index.html" title="mod openssl::pkcs12">pkcs12</a></div><div class="desc docblock-short">PKCS #12 archives.</div></li><li><div class="item-name"><a class="mod" href="pkey/index.html" title="mod openssl::pkey">pkey</a></div><div class="desc docblock-short">Public/private key processing.</div></li><li><div class="item-name"><a class="mod" href="pkey_ctx/index.html" title="mod openssl::pkey_ctx">pkey_<wbr>ctx</a></div><div class="desc docblock-short">The asymmetric encryption context.</div></li><li><div class="item-name"><a class="mod" href="provider/index.html" title="mod openssl::provider">provider</a></div></li><li><div class="item-name"><a class="mod" href="rand/index.html" title="mod openssl::rand">rand</a></div><div class="desc docblock-short">Utilities for secure random number generation.</div></li><li><div class="item-name"><a class="mod" href="rsa/index.html" title="mod openssl::rsa">rsa</a></div><div class="desc docblock-short">RivestShamirAdleman cryptosystem</div></li><li><div class="item-name"><a class="mod" href="sha/index.html" title="mod openssl::sha">sha</a></div><div class="desc docblock-short">The SHA family of hashes.</div></li><li><div class="item-name"><a class="mod" href="sign/index.html" title="mod openssl::sign">sign</a></div><div class="desc docblock-short">Message signatures.</div></li><li><div class="item-name"><a class="mod" href="srtp/index.html" title="mod openssl::srtp">srtp</a></div></li><li><div class="item-name"><a class="mod" href="ssl/index.html" title="mod openssl::ssl">ssl</a></div><div class="desc docblock-short">SSL/TLS support.</div></li><li><div class="item-name"><a class="mod" href="stack/index.html" title="mod openssl::stack">stack</a></div></li><li><div class="item-name"><a class="mod" href="string/index.html" title="mod openssl::string">string</a></div></li><li><div class="item-name"><a class="mod" href="symm/index.html" title="mod openssl::symm">symm</a></div><div class="desc docblock-short">High level interface to certain symmetric ciphers.</div></li><li><div class="item-name"><a class="mod" href="version/index.html" title="mod openssl::version">version</a></div><div class="desc docblock-short">Build and version information.</div></li><li><div class="item-name"><a class="mod" href="x509/index.html" title="mod openssl::x509">x509</a></div><div class="desc docblock-short">The standard defining the format of public key certificates.</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.init.html" title="fn openssl::init">init</a></div></li></ul></section></div></main></body></html>