I am working on porting a decryption function from .NET to elixir as a proof of concept.
Can anyone give me some guidance on if this is doable with the Erlang crypto module? I have played around the block_decrypt functions but am never able to get the correct result. I am thinking my problem is coming from an incorrect key and IV.
I am unsure how to derive byte data from the encrypted plain text value to pass into block_decrypt.
Here is the elixir code I'm using to attempt to decrypt:
defmodule TestApp.Decrypt do
@iv <<30,64,180,159,172,197,92,10,197,3,39,75,53,92,93,37>>
def unpad(data) do
to_remove = :binary.last(data)
:binary.part(data, 0, byte_size(data) - to_remove)
end
def decrypt(data, key) do
IO.puts "WOrking to decrypt #{data} using #{key}"
padded = :crypto.block_decrypt(:aes_cbc256, key, @iv, :base64.decode(data))
unpad(padded)
end
end
I have a 32 byte key I'm trying to pass in but am getting this error:
Erlang error: :notsup
The Crypto Library points that error to the fact that dirty scheduler wasn't enabled on my erlang build, but I don't know if I'm going about this in the right direction before I look into that.
crypto, it should be possible. - DogbertMay throw exception notsup in case the chosen Type is not supported by the underlying OpenSSL implementation.- ryanwinchesterunpad: s.ryanwinchester.ca/2W2n0L0H062v - ryanwinchester