Rename and Format

This commit is contained in:
Sarah Jamie Lewis 2021-01-12 05:40:33 -08:00
parent 53337d16f8
commit 6ff40ec75e
4 changed files with 29 additions and 31 deletions

View File

@ -1,12 +1,12 @@
use tapir::acns::tor::authentication::HashedPassword;
use ed25519_dalek::SecretKey;
use tapir::primitives::identity::Identity;
use tapir::connections::{OutboundConnection, Connection, ConnectionInterface};
use tapir::primitives::transcript::Transcript;
use tapir::applications::authentication_app::{AuthenicationApp, AUTHENTICATION_CAPABILITY};
use tapir::connections::service::Service;
use rand::rngs::OsRng;
use tapir::acns::tor::TorProcess;
use tapir_cwtch::acns::tor::authentication::HashedPassword;
use tapir_cwtch::acns::tor::TorProcess;
use tapir_cwtch::applications::authentication_app::{AuthenicationApp, AUTHENTICATION_CAPABILITY};
use tapir_cwtch::connections::service::Service;
use tapir_cwtch::connections::{Connection, ConnectionInterface, OutboundConnection};
use tapir_cwtch::primitives::identity::Identity;
use tapir_cwtch::primitives::transcript::Transcript;
fn main() {
let mut auth_control_port = TorProcess::connect(9051)
@ -45,4 +45,4 @@ fn main() {
}
Err(err) => println!("{:?}", err),
}
}
}

View File

@ -1,12 +1,12 @@
use tapir::acns::tor::authentication::HashedPassword;
use ed25519_dalek::SecretKey;
use tapir::primitives::identity::Identity;
use tapir::connections::{Connection, InboundConnection, ConnectionInterface};
use tapir::primitives::transcript::Transcript;
use tapir::applications::authentication_app::AuthenicationApp;
use tapir::connections::service::Service;
use rand::rngs::OsRng;
use tapir::acns::tor::TorProcess;
use tapir_cwtch::acns::tor::authentication::HashedPassword;
use tapir_cwtch::acns::tor::TorProcess;
use tapir_cwtch::applications::authentication_app::AuthenicationApp;
use tapir_cwtch::connections::service::Service;
use tapir_cwtch::connections::{Connection, ConnectionInterface, InboundConnection};
use tapir_cwtch::primitives::identity::Identity;
use tapir_cwtch::primitives::transcript::Transcript;
fn main() {
let mut auth_control_port = TorProcess::connect(9051)
@ -29,12 +29,8 @@ fn main() {
let mut transcript = Transcript::new_transcript("tapir-transcript");
let mut auth_app = AuthenicationApp::new(identity);
match auth_app.run_inbound(conn, &mut transcript) {
Ok(conn) => {
println!("Authenticated Inbound Connection from {}", conn.hostname())
}
_ => {
println!("Failed Inbound Authentication")
}
Ok(conn) => println!("Authenticated Inbound Connection from {}", conn.hostname()),
_ => println!("Failed Inbound Authentication"),
}
};
@ -44,4 +40,4 @@ fn main() {
}
Err(err) => println!("{:?}", err),
}
}
}

View File

@ -1,6 +1,6 @@
use crate::applications::authentication_app::AuthenticationAppError::NotAuthenticatedError;
use crate::connections::utils::public_key_to_hostname;
use crate::connections::{Connection, ConnectionInterface, InboundConnection, OutboundConnection, Capability};
use crate::connections::{Capability, Connection, ConnectionInterface, InboundConnection, OutboundConnection};
use crate::primitives::identity::Identity;
use crate::primitives::transcript::Transcript;
use ed25519_dalek::PublicKey;
@ -36,7 +36,10 @@ struct AuthenticationSession<Direction> {
conn: Connection<Direction>,
}
impl<Direction> AuthenticationSession<Direction> where Direction:Clone {
impl<Direction> AuthenticationSession<Direction>
where
Direction: Clone,
{
pub fn new_outbound(conn: Connection<OutboundConnection>, long_term_identity: Arc<Identity>) -> AuthenticationSession<OutboundConnection> {
let ephemeral_identity = Identity::initialize_ephemeral_identity();
let mut auth_session = AuthenticationSession {

View File

@ -1,9 +1,9 @@
use hashbrown::HashSet;
use integer_encoding::{FixedInt, VarInt};
use secretbox::CipherType::Salsa20;
use secretbox::SecretBox;
use std::io::{Error, Read, Write};
use std::net::{Shutdown, TcpStream};
use hashbrown::HashSet;
/// Connections provides an interface for manage sets of connections on top of a particular
/// ACN.
@ -25,13 +25,12 @@ pub struct OutboundConnection(());
#[derive(Clone, Eq, PartialEq, Hash)]
pub struct Capability(pub &'static str);
pub struct Connection<Direction> {
conn: TcpStream,
direction: Direction,
key: Vec<u8>,
hostname: String,
capabilities: HashSet<Capability>
capabilities: HashSet<Capability>,
}
pub trait ConnectionInterface {
@ -133,7 +132,7 @@ impl<Direction> ConnectionInterface for Connection<Direction> {
}
fn set_capability(&mut self, capability: &Capability) {
self.capabilities.insert(capability.clone());
self.capabilities.insert(capability.clone());
}
fn has_capability(&self, capability: &Capability) -> bool {
@ -151,7 +150,7 @@ where
direction: InboundConnection(()),
key: vec![],
hostname: String::new(),
capabilities: HashSet::new()
capabilities: HashSet::new(),
}
}
@ -161,7 +160,7 @@ where
direction: OutboundConnection(()),
key: vec![],
hostname: String::new(),
capabilities: HashSet::new()
capabilities: HashSet::new(),
}
}
@ -171,7 +170,7 @@ where
direction: self.direction.clone(),
key: self.key.clone(),
hostname: self.hostname.clone(),
capabilities: self.capabilities.clone()
capabilities: self.capabilities.clone(),
}
}
}