Skip to content

Commit 57d0b6e

Browse files
committed
bump rustcrypto dependencies to pre-release
Signed-off-by: Arthur Gautier <[email protected]>
1 parent dedbdaa commit 57d0b6e

File tree

9 files changed

+127
-96
lines changed

9 files changed

+127
-96
lines changed

Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
11
[workspace]
22
resolver = "2"
33
members = ["tss-esapi", "tss-esapi-sys"]
4+
5+
[patch.crates-io]
6+
p192 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" }
7+
p224 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" }
8+
p256 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" }
9+
p384 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" }
10+
p521 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" }
11+
sm2 = { git = "https://github.com/baloo/elliptic-curves.git", branch = "baloo/group/try-from-rng" }
12+
13+
rsa = { git = "https://github.com/RustCrypto/RSA.git" }
14+
crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" }
15+
crypto-primes = { git = "https://github.com/entropyxyz/crypto-primes.git" }
16+
17+
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
18+
rfc6979 = { git = "https://github.com/RustCrypto/signatures.git" }
19+
20+
x509-cert = { git = "https://github.com/baloo/formats.git", branch = "baloo/reunite-workspace" }
21+
22+
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" }
23+
signature = { git = "https://github.com/RustCrypto/traits.git" }
24+
25+
hmac = { git = "https://github.com/RustCrypto/MACs.git" }
26+
27+
ff = { git = "https://github.com/zkcrypto/ff.git", branch = "release-0.14.0" }
28+
group = { git = "https://github.com/baloo/group.git", branch = "baloo/try_from_rng" }
29+

tss-esapi/Cargo.toml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,40 +34,40 @@ hostname-validator = "1.1.0"
3434
regex = "1.3.9"
3535
zeroize = { version = "1.5.7", features = ["zeroize_derive"] }
3636
tss-esapi-sys = { path = "../tss-esapi-sys", version = "0.5.0" }
37-
x509-cert = { version = "0.2.0", optional = true }
38-
ecdsa = { version = "0.16.9", features = ["der", "hazmat", "arithmetic", "verifying"], optional = true }
39-
elliptic-curve = { version = "0.13.8", optional = true, features = ["alloc", "pkcs8"] }
40-
p192 = { version = "0.13.0", optional = true }
41-
p224 = { version = "0.13.2", optional = true }
42-
p256 = { version = "0.13.2", optional = true }
43-
p384 = { version = "0.13.0", optional = true }
44-
p521 = { version = "0.13.3", optional = true }
45-
pkcs8 = { version = "0.10.2", optional = true }
46-
rsa = { version = "0.9", optional = true }
47-
sha1 = { version = "0.10.6", optional = true }
48-
sha2 = { version = "0.10.8", optional = true }
49-
sha3 = { version = "0.10.8", optional = true }
50-
sm2 = { version = "0.13.3", optional = true }
51-
sm3 = { version = "0.4.2", optional = true }
52-
digest = { version = "0.10.7", optional = true }
53-
signature = { version = "2.2.0", features = ["std"], optional = true}
37+
x509-cert = { version = "0.3.0-pre.0", optional = true }
38+
ecdsa = { version = "0.17.0-pre.9", features = ["der", "hazmat", "arithmetic", "verifying"], optional = true }
39+
elliptic-curve = { version = "0.14.0-rc.1", optional = true, features = ["alloc", "pkcs8"] }
40+
p192 = { version = "0.14.0-pre", optional = true }
41+
p224 = { version = "0.14.0-pre", optional = true }
42+
p256 = { version = "0.14.0-pre.2", optional = true }
43+
p384 = { version = "0.14.0-pre.2", optional = true }
44+
p521 = { version = "0.14.0-pre.2", optional = true }
45+
pkcs8 = { version = "0.11.0-rc.1", optional = true }
46+
rsa = { version = "0.10.0-pre.4", optional = true }
47+
sha1 = { version = "0.11.0-pre.5", optional = true }
48+
sha2 = { version = "0.11.0-pre.5", optional = true }
49+
sha3 = { version = "0.11.0-pre.5", optional = true }
50+
sm2 = { version = "0.14.0-pre", optional = true }
51+
sm3 = { version = "0.5.0-pre.4", optional = true }
52+
digest = { version = "0.11.0-pre.9", optional = true }
53+
signature = { version = "2.3.0-pre.4", features = ["std"], optional = true}
5454
cfg-if = "1.0.0"
5555
strum = { version = "0.26.3", optional = true }
5656
strum_macros = { version = "0.26.4", optional = true }
5757
paste = "1.0.14"
58-
getrandom = "0.2.11"
58+
getrandom = "0.3"
5959

6060
[dev-dependencies]
6161
env_logger = "0.11.5"
6262
serde_json = "^1.0.108"
63-
sha2 = { version = "0.10.8", features = ["oid"] }
63+
sha2 = { version = "0.11.0-pre.4", features = ["oid"] }
6464
tss-esapi = { path = ".", features = [
6565
"integration-tests",
6666
"serde",
6767
"abstraction",
6868
"rustcrypto-full",
6969
] }
70-
x509-cert = { version = "0.2.0", features = ["builder"] }
70+
x509-cert = { version = "0.3.0-pre.0", features = ["builder"] }
7171

7272
[build-dependencies]
7373
semver = "1.0.7"

tss-esapi/src/abstraction/no_tpm/quote.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ use digest::{Digest, DynDigest};
1313
#[cfg(any(feature = "p224", feature = "p256", feature = "p384"))]
1414
use crate::{abstraction::public::AssociatedTpmCurve, structures::EccSignature};
1515
#[cfg(any(feature = "p224", feature = "p256", feature = "p384"))]
16-
use ecdsa::{
17-
hazmat::{DigestPrimitive, VerifyPrimitive},
18-
PrimeCurve, SignatureSize, VerifyingKey,
19-
};
16+
use ecdsa::{hazmat::DigestPrimitive, PrimeCurve, SignatureSize, VerifyingKey};
2017
#[cfg(any(feature = "p224", feature = "p256", feature = "p384"))]
2118
use elliptic_curve::{
22-
generic_array::ArrayLength,
19+
array::ArraySize,
2320
point::AffinePoint,
2421
sec1::{FromEncodedPoint, ModulusSize, ToEncodedPoint},
2522
CurveArithmetic, FieldBytesSize,
@@ -41,8 +38,8 @@ fn verify_ecdsa<C>(
4138
) -> Result<bool>
4239
where
4340
C: PrimeCurve + CurveArithmetic + DigestPrimitive + AssociatedTpmCurve,
44-
AffinePoint<C>: VerifyPrimitive<C> + FromEncodedPoint<C> + ToEncodedPoint<C>,
45-
SignatureSize<C>: ArrayLength<u8>,
41+
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
42+
SignatureSize<C>: ArraySize,
4643
FieldBytesSize<C>: ModulusSize,
4744
{
4845
let Ok(signature) = ecdsa::Signature::<C>::try_from(signature.clone()) else {

tss-esapi/src/abstraction/public.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{Error, WrapperErrorKind};
88

99
use core::convert::TryFrom;
1010
use elliptic_curve::{
11-
generic_array::typenum::Unsigned,
11+
array::typenum::Unsigned,
1212
sec1::{EncodedPoint, FromEncodedPoint, ModulusSize, ToEncodedPoint},
1313
AffinePoint, CurveArithmetic, FieldBytesSize, PublicKey,
1414
};
@@ -18,7 +18,7 @@ use x509_cert::spki::SubjectPublicKeyInfoOwned;
1818
#[cfg(feature = "rsa")]
1919
use {
2020
crate::structures::RsaExponent,
21-
rsa::{BigUint, RsaPublicKey},
21+
rsa::{BoxedUint, RsaPublicKey},
2222
};
2323

2424
#[cfg(any(
@@ -57,15 +57,13 @@ where
5757
let x = unique.x().as_bytes();
5858
let y = unique.y().as_bytes();
5959

60-
if x.len() != FieldBytesSize::<C>::USIZE {
61-
return Err(Error::local_error(WrapperErrorKind::InvalidParam));
62-
}
63-
if y.len() != FieldBytesSize::<C>::USIZE {
64-
return Err(Error::local_error(WrapperErrorKind::InvalidParam));
65-
}
66-
67-
let encoded_point =
68-
EncodedPoint::<C>::from_affine_coordinates(x.into(), y.into(), false);
60+
let encoded_point = EncodedPoint::<C>::from_affine_coordinates(
61+
x.try_into()
62+
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?,
63+
y.try_into()
64+
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?,
65+
false,
66+
);
6967
let public_key = PublicKey::<C>::try_from(&encoded_point)
7068
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?;
7169

@@ -86,10 +84,11 @@ impl TryFrom<&Public> for RsaPublicKey {
8684
unique, parameters, ..
8785
} => {
8886
let exponent = match parameters.exponent() {
89-
RsaExponent::ZERO_EXPONENT => BigUint::from(RSA_DEFAULT_EXP),
90-
_ => BigUint::from(parameters.exponent().value()),
87+
RsaExponent::ZERO_EXPONENT => BoxedUint::from(RSA_DEFAULT_EXP),
88+
_ => BoxedUint::from(parameters.exponent().value()),
9189
};
92-
let modulus = BigUint::from_bytes_be(unique.as_bytes());
90+
let modulus = BoxedUint::from_be_slice(unique.as_bytes(), 8192)
91+
.map_err(|_| Error::local_error(WrapperErrorKind::WrongParamSize))?;
9392

9493
let public_key = RsaPublicKey::new(modulus, exponent)
9594
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?;
@@ -173,17 +172,21 @@ where
173172
let x = x.as_slice();
174173
let y = y.as_slice();
175174

176-
// TODO: When elliptic_curve bumps to 0.14, we can use the TryFrom implementation instead
177-
// of checking lengths manually
178175
if x.len() != FieldBytesSize::<C>::USIZE {
179176
return Err(Error::local_error(WrapperErrorKind::InvalidParam));
180177
}
181178
if y.len() != FieldBytesSize::<C>::USIZE {
182179
return Err(Error::local_error(WrapperErrorKind::InvalidParam));
183180
}
184181

185-
let encoded_point =
186-
EncodedPoint::<C>::from_affine_coordinates(x.into(), y.into(), false);
182+
let encoded_point = EncodedPoint::<C>::from_affine_coordinates(
183+
x.try_into()
184+
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?,
185+
y.try_into()
186+
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?,
187+
false,
188+
);
189+
187190
let public_key = PublicKey::<C>::try_from(&encoded_point)
188191
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?;
189192

@@ -201,8 +204,9 @@ impl TryFrom<&TpmPublicKey> for RsaPublicKey {
201204
fn try_from(value: &TpmPublicKey) -> Result<Self, Self::Error> {
202205
match value {
203206
TpmPublicKey::Rsa(modulus) => {
204-
let exponent = BigUint::from(RSA_DEFAULT_EXP);
205-
let modulus = BigUint::from_bytes_be(modulus.as_slice());
207+
let exponent = BoxedUint::from(RSA_DEFAULT_EXP);
208+
let modulus = BoxedUint::from_be_slice(modulus.as_slice(), 8192)
209+
.map_err(|_| Error::local_error(WrapperErrorKind::WrongParamSize))?;
206210

207211
let public_key = RsaPublicKey::new(modulus, exponent)
208212
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?;

tss-esapi/src/abstraction/signatures.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use crate::{structures::EccSignature, Error, Result, WrapperErrorKind};
55

66
use std::convert::TryFrom;
77

8-
use ecdsa::SignatureSize;
8+
use ecdsa::{EcdsaCurve, SignatureSize};
99
use elliptic_curve::{
10-
generic_array::{typenum::Unsigned, ArrayLength},
10+
array::{typenum::Unsigned, ArraySize},
1111
FieldBytes, FieldBytesSize, PrimeCurve,
1212
};
1313

@@ -16,8 +16,8 @@ use crate::structures::Signature;
1616

1717
impl<C> TryFrom<EccSignature> for ecdsa::Signature<C>
1818
where
19-
C: PrimeCurve,
20-
SignatureSize<C>: ArrayLength<u8>,
19+
C: PrimeCurve + EcdsaCurve,
20+
SignatureSize<C>: ArraySize,
2121
{
2222
type Error = Error;
2323

@@ -33,8 +33,12 @@ where
3333
}
3434

3535
let signature = ecdsa::Signature::from_scalars(
36-
FieldBytes::<C>::from_slice(r).clone(),
37-
FieldBytes::<C>::from_slice(s).clone(),
36+
FieldBytes::<C>::try_from(r)
37+
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?
38+
.clone(),
39+
FieldBytes::<C>::try_from(s)
40+
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?
41+
.clone(),
3842
)
3943
.map_err(|_| Error::local_error(WrapperErrorKind::InvalidParam))?;
4044
Ok(signature)

0 commit comments

Comments
 (0)