-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fba3bea
commit 7e844b4
Showing
8 changed files
with
1,228 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,52 @@ | ||
use std::env; | ||
|
||
// This is not going to happen any more since we have a default feature definition in Cargo.toml | ||
//#[cfg(not(any(feature = "crypto_adaptor_openssl", feature = "crypto_adaptor_tongsuo")))] | ||
//compile_error! { | ||
// r#" | ||
// No cryptography adaptor is enabled! | ||
// | ||
// In RustyVault, the real cryptographic operations are done via "crypto_adaptor"s. | ||
// | ||
// A crypto adaptor is a module that conveys and translates high level cryptography | ||
// operations like encryption, signing into the APIs provided by underlying cryptography | ||
// libraries such as OpenSSL, Tongsuo and so forth. | ||
// | ||
// At current stage, only one crypto_adaptor can be enabled at compilation phase and later | ||
// be used at run-time. "crypto_adaptor"s are configured as 'feature's in the Cargo context. | ||
// | ||
// Currently, the supported feature names of crypto adaptors are as follows, you can enable | ||
// them by adding one '--features crypto_adaptor_name' option when running "cargo build": | ||
// 1. the OpenSSL adaptor: crypto_adaptor_openssl | ||
// 2. the Tongsuo adaptor: crypto_adaptor_tongsuo | ||
// "# | ||
//} | ||
|
||
#[cfg(all(feature = "crypto_adaptor_openssl", feature = "crypto_adaptor_tongsuo"))] | ||
compile_error! { | ||
r#" | ||
Only one cryptography adapator can be enabled! | ||
In RustyVault, the real cryptographic operations are done via "crypto_adaptor"s. | ||
A crypto adaptor is a module that conveys and translates high level cryptography | ||
operations like encryption, signing into the APIs provided by underlying cryptography | ||
libraries such as OpenSSL, Tongsuo and so forth. | ||
At current stage, only one crypto_adaptor can be enabled at compilation phase and later | ||
be used at run-time. "crypto_adaptor"s are configured as 'feature's in the Cargo context. | ||
Currently, the supported feature names of crypto adaptors are as follows, you can enable | ||
them by adding one '--features crypto_adaptor_name' option when running "cargo build": | ||
1. the OpenSSL adaptor: crypto_adaptor_openssl | ||
2. the Tongsuo adaptor: crypto_adaptor_tongsuo | ||
"# | ||
} | ||
|
||
fn main() { | ||
if let Ok(_) = env::var("DEP_OPENSSL_TONGSUO") { | ||
println!("cargo:rustc-cfg=tongsuo"); | ||
} else if cfg!(feature = "crypto_adaptor_tongsuo") { | ||
println!("cargo:rustc-cfg=tongsuo"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! This is a Rust module that contains several adaptors to different cryptography libraries. | ||
//! The rusty_vault::crypto module utilize these adaptors to do the real crypto operations. | ||
//! | ||
//! Only one crypto adaptor can be used in one build. It's configured when building RustyVault. | ||
//! An adaptor implements a set of methods that perform cryptograhpy operations like encryption, | ||
//! decription, signing, verification and so on. | ||
#[cfg(feature = "crypto_adaptor_openssl")] | ||
pub mod openssl_adaptor; | ||
#[cfg(feature = "crypto_adaptor_tongsuo")] | ||
pub mod tongsuo_adaptor; |
Oops, something went wrong.