Module: CryptoToolchain::Tools::DetermineBlocksize

Included in:
EcbCutAndPasteAttack, EcbInterpolateChosenPlaintextAttack, EcbPrependChosenPlaintextAttack
Defined in:
lib/crypto_toolchain/tools/determine_blocksize.rb

Instance Method Summary collapse

Instance Method Details

#blocksizeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/crypto_toolchain/tools/determine_blocksize.rb', line 4

def blocksize
  return @blocksize if defined?(@blocksize)
  original_size = oracle.encrypt("A").length
  i = 2
  loop do
    plain = "A" * i
    len = oracle.encrypt(plain).length
    if len != original_size
      @blocksize = len - original_size
      return @blocksize
    end
    i += 1
  end
end