-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
56 lines (56 loc) · 12.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!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="subtle "><title>subtle - 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-46132b98.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="subtle" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0 (4d91de4e4 2025-02-17)" data-channel="1.85.0" data-search-js="search-75f5ac3e.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><a class="logo-container" href="../subtle/index.html"><img src="https://doc.dalek.rs/assets/dalek-logo-clear.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../subtle/index.html"><img src="https://doc.dalek.rs/assets/dalek-logo-clear.png" alt="logo"></a><h2><a href="../subtle/index.html">subtle</a><span class="version">2.6.1</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="#subtle---" title="subtle ">subtle </a><ul><li><a href="#documentation" title="Documentation">Documentation</a></li><li><a href="#minimum-supported-rust-version" title="Minimum Supported Rust Version">Minimum Supported Rust Version</a></li><li><a href="#about" title="About">About</a></li><li><a href="#warning" title="Warning">Warning</a></li></ul></li></ul><h3><a href="#macros">Crate Items</a></h3><ul class="block"><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</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>subtle</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/subtle/lib.rs.html#11-1008">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="subtle---"><a class="doc-anchor" href="#subtle---">§</a>subtle <a href="https://crates.io/crates/subtle"><img src="https://img.shields.io/crates/v/subtle.svg" alt="" /></a> <a href="https://doc.dalek.rs/subtle"><img src="https://img.shields.io/badge/dynamic/json.svg?label=docs&uri=https%3A%2F%2Fcrates.io%2Fapi%2Fv1%2Fcrates%2Fsubtle%2Fversions&query=%24.versions%5B0%5D.num&colorB=4F74A6" alt="" /></a> <a href="https://travis-ci.org/dalek-cryptography/subtle"><img src="https://travis-ci.org/dalek-cryptography/subtle.svg?branch=master" alt="" /></a></h2>
<p><strong>Pure-Rust traits and utilities for constant-time cryptographic implementations.</strong></p>
<p>It consists of a <code>Choice</code> type, and a collection of traits using <code>Choice</code>
instead of <code>bool</code> which are intended to execute in constant-time. The <code>Choice</code>
type is a wrapper around a <code>u8</code> that holds a <code>0</code> or <code>1</code>.</p>
<div class="example-wrap"><pre class="language-toml"><code>subtle = "2.6"</code></pre></div>
<p>This crate represents a “best-effort” attempt, since side-channels
are ultimately a property of a deployed cryptographic system
including the hardware it runs on, not just of software.</p>
<p>The traits are implemented using bitwise operations, and should execute in
constant time provided that a) the bitwise operations are constant-time and
b) the bitwise operations are not recognized as a conditional assignment and
optimized back into a branch.</p>
<p>For a compiler to recognize that bitwise operations represent a conditional
assignment, it needs to know that the value used to generate the bitmasks is
really a boolean <code>i1</code> rather than an <code>i8</code> byte value. In an attempt to
prevent this refinement, the crate tries to hide the value of a <code>Choice</code>’s
inner <code>u8</code> by passing it through a volatile read. For more information, see
the <em>About</em> section below.</p>
<p>Rust versions from 1.51 or higher have const generics support. You may enable
<code>const-generics</code> feautre to have <code>subtle</code> traits implemented for arrays <code>[T; N]</code>.</p>
<p>Versions prior to <code>2.2</code> recommended use of the <code>nightly</code> feature to enable an
optimization barrier; this is not required in versions <code>2.2</code> and above.</p>
<p>Note: the <code>subtle</code> crate contains <code>debug_assert</code>s to check invariants during
debug builds. These invariant checks involve secret-dependent branches, and
are not present when compiled in release mode. This crate is intended to be
used in release mode.</p>
<h3 id="documentation"><a class="doc-anchor" href="#documentation">§</a>Documentation</h3>
<p>Documentation is available <a href="https://docs.rs/subtle">here</a>.</p>
<h3 id="minimum-supported-rust-version"><a class="doc-anchor" href="#minimum-supported-rust-version">§</a>Minimum Supported Rust Version</h3>
<p>Rust <strong>1.41</strong> or higher.</p>
<p>Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump.</p>
<h3 id="about"><a class="doc-anchor" href="#about">§</a>About</h3>
<p>This library aims to be the Rust equivalent of Go’s <code>crypto/subtle</code> module.</p>
<p>Old versions of the optimization barrier in <code>impl From<u8> for Choice</code> were
based on Tim Maclean’s <a href="https://www.chosenplaintext.ca/open-source/rust-timing-shield/security">work on <code>rust-timing-shield</code></a>,
which attempts to provide a more comprehensive approach for preventing
software side-channels in Rust code.
From version <code>2.2</code>, it was based on Diane Hosfelt and Amber Sprenkels’ work on
“Secret Types in Rust”.</p>
<p><code>subtle</code> is authored by isis agora lovecruft and Henry de Valence.</p>
<h3 id="warning"><a class="doc-anchor" href="#warning">§</a>Warning</h3>
<p>This code is a low-level library, intended for specific use-cases implementing
cryptographic protocols. It represents a best-effort attempt to protect
against some software side-channels. Because side-channel resistance is not a
property of software alone, but of software together with hardware, any such
effort is fundamentally limited.</p>
<p><strong>USE AT YOUR OWN RISK</strong></p>
</div></details><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.generate_integer_conditional_select.html" title="macro subtle::generate_integer_conditional_select">generate_<wbr>integer_<wbr>conditional_<wbr>select</a><span title="Restricted Visibility"> 🔒</span> </div></li><li><div class="item-name"><a class="macro" href="macro.generate_integer_equal.html" title="macro subtle::generate_integer_equal">generate_<wbr>integer_<wbr>equal</a><span title="Restricted Visibility"> 🔒</span> </div><div class="desc docblock-short">Given the bit-width <code>$bit_width</code> and the corresponding primitive
unsigned and signed types <code>$t_u</code> and <code>$t_i</code> respectively, generate
an <code>ConstantTimeEq</code> implementation.</div></li><li><div class="item-name"><a class="macro" href="macro.generate_unsigned_integer_greater.html" title="macro subtle::generate_unsigned_integer_greater">generate_<wbr>unsigned_<wbr>integer_<wbr>greater</a><span title="Restricted Visibility"> 🔒</span> </div></li><li><div class="item-name"><a class="macro" href="macro.to_signed_int.html" title="macro subtle::to_signed_int">to_<wbr>signed_<wbr>int</a><span title="Restricted Visibility"> 🔒</span> </div></li></ul><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.BlackBox.html" title="struct subtle::BlackBox">Black<wbr>Box</a></div><div class="desc docblock-short">Wrapper type which implements an optimization barrier for all accesses.</div></li><li><div class="item-name"><a class="struct" href="struct.Choice.html" title="struct subtle::Choice">Choice</a></div><div class="desc docblock-short">The <code>Choice</code> struct represents a choice for use in conditional assignment.</div></li><li><div class="item-name"><a class="struct" href="struct.CtOption.html" title="struct subtle::CtOption">CtOption</a></div><div class="desc docblock-short">The <code>CtOption<T></code> type represents an optional value similar to the
<a href="https://doc.rust-lang.org/1.85.0/core/option/enum.Option.html" title="enum core::option::Option"><code>Option<T></code></a> type but is intended for
use in constant time APIs.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.ConditionallyNegatable.html" title="trait subtle::ConditionallyNegatable">Conditionally<wbr>Negatable</a></div><div class="desc docblock-short">A type which can be conditionally negated in constant time.</div></li><li><div class="item-name"><a class="trait" href="trait.ConditionallySelectable.html" title="trait subtle::ConditionallySelectable">Conditionally<wbr>Selectable</a></div><div class="desc docblock-short">A type which can be conditionally selected in constant time.</div></li><li><div class="item-name"><a class="trait" href="trait.ConstantTimeEq.html" title="trait subtle::ConstantTimeEq">Constant<wbr>Time<wbr>Eq</a></div><div class="desc docblock-short">An <code>Eq</code>-like trait that produces a <code>Choice</code> instead of a <code>bool</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.ConstantTimeGreater.html" title="trait subtle::ConstantTimeGreater">Constant<wbr>Time<wbr>Greater</a></div><div class="desc docblock-short">A type which can be compared in some manner and be determined to be greater
than another of the same type.</div></li><li><div class="item-name"><a class="trait" href="trait.ConstantTimeLess.html" title="trait subtle::ConstantTimeLess">Constant<wbr>Time<wbr>Less</a></div><div class="desc docblock-short">A type which can be compared in some manner and be determined to be less
than another of the same type.</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.black_box.html" title="fn subtle::black_box">black_<wbr>box</a><span title="Restricted Visibility"> 🔒</span> </div><div class="desc docblock-short">This function is a best-effort attempt to prevent the compiler from knowing
anything about the value of the returned <code>u8</code>, other than its type.</div></li></ul></section></div></main></body></html>