Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(rust): gate SRP session behind feature only

Prateek Sunalfd65e49827d5
diff --git a/rust/core/src/auth/api.rs b/rust/core/src/auth/api.rs
index 3c0f708936..090d5556af 100644
--- a/rust/core/src/auth/api.rs
+++ b/rust/core/src/auth/api.rs
@@ -7,7 +7,7 @@ use crate::crypto::{self, argon, kdf, sealed, secretbox};
use super::{AuthError, KeyAttributes, Result, SrpAttributes};
-#[cfg(any(test, feature = "srp"))]
+#[cfg(feature = "srp")]
use super::srp::SrpSession;
/// Credentials derived from password for SRP authentication.
@@ -152,7 +152,7 @@ pub fn decrypt_secrets(
///
/// # Returns
/// * Tuple of (SrpSession, kek) - use session for SRP, keep kek for later decryption
-#[cfg(any(test, feature = "srp"))]
+#[cfg(feature = "srp")]
#[cfg_attr(not(test), allow(dead_code))]
pub(crate) fn start_srp_session(
password: &str,
@@ -261,6 +261,7 @@ mod tests {
assert!(matches!(result, Err(AuthError::IncorrectPassword)));
}
+ #[cfg(feature = "srp")]
#[test]
fn test_start_srp_session() {
crate::crypto::init().unwrap();
diff --git a/rust/core/src/auth/mod.rs b/rust/core/src/auth/mod.rs
index 9cfe22f7dd..e69e55ec77 100644
--- a/rust/core/src/auth/mod.rs
+++ b/rust/core/src/auth/mod.rs
@@ -6,12 +6,12 @@ mod api;
mod key_gen;
mod login;
mod recovery;
-#[cfg(any(test, feature = "srp"))]
+#[cfg(feature = "srp")]
mod srp;
mod types;
// SRP session type (behind the `srp` feature)
-#[cfg(any(test, feature = "srp"))]
+#[cfg(feature = "srp")]
pub use srp::SrpSession;
/// Stub type when the `srp` feature is disabled.
@@ -19,12 +19,12 @@ pub use srp::SrpSession;
/// This allows downstream crates to reference [`SrpSession`] in signatures and
/// get a runtime error if they accidentally call it without enabling the
/// feature.
-#[cfg(not(any(test, feature = "srp")))]
+#[cfg(not(feature = "srp"))]
pub struct SrpSession {
_private: (),
}
-#[cfg(not(any(test, feature = "srp")))]
+#[cfg(not(feature = "srp"))]
impl SrpSession {
fn feature_disabled() -> types::AuthError {
types::AuthError::Srp(