LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-04-2012, 04:00 PM   #1
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Rep: Reputation: Disabled
OpenSSL, aes.h, AES_cbc_encrypt(): length parameter?


I am using the aes.h function AES_cbc_encrypt(*in, *out, length, *key, *ivec, enc). I am wondering whether the length parameter is the size of "in" array or the size of the array being used for "out?" I looked for parameter definitions on the openssl site and couldn't find such a thing (there or anywhere else).

Thanks in advance.

Brandon
 
Old 12-05-2012, 04:25 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
The docs on openssl.org seem to be missing the aes page, but I looked at the des one which has a similar interface:

Quote:
DES_ncbc_encrypt() encrypts/decrypts using the cipher-block-chaining (CBC) mode of DES. If the encrypt argument is non-zero, the routine cipher-block-chain encrypts the cleartext data pointed to by the input argument into the ciphertext pointed to by the output argument, using the key schedule provided by the schedule argument, and initialization vector provided by the ivec argument. If the length argument is not an integral multiple of eight bytes, the last block is copied to a temporary area and zero filled. The output is always an integral multiple of eight bytes.
So it should be the same for AES except that it will be sixteen instead of eight bytes, since AES has a blocksize of 16 bytes while the blocksize for DES is 8 bytes.
 
Old 12-05-2012, 04:37 PM   #3
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
Thanks, but I'm not sure you answered the question. Does the length parameter refer to the input buffer or the output buffer?
 
Old 12-05-2012, 07:45 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
The length refers to both input and output, except that the output length is rounded up to the nearest multiple of the block size.
 
Old 12-06-2012, 01:02 PM   #5
Brandon9000
Member
 
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
So, presumably it refers to the input length before padding?
 
Old 12-06-2012, 04:42 PM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by Brandon9000 View Post
So, presumably it refers to the input length before padding?
Yup
 
  


Reply

Tags
aes, encryption, openssl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
OPENSSL AES-128-CBC Encoding Format AbdulKabani Linux - Newbie 0 05-20-2012 10:29 AM
dm-crypt aes-xts-plain64 vs aes-cbc-essiv for volumes > 2TiB Molly Linux - Security 1 09-13-2010 05:24 PM
OpenSSL Encryption with AES kaplan71 Linux - Software 3 11-26-2008 12:46 PM
Openssl Certificate Generation Question AES richinsc Linux - Security 11 09-18-2008 10:48 AM
AES for openssh and openssl powah Linux - Software 1 04-21-2008 08:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration