Commit 5a14bd71 authored by Luc Libralesso's avatar Luc Libralesso
Browse files

correct bug in lambda calling

parent 13573f88
......@@ -81,6 +81,11 @@ def subcell_matrix(i)
end
end
def get_indexed_subcell(index)
j,i = *index
return subcell_matrix(j*4+i)
end
def subcell_function(i, j, v)
ssb = subcell_matrix(j*4+i)
return ssb[v / 16][v % 16]
......
......@@ -40,7 +40,7 @@ class Midori128_Dag < CryptoDag
addkey = XorNode.new(name:"addKey", inputs:[@x.outputs[0],@k.outputs[0]])
nodes.push(addkey)
for i in 0..nb_rounds-2 do
subbytes = IndexedSubBytesNode.new(name:"SB_#{i}", input:addkey.outputs[0], subtable_function: method(:subcell_function))
subbytes = IndexedSubBytesNode.new(name:"SB_#{i}", input:addkey.outputs[0], subtable_function: method(:get_indexed_subcell))
nodes.push(subbytes)
shufflecell = ShuffleCellNode.new(name:"SC_#{i}", input:subbytes.outputs[0], permutation:shufflecell_matrix)
nodes.push(shufflecell)
......@@ -51,7 +51,7 @@ class Midori128_Dag < CryptoDag
addkey = XorNode.new(name:"End_#{i}", inputs:[mixcolumns.outputs[0],rk.outputs[0]])
nodes.push(addkey)
end
subcell = IndexedSubBytesNode.new(name:"SB_#{nb_rounds-1}", input:addkey.outputs[0], subtable_function: method(:subcell_function))
subcell = IndexedSubBytesNode.new(name:"SB_#{nb_rounds-1}", input:addkey.outputs[0], subtable_function: method(:get_indexed_subcell))
nodes.push(subcell)
out_xor = XorNode.new(name:"End", inputs:[subcell.outputs[0], @k.outputs[0]])
nodes.push(out_xor)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment