-
Notifications
You must be signed in to change notification settings - Fork 103
Update to mbedtls v0.13.0 #658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@mridul-manohar From CI, some errors used in code need to be updated. Please check. |
10ce53b
to
731c4e4
Compare
For all crates that didn't need any rust code modifications when upgrading to mbedtls 0.13, we should consider specifying the dependency as
This more accurately presents the actual dependency constraints of these crates and it may ease the process for upgrading them, since consumers won't be forced to simultaneously upgrade to the new mbedtls version. |
17c5949
to
0d2ff55
Compare
@Pagten ^Addressed this change-request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since changing error type in most cases is breaking change.
Could you check and bump the version of updated crates ?
intel-sgx/pcs/Cargo.toml
Outdated
@@ -35,11 +35,12 @@ failure = "0.1.1" | |||
anyhow = { version = "1", optional = true } | |||
quick-error = "1.2.3" | |||
num = "0.2" | |||
mbedtls = { version = "0.12.3", features = ["std", "time"], default-features = false, optional = true } | |||
mbedtls = { version = "0.13.2", features = ["std", "time"], default-features = false, optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mbedtls = { version = "0.13.2", features = ["std", "time"], default-features = false, optional = true } | |
mbedtls = { version = ">=0.12.0, <0.14.0", features = ["std", "time"], default-features = false, optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed as suggested. We are pointing it to exact version = "0.13.1"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many code changes that are (likely) not compatible with mbedtls 0.12. You may be able to call .into()
to ensure the code keeps working for both versions.
static ref NOT_VALID_YET_ERR: NitroError = NitroError::CertificateVerifyFailure("Certificate verify failure: X509CertVerifyFailed, The certificate validity starts in the future\n".to_string()); | ||
static ref EXPIRED_ERR: NitroError = NitroError::CertificateVerifyFailure("Certificate verify failure: X509CertVerifyFailed, The certificate validity has expired\n".to_string()); | ||
static ref NOT_VALID_YET_ERR: NitroError = NitroError::CertificateVerifyFailure("Certificate verify failure: HighLevel(X509CertVerifyFailed), The certificate validity starts in the future\n".to_string()); | ||
static ref EXPIRED_ERR: NitroError = NitroError::CertificateVerifyFailure("Certificate verify failure: HighLevel(X509CertVerifyFailed), The certificate validity has expired\n".to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change still work on mbedtls 0.12?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires v0.13.1 (therefore not backcompt)
and we are pointing to exact version = "0.13.1"
@@ -97,7 +98,7 @@ impl SigningPublicKey for WrappedCert { | |||
// We'll throw error if signature verify does not work | |||
match pk.verify(*md, &digest, &sig) { | |||
Ok(_) => Ok(true), | |||
Err(mbedtls::Error::EcpVerifyFailed) => Ok(false), | |||
Err(ErrMbed::HighLevel(codes::EcpVerifyFailed)) => Ok(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change still work on mbedtls 0.12?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires v0.13.1 (therefore not backcompt)
and we are pointing to exact version = "0.13.1"
now
Certificate::from_pem(cert.as_bytes_with_nul()).map_err(|_| MbedError::X509InvalidFormat) | ||
pub fn pck(&self) -> Result<MbedtlsBox<Certificate>, ErrMbed> { | ||
let cert = CString::new(self.cert.as_bytes()).map_err(|_| ErrMbed::HighLevel(codes::X509InvalidFormat))?; | ||
Certificate::from_pem(cert.as_bytes_with_nul()).map_err(|_| ErrMbed::HighLevel(codes::X509InvalidFormat)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change still work on mbedtls 0.12?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires v0.13.1 (therefore not backcompt)
and we are pointing to exact version = "0.13.1"
intel-sgx/pcs/Cargo.toml
Outdated
|
||
[dev-dependencies] | ||
hex = "0.4.2" | ||
tempdir = "0.3.7" | ||
mbedtls = { version = ">=0.12.0, <0.14.0" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had added this for mbedtls imports in mod tests { .. }
removed this now since it was not needed.
@raoulstrackx thanks for pointing this out. After discussing with @Taowyoo we have decided to point to specific |
What was the reasoning to force upgrades to mbedtls 0.13.1? It'd be at least a breaking change for |
HI @raoulstrackx
Crates that do not explicitly use mbedtls Error type could use range version ">=0.12.0, <0.14.0" to keep compatibility for 0.12 version |
rust-mbedtls PR #372 adds combined errors for mbedtls. this enhancement is available from mbedtls v0.13.0