Skip to content

Instantly share code, notes, and snippets.

@jerojasro
Created June 19, 2017 20:26
Show Gist options
  • Save jerojasro/5596646cdf0802db9126497925ad07e3 to your computer and use it in GitHub Desktop.
Save jerojasro/5596646cdf0802db9126497925ad07e3 to your computer and use it in GitHub Desktop.
# DOES NOT WORK
def sub_word(<< w :: size(32) >>) do
for <<b <- w>>, into: <<>> do
<< :binary.at(@s_box, b) >>
end
end
# ** (ArgumentError) argument error
# :erlang.bit_size(1)
# lib/symmetric/aes.ex:27: Symmetric.AES.sub_word/1
# WORKS
def sub_word_alt(<< a, b, c, d >>) do
<<
:binary.at(@s_box, a),
:binary.at(@s_box, b),
:binary.at(@s_box, c),
:binary.at(@s_box, d),
>>
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment