Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Cargo.lock

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

12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ do-lint-ci:

# Test crate packages features
test-feat:
cargo test -p keetanetwork-crypto --no-default-features --features signature
cargo test -p keetanetwork-crypto --no-default-features --features encryption
cargo test -p keetanetwork-crypto --no-default-features --features der
cargo test -p keetanetwork-crypto --no-default-features --features std,signature
cargo test -p keetanetwork-crypto --no-default-features --features std,encryption
cargo test -p keetanetwork-crypto --no-default-features --features std,der
cargo test -p keetanetwork-account --no-default-features --features der
cargo test -p keetanetwork-account --no-default-features --features rasn
cargo test -p keetanetwork-crypto --no-default-features --features std
cargo check -p keetanetwork-crypto --no-default-features
cargo check -p keetanetwork-crypto --no-default-features --features signature
cargo check -p keetanetwork-crypto --no-default-features --features encryption
cargo check -p keetanetwork-crypto --no-default-features --features signature,encryption,rasn
cargo test -p keetanetwork-x509 --no-default-features --features der
cargo test -p keetanetwork-x509 --no-default-features --features rasn
cargo test -p keetanetwork-x509 --no-default-features --features der, serde
Expand All @@ -73,7 +78,6 @@ test-feat:
cargo test -p keetanetwork-asn1 --no-default-features --features der,serde
cargo test -p keetanetwork-asn1 --no-default-features --features rasn,serde
cargo test -p keetanetwork-crypto -p keetanetwork-x509 --all-features
cargo test -p keetanetwork-crypto --no-default-features

# Run tests with host system's default target
test:
Expand Down
1 change: 0 additions & 1 deletion keetanetwork-account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ homepage.workspace = true
description = "Account management and cryptographic identities for Keetanetwork"

[lib]
crate-type = ["staticlib", "rlib"]
path = "src/lib.rs"

[dependencies]
Expand Down
1 change: 0 additions & 1 deletion keetanetwork-asn1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ homepage.workspace = true
description = "ASN.1 definitions and utilities for Keetanetwork"

[lib]
crate-type = ["staticlib", "rlib"]
path = "src/lib.rs"

[dependencies.spki]
Expand Down
5 changes: 2 additions & 3 deletions keetanetwork-asn1/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ mod subject_public_key_info_definitions {
}

// Re-export all types from the generated modules
pub use algorithm_identifier_definitions::{AlgorithmIdentifier};
pub use subject_public_key_info_definitions::{SubjectPublicKeyInfo};

pub use algorithm_identifier_definitions::AlgorithmIdentifier;
pub use subject_public_key_info_definitions::SubjectPublicKeyInfo;
67 changes: 53 additions & 14 deletions keetanetwork-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,68 @@ homepage.workspace = true
description = "Cryptographic primitives and operations for Keetanetwork"

[lib]
crate-type = ["staticlib", "rlib"]
path = "src/lib.rs"

[dependencies]
# Cryptographic libraries
[dependencies.k256]
version = "0.13.2"
features = ["ecdsa", "ecdh"]
default-features = false
features = ["ecdsa", "ecdh", "alloc"]

[dependencies.p256]
version = "0.13.2"
features = ["ecdsa", "ecdh"]
default-features = false
features = ["ecdsa", "ecdh", "alloc"]

[dependencies.ed25519-dalek]
version = "2.0"
features = ["std", "rand_core", "zeroize"]
default-features = false
features = ["rand_core", "zeroize"]

[dependencies.x25519-dalek]
version = "2.0"
default-features = false
features = ["zeroize"]

[dependencies.curve25519-dalek]
version = "4.1.3"
default-features = false
features = ["zeroize"]

[dependencies.hkdf]
version = "0.12.4"
features = ["std"]
default-features = false

[dependencies.pbkdf2]
version = "0.12.2"
features = ["hmac", "parallel", "sha2", "std"]
default-features = false
features = ["hmac", "sha2"]

[dependencies.sha1]
version = "0.10.6"
features = ["asm"]
default-features = false

[dependencies.sha2]
version = "0.10.9"
features = ["asm", "asm-aarch64", "sha2-asm"]
default-features = false

[dependencies.sha3]
version = "0.10.8"
features = ["asm"]
default-features = false

[dependencies.zeroize]
version = "1.8.1"
features = ["derive"]

[dependencies.rand_core]
version = "0.9.3"
features = ["std", "os_rng"]
default-features = false
features = ["os_rng"]

[dependencies.snafu]
workspace = true
default-features = false

# RustCrypto trait crates
[dependencies.signature]
Expand Down Expand Up @@ -107,18 +114,22 @@ optional = true

[dependencies.aes-gcm]
version = "0.10.3"
features = ["std"]
default-features = false
features = ["alloc", "aes", "getrandom"]

# Utilities
[dependencies.bip39-dict]
version = "0.1.3"

[dependencies.crypto-bigint]
version = "0.6.1"
default-features = false
features = ["serde", "der", "zeroize"]

[dependencies.strum]
workspace = true
version = "0.27.2"
default-features = false
features = ["derive"]

[dependencies.strum_macros]
workspace = true
Expand All @@ -135,7 +146,9 @@ workspace = true
version = "0.22"

[dependencies.hex]
workspace = true
version = "0.4.3"
default-features = false
features = ["serde", "alloc"]

[dependencies.chrono]
workspace = true
Expand All @@ -145,6 +158,7 @@ optional = true
[dependencies.keetanetwork-error]
version = "0.1.0"
path = "../keetanetwork-error"
optional = true

[dependencies.keetanetwork-asn1]
version = "0.1.0"
Expand All @@ -154,9 +168,34 @@ optional = true
[dependencies.keetanetwork-utils]
version = "0.1.0"
path = "../keetanetwork-utils"
default-features = false

[features]
default = ["signature", "encryption", "rasn"]
default = ["std", "signature", "encryption", "rasn"]
std = [
"alloc",
"snafu/std",
"ed25519-dalek/std",
"hkdf/std",
"pbkdf2/std",
"pbkdf2/parallel",
"rand_core/std",
"aes-gcm/std",
"strum/std",
"hex/std",
"sha1/asm",
"sha2/asm",
"sha2/asm-aarch64",
"sha2/sha2-asm",
"sha3/asm",
"dep:chrono",
"dep:keetanetwork-error",
"keetanetwork-utils/std",
"signature?/std",
"aead?/std",
"rand?/std",
]
alloc = []
signature = ["dep:signature"]
encryption = [
"dep:aead",
Expand Down
2 changes: 2 additions & 0 deletions keetanetwork-crypto/src/algorithms/aes_cbc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! This module provides AES-CBC encryption.
use alloc::vec::Vec;

use aes::Aes256;
use cbc::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit};
use cbc::{Decryptor, Encryptor};
Expand Down
2 changes: 2 additions & 0 deletions keetanetwork-crypto/src/algorithms/aes_ctr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! This module provides AES-CTR symmetric encryption.

use alloc::vec::Vec;

use aes::Aes128;
use ctr::cipher::{KeyIvInit, StreamCipher};
use ctr::Ctr128BE;
Expand Down
2 changes: 2 additions & 0 deletions keetanetwork-crypto/src/algorithms/aes_gcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! This module provides AES-GCM AEAD.

use alloc::vec::Vec;

use aes_gcm::aead::{Aead, AeadCore, KeyInit, OsRng};
use aes_gcm::{Aes256Gcm as AesGcmCipher, Key};

Expand Down
2 changes: 2 additions & 0 deletions keetanetwork-crypto/src/algorithms/ecies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! This module provides ECIES encryption.
use alloc::vec::Vec;

use core::sync::atomic::{fence, Ordering};

use hmac::{Hmac, Mac};
Expand Down
3 changes: 3 additions & 0 deletions keetanetwork-crypto/src/algorithms/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
// Re-export algorithm-specific signature types
pub use ed25519_dalek::Signature as Ed25519Signature;

use alloc::vec::Vec;

use core::fmt::{Debug, Formatter, Result as FmtResult};
use core::sync::atomic::{fence, Ordering};

Expand Down Expand Up @@ -612,6 +614,7 @@ impl KeyDerivation for Ed25519Derivation {

#[cfg(test)]
mod tests {
extern crate std;
use std::collections::HashMap;

use super::*;
Expand Down
4 changes: 4 additions & 0 deletions keetanetwork-crypto/src/algorithms/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use core::fmt::Debug;

use secrecy::SecretBox;
Expand Down Expand Up @@ -193,6 +195,8 @@ macro_rules! impl_any_signature {

impl $any_signature_type {
pub fn to_bytes(&self) -> Vec<u8> {
#[allow(unused_imports)]
use ::signature::SignatureEncoding;
match self {
$(
$any_signature_type::$variant(sig) => sig.to_vec(),
Expand Down
2 changes: 2 additions & 0 deletions keetanetwork-crypto/src/algorithms/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// Re-export algorithm-specific signature types
pub use k256::ecdsa::Signature as Secp256k1Signature;

use alloc::vec::Vec;

use core::fmt::{Debug, Formatter, Result as FmtResult};

use k256::ecdsa::{Signature, SigningKey};
Expand Down
2 changes: 2 additions & 0 deletions keetanetwork-crypto/src/algorithms/secp256r1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// Re-export algorithm-specific signature types
pub use p256::ecdsa::Signature as Secp256r1Signature;

use alloc::vec::Vec;

use core::fmt::{Debug, Formatter, Result as FmtResult};

use p256::ecdsa::{Signature, SigningKey};
Expand Down
4 changes: 4 additions & 0 deletions keetanetwork-crypto/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use alloc::string::String;
#[cfg(all(not(feature = "std"), feature = "encryption"))]
use alloc::string::ToString;

use keetanetwork_utils::impl_variant_error_from;
use snafu::Snafu;

Expand Down
2 changes: 2 additions & 0 deletions keetanetwork-crypto/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! This module provides a flexible abstraction over different hash algorithms.

use alloc::vec::Vec;

use sha1::Sha1;
use sha2::{Sha256, Sha512};
use sha3::{Digest, Sha3_256};
Expand Down
2 changes: 2 additions & 0 deletions keetanetwork-crypto/src/kdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//! This module provides abstractions over different key derivation functions
//! used for expanding key material and deriving cryptographic keys.

use alloc::vec::Vec;

use hkdf::Hkdf;
use sha2::{Sha256, Sha512};
use sha3::Sha3_256;
Expand Down
Loading
Loading