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

AES module level docs and example #734

Merged
merged 5 commits into from Sep 28, 2017

Conversation

Projects
None yet
3 participants
@AndyGauge
Copy link
Contributor

AndyGauge commented Sep 26, 2017

Fixes #698

@@ -63,6 +107,14 @@ impl AesKey {

/// Performs AES IGE encryption or decryption
///
/// AES IGE (Infinite Garble Extension) is the form of AES block cipher utilized in

This comment has been minimized.

@sfackler

sfackler Sep 27, 2017

Owner

It's a form, not the form. An obscure one at that.

@@ -1,15 +1,59 @@
//! Low level AES functionality
//!
//! The `symm` module should be used in preference to this module in most cases.
//! Advanced Encryption Standard (AES) provides symmetric key cipher that

This comment has been minimized.

@sfackler

sfackler Sep 27, 2017

Owner

This should probably mention that most people looking for symmetric encryption should be using the Crypter type. This module maps to the lower-level and more obscure options that aren't covered by the Crypter interface.

//! create a new key with [`new_encrypt`] and perform an encryption/decryption
//! using that key with [`aes_ige`].
//!
//! AES is a 128-bit (16 byte) block cipher. The rust implmentation will panic

This comment has been minimized.

@sfackler

sfackler Sep 28, 2017

Owner

There are 128 and 256 bit variants of AES.

I'm not sure what the panic note is referring to - aes_ige doesn't have any asserts around the lengths of the input and output buffers.

This comment has been minimized.

@BrianOn99

BrianOn99 Sep 28, 2017

Contributor

@sfackler I think it is refering to those lines

/// Performs AES IGE encryption or decryption
///
/// # Panics
///
/// Panics if `in_` is not the same length as `out`, if that length is not a multiple of 16, or if
/// `iv` is not at least 32 bytes.
pub fn aes_ige(in_: &[u8], out: &mut [u8], key: &AesKey, iv: &mut [u8], mode: Mode) {
    unsafe {
        assert!(in_.len() == out.len());
        assert!(in_.len() % ffi::AES_BLOCK_SIZE as usize == 0);
        assert!(iv.len() >= ffi::AES_BLOCK_SIZE as usize * 2);

Doesn't it panic if the buffer lengths is not multiple of ffi::AES_BLOCK_SIZE ?

This comment has been minimized.

@AndyGauge

AndyGauge Sep 28, 2017

Author Contributor

I can see the confusion. I'll try to incorporate both of those details at the top (the key is 128-bit, 192-bit, or 256-bit and that the input must be bounded to 16-bytes)

@sfackler

This comment has been minimized.

Copy link
Owner

sfackler commented Sep 28, 2017

@sfackler

This comment has been minimized.

Copy link
Owner

sfackler commented Sep 28, 2017

@BrianOn99

This comment has been minimized.

Copy link
Contributor

BrianOn99 commented Sep 28, 2017

Agree, and the line 128-bit (16 byte) block cipher need change.

@BrianOn99

This comment has been minimized.

Copy link
Contributor

BrianOn99 commented Sep 28, 2017

Sorry. that line is correct. Please ignore my prevoius comment.

@sfackler

This comment has been minimized.

Copy link
Owner

sfackler commented Sep 28, 2017

Looks good, thanks!

@sfackler sfackler merged commit 67ca96a into sfackler:master Sep 28, 2017

12 of 13 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
ci/circleci: armhf-openssl-1.0.1 Your tests passed on CircleCI!
Details
ci/circleci: armhf-openssl-1.0.2 Your tests passed on CircleCI!
Details
ci/circleci: armhf-openssl-1.1.0 Your tests passed on CircleCI!
Details
ci/circleci: i686-openssl-1.0.1 Your tests passed on CircleCI!
Details
ci/circleci: i686-openssl-1.0.2 Your tests passed on CircleCI!
Details
ci/circleci: i686-openssl-1.1.0 Your tests passed on CircleCI!
Details
ci/circleci: x86_64-libressl-2.5.0 Your tests passed on CircleCI!
Details
ci/circleci: x86_64-libressl-2.6.1 Your tests passed on CircleCI!
Details
ci/circleci: x86_64-openssl-1.0.1 Your tests passed on CircleCI!
Details
ci/circleci: x86_64-openssl-1.0.2 Your tests passed on CircleCI!
Details
ci/circleci: x86_64-openssl-1.1.0 Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.