update for base64 0.21
authorPeter Michael Green <plugwash@debian.org>
Mon, 15 Apr 2024 15:48:40 +0000 (18:48 +0300)
committerTimo Aaltonen <tjaalton@debian.org>
Mon, 15 Apr 2024 15:48:40 +0000 (18:48 +0300)
Gbp-Pq: Name base64-0.21.diff

src/plugins/pwdchan/Cargo.toml
src/plugins/pwdchan/src/lib.rs

index 20645cee5c1064605d627f901655741ee4404548..fd8b87ad6739f22df08525c838a452f9f4413bd4 100644 (file)
@@ -18,7 +18,7 @@ paste = "1.*"
 slapi_r_plugin = { path="../../slapi_r_plugin" }
 uuid = { version = "0.8", features = [ "v4" ] }
 openssl = { version = "0.10" }
-base64 = "0.13"
+base64 = "0.21"
 
 [build-dependencies]
 cc = { version = "1.0", features = ["parallel"] }
index 7f938fccba26b019aed48dfdac15e15dde506f7e..c2bd961074c78a201f79c5f96c495a19e3a311eb 100644 (file)
@@ -42,6 +42,12 @@ macro_rules! ab64_to_b64 {
     }};
 }
 
+use base64::engine::GeneralPurpose;
+use base64::engine::GeneralPurposeConfig;
+use base64::Engine;
+use base64::alphabet;
+static BASE64CONFIG: GeneralPurposeConfig = GeneralPurposeConfig::new().with_decode_allow_trailing_bits(true);
+static BASE64ENGINE: GeneralPurpose = GeneralPurpose::new(&alphabet::STANDARD,BASE64CONFIG);
 impl PwdChanCrypto {
     #[inline(always)]
     fn pbkdf2_decompose(encrypted: &str) -> Result<(usize, Vec<u8>, Vec<u8>), PluginError> {
@@ -62,7 +68,7 @@ impl PwdChanCrypto {
             .ok_or(PluginError::MissingValue)
             .and_then(|ab64| {
                 let s = ab64_to_b64!(ab64);
-                base64::decode_config(&s, base64::STANDARD.decode_allow_trailing_bits(true))
+                BASE64ENGINE.decode(&s)
                     .map_err(|e| {
                         log_error!(ErrorLevel::Error, "Invalid Base 64 {} -> {:?}", s, e);
                         PluginError::InvalidBase64
@@ -74,7 +80,7 @@ impl PwdChanCrypto {
             .ok_or(PluginError::MissingValue)
             .and_then(|ab64| {
                 let s = ab64_to_b64!(ab64);
-                base64::decode_config(&s, base64::STANDARD.decode_allow_trailing_bits(true))
+                BASE64ENGINE.decode(&s)
                     .map_err(|e| {
                         log_error!(ErrorLevel::Error, "Invalid Base 64 {} -> {:?}", s, e);
                         PluginError::InvalidBase64
@@ -152,11 +158,11 @@ impl PwdChanCrypto {
             PluginError::Format
         })?;
         // the base64 salt
-        base64::encode_config_buf(&salt, base64::STANDARD, &mut output);
+        BASE64ENGINE.encode_string(&salt, &mut output);
         // Push the delim
         output.push_str("$");
         // Finally the base64 hash
-        base64::encode_config_buf(&hash_input, base64::STANDARD, &mut output);
+        BASE64ENGINE.encode_string(&hash_input, &mut output);
         // Return it
         Ok(output)
     }