Skip to content

Commit

Permalink
Add Hash as SymKey super trait.
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrezot committed Sep 2, 2022
1 parent 0d26ef8 commit e5448fb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file.

---
## [2.0.1] - 2022-09-02
### Added
- `Hash` super trait to `SymKey`
### Changed
### Fixed
### Removed
---

---
## [2.0.0] - 2022-08-22
### Added
Expand Down
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Crypto lib for pure crypto primitives"
edition = "2021"
license = "MIT/Apache-2.0"
name = "cosmian_crypto_core"
version = "2.0.0"
version = "2.0.1"

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
4 changes: 2 additions & 2 deletions src/symmetric_crypto/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{symmetric_crypto::SymKey, CryptoCoreError, KeyTrait};
use aes::cipher::generic_array::{ArrayLength, GenericArray};
use rand_core::{CryptoRng, RngCore};
use serde::{Deserialize, Serialize};
use std::{convert::TryFrom, fmt::Display, ops::Deref};
use std::{convert::TryFrom, fmt::Display, hash::Hash, ops::Deref};
use zeroize::{Zeroize, ZeroizeOnDrop};

/// Symmetric key of a given size.
Expand Down Expand Up @@ -36,7 +36,7 @@ impl<KeyLength: Eq + ArrayLength<u8>> KeyTrait for Key<KeyLength> {
}
}

impl<KeyLength: Eq + ArrayLength<u8>> SymKey for Key<KeyLength> {
impl<KeyLength: Hash + Eq + ArrayLength<u8>> SymKey for Key<KeyLength> {
/// Convert the given key into a byte slice, without copy.
fn as_bytes(&self) -> &[u8] {
&self.0
Expand Down
3 changes: 2 additions & 1 deletion src/symmetric_crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ use crate::{CryptoCoreError, KeyTrait};
use generic_array::GenericArray;
use nonce::NonceTrait;
use rand_core::{CryptoRng, RngCore};
use std::hash::Hash;
use std::vec::Vec;

/// Defines a symmetric encryption key.
pub trait SymKey: KeyTrait {
pub trait SymKey: KeyTrait + Hash {
/// Convert the given key into a byte slice.
fn as_bytes(&self) -> &[u8];

Expand Down

0 comments on commit e5448fb

Please sign in to comment.