Skip to content

Commit

Permalink
deploy: cff2e66
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Mar 1, 2024
1 parent dd55c27 commit 5b93af0
Show file tree
Hide file tree
Showing 22 changed files with 161 additions and 109 deletions.
2 changes: 1 addition & 1 deletion search-index.js

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions src/trussed/client/mechanisms.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,14 @@
<a href="#489" id="489">489</a>
<a href="#490" id="490">490</a>
<a href="#491" id="491">491</a>
<a href="#492" id="492">492</a>
<a href="#493" id="493">493</a>
<a href="#494" id="494">494</a>
<a href="#495" id="495">495</a>
<a href="#496" id="496">496</a>
<a href="#497" id="497">497</a>
<a href="#498" id="498">498</a>
<a href="#499" id="499">499</a>
</pre></div><pre class="rust"><code><span class="kw">use super</span>::<span class="kw-2">*</span>;

<span class="attr">#[cfg(feature = <span class="string">"aes256-cbc"</span>)]
Expand All @@ -500,16 +508,24 @@
<span class="kw-2">&amp;</span><span class="lifetime">'c </span><span class="kw-2">mut </span><span class="self">self</span>,
key: KeyId,
message: <span class="kw-2">&amp;</span>[u8],
iv: <span class="kw-2">&amp;</span>[u8],
) -&gt; ClientResult&lt;<span class="lifetime">'c</span>, reply::Decrypt, <span class="self">Self</span>&gt; {
<span class="self">self</span>.decrypt(Mechanism::Aes256Cbc, key, message, <span class="kw-2">&amp;</span>[], <span class="kw-2">&amp;</span>[], <span class="kw-2">&amp;</span>[])
<span class="self">self</span>.decrypt(Mechanism::Aes256Cbc, key, message, <span class="kw-2">&amp;</span>[], iv, <span class="kw-2">&amp;</span>[])
}

<span class="kw">fn </span>wrap_key_aes256cbc(
<span class="kw-2">&amp;mut </span><span class="self">self</span>,
wrapping_key: KeyId,
key: KeyId,
iv: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span>[u8; <span class="number">16</span>]&gt;,
) -&gt; ClientResult&lt;<span class="lifetime">'_</span>, reply::WrapKey, <span class="self">Self</span>&gt; {
<span class="self">self</span>.wrap_key(Mechanism::Aes256Cbc, wrapping_key, key, <span class="kw-2">&amp;</span>[], <span class="prelude-val">None</span>)
<span class="self">self</span>.wrap_key(
Mechanism::Aes256Cbc,
wrapping_key,
key,
<span class="kw-2">&amp;</span>[],
iv.and_then(|iv| ShortData::from_slice(iv).ok()),
)
}
}

Expand Down
38 changes: 34 additions & 4 deletions src/trussed/mechanisms/aes256cbc.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@
<a href="#173" id="173">173</a>
<a href="#174" id="174">174</a>
<a href="#175" id="175">175</a>
<a href="#176" id="176">176</a>
<a href="#177" id="177">177</a>
<a href="#178" id="178">178</a>
<a href="#179" id="179">179</a>
<a href="#180" id="180">180</a>
<a href="#181" id="181">181</a>
<a href="#182" id="182">182</a>
<a href="#183" id="183">183</a>
<a href="#184" id="184">184</a>
<a href="#185" id="185">185</a>
<a href="#186" id="186">186</a>
<a href="#187" id="187">187</a>
<a href="#188" id="188">188</a>
<a href="#189" id="189">189</a>
<a href="#190" id="190">190</a>
</pre></div><pre class="rust"><code><span class="kw">use </span><span class="kw">crate</span>::api::<span class="kw-2">*</span>;
<span class="comment">// use crate::config::*;
</span><span class="kw">use </span><span class="kw">crate</span>::error::Error;
Expand Down Expand Up @@ -207,8 +222,15 @@
.try_into()
.map_err(|<span class="kw">_</span>| Error::InternalError)<span class="question-mark">?</span>;

<span class="kw">let </span>zero_iv = [<span class="number">0u8</span>; <span class="number">16</span>];
<span class="kw">let </span>cipher = Aes256CbcEnc::new_from_slices(<span class="kw-2">&amp;</span>symmetric_key, <span class="kw-2">&amp;</span>zero_iv).unwrap();
<span class="kw">let </span>iv = <span class="kw">if let </span><span class="prelude-val">Some</span>(nonce) = <span class="kw-2">&amp;</span>request.nonce {
nonce
.as_slice()
.try_into()
.map_err(|<span class="kw">_</span>| Error::MechanismParamInvalid)<span class="question-mark">?
</span>} <span class="kw">else </span>{
[<span class="number">0u8</span>; <span class="number">16</span>]
};
<span class="kw">let </span>cipher = Aes256CbcEnc::new_from_slices(<span class="kw-2">&amp;</span>symmetric_key, <span class="kw-2">&amp;</span>iv).unwrap();

<span class="comment">// buffer must have enough space for message+padding
</span><span class="kw">let </span><span class="kw-2">mut </span>buffer = request.message.clone();
Expand Down Expand Up @@ -293,8 +315,16 @@
.try_into()
.map_err(|<span class="kw">_</span>| Error::InternalError)<span class="question-mark">?</span>;

<span class="kw">let </span>zero_iv = [<span class="number">0u8</span>; <span class="number">16</span>];
<span class="kw">let </span>cipher = Aes256CbcDec::new_from_slices(<span class="kw-2">&amp;</span>symmetric_key, <span class="kw-2">&amp;</span>zero_iv).unwrap();
<span class="kw">let </span>iv = <span class="kw">if </span>request.nonce.is_empty() {
[<span class="number">0u8</span>; <span class="number">16</span>]
} <span class="kw">else </span>{
request
.nonce
.as_slice()
.try_into()
.map_err(|<span class="kw">_</span>| Error::MechanismParamInvalid)<span class="question-mark">?
</span>};
<span class="kw">let </span>cipher = Aes256CbcDec::new_from_slices(<span class="kw-2">&amp;</span>symmetric_key, <span class="kw-2">&amp;</span>iv).unwrap();

<span class="comment">// buffer must have enough space for message+padding
</span><span class="kw">let </span><span class="kw-2">mut </span>buffer = request.message.clone();
Expand Down
2 changes: 1 addition & 1 deletion trussed/client/mechanisms/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!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 `mechanisms` mod in crate `trussed`."><title>trussed::client::mechanisms - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="trussed" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-2c020d218678b618.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">&#9776;</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../trussed/index.html">trussed</a><span class="version">0.1.0</span></h2></div><h2 class="location"><a href="#">Module mechanisms</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#traits">Traits</a></li></ul></section><h2><a href="../index.html">In trussed::client</a></h2></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../../../trussed/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../../../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Module <a href="../../index.html">trussed</a>::<wbr><a href="../index.html">client</a>::<wbr><a class="mod" href="#">mechanisms</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../../src/trussed/client/mechanisms.rs.html#1-491">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><h2 id="traits" class="section-header"><a href="#traits">Traits</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Aes256Cbc.html" title="trait trussed::client::mechanisms::Aes256Cbc">Aes256Cbc</a></div></li><li><div class="item-name"><a class="trait" href="trait.Chacha8Poly1305.html" title="trait trussed::client::mechanisms::Chacha8Poly1305">Chacha8Poly1305</a></div></li><li><div class="item-name"><a class="trait" href="trait.Ed255.html" title="trait trussed::client::mechanisms::Ed255">Ed255</a></div></li><li><div class="item-name"><a class="trait" href="trait.HmacBlake2s.html" title="trait trussed::client::mechanisms::HmacBlake2s">HmacBlake2s</a></div></li><li><div class="item-name"><a class="trait" href="trait.HmacSha1.html" title="trait trussed::client::mechanisms::HmacSha1">HmacSha1</a></div></li><li><div class="item-name"><a class="trait" href="trait.HmacSha256.html" title="trait trussed::client::mechanisms::HmacSha256">HmacSha256</a></div></li><li><div class="item-name"><a class="trait" href="trait.HmacSha512.html" title="trait trussed::client::mechanisms::HmacSha512">HmacSha512</a></div></li><li><div class="item-name"><a class="trait" href="trait.P256.html" title="trait trussed::client::mechanisms::P256">P256</a></div></li><li><div class="item-name"><a class="trait" href="trait.Sha256.html" title="trait trussed::client::mechanisms::Sha256">Sha256</a></div></li><li><div class="item-name"><a class="trait" href="trait.Tdes.html" title="trait trussed::client::mechanisms::Tdes">Tdes</a></div></li><li><div class="item-name"><a class="trait" href="trait.Totp.html" title="trait trussed::client::mechanisms::Totp">Totp</a></div></li><li><div class="item-name"><a class="trait" href="trait.X255.html" title="trait trussed::client::mechanisms::X255">X255</a></div></li></ul></section></div></main></body></html>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../../../trussed/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../../../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Module <a href="../../index.html">trussed</a>::<wbr><a href="../index.html">client</a>::<wbr><a class="mod" href="#">mechanisms</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../../src/trussed/client/mechanisms.rs.html#1-499">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><h2 id="traits" class="section-header"><a href="#traits">Traits</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Aes256Cbc.html" title="trait trussed::client::mechanisms::Aes256Cbc">Aes256Cbc</a></div></li><li><div class="item-name"><a class="trait" href="trait.Chacha8Poly1305.html" title="trait trussed::client::mechanisms::Chacha8Poly1305">Chacha8Poly1305</a></div></li><li><div class="item-name"><a class="trait" href="trait.Ed255.html" title="trait trussed::client::mechanisms::Ed255">Ed255</a></div></li><li><div class="item-name"><a class="trait" href="trait.HmacBlake2s.html" title="trait trussed::client::mechanisms::HmacBlake2s">HmacBlake2s</a></div></li><li><div class="item-name"><a class="trait" href="trait.HmacSha1.html" title="trait trussed::client::mechanisms::HmacSha1">HmacSha1</a></div></li><li><div class="item-name"><a class="trait" href="trait.HmacSha256.html" title="trait trussed::client::mechanisms::HmacSha256">HmacSha256</a></div></li><li><div class="item-name"><a class="trait" href="trait.HmacSha512.html" title="trait trussed::client::mechanisms::HmacSha512">HmacSha512</a></div></li><li><div class="item-name"><a class="trait" href="trait.P256.html" title="trait trussed::client::mechanisms::P256">P256</a></div></li><li><div class="item-name"><a class="trait" href="trait.Sha256.html" title="trait trussed::client::mechanisms::Sha256">Sha256</a></div></li><li><div class="item-name"><a class="trait" href="trait.Tdes.html" title="trait trussed::client::mechanisms::Tdes">Tdes</a></div></li><li><div class="item-name"><a class="trait" href="trait.Totp.html" title="trait trussed::client::mechanisms::Totp">Totp</a></div></li><li><div class="item-name"><a class="trait" href="trait.X255.html" title="trait trussed::client::mechanisms::X255">X255</a></div></li></ul></section></div></main></body></html>
Loading

0 comments on commit 5b93af0

Please sign in to comment.