Skip to content

Commit

Permalink
Remove SymmetricCrypto
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrezot committed Sep 6, 2022
1 parent 3663925 commit bd462e9
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 579 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
All notable changes to this project will be documented in this file.

---
## [3.0.0] - 2022-09-02
## [2.0.1] - 2022-09-06
### Added
### Changed
- use constant generics
Expand Down
2 changes: 1 addition & 1 deletion 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 = "3.0.0"
version = "2.0.1"

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
11 changes: 2 additions & 9 deletions src/asymmetric_crypto/curve25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl TryFrom<&[u8]> for X25519PrivateKey {
impl From<X25519PrivateKey> for [u8; X25519_SK_LENGTH] {
#[inline]
fn from(key: X25519PrivateKey) -> Self {
key.0.to_bytes()
key.to_bytes()
}
}

Expand Down Expand Up @@ -292,14 +292,7 @@ impl TryFrom<&[u8]> for X25519PublicKey {
impl From<X25519PublicKey> for [u8; X25519_PK_LENGTH] {
#[inline]
fn from(key: X25519PublicKey) -> Self {
key.0.compress().to_bytes()
}
}

impl From<&X25519PublicKey> for [u8; X25519_PK_LENGTH] {
#[inline]
fn from(key: &X25519PublicKey) -> Self {
key.0.compress().to_bytes()
key.to_bytes()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/asymmetric_crypto/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::KeyTrait;
use rand_core::{CryptoRng, RngCore};
use core::{
fmt::Debug,
ops::{Add, Mul},
};
use rand_core::{CryptoRng, RngCore};
use zeroize::{Zeroize, ZeroizeOnDrop};

pub mod curve25519;
Expand Down
17 changes: 9 additions & 8 deletions src/kdf.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
use crate::CryptoCoreError;
use hkdf::Hkdf;
use sha2::Sha256;
use sha2::{digest::OutputSizeUser, Sha256};

/// Derive a key of `KEY_LENGTH` bytes using a HMAC-based Extract-and-Expand
/// Key Derivation Function (HKDF) supplying a `bytes` and some `info` context
/// `String`. The hash function used is Sha256.
///
/// - `bytes` : input bytes to hash, should be at least 32-bytes long
/// - `ikm` : input key material, should be at least 32-bytes long
/// - `info` : some optional additional information to use in the hash
pub fn hkdf_256<const LENGTH: usize>(
bytes: &[u8],
ikm: &[u8],
info: &[u8],
) -> Result<[u8; LENGTH], CryptoCoreError> {
if bytes.len() < 32 {
return Err(CryptoCoreError::InvalidSize(
"Input `bytes` size should be at least 32 bytes".to_string(),
));
if ikm.len() < <Sha256 as OutputSizeUser>::output_size() {
return Err(CryptoCoreError::InvalidSize(format!(
"Input `bytes` size should be at least {} bytes",
<Sha256 as OutputSizeUser>::output_size()
)));
}
let h = Hkdf::<Sha256>::new(None, bytes);
let h = Hkdf::<Sha256>::new(None, ikm);
let mut out = [0; LENGTH];
h.expand(info, &mut out)
.map_err(|_| CryptoCoreError::KdfError(LENGTH))?;
Expand Down
89 changes: 0 additions & 89 deletions src/symmetric_crypto/aes_256_gcm_pure/dem.rs

This file was deleted.

Loading

0 comments on commit bd462e9

Please sign in to comment.