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

Initial Rust binding #340

Merged
merged 1 commit into from
Jan 12, 2019
Merged

Initial Rust binding #340

merged 1 commit into from
Jan 12, 2019

Conversation

ilammy
Copy link
Collaborator

@ilammy ilammy commented Nov 18, 2018

This adds initial Rust binding for Themis.

The code comes from here, version 0.0.2:

https://github.com/ilammy/rust-themis

I could have transferred the whole git history, but that's too much of a bother and I don't think anybody would be interested in it that much. If you wish to read the older commit messages you can always look into the original repo. Not very convenient but that's at least something.

The core repository layout is a bit different from a traditional one for Rust projects. I have moved the files into appropriate places and adapted the Cargo.toml file to that. Importantly, it now requires an include directive so that published crates include only Rust code.

Here's the current layout of Rust code:

.
├─ Cargo.toml           -  root Cargo.toml file
├─ docs/examples
│  └─ rust              -  Rust wrapper examples
├─ src/wrappers/themis
│  └─ rust              -  root of the "themis" crate
│     ├─ libthemis-sys  -  root of the "libthemis-sys" crate
│     └─ src            -  Rust wrapper source code
└─ tests
   └─ rust              -  Rust wrapper tests

The Cargo.toml file is placed in the root directory so that all usual Cargo commands work from there after a fresh checkout. They do work indeed, but the Rust binding is not integrated into the core build system. We'll improve that later.

The links throughout the docs and Cargo.toml files have been updated to point to Cossack Labs repo. I have also removed TravisCI badges because Rust wrapper is going to use CircleCI just like the other bindings.

I have kept the original README files. These are used when publishing on crates.io and contain Rust-specific instructions. The LICENSE files in Rust wrappers are also kept intact in accordance with item 4.a of the Apache 2.0 license.

As for licensing of this contribution, I'm not a lawyer, but Apache license gives the same rights to the original licensor as well as any future contributors. That's why I did not bother updating all the boilerplate comments all over the code. They still assign copyright of Rust code to "rust-themis developers". By submitting this code to the core repository the developers agree to keep the Apache 2.0 license for it, as per item 5 of the license. There are no separate prior agreements other than that.

This adds initial Rust binding for Themis.

The code comes from here, version 0.0.2:

    https://github.com/ilammy/rust-themis

I could have transferred the whole git history, but that's too much of
a bother and I don't think anybody would be interested in it that much.
If you wish to read the older commit messages you can always look into
the original repo. Not very convenient but that's at least something.

The core repository layout is a bit different from a traditional one
for Rust projects. I have moved the files into appropriate places and
adapted the Cargo.toml file to that. Importantly, it now requires an
`include` directive so that published crates include only Rust code.

Here's the current layout of Rust code:

    .
    ├─ Cargo.toml           -  root Cargo.toml file
    ├─ docs/examples
    │  └─ rust              -  Rust wrapper examples
    ├─ src/wrappers/themis
    │  └─ rust              -  root of the "themis" crate
    │     ├─ libthemis-sys  -  root of the "libthemis-sys" crate
    │     └─ src            -  Rust wrapper source code
    └─ tests
       └─ rust              -  Rust wrapper tests

The Cargo.toml file is placed in the root directory so that all usual
Cargo commands work from there after a fresh checkout. They do work
indeed, but the Rust binding is not integrated into the core build
system. We'll improve that later.

The links throughout the docs and Cargo.toml files have been updated to
point to Cossack Labs repo. I have also removed TravisCI badges because
Rust wrapper is going to use CircleCI just like the other bindings.

I have kept the original README files. These are used when publishing on
crates.io and contain Rust-specific instructions. The LICENSE files in
Rust wrappers are also kept intact in accordance with item 4.a of the
Apache 2.0 license.

As for licensing of this contribution, I'm not a lawyer, but Apache
license gives the same rights to the original licensor as well as any
future contributors. That's why I did not bother updating all the
boilerplate comments all over the code. They still assign copyright of
Rust code to "rust-themis developers". By submitting this code to the
core repository the developers agree to keep the Apache 2.0 license
for it, as per item 5 of the license. There are no separate prior
agreements other than that.
@ilammy ilammy added the W-RustThemis 🦀 Wrapper: Rust-Themis, Rust API, Cargo crates label Nov 18, 2018
@ilammy ilammy mentioned this pull request Nov 18, 2018
11 tasks
@vixentael
Copy link
Contributor

vixentael commented Nov 19, 2018

Yey, themis will have rust binding, that's incredible!

Thank you @ilammy, you're doing great things!

Please don't be irritated while we're reading code and asking simple questions – rust is still very new for us.

Apache 2.0 license

That's right, having Apache 2.0 license makes total sense, as you said, it gives the same rights to the original licensor as well as any future contributors.

#[derive(Clone, Eq, PartialEq, Hash)]
pub(crate) struct KeyBytes(Vec<u8>);

// TODO: securely zero memory when dropping KeyBytes (?)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be good if you add it now. it's really important and easy in rust as I understand. to be sure that keys will be filled with zeroes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for good catch!
Zeroing private keys is gonna be part of next PR

Copy link
Contributor

@shadinua shadinua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great job! Thank you!

@vixentael
Copy link
Contributor

Agreed to merge this PR, and to add future Rust changes (including zeroing of private keys) into next PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
W-RustThemis 🦀 Wrapper: Rust-Themis, Rust API, Cargo crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants