From ae4c20bc7c8822b6e9ec336ff0ecd33e489f2ce5 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Sat, 2 Nov 2024 13:23:54 +0800 Subject: [PATCH] fix: fixed build errors when only v2 is enabled --- Cargo.toml | 4 ++-- src/kind.rs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b172065..2646b3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shadowsocks-crypto" -version = "0.5.6" +version = "0.5.7" authors = ["luozijun ", "ty "] edition = "2021" license = "MIT" @@ -27,7 +27,7 @@ v1-aead-extra = [ "subtle", "ctr", ] -v2 = ["aes", "aes-gcm", "blake3", "chacha20poly1305", "bytes"] +v2 = ["aes", "aes-gcm", "blake3", "chacha20poly1305", "bytes", "cfg-if"] v2-extra = ["v2", "chacha20poly1305/reduced-round"] ring = ["ring-compat"] diff --git a/src/kind.rs b/src/kind.rs index a0cd6b5..6da9dee 100644 --- a/src/kind.rs +++ b/src/kind.rs @@ -503,6 +503,7 @@ impl CipherKind { RC4 => Rc4::nonce_size(), CHACHA20 => Chacha20::nonce_size(), + #[allow(unreachable_patterns)] _ => panic!("only support Stream ciphers"), } } @@ -513,7 +514,9 @@ impl CipherKind { use self::CipherKind::*; match *self { + #[cfg(feature = "v1-aead")] AES_128_GCM => Aes128Gcm::tag_size(), + #[cfg(feature = "v1-aead")] AES_256_GCM => Aes256Gcm::tag_size(), #[cfg(feature = "v1-aead-extra")] @@ -526,6 +529,7 @@ impl CipherKind { #[cfg(feature = "v1-aead-extra")] AES_256_CCM => Aes256Ccm::tag_size(), + #[cfg(feature = "v1-aead")] CHACHA20_POLY1305 => ChaCha20Poly1305::tag_size(), #[cfg(feature = "v1-aead-extra")]