crypto-toolbox 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f9b9033bbd39aad71fa0a549e3af7e8b8c8b997
|
4
|
+
data.tar.gz: f9e59d8234a4acb4a123d7ca7e83f7cb638acae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff3d96493b71d4a8cd6c4fa2b5f048cc5c3b04f0b03f51d14914173dd85587dd0f02e0f0e257917b54f19bcbd4380992fe2afd5a5b28cb0bbe4d144df7eb7faf
|
7
|
+
data.tar.gz: 8be45f26f5ca4ad275161df8166ff14727c4f1c5d5277a5ac4113ad1a9560bef5ceeb8ff45ab801f70a7da2e9568f65747007737c3d6d3785def1da6f792170a
|
data/lib/crypto-toolbox.rb
CHANGED
@@ -17,4 +17,7 @@ require 'crypto-toolbox/ciphers/aes.rb'
|
|
17
17
|
require 'crypto-toolbox/ciphers/caesar.rb'
|
18
18
|
require 'crypto-toolbox/ciphers/rot13.rb'
|
19
19
|
|
20
|
+
|
21
|
+
require 'crypto-toolbox/forgers/stream_ciphers/forge_generator.rb'
|
22
|
+
|
20
23
|
require 'crypto-toolbox/crypto_challanges/solver.rb'
|
@@ -5,13 +5,13 @@ module Ciphers
|
|
5
5
|
@cipher = OpenSSL::Cipher::AES.new(keysize,mode)
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
8
|
+
def decipher_ecb(input,key)
|
9
9
|
@cipher.decrypt
|
10
10
|
@cipher.key = key
|
11
11
|
(@cipher.update(input) + @cipher.final)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def encipher_ecb(input,key)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module Forgers
|
3
|
+
module StreamCipher
|
4
|
+
# This class generates a forged ciphertext that has been constructed
|
5
|
+
# to decipher to a specific and specified forged plaintext.
|
6
|
+
# It receives a observed orginal ciphertext c, its (partial or full) plaintext
|
7
|
+
# and the plaintext the attacker would like to have.
|
8
|
+
# It returns the ciphertext that correcponds to the forged message
|
9
|
+
class ForgeGenerator
|
10
|
+
|
11
|
+
# Create the xor of the two plaintext messages, that can also just be a
|
12
|
+
# part of the real message or have some pseudo padding for any unknown position
|
13
|
+
# finally xor that difference of the plaintexts at the correct position of the
|
14
|
+
# ciphertext
|
15
|
+
def forge(ciphertext,plaintext,target_plaintext)
|
16
|
+
diff = CryptBuffer(plaintext).xor(target_plaintext)
|
17
|
+
c = CryptBuffer.from_hex(ciphertext)
|
18
|
+
c.xor(diff)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.forge(ciphertext,plaintext,target_plaintext)
|
22
|
+
new.forge(ciphertext,plaintext,target_plaintext)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crypto-toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Sivia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aes
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/crypto-toolbox/crypt_buffer/concerns/xor.rb
|
82
82
|
- lib/crypto-toolbox/crypt_buffer_input_converter.rb
|
83
83
|
- lib/crypto-toolbox/crypto_challanges/solver.rb
|
84
|
+
- lib/crypto-toolbox/forgers/stream_ciphers/forge_generator.rb
|
84
85
|
- lib/crypto-toolbox/utils/reporting/console.rb
|
85
86
|
homepage: https://github.com/scepticulous/crypto-toolbox
|
86
87
|
licenses:
|