Skip to content

Commit 07b9f52

Browse files
author
Jared Stanbrough
committed
docs(rust): doc comment update for ockam_channel
1 parent 02985f7 commit 07b9f52

12 files changed

Lines changed: 103 additions & 31 deletions

File tree

implementations/rust/ockam/ockam_channel/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this crate will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## v0.1.0 - DATE
8+
## v0.1.0 - 2021-04-05
99

10-
Initial release.
10+
- Initial release.
1111

implementations/rust/ockam/ockam_channel/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ default = ["std"]
1818
std = []
1919

2020
[dependencies]
21-
ockam_node = {path = "../ockam_node", version = "*"}
22-
ockam_core = {path = "../ockam_core", version = "*"}
21+
ockam_core = {path = "../ockam_core", version = "0"}
22+
ockam_key_exchange_xx = {path = "../ockam_key_exchange_xx", version = "0"}
23+
ockam_key_exchange_core = {path = "../ockam_key_exchange_core", version = "0"}
24+
ockam_node = {path = "../ockam_node", version = "0"}
25+
ockam_vault_core = { path = "../ockam_vault_core", version = "0" }
26+
ockam_vault = { path = "../ockam_vault", version = "0" }
2327
serde_bare = "0.3.0"
2428
rand = "0.8"
25-
ockam_key_exchange_xx = {path = "../ockam_key_exchange_xx", version = "*"}
26-
ockam_key_exchange_core = {path = "../ockam_key_exchange_core", version = "*"}
27-
ockam_vault_core = { path = "../ockam_vault_core", version = "*" }
28-
ockam_vault = { path = "../ockam_vault", version = "*" }
2929
async-trait = "0.1.42"
3030
serde = {version = "1.0.120", features = ["derive"]}
3131
tracing = "0.1"

implementations/rust/ockam/ockam_channel/src/error.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
use ockam_core::Error;
22

3+
/// Types of errors that may occur constructing a secure channel.
34
pub enum SecureChannelError {
5+
/// No error.
46
None,
7+
/// The key exchange process failed.
58
KeyExchange,
9+
/// Internal state is invalid.
610
InvalidInternalState,
11+
/// Expected nonce was invalid.
712
InvalidNonce,
13+
/// Key exchange process did not complete.
814
KeyExchangeNotComplete,
15+
/// Invalid response received from the Hub.
916
InvalidHubResponse,
1017
}
1118

implementations/rust/ockam/ockam_channel/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
//! Secure channel types and traits of the Ockam library.
2+
//!
3+
//! This crate contains the secure channel types of the Ockam library and is intended
4+
//! for use by other crates that provide features and add-ons to the main
5+
//! Ockam library.
6+
//!
7+
//! The main Ockam crate re-exports types defined in this crate.
8+
#![deny(
9+
missing_docs,
10+
trivial_casts,
11+
trivial_numeric_casts,
12+
unsafe_code,
13+
unused_import_braces,
14+
unused_qualifications,
15+
warnings
16+
)]
117
mod error;
218
mod key_exchange;
319
mod secure_channel;

implementations/rust/ockam/ockam_channel/src/secure_channel.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ pub struct SecureChannelInfo {
3030
}
3131

3232
impl SecureChannelInfo {
33+
/// Return the address of the worker.
3334
pub fn worker_address(&self) -> &Address {
3435
&self.worker_address
3536
}
37+
/// Return the auth hash.
3638
pub fn auth_hash(&self) -> [u8; 32] {
3739
self.auth_hash
3840
}
@@ -195,11 +197,24 @@ impl SecureChannel {
195197
}
196198
}
197199

200+
/// A message in the secure channel protocol.
198201
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
199202
pub enum SecureChannelMessage {
200-
KeyExchange { payload: Vec<u8> },
201-
Encrypt { m: Vec<u8> },
202-
Decrypt { payload: Vec<u8> },
203+
/// Key exchange requested.
204+
KeyExchange {
205+
/// Information for key exchange.
206+
payload: Vec<u8>,
207+
},
208+
/// Encrypted data.
209+
Encrypt {
210+
/// Encrypted data.
211+
m: Vec<u8>,
212+
},
213+
/// Decrypted data.
214+
Decrypt {
215+
/// Decrypted payload.
216+
payload: Vec<u8>,
217+
},
203218
}
204219

205220
impl SecureChannelMessage {

implementations/rust/ockam/ockam_channel/src/secure_channel_listener.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ use serde::{Deserialize, Serialize};
99
pub struct SecureChannelListener;
1010

1111
impl SecureChannelListener {
12+
/// Create a new SecureChannelListener.
1213
pub fn new() -> Self {
1314
Self {}
1415
}
1516
}
1617

18+
/// SecureChannelListener message wrapper.
1719
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
1820
pub enum SecureChannelListenerMessage {
21+
/// Create a new responder channel.
1922
CreateResponderChannel {
23+
/// Channel ID.
2024
channel_id: String,
25+
/// Channel information.
2126
payload: Vec<u8>,
2227
},
2328
}

implementations/rust/ockam/ockam_key_exchange_core/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ All notable changes to this crate will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## v0.1.0 - [RELEASE_DATE]
8+
## v0.1.0 - 2021-04-05
99

10-
Initial release.
10+
- Initial release.

implementations/rust/ockam/ockam_key_exchange_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ description = """The Ockam Key Exchange trait.
1414

1515
[dependencies]
1616
ockam_core = { version = "0.6.0", path = "../ockam_core" }
17-
ockam_vault_core = { version = "0.3.0", path = "../ockam_vault_core" }
17+
ockam_vault_core = { version = "0.3.1", path = "../ockam_vault_core" }
1818
zeroize = { version = "1.1", features = ["zeroize_derive"] }

implementations/rust/ockam/ockam_key_exchange_core/src/lib.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
//! Key exchange types and traits of the Ockam library.
2+
//!
3+
//! This crate contains the key exchange types of the Ockam library and is intended
4+
//! for use by other crates that provide features and add-ons to the main
5+
//! Ockam library.
6+
//!
7+
//! The main Ockam crate re-exports types defined in this crate.
18
#![deny(
2-
// missing_docs,
9+
missing_docs,
310
trivial_casts,
411
trivial_numeric_casts,
512
unsafe_code,
@@ -11,25 +18,26 @@
1118
use ockam_vault_core::{PublicKey, Secret};
1219
use zeroize::Zeroize;
1320

14-
/// Represents either the Initiator or the Responder
21+
/// A trait implemented by both Initiator and Responder peers.
1522
pub trait KeyExchanger {
16-
/// Handle the current step in the key exchange process
23+
/// Run the current phase of the key exchange process.
1724
fn process(&mut self, data: &[u8]) -> ockam_core::Result<Vec<u8>>;
18-
/// Is the key exchange process completed yet
25+
/// Returns true if the key exchange process is complete.
1926
fn is_complete(&self) -> bool;
20-
/// If completed, then return the data and keys needed for channels
27+
28+
/// Return the data and keys needed for channels. Key exchange must be completed prior to calling this function.
2129
fn finalize(self) -> ockam_core::Result<CompletedKeyExchange>;
2230
}
2331

24-
/// Instantiate a stateful key exchange vault instance
25-
pub trait NewKeyExchanger<E: KeyExchanger = Self, F: KeyExchanger = Self> {
32+
/// A creator of both initiator and responder peers of a key exchange.
33+
pub trait NewKeyExchanger<I: KeyExchanger = Self, R: KeyExchanger = Self> {
2634
/// Create a new Key Exchanger with the initiator role
27-
fn initiator(&self) -> E;
35+
fn initiator(&self) -> I;
2836
/// Create a new Key Exchanger with the responder role
29-
fn responder(&self) -> F;
37+
fn responder(&self) -> R;
3038
}
3139

32-
/// A Completed Key Exchange elements
40+
/// The state of a completed key exchange.
3341
#[derive(Debug, Zeroize)]
3442
pub struct CompletedKeyExchange {
3543
h: [u8; 32],
@@ -40,29 +48,30 @@ pub struct CompletedKeyExchange {
4048
}
4149

4250
impl CompletedKeyExchange {
43-
/// The state hash
51+
/// The state hash.
4452
pub fn h(&self) -> &[u8; 32] {
4553
&self.h
4654
}
47-
/// The derived encryption key handle
55+
/// The derived encryption key.
4856
pub fn encrypt_key(&self) -> &Secret {
4957
&self.encrypt_key
5058
}
51-
/// The derived decryption key handle
59+
/// The derived decryption key.
5260
pub fn decrypt_key(&self) -> &Secret {
5361
&self.decrypt_key
5462
}
55-
/// The long term static key handle
63+
/// The long term static key.
5664
pub fn local_static_secret(&self) -> &Secret {
5765
&self.local_static_secret
5866
}
59-
/// The long term static public key from remote party
67+
/// Remote peer well known public key.
6068
pub fn remote_static_public_key(&self) -> &PublicKey {
6169
&self.remote_static_public_key
6270
}
6371
}
6472

6573
impl CompletedKeyExchange {
74+
/// Build a CompletedKeyExchange comprised of the input parameters.
6675
pub fn new(
6776
h: [u8; 32],
6877
encrypt_key: Secret,

implementations/rust/ockam/ockam_key_exchange_xx/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this crate will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## v0.1.0 - [RELEASE_DATE]
8+
## v0.1.0 - 2012-04-05
99

10-
Initial release.
10+
- Initial release.
1111

0 commit comments

Comments
 (0)