aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2015-08-02 22:25:09 -0400
committerSteven Fackler <[email protected]>2015-08-02 22:25:09 -0400
commit02dc3eda2fd607ddb43a09ac197a60d15510e45e (patch)
treeb710f08f3698e20667a4d0a7561e30db191d8c89 /openssl/src
parentMerge pull request #247 from panicbit/pub-init (diff)
parentAdded AES CTR-mode under feature flag. (diff)
downloadrust-openssl-02dc3eda2fd607ddb43a09ac197a60d15510e45e.tar.xz
rust-openssl-02dc3eda2fd607ddb43a09ac197a60d15510e45e.zip
Merge pull request #242 from awelkie/master
Added AES CTR-mode under feature flag.
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/crypto/symm.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/openssl/src/crypto/symm.rs b/openssl/src/crypto/symm.rs
index 82c668ba..79cffcc6 100644
--- a/openssl/src/crypto/symm.rs
+++ b/openssl/src/crypto/symm.rs
@@ -18,7 +18,8 @@ pub enum Type {
/// Requires the `aes_xts` feature
#[cfg(feature = "aes_xts")]
AES_128_XTS,
- // AES_128_CTR,
+ #[cfg(feature = "aes_ctr")]
+ AES_128_CTR,
//AES_128_GCM,
AES_256_ECB,
@@ -26,7 +27,8 @@ pub enum Type {
/// Requires the `aes_xts` feature
#[cfg(feature = "aes_xts")]
AES_256_XTS,
- // AES_256_CTR,
+ #[cfg(feature = "aes_ctr")]
+ AES_256_CTR,
//AES_256_GCM,
RC4_128,
@@ -39,14 +41,16 @@ fn evpc(t: Type) -> (*const ffi::EVP_CIPHER, u32, u32) {
Type::AES_128_CBC => (ffi::EVP_aes_128_cbc(), 16, 16),
#[cfg(feature = "aes_xts")]
Type::AES_128_XTS => (ffi::EVP_aes_128_xts(), 32, 16),
- // AES_128_CTR => (EVP_aes_128_ctr(), 16, 0),
+ #[cfg(feature = "aes_ctr")]
+ Type::AES_128_CTR => (ffi::EVP_aes_128_ctr(), 16, 0),
//AES_128_GCM => (EVP_aes_128_gcm(), 16, 16),
Type::AES_256_ECB => (ffi::EVP_aes_256_ecb(), 32, 16),
Type::AES_256_CBC => (ffi::EVP_aes_256_cbc(), 32, 16),
#[cfg(feature = "aes_xts")]
Type::AES_256_XTS => (ffi::EVP_aes_256_xts(), 64, 16),
- // AES_256_CTR => (EVP_aes_256_ctr(), 32, 0),
+ #[cfg(feature = "aes_ctr")]
+ Type::AES_256_CTR => (ffi::EVP_aes_256_ctr(), 32, 0),
//AES_256_GCM => (EVP_aes_256_gcm(), 32, 16),
Type::RC4_128 => (ffi::EVP_rc4(), 16, 0),
@@ -288,16 +292,17 @@ mod tests {
cipher_test(super::Type::AES_256_XTS, pt, ct, key, iv);
}
- /*#[test]
+ #[test]
+ #[cfg(feature = "aes_ctr")]
fn test_aes128_ctr() {
- let pt = ~"6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710";
- let ct = ~"874D6191B620E3261BEF6864990DB6CE9806F66B7970FDFF8617187BB9FFFDFF5AE4DF3EDBD5D35E5B4F09020DB03EAB1E031DDA2FBE03D1792170A0F3009CEE";
- let key = ~"2B7E151628AED2A6ABF7158809CF4F3C";
- let iv = ~"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";
+ let pt = "6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710";
+ let ct = "874D6191B620E3261BEF6864990DB6CE9806F66B7970FDFF8617187BB9FFFDFF5AE4DF3EDBD5D35E5B4F09020DB03EAB1E031DDA2FBE03D1792170A0F3009CEE";
+ let key = "2B7E151628AED2A6ABF7158809CF4F3C";
+ let iv = "F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";
- cipher_test(super::AES_128_CTR, pt, ct, key, iv);
- }*/
+ cipher_test(super::Type::AES_128_CTR, pt, ct, key, iv);
+ }
/*#[test]
fn test_aes128_gcm() {