Skip to content

Commit c85eb64

Browse files
committed
feat(rust): removed secure channel key exchange and persistency
1 parent 098958d commit c85eb64

File tree

24 files changed

+173
-1250
lines changed

24 files changed

+173
-1250
lines changed

implementations/rust/ockam/ockam_api/src/authority_node/authority.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use crate::authenticator::{
1212
};
1313
use ockam::identity::utils::now;
1414
use ockam::identity::{
15-
Identifier, Identities, SecureChannelListenerOptions, SecureChannelSqlxDatabase,
16-
SecureChannels, TrustEveryonePolicy,
15+
Identifier, Identities, SecureChannelListenerOptions, SecureChannels, TrustEveryonePolicy,
1716
};
1817
use ockam::tcp::{TcpListenerOptions, TcpTransport};
1918
use ockam_core::compat::sync::Arc;
@@ -75,14 +74,12 @@ impl Authority {
7574

7675
let members = Arc::new(AuthorityMembersSqlxDatabase::new(database.clone()));
7776
let tokens = Arc::new(AuthorityEnrollmentTokenSqlxDatabase::new(database.clone()));
78-
let secure_channel_repository = Arc::new(SecureChannelSqlxDatabase::new(database.clone()));
7977

8078
Self::bootstrap_repository(members.clone(), configuration).await?;
8179

8280
let identities = Identities::create_with_node(database, node_name).build();
8381

84-
let secure_channels =
85-
SecureChannels::from_identities(identities.clone(), secure_channel_repository);
82+
let secure_channels = SecureChannels::from_identities(identities.clone());
8683

8784
let identifier = configuration.identifier();
8885
info!(identifier=%identifier, "retrieved the authority identifier");

implementations/rust/ockam/ockam_api/src/cli_state/secure_channels.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::sync::Arc;
22

33
use crate::cli_state::CliState;
44
use crate::cli_state::Result;
5-
use ockam::identity::{Identities, SecureChannelSqlxDatabase, SecureChannels};
5+
use ockam::identity::{Identities, SecureChannels};
66
use ockam_node::Context;
77

88
impl CliState {
@@ -17,9 +17,6 @@ impl CliState {
1717
let identities = Identities::create_with_node(self.database(), node_name)
1818
.with_vault(vault)
1919
.build();
20-
Ok(SecureChannels::from_identities(
21-
identities,
22-
Arc::new(SecureChannelSqlxDatabase::new(self.database())),
23-
))
20+
Ok(SecureChannels::from_identities(identities))
2421
}
2522
}

implementations/rust/ockam/ockam_api/src/cli_state/vaults.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use colorful::Colorful;
22
use ockam::identity::{
3-
Identifier, Identities, RemoteCredentialRetrieverInfo, SecureChannelRegistry,
4-
SecureChannelSqlxDatabase, SecureChannels, Vault,
3+
Identifier, Identities, RemoteCredentialRetrieverInfo, SecureChannelRegistry, SecureChannels,
4+
Vault,
55
};
66
use ockam_core::errcode::{Kind, Origin};
77
use ockam_core::{AsyncTryClone, Error};
@@ -398,7 +398,6 @@ impl CliState {
398398
let secure_channels = Arc::new(SecureChannels::new(
399399
identities,
400400
SecureChannelRegistry::default(), //TODO: inherit registry from the node
401-
Arc::new(SecureChannelSqlxDatabase::new(self.database())),
402401
));
403402

404403
let credential_retriever_creator = credential_retriever_options

implementations/rust/ockam/ockam_api/src/nodes/service.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ mod trust;
2828
mod worker;
2929

3030
pub use manager::*;
31-
pub use secure_channel::SecureChannelType;
3231
pub use trust::*;
3332
pub use worker::*;
3433

implementations/rust/ockam/ockam_api/src/nodes/service/manager.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::nodes::registry::Registry;
1010
use crate::nodes::service::http::HttpServer;
1111
use crate::nodes::service::{
1212
CredentialRetrieverCreators, CredentialRetrieverOptions, NodeManagerTrustOptions,
13-
SecureChannelType,
1413
};
1514

1615
use crate::cli_state::journeys::{NODE_NAME, USER_EMAIL, USER_NAME};
@@ -205,7 +204,6 @@ impl NodeManager {
205204
None, // Not checking identifiers here in favor of credential check
206205
None,
207206
ctx,
208-
SecureChannelType::KeyExchangeAndMessages,
209207
)
210208
.await?;
211209

implementations/rust/ockam/ockam_api/src/nodes/service/relay.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use crate::nodes::models::secure_channel::{
2121
};
2222
use crate::nodes::registry::RegistryRelayInfo;
2323
use crate::nodes::service::in_memory_node::InMemoryNode;
24-
use crate::nodes::service::secure_channel::SecureChannelType;
2524
use crate::nodes::BackgroundNodeClient;
2625
use crate::session::replacer::{ReplacerOutcome, ReplacerOutputKind, SessionReplacer};
2726
use crate::session::session::Session;
@@ -440,7 +439,6 @@ impl SecureChannelsCreation for InMemoryNode {
440439
Some(vec![authorized]),
441440
credential,
442441
timeout,
443-
SecureChannelType::KeyExchangeAndMessages,
444442
)
445443
.await
446444
.into_diagnostic()

implementations/rust/ockam/ockam_api/src/nodes/service/secure_channel.rs

Lines changed: 21 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::time::Duration;
22

33
use ockam::identity::models::CredentialAndPurposeKey;
4+
use ockam::identity::TrustEveryonePolicy;
45
use ockam::identity::Vault;
56
use ockam::identity::{
67
Identifier, Identities, SecureChannelListenerOptions, SecureChannelOptions, SecureChannels,
78
TrustMultiIdentifiersPolicy,
89
};
910
use ockam::identity::{SecureChannel, SecureChannelListener};
10-
use ockam::identity::{SecureChannelSqlxDatabase, TrustEveryonePolicy};
1111
use ockam::{Address, Result, Route};
1212
use ockam_core::api::{Error, Response};
1313
use ockam_core::compat::sync::Arc;
@@ -29,12 +29,6 @@ use crate::nodes::registry::SecureChannelInfo;
2929
use crate::nodes::service::default_address::DefaultAddress;
3030
use crate::nodes::{NodeManager, NodeManagerWorker};
3131

32-
#[derive(PartialOrd, PartialEq, Debug)]
33-
pub enum SecureChannelType {
34-
KeyExchangeAndMessages,
35-
KeyExchangeOnly,
36-
}
37-
3832
/// SECURE CHANNELS
3933
impl NodeManagerWorker {
4034
pub async fn list_secure_channels(&self) -> Result<Response<Vec<String>>, Response<Error>> {
@@ -64,7 +58,6 @@ impl NodeManagerWorker {
6458
authorized_identifiers,
6559
credential,
6660
timeout,
67-
SecureChannelType::KeyExchangeAndMessages,
6861
)
6962
.await
7063
.map(|secure_channel| {
@@ -124,13 +117,7 @@ impl NodeManagerWorker {
124117

125118
let response = self
126119
.node_manager
127-
.create_secure_channel_listener(
128-
addr,
129-
authorized_identifiers,
130-
identity_name,
131-
ctx,
132-
SecureChannelType::KeyExchangeAndMessages,
133-
)
120+
.create_secure_channel_listener(addr, authorized_identifiers, identity_name, ctx)
134121
.await
135122
.map(|_| Response::ok())?;
136123
Ok(response)
@@ -177,7 +164,6 @@ impl NodeManager {
177164
authorized_identifiers: Option<Vec<Identifier>>,
178165
credential: Option<CredentialAndPurposeKey>,
179166
timeout: Option<Duration>,
180-
secure_channel_type: SecureChannelType,
181167
) -> Result<SecureChannel> {
182168
let identifier = self.get_identifier_by_name(identity_name.clone()).await?;
183169

@@ -192,7 +178,6 @@ impl NodeManager {
192178
authorized_identifiers,
193179
credential,
194180
timeout,
195-
secure_channel_type,
196181
)
197182
.await?;
198183

@@ -209,7 +194,6 @@ impl NodeManager {
209194
authorized_identifiers: Option<Vec<Identifier>>,
210195
credential: Option<CredentialAndPurposeKey>,
211196
timeout: Option<Duration>,
212-
secure_channel_type: SecureChannelType,
213197
) -> Result<SecureChannel> {
214198
debug!(%sc_route, "Creating secure channel");
215199
let options = SecureChannelOptions::new();
@@ -240,13 +224,6 @@ impl NodeManager {
240224
None => options.with_trust_policy(TrustEveryonePolicy),
241225
};
242226

243-
let options = if secure_channel_type == SecureChannelType::KeyExchangeOnly {
244-
// TODO: Should key exchange channels be persisted automatically?
245-
options.key_exchange_only().persist()?
246-
} else {
247-
options
248-
};
249-
250227
let sc = self
251228
.secure_channels
252229
.create_secure_channel(ctx, identifier, sc_route.clone(), options)
@@ -303,35 +280,12 @@ impl NodeManager {
303280

304281
/// SECURE CHANNEL LISTENERS
305282
impl NodeManager {
306-
//TODO: remove everything about key exchange service from secure channel
307-
#[allow(dead_code)]
308-
pub(crate) async fn start_key_exchanger_service(
309-
&self,
310-
context: &Context,
311-
address: Address,
312-
) -> Result<SecureChannelListener> {
313-
// skip creation if it already exists
314-
if let Some(listener) = self.registry.secure_channel_listeners.get(&address).await {
315-
return Ok(listener);
316-
}
317-
318-
self.create_secure_channel_listener(
319-
address.clone(),
320-
None,
321-
None,
322-
context,
323-
SecureChannelType::KeyExchangeOnly,
324-
)
325-
.await
326-
}
327-
328283
pub async fn create_secure_channel_listener(
329284
&self,
330285
address: Address,
331286
authorized_identifiers: Option<Vec<Identifier>>,
332287
identity_name: Option<String>,
333288
ctx: &Context,
334-
secure_channel_type: SecureChannelType,
335289
) -> Result<SecureChannelListener> {
336290
debug!(
337291
"Handling request to create a new secure channel listener: {}",
@@ -381,13 +335,6 @@ impl NodeManager {
381335
}
382336
};
383337

384-
let options = if secure_channel_type == SecureChannelType::KeyExchangeOnly {
385-
// TODO: Should key exchange channels be persisted automatically?
386-
options.key_exchange_only().persist()?
387-
} else {
388-
options
389-
};
390-
391338
let listener = secure_channels
392339
.create_secure_channel_listener(ctx, &identifier, address.clone(), options)
393340
.await?;
@@ -399,27 +346,25 @@ impl NodeManager {
399346
.insert(address.clone(), listener.clone())
400347
.await;
401348

402-
if secure_channel_type == SecureChannelType::KeyExchangeAndMessages {
403-
// TODO: Clean
404-
// Add Echoer as a consumer by default
405-
ctx.flow_controls()
406-
.add_consumer(DefaultAddress::ECHO_SERVICE, listener.flow_control_id());
407-
408-
// TODO: PUNCTURE Make optional?
409-
ctx.flow_controls().add_consumer(
410-
DefaultAddress::UDP_PUNCTURE_NEGOTIATION_LISTENER,
411-
listener.flow_control_id(),
412-
);
413-
414-
// Add ourselves to allow tunneling
415-
ctx.flow_controls()
416-
.add_consumer(address, listener.flow_control_id());
417-
418-
ctx.flow_controls().add_consumer(
419-
DefaultAddress::UPPERCASE_SERVICE,
420-
listener.flow_control_id(),
421-
);
422-
}
349+
// TODO: Clean
350+
// Add Echoer as a consumer by default
351+
ctx.flow_controls()
352+
.add_consumer(DefaultAddress::ECHO_SERVICE, listener.flow_control_id());
353+
354+
// TODO: PUNCTURE Make optional?
355+
ctx.flow_controls().add_consumer(
356+
DefaultAddress::UDP_PUNCTURE_NEGOTIATION_LISTENER,
357+
listener.flow_control_id(),
358+
);
359+
360+
// Add ourselves to allow tunneling
361+
ctx.flow_controls()
362+
.add_consumer(address, listener.flow_control_id());
363+
364+
ctx.flow_controls().add_consumer(
365+
DefaultAddress::UPPERCASE_SERVICE,
366+
listener.flow_control_id(),
367+
);
423368

424369
Ok(listener)
425370
}
@@ -477,7 +422,6 @@ impl NodeManager {
477422
Ok(Arc::new(SecureChannels::new(
478423
identities,
479424
self.secure_channels.secure_channel_registry(),
480-
Arc::new(SecureChannelSqlxDatabase::new(self.cli_state.database())),
481425
)))
482426
}
483427
}

implementations/rust/ockam/ockam_api/src/nodes/service/tcp_inlets/session_replacer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use ockam_transport_tcp::TcpInlet;
2020

2121
use crate::error::ApiError;
2222
use crate::nodes::connection::Connection;
23-
use crate::nodes::service::SecureChannelType;
2423
use crate::nodes::NodeManager;
2524
use crate::session::replacer::{
2625
AdditionalSessionReplacer, CurrentInletStatus, ReplacerOutcome, ReplacerOutputKind,
@@ -356,7 +355,6 @@ impl AdditionalSessionReplacer for InletSessionReplacer {
356355
None,
357356
// TODO: Have a dedicated timeout
358357
Some(Duration::from_secs(10)),
359-
SecureChannelType::KeyExchangeAndMessages,
360358
)
361359
.await?;
362360
let additional_sc = self.additional_secure_channel.insert(additional_sc);

implementations/rust/ockam/ockam_api/tests/credential_issuer.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use minicbor::bytes::ByteSlice;
2+
use ockam::identity::identities;
23
use ockam::identity::models::CredentialAndPurposeKey;
34
use ockam::identity::utils::now;
4-
use ockam::identity::{identities, SecureChannelSqlxDatabase};
55
use ockam::identity::{
66
Identities, SecureChannelListenerOptions, SecureChannelOptions, SecureChannels,
77
};
@@ -55,10 +55,7 @@ async fn credential(ctx: &mut Context) -> Result<()> {
5555
.with_purpose_keys_repository(identities.purpose_keys_repository())
5656
.with_cached_credential_repository(identities.cached_credentials_repository())
5757
.build();
58-
let secure_channels = SecureChannels::from_identities(
59-
identities.clone(),
60-
Arc::new(SecureChannelSqlxDatabase::create().await?),
61-
);
58+
let secure_channels = SecureChannels::from_identities(identities.clone());
6259
let identities_verification = identities.identities_verification();
6360

6461
// Create the CredentialIssuer:

implementations/rust/ockam/ockam_api/tests/latency.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![recursion_limit = "256"]
22

3-
use ockam_api::nodes::service::SecureChannelType;
43
use std::sync::Arc;
54
use std::time::{Duration, Instant};
65

@@ -48,7 +47,6 @@ pub fn measure_message_latency_two_nodes() -> ockam_core::Result<()> {
4847
None,
4948
None,
5049
None,
51-
SecureChannelType::KeyExchangeAndMessages,
5250
)
5351
.await
5452
.unwrap();

0 commit comments

Comments
 (0)