Comments (16)
Hello, I was trying to use this library but had trouble compiling it. Using the changes in #102 I everything compiled and it works fine. What is the reason that issues has been idle for so long? Are there problems with the fixes in #102. In that case I would be glad to help to resolve them.
from rust-mbedtls.
Hi folks. I also tried to use this library on windows, have been able to use it thanks to #102. As @nouwaarom, I also would be glad to help if anything is required to merge this fix.
from rust-mbedtls.
I would like to give this a try. Since Builder::remove_prefix was removed, are you ok with using names with the "mbedtls_" prefix, except when we reexport values?
from rust-mbedtls.
Oh I forgot about this issue. See rust-lang/rust-bindgen#428 . I'd really like to automate this since I'm not a big fan of having to use the prefixes everywhere.
from rust-mbedtls.
I worked on this issue in the last few days, here is a status update on my progress so far. I would like to discuss potential approaches to deal with issues I encountered. You can find my work branch at https://github.com/ekse/rust-mbedtls/tree/bindgen-upgrade.
First, a quick note on why I want to upgrade. The current master branch does not compile on my computers, it fails with the error Bindgen ERROR: unsupported type CXTypeKind(119)
. Upgrading bindgen fixes this issue. I get this build error on libclang 3.9, 4.0 and 6.0.
"mbedtls_" prefix
To deal with the "mbedtls_" prefix, I tried the approach suggested by the bindgen maintainer to rename the imports with use x as y
statements. To reduce the amount of boilerplate, I experimented with creating a procedural macro "mbedtls_use" https://github.com/ekse/rust-mbedtls/tree/bindgen-upgrade/mbedtls-use. An example use of this macro looks like this: (https://github.com/ekse/rust-mbedtls/blob/bindgen-upgrade/mbedtls/src/cipher/raw/serde.rs#L24)
#[mbedtls_use]
use {
mbedtls_aes_context, mbedtls_cipher_context_t, mbedtls_cipher_id_t, mbedtls_cipher_mode_t,
mbedtls_des3_context, mbedtls_des_context, MBEDTLS_CIPHER_ID_3DES, MBEDTLS_CIPHER_ID_AES,
MBEDTLS_CIPHER_ID_DES, MBEDTLS_MODE_CBC, MBEDTLS_MODE_CFB, MBEDTLS_MODE_CTR,
};
There are a couple downsides to this approach. Procedural macros were just stabilized in Rust 1.30, that would make it a hard requirement. Also, the use statements are not in scope when using macros like define!, so I used the full type names (see https://github.com/ekse/rust-mbedtls/blob/bindgen-upgrade/mbedtls/src/pk/ec.rs#L19).
Alternatively, we could remove the proc_macro and write the complete use x as y
statements, at the cost of longer use statements.
unsigned constants
The second issue I encountered is with constants. Bindgen defines constants such as MBEDTLS_SSL_IS_CLIENT
as u32. This fails to compile for define! statements that map to c_int as it maps to i32. I assume the older version of bindgen defined those constants as i32.
error[E0308]: match arms have incompatible types
--> mbedtls/src/wrapper_macros.rs:75:5
|
75 | match self {
| _________________^
76 | | $($n::$rust => ::mbedtls_sys::$c,)*
| | ----------------- match arm with an incompatible type
77 | | }
| |_________________^ expected i32, found u32
|
::: mbedtls/src/ssl/config.rs:62:1
|
62 | / define!(enum UseSessionTickets -> c_int {
63 | | Enabled => MBEDTLS_SSL_SESSION_TICKETS_ENABLED,
64 | | Disabled => MBEDTLS_SSL_SESSION_TICKETS_DISABLED,
65 | | });
| |___- in this macro invocation
Also, some getters and setters fail to compile because enums do not implement From conversions for i32 (because values in u32 could be outside the range of i32).
setter!(set_session_tickets(u: UseSessionTickets) = mbedtls_ssl_conf_session_tickets)
error[E0277]: the trait bound `i32: std::convert::From<ssl::config::UseSessionTickets>` is not satisfied
--> mbedtls/src/wrapper_macros.rs:192:50
|
192 | unsafe{::mbedtls_sys::$cfn(&mut self.inner,$n.into())}
| ^^^^ the trait `std::convert::From<ssl::config::UseSessionTickets>` is not implemented for `i32`
I temporarily worked around this by manually defining the constants as i32, and the crate successfully compiles at that point. To could be an approach to deal with this issue, I'm not sure what the best way to do that with bindgen would be.
Sorry for the long message, it seems upgrading the bindgen dependency will require a good amount of effort. I suggest we decide on a way to deal with the mbedtls_ prefix issue and move on from there.
Thanks,
Sébastien
from rust-mbedtls.
prefix
If you take a look at the latest comments at rust-lang/rust-bindgen#428 it seems to me that reimplementing remove_prefix
shouldn't be too hard. That would have my preference over procedural macros.
constants
I think it should be pretty easy to replace the current macro_int_types
configuration with an appropriate ParseCallbacks::int_macro
implementation.
from rust-mbedtls.
Thanks for the reply, I had not seen the reply on the bindgen issue. I implemented an item_name` callback and it is now merged in the master branch of bindgen.
I pushed a new branch with your suggested approaches, the changeset is now much much smaller.
master...ekse:bindgen-upgrade-v2
client_server_test
is failing with X509CertVerifyFailed
on the client. I will try to figure out why.
from rust-mbedtls.
Haha I found it: The certificate is expired, the expiration date is '16 Aug 2016'.
from rust-mbedtls.
@ekse any progress? Do you need help figuring anything out?
from rust-mbedtls.
I opened a pull request (#13) to replace the expired certificate in the tests.
For the bindgen upgrade, I was waiting for a new release of bindgen. I asked the maintainers today if they could make a new release. My branch currently compiles and all the tests are passing, it depends on the git repository of bindgen at the moment, so once the bindgen crate is updated it will be ready for a pull request.
master...ekse:bindgen-upgrade-v2
from rust-mbedtls.
This is also necessary for the docs to show up properly on docs.rs
from rust-mbedtls.
With recent nightly, the version of syntex-syntax pulled in by bindgen 0.19 fails to compile.
In some months, that nightly behavior will become stable at which point mbedtls crate will be broken :(
@jethrogb it seems like #14 is stalled on unresolved bindgen bugs. It is possible we can move to some intermediate version of bindgen to avoid the compilation problem but without hitting the bugs in more recent bindgen?
from rust-mbedtls.
No, we are on the latest possible bindgen. It works if you patch syntex_syntax to 0.40 and disable deny(warnings)
from rust-mbedtls.
I echo the previous requests. This is too much of a problem to be left unfixed (I came here because this breaks fortanix sgx sdk tls
example, so you can imagine).
Let me know if there is help required with this.
from rust-mbedtls.
As mentioned in #14 (comment) the new version of bindgen (after 0.19) is not capable of generating the bindings the way we are generating them today, so they'd be incompatible. In order to make progress, features need to be added to bindgen to make sure it can generate code the right way.
from rust-mbedtls.
Final PR: #152
from rust-mbedtls.
Related Issues (20)
- Totally fix performance issue related to cflag `-f-no-builtin` HOT 1
- Profile changes on `mbedtls_x509_crt_profile_default` HOT 1
- [mbedtls3] `mbedlts` would breaks the record size limit when sending big record HOT 2
- Add support to pass salt length for RSASSA_PSS
- Avoid tests depending on external services
- Tracking outage of Travis CI HOT 2
- `gcm_context` size mismatch for target `i686-linux-android` HOT 6
- [mbedtls3] TLS 1.3 connection is unstable and sometime break in multi-thread env
- Build failed in ```no_std``` environment.
- Link error with v0.11.0 rust-lld: error: undefined symbol: mbedtls_pk_ec__extern mbedtls_cipher_get_cipher_mode__extern HOT 2
- Unable to build for ESP-IDF target HOT 3
- `mbedtls::x509::certificate::Certificate::verify()` segfaults when passing in an empty certificate chain to verify
- Don't use `alloca()` or variable-sized arrays in `rust_printf.c`
- Certificate from_pem_multiple error HOT 1
- [IMPORTANT] Crate status change
- A security vulnerability has been detected in spin v0.4.* used in v0.9.3 HOT 1
- Features that need to be ported to 2.28.X mbedtls (current master) HOT 2
- Encountered test failures when randomizing tests HOT 1
- Check to set `CMAKE_TRY_COMPILE_TARGET_TYPE` too restrictive HOT 1
- Fix and Setup daily CI for keeping track of nightly compiler changes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-mbedtls.