summaryrefslogtreecommitdiffstats
path: root/vendor/block-buffer
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/block-buffer
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/block-buffer')
-rw-r--r--vendor/block-buffer/.cargo-checksum.json2
-rw-r--r--vendor/block-buffer/CHANGELOG.md12
-rw-r--r--vendor/block-buffer/Cargo.toml13
-rw-r--r--vendor/block-buffer/src/lib.rs41
-rw-r--r--vendor/block-buffer/src/sealed.rs2
-rw-r--r--vendor/block-buffer/tests/mod.rs8
6 files changed, 65 insertions, 13 deletions
diff --git a/vendor/block-buffer/.cargo-checksum.json b/vendor/block-buffer/.cargo-checksum.json
index 437d1e56c..59dbb3f0f 100644
--- a/vendor/block-buffer/.cargo-checksum.json
+++ b/vendor/block-buffer/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"6d73524a3689766ef673022d56aa675012bb48068cc39470743a984904db72cb","Cargo.toml":"66f91b099c9807c3dbabfebf3ed42eab4be69e86ae1c759941765b5226cca3b8","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"d5c22aa3118d240e877ad41c5d9fa232f9c77d757d4aac0c2f943afc0a95e0ef","README.md":"9bf3545872bdad2fb41557be5cefc21a48f0c7804f8124e24b67760429036472","src/lib.rs":"73676ca504520fb62a25bcc442674774cc79cf27f5eb23fb997fc60c93504cd8","src/sealed.rs":"65afa9015a3ddb8d1a56733ef3103b1459842f69155f00cefdb235dc73255d4e","tests/mod.rs":"58ecfa416e3d30b420975aef1d7b9d52d779696c6ba3f204130cf9e8b4743b10"},"package":"0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324"} \ No newline at end of file
+{"files":{"CHANGELOG.md":"aa53da4c09163e6c269f9536ade5363ae62549295b4f4a85bdf923540f6442e1","Cargo.toml":"c76e4bd298cd6223882238449e31939d75613e82757ca87e249df843decf5f9a","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"d5c22aa3118d240e877ad41c5d9fa232f9c77d757d4aac0c2f943afc0a95e0ef","README.md":"9bf3545872bdad2fb41557be5cefc21a48f0c7804f8124e24b67760429036472","src/lib.rs":"b437252d389042d894b1ef17859b043e827d2bd2a1bca4b5311c67dff565274d","src/sealed.rs":"9327ee3e567ae779b83c2b7f4f3ff56fcb2117163e023e7b0e37759e7e8d1f5c","tests/mod.rs":"a42403629557eea432a8797f2d81a4ab65de15ce9a2db933496c53f05669e1d7"},"package":"3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"} \ No newline at end of file
diff --git a/vendor/block-buffer/CHANGELOG.md b/vendor/block-buffer/CHANGELOG.md
index 13c6a9362..66bcf0a1a 100644
--- a/vendor/block-buffer/CHANGELOG.md
+++ b/vendor/block-buffer/CHANGELOG.md
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## 0.10.4 (2023-03-09)
+### Fixed
+- Unsoundness triggered by zero block size ([#844])
+
+[#844]: https://github.com/RustCrypto/utils/pull/844
+
+## 0.10.3 (2022-09-04)
+### Added
+- `try_new` method ([#799])
+
+[#799]: https://github.com/RustCrypto/utils/pull/799
+
## 0.10.2 (2021-02-08)
### Fixed
- Eliminate unreachable panic in `LazyBuffer::digest_blocks` ([#731])
diff --git a/vendor/block-buffer/Cargo.toml b/vendor/block-buffer/Cargo.toml
index fbcd167eb..4e50744a9 100644
--- a/vendor/block-buffer/Cargo.toml
+++ b/vendor/block-buffer/Cargo.toml
@@ -12,14 +12,21 @@
[package]
edition = "2018"
name = "block-buffer"
-version = "0.10.2"
+version = "0.10.4"
authors = ["RustCrypto Developers"]
description = "Buffer type for block processing of data"
documentation = "https://docs.rs/block-buffer"
readme = "README.md"
-keywords = ["block", "buffer"]
-categories = ["cryptography", "no-std"]
+keywords = [
+ "block",
+ "buffer",
+]
+categories = [
+ "cryptography",
+ "no-std",
+]
license = "MIT OR Apache-2.0"
repository = "https://github.com/RustCrypto/utils"
+
[dependencies.generic-array]
version = "0.14"
diff --git a/vendor/block-buffer/src/lib.rs b/vendor/block-buffer/src/lib.rs
index ebe736959..441621e93 100644
--- a/vendor/block-buffer/src/lib.rs
+++ b/vendor/block-buffer/src/lib.rs
@@ -2,14 +2,13 @@
#![no_std]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
- html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
- html_root_url = "https://docs.rs/block-buffer/0.10.2"
+ html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
)]
#![warn(missing_docs, rust_2018_idioms)]
pub use generic_array;
-use core::{marker::PhantomData, slice};
+use core::{fmt, marker::PhantomData, slice};
use generic_array::{
typenum::{IsLess, Le, NonZero, U256},
ArrayLength, GenericArray,
@@ -41,6 +40,16 @@ pub type EagerBuffer<B> = BlockBuffer<B, Eager>;
/// Lazy block buffer.
pub type LazyBuffer<B> = BlockBuffer<B, Lazy>;
+/// Block buffer error.
+#[derive(Copy, Clone, Eq, PartialEq, Debug)]
+pub struct Error;
+
+impl fmt::Display for Error {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
+ f.write_str("Block buffer error")
+ }
+}
+
/// Buffer for block processing of data.
#[derive(Debug)]
pub struct BlockBuffer<BlockSize, Kind>
@@ -61,6 +70,9 @@ where
Kind: BufferKind,
{
fn default() -> Self {
+ if BlockSize::USIZE == 0 {
+ panic!("Block size can not be equal to zero");
+ }
Self {
buffer: Default::default(),
pos: 0,
@@ -96,15 +108,28 @@ where
/// If slice length is not valid for used buffer kind.
#[inline(always)]
pub fn new(buf: &[u8]) -> Self {
+ Self::try_new(buf).unwrap()
+ }
+
+ /// Create new buffer from slice.
+ ///
+ /// Returns an error if slice length is not valid for used buffer kind.
+ #[inline(always)]
+ pub fn try_new(buf: &[u8]) -> Result<Self, Error> {
+ if BlockSize::USIZE == 0 {
+ panic!("Block size can not be equal to zero");
+ }
let pos = buf.len();
- assert!(Kind::invariant(pos, BlockSize::USIZE));
+ if !Kind::invariant(pos, BlockSize::USIZE) {
+ return Err(Error);
+ }
let mut buffer = Block::<BlockSize>::default();
buffer[..pos].copy_from_slice(buf);
- Self {
+ Ok(Self {
buffer,
pos: pos as u8,
_pd: PhantomData,
- }
+ })
}
/// Digest data in `input` in blocks of size `BlockSize` using
@@ -196,13 +221,13 @@ where
self.set_pos_unchecked(pos);
}
- /// Return size of the internall buffer in bytes.
+ /// Return size of the internal buffer in bytes.
#[inline(always)]
pub fn size(&self) -> usize {
BlockSize::USIZE
}
- /// Return number of remaining bytes in the internall buffer.
+ /// Return number of remaining bytes in the internal buffer.
#[inline(always)]
pub fn remaining(&self) -> usize {
self.size() - self.get_pos()
diff --git a/vendor/block-buffer/src/sealed.rs b/vendor/block-buffer/src/sealed.rs
index 371a8b703..247dec233 100644
--- a/vendor/block-buffer/src/sealed.rs
+++ b/vendor/block-buffer/src/sealed.rs
@@ -7,7 +7,7 @@ pub trait Sealed {
/// buffer code this function always returns true.
fn invariant(pos: usize, block_size: usize) -> bool;
- /// Split input data into slice fo blocks and tail.
+ /// Split input data into slice of blocks and tail.
fn split_blocks<N: ArrayLength<u8>>(data: &[u8]) -> (&[Block<N>], &[u8]);
}
diff --git a/vendor/block-buffer/tests/mod.rs b/vendor/block-buffer/tests/mod.rs
index 6dfa1ae14..ee08f979f 100644
--- a/vendor/block-buffer/tests/mod.rs
+++ b/vendor/block-buffer/tests/mod.rs
@@ -186,3 +186,11 @@ fn test_eager_paddings() {
[0x42, 0xff, 0x10, 0x11],
);
}
+
+#[test]
+fn test_try_new() {
+ assert!(EagerBuffer::<U4>::try_new(&[0; 3]).is_ok());
+ assert!(EagerBuffer::<U4>::try_new(&[0; 4]).is_err());
+ assert!(LazyBuffer::<U4>::try_new(&[0; 4]).is_ok());
+ assert!(LazyBuffer::<U4>::try_new(&[0; 5]).is_err());
+}