Module openssl::aes [] [src]

Low level AES IGE functionality

AES ECB, CBC, XTS, CTR, CFB, GCM and other conventional symmetric encryption modes are found in symm. This is the implementation of AES IGE.

Advanced Encryption Standard (AES) provides symmetric key cipher that the same key is used to encrypt and decrypt data. This implementation uses 128, 192, or 256 bit keys. This module provides functions to create a new key with new_encrypt and perform an encryption/decryption using that key with aes_ige.

The symm module should be used in preference to this module in most cases. The IGE block cypher is a non-traditional cipher mode. More traditional AES encryption methods are found in the Crypter and Cipher structs.

Examples

extern crate hex;
use openssl::aes::{AesKey, KeyError, aes_ige};
use openssl::symm::Mode;
use hex::FromHex;

fn decrypt() -> Result<(), KeyError> {
  let raw_key = "000102030405060708090A0B0C0D0E0F";
  let hex_cipher = "12345678901234561234567890123456";
  let randomness = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F";
  if let (Ok(key_as_u8), Ok(cipher_as_u8), Ok(mut iv_as_u8)) =
      (Vec::from_hex(raw_key), Vec::from_hex(hex_cipher), Vec::from_hex(randomness)) {
    let key = AesKey::new_encrypt(&key_as_u8)?;
    let mut output = vec![0u8; cipher_as_u8.len()];
    aes_ige(&cipher_as_u8, &mut output, &key, &mut iv_as_u8, Mode::Encrypt);
    assert_eq!(hex::encode(output), "a6ad974d5cea1d36d2f367980907ed32");
  }
  Ok(())
}

Structs

AesKey

The key used to encrypt or decrypt cipher blocks.

KeyError

Provides Error handling for parsing keys.

Functions

aes_ige

Performs AES IGE encryption or decryption