Class: CryptoToolchain::Tools::MD4LengthExtensionAttack
- Defined in:
- lib/crypto_toolchain/tools/md4_length_extension_attack.rb
Instance Attribute Summary collapse
-
#add ⇒ Object
readonly
Returns the value of attribute add.
-
#key_length ⇒ Object
readonly
Returns the value of attribute key_length.
-
#mac ⇒ Object
readonly
Returns the value of attribute mac.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(message:, add:, mac:, key_length:) ⇒ MD4LengthExtensionAttack
constructor
A new instance of MD4LengthExtensionAttack.
Constructor Details
#initialize(message:, add:, mac:, key_length:) ⇒ MD4LengthExtensionAttack
Returns a new instance of MD4LengthExtensionAttack.
5 6 7 8 9 10 |
# File 'lib/crypto_toolchain/tools/md4_length_extension_attack.rb', line 5 def initialize(message: , add: , mac: , key_length: ) @message = @mac = mac @add = add @key_length = key_length end |
Instance Attribute Details
#add ⇒ Object (readonly)
Returns the value of attribute add.
25 26 27 |
# File 'lib/crypto_toolchain/tools/md4_length_extension_attack.rb', line 25 def add @add end |
#key_length ⇒ Object (readonly)
Returns the value of attribute key_length.
25 26 27 |
# File 'lib/crypto_toolchain/tools/md4_length_extension_attack.rb', line 25 def key_length @key_length end |
#mac ⇒ Object (readonly)
Returns the value of attribute mac.
25 26 27 |
# File 'lib/crypto_toolchain/tools/md4_length_extension_attack.rb', line 25 def mac @mac end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
25 26 27 |
# File 'lib/crypto_toolchain/tools/md4_length_extension_attack.rb', line 25 def @message end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/crypto_toolchain/tools/md4_length_extension_attack.rb', line 13 def execute dummy_key = "A" * key_length padding = CryptoToolchain::Utilities::MD4.padding(dummy_key + ) [ + padding + add, CryptoToolchain::Utilities::MD4.hexdigest(add, state: mac, append_length: (padding + + dummy_key).length ) ] end |