Skip to content

Commit

Permalink
fix(utils): remove backport of libsodium padding methods
Browse files Browse the repository at this point in the history
These were backported in 9279c15, and
have since been merged upstream in sodiumoxide 0.2.7.
  • Loading branch information
Xiretza authored and tasn committed May 22, 2022
1 parent 78e2884 commit db36892
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 50 deletions.
14 changes: 7 additions & 7 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-FileCopyrightText: © 2020 Etebase Authors
// SPDX-License-Identifier: LGPL-2.1-only

mod sodium_padding;

use sodiumoxide::base64;
use sodiumoxide::{
base64,
padding::{pad, unpad},
};

use super::error::{Error, Result};

Expand Down Expand Up @@ -236,8 +237,7 @@ pub(crate) fn buffer_pad_fixed(buf: &[u8], blocksize: usize) -> Result<Vec<u8>>
let mut ret = vec![0; padding];
ret[..len].copy_from_slice(buf);

sodium_padding::pad(&mut ret[..], len, blocksize)
.map_err(|_| Error::Padding("Failed padding"))?;
pad(&mut ret[..], len, blocksize).map_err(|_| Error::Padding("Failed padding"))?;

Ok(ret)
}
Expand All @@ -250,8 +250,8 @@ pub(crate) fn buffer_unpad_fixed(buf: &[u8], blocksize: usize) -> Result<Vec<u8>

let mut buf = buf.to_vec();

let new_len = sodium_padding::unpad(&buf[..], len, blocksize)
.map_err(|_| Error::Padding("Failed unpadding"))?;
let new_len =
unpad(&buf[..], len, blocksize).map_err(|_| Error::Padding("Failed unpadding"))?;
buf.truncate(new_len);
Ok(buf)
}
Expand Down
43 changes: 0 additions & 43 deletions src/utils/sodium_padding.rs

This file was deleted.

0 comments on commit db36892

Please sign in to comment.