Skip to content

Commit c2fe375

Browse files
authored
Bump crypto-bigint to v0.7.0-pre.5 (#533)
This notably adds `BoxedUint::from_be_slice_vartime` which has been used where appropriate, namely for parsing signatures
1 parent 4631ab6 commit c2fe375

File tree

6 files changed

+11
-24
lines changed

6 files changed

+11
-24
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pkcs8 = { version = "0.11.0-rc.4", default-features = false, features = ["alloc"
2222
signature = { version = "3.0.0-rc.1", default-features = false, features = ["alloc", "digest", "rand_core"] }
2323
spki = { version = "0.8.0-rc.2", default-features = false, features = ["alloc"] }
2424
zeroize = { version = "1.5", features = ["alloc"] }
25-
crypto-bigint = { version = "0.7.0-pre.4", default-features = false, features = ["zeroize", "alloc"] }
25+
crypto-bigint = { version = "0.7.0-pre.5", default-features = false, features = ["zeroize", "alloc"] }
2626
crypto-primes = { version = "0.7.0-pre.1", default-features = false }
2727

2828
# optional dependencies

src/pkcs1v15.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl SignatureScheme for Pkcs1v15Sign {
118118
pub_key,
119119
self.prefix.as_ref(),
120120
hashed,
121-
&BoxedUint::from_be_slice(sig, sig.len() as u32 * 8)?,
121+
&BoxedUint::from_be_slice_vartime(sig),
122122
)
123123
}
124124
}

src/pkcs1v15/signature.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! `RSASSA-PKCS1-v1_5` signatures.
22
3-
use ::signature::SignatureEncoding;
43
use alloc::boxed::Box;
54
use core::fmt::{Debug, Display, Formatter, LowerHex, UpperHex};
65
use crypto_bigint::BoxedUint;
6+
use signature::SignatureEncoding;
77

88
#[cfg(feature = "serde")]
99
use serdect::serde::{de, Deserialize, Serialize};
@@ -34,14 +34,8 @@ impl TryFrom<&[u8]> for Signature {
3434
type Error = signature::Error;
3535

3636
fn try_from(bytes: &[u8]) -> signature::Result<Self> {
37-
let len = bytes.len();
38-
let inner = BoxedUint::from_be_slice(bytes, len as u32 * 8);
39-
#[cfg(feature = "std")]
40-
let inner = inner
41-
.map_err(|e| Box::new(e) as Box<dyn core::error::Error + Send + Sync + 'static>)?;
42-
#[cfg(not(feature = "std"))]
43-
let inner = inner.map_err(|_| signature::Error::new())?;
44-
37+
// TODO(tarcieri): max length restriction? (#350)
38+
let inner = BoxedUint::from_be_slice_vartime(bytes);
4539
Ok(Self { inner })
4640
}
4741
}

src/pss.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl SignatureScheme for Pss {
106106
verify(
107107
pub_key,
108108
hashed,
109-
&BoxedUint::from_be_slice(sig, sig.len() as u32 * 8)?,
109+
&BoxedUint::from_be_slice_vartime(sig),
110110
sig.len(),
111111
&mut *self.digest,
112112
self.salt_len,

src/pss/signature.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! `RSASSA-PSS` signatures.
22
3-
use ::signature::SignatureEncoding;
43
use alloc::boxed::Box;
54
use core::fmt::{Debug, Display, Formatter, LowerHex, UpperHex};
65
use crypto_bigint::BoxedUint;
6+
use signature::SignatureEncoding;
77

88
#[cfg(feature = "serde")]
99
use serdect::serde::{de, Deserialize, Serialize};
@@ -34,15 +34,8 @@ impl TryFrom<&[u8]> for Signature {
3434
type Error = signature::Error;
3535

3636
fn try_from(bytes: &[u8]) -> signature::Result<Self> {
37-
let len = bytes.len();
38-
let inner = BoxedUint::from_be_slice(bytes, len as u32 * 8);
39-
40-
#[cfg(feature = "std")]
41-
let inner = inner
42-
.map_err(|e| Box::new(e) as Box<dyn core::error::Error + Send + Sync + 'static>)?;
43-
#[cfg(not(feature = "std"))]
44-
let inner = inner.map_err(|_| signature::Error::new())?;
45-
37+
// TODO(tarcieri): max length restriction? (#350)
38+
let inner = BoxedUint::from_be_slice_vartime(bytes);
4639
Ok(Self { inner })
4740
}
4841
}

0 commit comments

Comments
 (0)