Ver a proveniência

swapping orion for ring

master
Isabelle L. há 5 anos
ascendente
cometimento
cb0257e966
2 ficheiros alterados com 1 adições e 32 eliminações
  1. +1
    -1
      Cargo.toml
  2. +0
    -31
      src/lib.rs

+ 1
- 1
Cargo.toml Ver ficheiro

@@ -5,10 +5,10 @@ authors = ["Isabelle L. <me@izzabelle.dev>"]
edition = "2018"

[dependencies]
orion = "0.15.1"
serde = { version = "1.0.110", features = ["derive"]}
serde_json = "1.0.53"
futures = "0.3.5"
futures-util = "0.3.5"
uuid = { version = "0.8.1", features = ["v4"] }
chrono = "0.4.11"
ring = "0.16.13"

+ 0
- 31
src/lib.rs Ver ficheiro

@@ -2,7 +2,6 @@
#![allow(dead_code)]

use futures_util::io::{AsyncReadExt, AsyncWriteExt};
use orion::aead;
use std::convert::TryInto;
use std::marker::Unpin;

@@ -73,23 +72,6 @@ where
Ok(Some(packet))
}

/// reads a `Packet` from a stream and decrypts
///
/// if `Ok(None)` is returned the stream has been disconnected.
pub async fn read_encrypted<S>(stream: &mut S, key: &aead::SecretKey) -> Result<Option<Packet>>
where
S: AsyncReadExt + Unpin,
{
let packet = read(stream).await?;
match packet {
None => Ok(packet),
Some(mut packet) => {
packet.contents = aead::open(&key, &packet.contents)?;
Ok(Some(packet))
}
}
}

/// Writes a `Sendable` packet to a stream
pub async fn write<S, P>(stream: &mut S, packet: P) -> Result<()>
where
@@ -101,19 +83,6 @@ where
Ok(())
}

/// Writes an encrypted `Sendable` packet to a stream
pub async fn write_encrypted<S, P>(stream: &mut S, packet: P, key: &aead::SecretKey) -> Result<()>
where
S: AsyncWriteExt + Unpin,
P: Sendable,
{
let mut packet = packet.to_packet()?;
packet.contents = aead::seal(&key, &packet.contents)?;
let network_packet = packet.to_network_packet();
stream.write(&network_packet.0).await?;
Ok(())
}

/// Kinds of packets that can be sent
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]


Carregando…
Cancelar
Guardar