-
Notifications
You must be signed in to change notification settings - Fork 314
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
Add artifact sign/verify via libsodium. #357
Conversation
97e26f3
to
22596a5
Compare
I'll make the verify subcommand return an appropriate exit code instead of spitting out the tar file. |
80a527a
to
df8f586
Compare
iproute2 \ | ||
libsodium-dev \ | ||
sudo \ | ||
vim \ |
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.
Could you alphabetize into the list? It should help with future merging
@metadave I realize this might still be finishing up, but great work! You must have had fun with Rust/IO pushing all those files around. |
Because we're using components/.cargo/config to override sodiumoxide to point at a custom fork, we need to CD into each directory instead of specifying the manifest location to allow the build to complete. - add iproute2 dep for `ip` command
e9cc7ab
to
f58804e
Compare
6c58788
to
45a6776
Compare
$(run) cargo build --manifest-path components/hab/Cargo.toml | ||
$(run) cargo build --manifest-path components/sup/Cargo.toml | ||
$(run) cargo build --manifest-path components/depot/Cargo.toml | ||
$(run) sh -c 'cd components/hab && cargo build' |
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.
Did this become a problem? Why change directory instead of just pass the manifest-path?
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.
yes, because of the components/.cargo/config
file
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 PR has passed 'Verify' and is ready for review and approval! |
|
||
/// If an env var is set, then return it's value. | ||
/// If it's not, return the default | ||
fn env_var_or_default(env_var: &str, default: &str) -> 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.
This might be better served in the util
module instead of crypto
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.
agreed, I'll pull it out in my next few crypto PR's, as I have some more work do to w/ env vars etc.
@metadave great work man, I'm looking forward to when they merge your changes ;). My comments are mostly just tips on how to be more fluent in Rust |
Note, this needs to be merged after: #361 |
This PR has passed 'Verify' and is ready for review and approval! |
@delivery approve |
Change: b7477faa-3da9-4c5d-b8a4-0697e52ae948 approved by: @metadave |
This PR adds artifact sign/verify via libsodium.
The following subcommands have been implemented:
hab archive
has been renamed tohab artifact
.Note, this does not implement user or service keys, and also excludes encryption/decryption. I'm going to leave some commented out code in (any code that includes "box"), please ignore for now and I'll update it when this story is completed next week.
1 minute tutorial
OR
TODO:
Development notes
GPG still exists in the repo
I'll remove references to GPG in a later PR
sodiumoxide + libsodium-sys
While we are waiting for the generichash functions from this PR to be merged, we're pointing to a fork. The annoying thing about this is that we have to include the entire repo as a cargo override via
components/.cargo/config
andCargo.toml
. Once the PR is merged to the official repo, we can remove these files and continue in peace.Compiling
In order to compile this today, you'll need the libsodium package installed and Rust needs to know how to link to libsodium via
SODIUM_LIB_DIR
.I updated the depot and sup plans to include libsodium, but we'll need to address the plan that builds
hab
asap.These are a prettier version of the docs I've embedded inside of
hab_crypto.rs
:Habitat uses libsodium and it's Rust counterpart sodiumoxide for cryptographic operations.
Concepts and terminology:
key
by itself does not indicate public or secret. The only exception is if the word key appears as part of a file suffix, where it is then considered the secret key file.sig.key
file suffix. Sig keys are NOT compatible with box keys..box.key
file suffix. Box keys are NOT compatible with sig keys.{year}{month}{day}{hour24}{minute}{second}
. For all user-facing cryptographic operations (sign/verify/encrypt/decrypt), the latest key is tried first, and upon failure, Habitat will try keys in reverse chronological order until success or there are no more keys. _TODO: key revisions are generated as part of a filename, but only the most recent key is used during crypto operations._Example origin key file names ("sig" keys):
Example user keys ("box" keys)
Example Service keys:
Habitat signed artifact format
A signed
.hab
artifact has 3 plaintext lines followed by a binary blob of data, which is the unsigned tarfile.BLAKE2b
unless our use of crypto is expanded some time in the future.Example header:
https://download.libsodium.org/doc/hashing/generic_hashing.html
It's possible to examine the contents of a
.hab
file from a Linux shell:It is also possible to extract a plain tarball from a signed
.hab
artifact using the following command: