Skip to content
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

Incorrect FFI binding #1

Open
icmccorm opened this issue Dec 15, 2023 · 0 comments
Open

Incorrect FFI binding #1

icmccorm opened this issue Dec 15, 2023 · 0 comments

Comments

@icmccorm
Copy link

I've been experimenting with a version of Miri that can execute foreign functions by interpreting the LLVM bytecode that is produced during a crate's build process. We're hoping that our results can assist with the Krabcake project.

Miri reports the following error when executing the test x25519::tests::diffie_hellman_test:

error: LLI interoperation error: LLVM field width mismatch: cannot convert an LLVM field of width 1 to a Rust field of type `i32` which has width 4
   --> src/x25519.rs:65:13
    |
65  |             );
    |             ^ LLVM field width mismatch: cannot convert an LLVM field of width 1 to a Rust field of type `i32` which has width 4
    |
    = note: inside `x25519::SecretKey::diffie_hellman` at src/x25519.rs:65:13: 65:14
note: inside closure
   --> src/x25519.rs:117:17
    |
117 |                 sk1.diffie_hellman(&pk2).as_bytes(),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^

It seems like this function is declared in Rust to return a 32-bit integer, but the C definition returns an 8-bit boolean value:

bool EverCrypt_Curve25519_ecdh(uint8_t *shared, uint8_t *my_priv, uint8_t *their_pub)
{
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant