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

Support cryptography module #65

Merged
merged 5 commits into from
Aug 2, 2024
Merged

Conversation

InfoHunter
Copy link
Member

This pull request implements the rusty_vault::modules::crypto module and relevant cryptography adaptor mechanism. In every build of RustyVault, users can select one of the supported adaptors as the real cryptography operations provider in RustyVault.

A set of new feature names are added in Cargo and they can be specified during cargo build by:

cargo build --features crypto_adaptor_tongsuo

or 

cargo build --features crypto_adaptor_openssl

If no adaptor is explicitly configured, then the OpenSSL adaptor is selected by default - for the compatibility considerations.

@InfoHunter InfoHunter marked this pull request as draft May 21, 2024 09:20
@Tongsuo-Project Tongsuo-Project deleted a comment from netlify bot May 28, 2024
@InfoHunter
Copy link
Member Author

InfoHunter commented May 31, 2024

It seems Cargo doesn't support dynamic patching for dependencies. So if Tongsuo is selected as the underlying adaptor, one must run the following command to patch openssl and openssl-sys to the rust-tongsuo version:

cargo build --features crypto_adaptor_tongsuo \
    --no-default-features \
    --config 'patch.crates-io.openssl.git="https://github.com/Tongsuo-Project/rust-tongsuo.git"'\
    --config 'patch.crates-io.openssl-sys.git="https://github.com/Tongsuo-Project/rust-tongsuo.git"'

Or, just uncomment the following lines in Cargo.toml:

#[patch.crates-io]
#openssl = { git = "https://github.com/Tongsuo-Project/rust-tongsuo.git" }
#openssl-sys = { git = "https://github.com/Tongsuo-Project/rust-tongsuo.git" }

and then:

cargo build --features crypto_adaptor_tongsuo --no-default-features

@InfoHunter
Copy link
Member Author

To use Tongsuo as the underlying cryptography library, the user needs to set a OPENSSL_DIR=/path/to/tongsuo/install/directory, to indicate where Tongsuo is installed. Currently only Tonsguo 8.4 and later are supported.

@InfoHunter InfoHunter marked this pull request as ready for review June 13, 2024 16:57
@InfoHunter InfoHunter force-pushed the crypto branch 2 times, most recently from b6982d6 to 350bc7b Compare June 14, 2024 14:55
@InfoHunter
Copy link
Member Author

some in-code document snips:

Screen Shot 2024-06-15 at 00 23 00

@InfoHunter InfoHunter changed the title WIP: Support cryptography module Support cryptography module Jul 23, 2024
@InfoHunter InfoHunter requested a review from wa5i July 23, 2024 05:35
@InfoHunter
Copy link
Member Author

Support of public key and digest algorithms will be in a separate pull request.

.github/workflows/rust.yml Outdated Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
build.rs Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/mod.rs Show resolved Hide resolved
This is prepared for later usage of crypto adaptor module and can also
suppress compilation warnings when using latest rustc compiler.
src/modules/crypto/crypto_adaptors/common.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/common.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/common.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/common.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/common.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/tongsuo_adaptor.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/tongsuo_adaptor.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/tongsuo_adaptor.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/tongsuo_adaptor.rs Outdated Show resolved Hide resolved
src/modules/crypto/crypto_adaptors/tongsuo_adaptor.rs Outdated Show resolved Hide resolved
@InfoHunter
Copy link
Member Author

All have been resolved.

@InfoHunter
Copy link
Member Author

Able to merge subject to CIs are green

Copy link
Collaborator

@wa5i wa5i left a comment

Choose a reason for hiding this comment

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

LGTM

@wa5i wa5i merged commit 0f1b1f6 into Tongsuo-Project:main Aug 2, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

3 participants