crypto-toolbox 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86f8571212724c4325fba91efd1b781af0f2397c
4
- data.tar.gz: 5a418ad3b0eb7eb3e653f4788c5272fdc339cc2c
3
+ metadata.gz: 0f9b9033bbd39aad71fa0a549e3af7e8b8c8b997
4
+ data.tar.gz: f9e59d8234a4acb4a123d7ca7e83f7cb638acae4
5
5
  SHA512:
6
- metadata.gz: 03272a1b10a23da115f9a2ff84010a4e30b62313037ab34d56e16596a77afc64c6b89b635fc0ca48f5031647cc2648a433932186f8dee21d7097abe512e3d1b5
7
- data.tar.gz: f5d4fd7146c99b5da0fdd6d1d08335cbaa4cc063f228eaef3f0d9f0735375d1974a868987c398f612a9440249a4956b7e38ffde0ba158cb1e61b00fca41aba44
6
+ metadata.gz: ff3d96493b71d4a8cd6c4fa2b5f048cc5c3b04f0b03f51d14914173dd85587dd0f02e0f0e257917b54f19bcbd4380992fe2afd5a5b28cb0bbe4d144df7eb7faf
7
+ data.tar.gz: 8be45f26f5ca4ad275161df8166ff14727c4f1c5d5277a5ac4113ad1a9560bef5ceeb8ff45ab801f70a7da2e9568f65747007737c3d6d3785def1da6f792170a
@@ -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 decipher(input,key)
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 encipher(input,key)
14
+ def encipher_ecb(input,key)
15
15
  end
16
16
  end
17
17
  end
@@ -50,7 +50,7 @@ module CryptoChallanges
50
50
 
51
51
  def solve7(input,key)
52
52
  data = CryptBuffer.from_base64(input).str
53
- Ciphers::Aes.new(128,:ECB).decipher(data,key)
53
+ Ciphers::Aes.new(128,:ECB).decipher_ecb(data,key)
54
54
  end
55
55
 
56
56
  def solve8(ciphers)
@@ -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.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-14 00:00:00.000000000 Z
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: