Skip to content

Commit

Permalink
Revert "Allow other cbc key lengths "
Browse files Browse the repository at this point in the history
    This reverts commit 7573e5f
  • Loading branch information
bglusman committed Dec 29, 2016
1 parent a97c2f5 commit a29f5b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/ex_crypto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ defmodule ExCrypto do
@spec encrypt(binary, binary, binary) :: {:ok, {binary, {binary, binary}}} | {:error, binary}
def encrypt(key, clear_text) do
{:ok, initialization_vector} = rand_bytes(16) # new 128 bit random initialization_vector
_encrypt(key, initialization_vector, pad(clear_text, @aes_block_size), :aes_cbc)
_encrypt(key, initialization_vector, pad(clear_text, @aes_block_size), :aes_cbc256)
catch
kind, error ->
{:ok, initialization_vector} = rand_bytes(16)
Expand Down Expand Up @@ -278,7 +278,7 @@ defmodule ExCrypto do
"""
def encrypt(key, clear_text, %{initialization_vector: initialization_vector}) do
_encrypt(key, initialization_vector, pad(clear_text, @aes_block_size), :aes_cbc)
_encrypt(key, initialization_vector, pad(clear_text, @aes_block_size), :aes_cbc256)
catch
kind, error -> normalize_error(kind, error, {key, initialization_vector})
end
Expand Down Expand Up @@ -371,7 +371,7 @@ defmodule ExCrypto do
"""
@spec decrypt(binary, binary, binary) :: {:ok, binary} | {:error, binary}
def decrypt(key, initialization_vector, cipher_text) do
{:ok, padded_cleartext} = _decrypt(key, initialization_vector, cipher_text, :aes_cbc)
{:ok, padded_cleartext} = _decrypt(key, initialization_vector, cipher_text, :aes_cbc256)
{:ok, unpad(padded_cleartext)}
catch
kind, error -> normalize_error(kind, error, {key, initialization_vector})
Expand Down

0 comments on commit a29f5b8

Please sign in to comment.