Skip to content
Snippets Groups Projects
Commit 2871ad9a authored by SamwiseFilmore's avatar SamwiseFilmore
Browse files

Clean up old code/comments

parent 069b96b3
No related branches found
No related tags found
1 merge request!4Port to libsodium
......@@ -29,11 +29,6 @@ impl Header {
let signed = data.get(..mem::size_of::<Header>())
.ok_or(Error::Plain(plain::Error::TooShort))?;
// Verify signature and retrieve verified data
//let mut verified = [0; mem::size_of::<Header>()];
//let count = sodalite::sign_attached_open(&mut verified, signed, public_key.as_data())
// .map_err(|_err| Error::InvalidSignature)?;
let verified = sign::verify(signed, public_key)
.map_err(|_err| Error::InvalidSignature)?;
......
use rand_core::{CryptoRng, Error, RngCore};
pub struct PublicKey([u8; 32]);
impl PublicKey {
pub fn from_data(data: [u8; 32]) -> Self {
Self(data)
}
pub fn as_data(&self) -> &[u8; 32] {
&self.0
}
pub fn into_data(self) -> [u8; 32] {
self.0
}
}
pub struct SecretKey([u8; 64]);
impl SecretKey {
pub fn new<R: CryptoRng + RngCore>(rng: &mut R) -> Result<Self, Error> {
let mut seed = [0; 32];
rng.try_fill_bytes(&mut seed)?;
let mut public_key = [0; 32];
let mut secret_key = [0; 64];
sodalite::sign_keypair_seed(&mut public_key, &mut secret_key, &seed);
assert_eq!(public_key, secret_key[32..]);
Ok(Self::from_data(secret_key))
}
pub fn from_data(data: [u8; 64]) -> Self {
Self(data)
}
pub fn as_data(&self) -> &[u8; 64] {
&self.0
}
pub fn into_data(self) -> [u8; 64] {
self.0
}
pub fn public_key(&self) -> PublicKey {
let mut public_key = [0; 32];
public_key.copy_from_slice(&self.0[32..]);
PublicKey::from_data(public_key)
}
}
......@@ -3,13 +3,11 @@
pub use crate::entry::Entry;
pub use crate::error::Error;
pub use crate::header::Header;
//pub use crate::key::{PublicKey, SecretKey};
pub use crate::package::{Package, PackageSrc};
mod entry;
mod error;
mod header;
//mod key;
mod package;
#[cfg(feature = "std")]
......@@ -31,3 +29,4 @@ mod tests {
assert_eq!(mem::size_of::<Entry>(), 308);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment