Skip to content

Commit

Permalink
Fix: V1.3.10
Browse files Browse the repository at this point in the history
Fixed the errors of the new beta-1.85-1
  • Loading branch information
mm9942 authored Jan 22, 2025
1 parent d86a957 commit 8dd5284
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
workspace = { members = [ "crypt_guard_proc"] }
[package]
name = "crypt_guard"
version = "1.3.9"
version = "1.3.10"
edition = "2021"
description = "CryptGuard is a post-quantum cryptography library with support for Kyber, Falcon, Dilithium in combination with AES and XChaCha20."
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The macros now automatically zero out the used values to enhance data security d

### Current Release

The current version, **1.3.9**, focuses on detailed cryptographic operations with enhanced data handling through automated macros. These macros simplify execution by wrapping up the necessary steps of definition, leveraging generic types and trait definitions. This version avoids asynchronous code, which will be reintroduced as a feature in future updates. Users preferring async implementation should use version 1.0.3. Note that version 1.0.3 uses the old syntax and has indirect documentation through the README, lacking Cargo's auto-generated documentation due to missing comments. The new version offers user-friendly syntax, reducing the need for extensive struct definitions, and supports Kyber1024, Kyber768, and Kyber512, along with logging capabilities.
The current version, **1.3.10**, focuses on detailed cryptographic operations with enhanced data handling through automated macros. These macros simplify execution by wrapping up the necessary steps of definition, leveraging generic types and trait definitions. This version avoids asynchronous code, which will be reintroduced as a feature in future updates. Users preferring async implementation should use version 1.0.3. Note that version 1.0.3 uses the old syntax and has indirect documentation through the README, lacking Cargo's auto-generated documentation due to missing comments. The new version offers user-friendly syntax, reducing the need for extensive struct definitions, and supports Kyber1024, Kyber768, and Kyber512, along with logging capabilities.

### Simplifying Encryption and Decryption with Macros

Expand Down
8 changes: 3 additions & 5 deletions src/Core/cipher_aes.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use super::*;
//use super::*;
use crate::{
*,
error::CryptError,
cryptography::{
CryptographicInformation,
CipherAES,
},
cryptography::{*, hmac_sign::{Sign, SignType, Operation}},
Core::{
KyberKeyFunctions,
KeyControlVariant,
Expand Down
7 changes: 2 additions & 5 deletions src/Core/cipher_aes_ctr.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use super::*;
//use super::*;

//use crypt_guard_proc::{*, log_activity, write_log};
use crate::{
*,
cryptography::{
CryptographicInformation,
CipherAES_CTR,
},
cryptography::{*, hmac_sign::{Sign, SignType, Operation}},
error::{*},
Core::{
KyberKeyFunctions,
Expand Down
7 changes: 2 additions & 5 deletions src/Core/cipher_aes_gcm_siv.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use super::*;
//use super::*;

//use crypt_guard_proc::{*, log_activity, write_log};
use crate::{
*,
cryptography::{
CryptographicInformation,
CipherChaCha,
},
cryptography::{*, hmac_sign::{Sign, SignType, Operation}},
error::{*},
Core::{
KyberKeyFunctions,
Expand Down
7 changes: 2 additions & 5 deletions src/Core/cipher_aes_xts.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use super::*;
//use super::*;

//use crypt_guard_proc::{*, log_activity, write_log};
use crate::{
*,
cryptography::{
CryptographicInformation,
CipherChaCha,
},
cryptography::{*, hmac_sign::{Sign, SignType, Operation}},
error::{*},
Core::{
KyberKeyFunctions,
Expand Down
7 changes: 2 additions & 5 deletions src/Core/cipher_xchacha.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use super::*;
//use super::*;

//use crypt_guard_proc::{*, log_activity, write_log};
use crate::{
*,
cryptography::{
CryptographicInformation,
CipherChaCha,
},
cryptography::{*, hmac_sign::{Sign, SignType, Operation}},
error::*,
Core::{
KyberKeyFunctions,
Expand Down
12 changes: 4 additions & 8 deletions src/Core/cipher_xchacha_poly.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use super::*;

use kyber::KeyControler::*;
//use crypt_guard_proc::{*, log_actnonceity, write_log};
use crate::{
*,
cryptography::{
CryptographicInformation,
CipherChaCha,
},
error::{*},
cryptography::{*, hmac_sign::{Sign, SignType, Operation}},
error::CryptError,
Core::{
KyberKeyFunctions,
KeyControlVariant,
Expand Down Expand Up @@ -46,7 +42,7 @@ impl CipherChaCha_Poly {
///
/// # Returns
/// A new CipherChaCha instance.
pub fn new(infos: CryptographicInformation, nonce: Option<String>) -> Self {
pub fn create(infos: CryptographicInformation, nonce: Option<String>) -> Self {
let nonce: [u8; 24] = match nonce {
Some(nonce) => {
let mut array = [0u8; 24];
Expand Down
21 changes: 20 additions & 1 deletion src/Core/kyber/KeyControler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
use super::*;
use pqcrypto_traits::kem::{PublicKey, SecretKey, SharedSecret, Ciphertext};
use crate::{
*,
log_activity,
cryptography::*,
error::CryptError,
//hmac_sign::*,
FileTypes,
FileState,
FileMetadata,
KeyTypes,
Key,
Core::CryptographicFunctions,
write_log,
};
use std::{
path::{PathBuf, Path},
marker::PhantomData,
result::Result,
};

/// Trait for implementing key management functions. This trait provides
/// an interface for key pair generation, encapsulation/decapsulation of secrets,
Expand Down
21 changes: 20 additions & 1 deletion src/Core/kyber/KeyKyber.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
use super::*;
use pqcrypto_traits::kem::{PublicKey, SecretKey, SharedSecret, Ciphertext};
use crate::{
*,
log_activity,
cryptography::*,
error::CryptError,
//hmac_sign::*,
FileTypes,
FileState,
FileMetadata,
KeyTypes,
Key,
Core::CryptographicFunctions,
write_log,
};
use std::{
path::{PathBuf, Path},
marker::PhantomData,
result::Result,
};

/// Trait for implementing key management functions. This trait provides
/// an interface for key pair generation, encapsulation/decapsulation of secrets,
Expand Down
21 changes: 20 additions & 1 deletion src/Core/kyber/kyber_crypto.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
use super::*;
use pqcrypto_traits::kem::{PublicKey, SecretKey, SharedSecret, Ciphertext};
use crate::{
*,
log_activity,
cryptography::*,
error::CryptError,
//hmac_sign::*,
FileTypes,
FileState,
FileMetadata,
KeyTypes,
Key,
Core::CryptographicFunctions,
write_log,
};
use std::{
path::{PathBuf, Path},
marker::PhantomData,
result::Result,
};

/// Provides Kyber encryption functions for AES algorithm.
impl<KyberSize, ContentStatus> KyberFunctions for Kyber<Encryption, KyberSize, ContentStatus, AES>
Expand Down
21 changes: 20 additions & 1 deletion src/Core/kyber/kyber_crypto_aes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
use super::*;
use pqcrypto_traits::kem::{PublicKey, SecretKey, SharedSecret, Ciphertext};
use crate::{
*,
log_activity,
cryptography::*,
error::CryptError,
//hmac_sign::*,
FileTypes,
FileState,
FileMetadata,
KeyTypes,
Key,
Core::CryptographicFunctions,
write_log,
};
use std::{
path::{PathBuf, Path},
marker::PhantomData,
result::Result,
};

/// Provides Kyber encryption functions for AES algorithm.
impl<KyberSize, ContentStatus> KyberFunctions for Kyber<Encryption, KyberSize, ContentStatus, AES>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/kyber/kyber_crypto_aes_ctr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::{
*,
cryptography::{CipherAES_CTR, CryptographicInformation, CryptographicMetadata, ContentType, Process, CryptographicMechanism, KeyEncapMechanism},
error::CryptError,
Core::CryptographicFunctions,
Expand Down
17 changes: 13 additions & 4 deletions src/Core/kyber/kyber_crypto_aes_gcm_siv.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
use super::*;
use pqcrypto_traits::kem::{PublicKey, SecretKey, SharedSecret, Ciphertext};
use crate::{
cryptography::{CipherAES_GCM_SIV, CryptographicInformation, CryptographicMetadata, ContentType, Process, CryptographicMechanism, KeyEncapMechanism},
error::CryptError,
*,
log_activity,
cryptography::*,
error::CryptError,
//hmac_sign::*,
FileTypes,
FileState,
FileMetadata,
KeyTypes,
Key,
Core::CryptographicFunctions,
KeyControl::FileMetadata,
write_log,
};
use std::{
marker::PhantomData,
path::{Path, PathBuf},
result::Result,
};
Expand Down
21 changes: 20 additions & 1 deletion src/Core/kyber/kyber_crypto_aes_xts.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
use super::*;
use pqcrypto_traits::kem::{PublicKey, SecretKey, SharedSecret, Ciphertext};
use crate::{
*,
log_activity,
cryptography::*,
error::CryptError,
//hmac_sign::*,
FileTypes,
FileState,
FileMetadata,
KeyTypes,
Key,
Core::CryptographicFunctions,
write_log,
};
use std::{
path::{PathBuf, Path},
marker::PhantomData,
result::Result,
};

/// Provides Kyber encryption functions for AES_XTS algorithm.
impl<KyberSize, ContentStatus> KyberFunctions for Kyber<Encryption, KyberSize, ContentStatus, AES_XTS>
Expand Down
21 changes: 20 additions & 1 deletion src/Core/kyber/kyber_crypto_xchacha.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
use super::*;
use pqcrypto_traits::kem::{PublicKey, SecretKey, SharedSecret, Ciphertext};
use crate::{
*,
log_activity,
cryptography::*,
error::CryptError,
//hmac_sign::*,
FileTypes,
FileState,
FileMetadata,
KeyTypes,
Key,
Core::CryptographicFunctions,
write_log,
};
use std::{
path::{PathBuf, Path},
marker::PhantomData,
result::Result,
};

/// Provides Kyber encryption functions for XChaCha20 algorithm.
impl<KyberSize, ContentStatus> KyberFunctions for Kyber<Encryption, KyberSize, ContentStatus, XChaCha20>
Expand Down
33 changes: 26 additions & 7 deletions src/Core/kyber/kyber_crypto_xchacha_poly.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
use super::*;
use pqcrypto_traits::kem::{PublicKey, SecretKey, SharedSecret, Ciphertext};
use crate::{
*,
log_activity,
cryptography::*,
error::CryptError,
//hmac_sign::*,
FileTypes,
FileState,
FileMetadata,
KeyTypes,
Key,
Core::CryptographicFunctions,
write_log,
};
use std::{
path::{PathBuf, Path},
marker::PhantomData,
result::Result,
};

/// Provides Kyber encryption functions for XChaCha20Poly1305 algorithm.
impl<KyberSize, ContentStatus> KyberFunctions for Kyber<Encryption, KyberSize, ContentStatus, XChaCha20Poly1305>
Expand Down Expand Up @@ -32,7 +51,7 @@ where
);
let file = FileMetadata::from(path, FileTypes::other(), FileState::not_encrypted());
let infos = CryptographicInformation::from(Vec::new(), passphrase.as_bytes().to_vec(), crypt_metadata, true, Some(file));
let mut xchacha = CipherChaCha_Poly::new(infos, None);
let mut xchacha = CipherChaCha_Poly::create(infos, None);
log_activity!("Creating a new cipher instance of XChaCha20Poly1305.", "");

let _ = self.kyber_data.set_nonce(hex::encode(xchacha.nonce()));
Expand Down Expand Up @@ -64,7 +83,7 @@ where
ContentType::message(),
);
let infos = CryptographicInformation::from(message.as_bytes().to_owned(), passphrase.as_bytes().to_vec(), crypt_metadata, false, None);
let mut xchacha = CipherChaCha_Poly::new(infos, None);
let mut xchacha = CipherChaCha_Poly::create(infos, None);
log_activity!("Creating a new cipher instance of XChaCha20Poly1305.", "");

let _ = self.kyber_data.set_nonce(hex::encode(xchacha.nonce()));
Expand Down Expand Up @@ -96,7 +115,7 @@ where
ContentType::message(),
);
let infos = CryptographicInformation::from(data, passphrase.as_bytes().to_vec(), crypt_metadata, false, None);
let mut xchacha = CipherChaCha_Poly::new(infos, None);
let mut xchacha = CipherChaCha_Poly::create(infos, None);
log_activity!("Creating a new cipher instance of XChaCha20Poly1305.", "");

let _ = self.kyber_data.set_nonce(hex::encode(xchacha.nonce()));
Expand Down Expand Up @@ -166,7 +185,7 @@ where
);
let file = FileMetadata::from(path, FileTypes::other(), FileState::encrypted());
let infos = CryptographicInformation::from(Vec::new(), passphrase.as_bytes().to_vec(), crypt_metadata, true, Some(file));
let mut xchacha = CipherChaCha_Poly::new(infos, Some(self.kyber_data.nonce()?.to_string()));
let mut xchacha = CipherChaCha_Poly::create(infos, Some(self.kyber_data.nonce()?.to_string()));
log_activity!("Creating a new cipher instance of XChaCha20Poly1305.", "");

let data = xchacha.decrypt(self.kyber_data.key()?, ciphertext).unwrap();
Expand Down Expand Up @@ -196,7 +215,7 @@ where
ContentType::message(),
);
let infos = CryptographicInformation::from(message, passphrase.as_bytes().to_vec(), crypt_metadata, false, None);
let mut xchacha = CipherChaCha_Poly::new(infos, Some(self.kyber_data.nonce()?.to_string()));
let mut xchacha = CipherChaCha_Poly::create(infos, Some(self.kyber_data.nonce()?.to_string()));
log_activity!("Creating a new cipher instance of XChaCha20Poly1305.", "");

let data = xchacha.decrypt(self.kyber_data.key()?, ciphertext).unwrap();
Expand Down Expand Up @@ -227,7 +246,7 @@ where
ContentType::message(),
);
let infos = CryptographicInformation::from(data, passphrase.as_bytes().to_vec(), crypt_metadata, false, None);
let mut xchacha = CipherChaCha_Poly::new(infos, Some(self.kyber_data.nonce()?.to_string()));
let mut xchacha = CipherChaCha_Poly::create(infos, Some(self.kyber_data.nonce()?.to_string()));
log_activity!("Creating a new cipher instance of XChaCha20Poly1305.", "");

let data = xchacha.decrypt(self.kyber_data.key()?, ciphertext).unwrap();
Expand Down
Loading

0 comments on commit 8dd5284

Please sign in to comment.