Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAES module level docs and example #734
Conversation
AndyGauge
added some commits
Sep 26, 2017
sfackler
reviewed
Sep 27, 2017
| @@ -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.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
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.
sfackler
reviewed
Sep 28, 2017
| //! 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.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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)
This comment has been minimized.
This comment has been minimized.
|
Oh jeez, I totally misread in_ as iv, sorry!
…On Wed, Sep 27, 2017 at 10:40 PM Chiu Yue Chun ***@***.***> wrote:
*@BrianOn99* commented on this pull request.
------------------------------
In openssl/src/aes.rs
<#734 (comment)>:
> //!
-//! The `symm` module should be used in preference to this module in most cases.
+//! 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`].
+//!
+//! AES is a 128-bit (16 byte) block cipher. The rust implmentation will panic
@sfackler <https://github.com/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 ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#734 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABY2UfNdRXPzuCRlL3cKmuS7ALmD25pmks5smzFVgaJpZM4PlCHL>
.
|
This comment has been minimized.
This comment has been minimized.
|
I would move those details to the function they describe though.
…On Wed, Sep 27, 2017 at 10:51 PM Steven Fackler ***@***.***> wrote:
Oh jeez, I totally misread in_ as iv, sorry!
On Wed, Sep 27, 2017 at 10:40 PM Chiu Yue Chun ***@***.***>
wrote:
> *@BrianOn99* commented on this pull request.
> ------------------------------
>
> In openssl/src/aes.rs
> <#734 (comment)>
> :
>
> > //!
> -//! The `symm` module should be used in preference to this module in most cases.
> +//! 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`].
> +//!
> +//! AES is a 128-bit (16 byte) block cipher. The rust implmentation will panic
>
> @sfackler <https://github.com/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 ?
>
> —
> You are receiving this because you were mentioned.
>
>
> Reply to this email directly, view it on GitHub
> <#734 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABY2UfNdRXPzuCRlL3cKmuS7ALmD25pmks5smzFVgaJpZM4PlCHL>
> .
>
|
This comment has been minimized.
This comment has been minimized.
|
Agree, and the line |
This comment has been minimized.
This comment has been minimized.
|
Sorry. that line is correct. Please ignore my prevoius comment. |
This comment has been minimized.
This comment has been minimized.
|
Looks good, thanks! |
AndyGauge commentedSep 26, 2017
Fixes #698