Class: Forgers::StreamCipher::ForgeGenerator
- Inherits:
-
Object
- Object
- Forgers::StreamCipher::ForgeGenerator
- Defined in:
- lib/crypto-toolbox/forgers/stream_ciphers/forge_generator.rb
Overview
This class generates a forged ciphertext that has been constructed to decipher to a specific and specified forged plaintext. It receives a observed orginal ciphertext c, its (partial or full) plaintext and the plaintext the attacker would like to have. It returns the ciphertext that correcponds to the forged message
Class Method Summary collapse
Instance Method Summary collapse
-
#forge(ciphertext, plaintext, target_plaintext) ⇒ Object
Create the xor of the two plaintext messages, that can also just be a part of the real message or have some pseudo padding for any unknown position finally xor that difference of the plaintexts at the correct position of the ciphertext.
Class Method Details
.forge(ciphertext, plaintext, target_plaintext) ⇒ Object
21 22 23 |
# File 'lib/crypto-toolbox/forgers/stream_ciphers/forge_generator.rb', line 21 def self.forge(ciphertext,plaintext,target_plaintext) new.forge(ciphertext,plaintext,target_plaintext) end |
Instance Method Details
#forge(ciphertext, plaintext, target_plaintext) ⇒ Object
Create the xor of the two plaintext messages, that can also just be a part of the real message or have some pseudo padding for any unknown position finally xor that difference of the plaintexts at the correct position of the ciphertext
15 16 17 18 19 |
# File 'lib/crypto-toolbox/forgers/stream_ciphers/forge_generator.rb', line 15 def forge(ciphertext,plaintext,target_plaintext) diff = CryptBuffer(plaintext).xor(target_plaintext) c = CryptBuffer.from_hex(ciphertext) c.xor(diff) end |