Skip to content
This repository has been archived by the owner on Jan 9, 2018. It is now read-only.

Made it randomize the IV and added a test #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KMarshland
Copy link

Fixes issue #4.

Additionally, adds a basic test.

iv = aes.random_iv if iv.nil? && cipher_type == 'AES-256-CBC'

if iv.nil?
aes.update(data) + aes.final

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if iv.nil?

I don't think it is necessary. It will never be nil. You must check for the length of IV.

iv = aes.random_vi if iv.length < 12 && cipher_type.downcase =  'aes-256-cbc'

if iv.nil?
aes.update(data) + aes.final
else
aes.iv = iv

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this one, just simply have above condition.

iv = aes.random_vi if iv.length < 12 && cipher_type.downcase =  'aes-256-cbc'

Isn't it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants