types are now Ord

tokio-1.0
Avril 4 years ago
parent 2e3ff12cb7
commit 41c0945bea
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,6 +1,6 @@
[package] [package]
name = "cryptohelpers" name = "cryptohelpers"
version = "1.7.1" version = "1.7.2"
license= "MIT" license= "MIT"
description = "Collection of helpers and simplifying functions for cryptography things" description = "Collection of helpers and simplifying functions for cryptography things"
authors = ["Avril <flanchan@cumallover.me>"] authors = ["Avril <flanchan@cumallover.me>"]
@ -9,7 +9,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
openssl = {version = "0.10", optional = true} openssl = { version = "0.10.32", optional = true }
pbkdf2 = {version = "0.5", optional = true } pbkdf2 = {version = "0.5", optional = true }
sha2 = {version = "0.9", optional = true } sha2 = {version = "0.9", optional = true }
hmac = {version = "0.9", optional = true } hmac = {version = "0.9", optional = true }

@ -29,7 +29,7 @@ use consts::BUFFER_SIZE;
const BLOCKSIZE: usize = 16; const BLOCKSIZE: usize = 16;
/// A key and IV for the AES algorithm /// A key and IV for the AES algorithm
#[derive(Debug, PartialEq, Eq, Clone, Hash, Default)] #[derive(Debug, PartialEq, Eq, Clone, Hash, Default, PartialOrd, Ord)]
#[cfg_attr(feature="serialise", derive(Serialize,Deserialize))] #[cfg_attr(feature="serialise", derive(Serialize,Deserialize))]
#[repr(align(1))] #[repr(align(1))]
pub struct AesKey { pub struct AesKey {

@ -37,9 +37,17 @@ use consts::RSA_SIG_SIZE as SIZE;
use consts::BUFFER_SIZE; use consts::BUFFER_SIZE;
/// Represents an RSA signature /// Represents an RSA signature
#[derive(Copy, Clone)] #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)] #[repr(transparent)]
pub struct Signature([u8; SIZE]); pub struct Signature([u8; SIZE]);
impl Default for Signature
{
#[inline]
fn default() -> Self
{
Self([0u8; SIZE])
}
}
#[cfg(feature="serialise")] const _: () = { #[cfg(feature="serialise")] const _: () = {
use serde::{ use serde::{
@ -309,38 +317,6 @@ impl AsMut<[u8]> for Signature
} }
} }
impl Default for Signature
{
#[inline]
fn default() -> Self
{
Self([0u8; SIZE])
}
}
impl Eq for Signature{}
impl PartialEq for Signature
{
#[inline] fn eq(&self, other: &Self) -> bool
{
&self.0[..] == &other.0[..]
}
}
impl Hash for Signature {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0[..].hash(state)
}
}
impl Debug for Signature
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{
write!(f, "Signature ({:?})", &self.0[..])
}
}
impl Display for Signature impl Display for Signature
{ {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result

@ -18,7 +18,7 @@ use tokio::{
pub const SIZE: usize = consts::SHA256_SIZE; pub const SIZE: usize = consts::SHA256_SIZE;
/// Represents a SHA256 hash /// Represents a SHA256 hash
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, Debug)] #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[repr(transparent)] #[repr(transparent)]
#[cfg_attr(feature="serialise", derive(Serialize,Deserialize))] #[cfg_attr(feature="serialise", derive(Serialize,Deserialize))]
pub struct Sha256Hash pub struct Sha256Hash

Loading…
Cancel
Save