class CryptoToolchain::BlackBoxes::EcbInterpolateChosenPlaintextOracle

Constants

MYSTERY_TEXT

Attributes

key[R]

Public Class Methods

new(key: String.random_bytes(16)) click to toggle source
# File lib/crypto_toolchain/black_boxes/ecb_interpolate_chosen_plaintext_oracle.rb, line 7
def initialize(key: String.random_bytes(16))
  @key = key
end

Public Instance Methods

encrypt(plaintext) click to toggle source
# File lib/crypto_toolchain/black_boxes/ecb_interpolate_chosen_plaintext_oracle.rb, line 11
def encrypt(plaintext)
  obfuscate(plaintext).encrypt_ecb(key: key, blocksize: 16)
end

Private Instance Methods

obfuscate(str) click to toggle source
# File lib/crypto_toolchain/black_boxes/ecb_interpolate_chosen_plaintext_oracle.rb, line 19
def obfuscate(str)
  "#{prefix}#{str}#{MYSTERY_TEXT.from_base64}"
end
prefix() click to toggle source
# File lib/crypto_toolchain/black_boxes/ecb_interpolate_chosen_plaintext_oracle.rb, line 23
def prefix
  @prefix ||= String.random_bytes(rand(1..64))
end