Skip to content

Instantly share code, notes, and snippets.

@dpick
Created April 5, 2011 17:43
Show Gist options
  • Save dpick/904090 to your computer and use it in GitHub Desktop.
Save dpick/904090 to your computer and use it in GitHub Desktop.
before(:each) do
@key = "0111111101001001110000101000001100011100000011101111010011101001".split("").map { |i| i.to_i }
@text = "0101010101010101010101010101010101010101010101010101010101010101".split("").map { |i| i.to_i }
@text_bitfield = BitField.new(@text)
@right = @text_bitfield.right
@left = @text_bitfield.left
@keys = KeySchedule.sub_keys(@key)
end
it "should xor expanded right with the first key" do
@right.expand!
puts @keys[0].join(" ") # => 1 1 0 0 1 1 0 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 1 0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 0 1
@keys[0].should == [1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1] # => Fails
# fails here
@right.xor(BitField.new(@keys[0])).field.should == [1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment