Class: CryptoToolchain::Tools::RSABroadcastAttack

Inherits:
Object
  • Object
show all
Defined in:
lib/crypto_toolchain/tools/rsa_broadcast_attack.rb

Defined Under Namespace

Classes: Input

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inputs) ⇒ RSABroadcastAttack

Returns a new instance of RSABroadcastAttack.



5
6
7
8
# File 'lib/crypto_toolchain/tools/rsa_broadcast_attack.rb', line 5

def initialize(inputs)
  @e = inputs.length
  @inputs = inputs
end

Instance Attribute Details

#eObject (readonly)

Returns the value of attribute e.



9
10
11
# File 'lib/crypto_toolchain/tools/rsa_broadcast_attack.rb', line 9

def e
  @e
end

#inputsObject (readonly)

Returns the value of attribute inputs.



9
10
11
# File 'lib/crypto_toolchain/tools/rsa_broadcast_attack.rb', line 9

def inputs
  @inputs
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
# File 'lib/crypto_toolchain/tools/rsa_broadcast_attack.rb', line 11

def execute
  residues = inputs.map(&:ciphertext)
  mods = inputs.map {|i| i.public_key.n }
  result = chinese_remainder(residues, mods)
  result.root(e).
    to_s(16).
    from_hex
end