diff --git a/Cargo.toml b/Cargo.toml index 3b56e40..f51bf28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ cfg-if = "1.0" libc = "0.2" once_cell = "1.18.0" ctor = "^0" -zssp = { git = "ssh://git@github.com/zerotier/zssp.git", branch = "main", features = ["openssl-sys"], default-features = false } +zssp = { git = "ssh://git@github.com/zerotier/zssp.git", branch = "main", features = ["openssl-sys", "pqc_kyber"], default-features = false } rand_xoshiro = { version = "0.6.0"} [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 6e473f4..01174ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,7 @@ pub mod x25519; // TODO: Bring back the faster Apple API implementations. pub mod aes_openssl; + pub use aes_openssl as aes; pub mod aes_gmac_siv_openssl; @@ -29,6 +30,31 @@ pub use aes_gmac_siv_openssl as aes_gmac_siv; /// Dependency re-export pub use zssp; +#[macro_export] +macro_rules! impl_zssp_crypto { + ($t:ty, $session_data:ty, $packet_buffer:ty) => { + impl zssp::application::CryptoLayer for $t { + type Rng = crate::random::SecureRandom; + + type PrpEnc = zssp::crypto_impl::OpenSSLAes256Enc; + type PrpDec = zssp::crypto_impl::OpenSSLAes256Dec; + + type Aead = zssp::crypto_impl::OpenSSLAesGcm; + type AeadPool = zssp::crypto_impl::OpenSSLAesGcmPool; + + type Hash = crate::hash::SHA512; + type Hmac = crate::hash::HMACSHA512; + + type PublicKey = crate::p384::P384PublicKey; + type KeyPair = crate::p384::P384KeyPair; + type Kem = zssp::crypto_impl::CrateKyber1024PrivateKey; + + type SessionData = $session_data; + type IncomingPacketBuffer = $packet_buffer; + } + } +} + use ctor::ctor; #[ctor] fn openssl_init() {