crypto-toolbox 0.2.4 → 0.2.5
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 +4 -4
 - data/lib/crypto-toolbox/analyzers/cbc_mac/variable_length/oracles/tcp.rb +12 -4
 - data/lib/crypto-toolbox/analyzers/utils/spell_checker.rb +3 -3
 - data/lib/crypto-toolbox/crypt_buffer/concerns/padding.rb +1 -0
 - data/lib/crypto-toolbox/crypto_challanges/solver.rb +12 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6b4aeddf63a07920d3d86fb7e0414657b9760105
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 14d41f8ef3a8180a7345b0ebfdc50aed896dde6a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c76e3531f39e618e8d73c23fa889ea1e0669dd6a8c05103f90ea31f197ba11955cfbe71606f534cc18899b0fd692a5b9d3f8d14e4c85668da28fe21d0c41348c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 36b518c0a99a911a205b2e5c29c12f7a9bbed101f0425e19b083acb9c6ada9d2623d4aa8a132acc5bf95959979886196f8e895f4bd526b221bdf1ddaf31ba880
         
     | 
| 
         @@ -25,7 +25,7 @@ module Analyzers 
     | 
|
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                      def mac(message)
         
     | 
| 
       27 
27 
     | 
    
         
             
                        connect unless @mac_socket
         
     | 
| 
       28 
     | 
    
         
            -
                        packet = ( 
     | 
| 
      
 28 
     | 
    
         
            +
                        packet = assemble_mac_message(message)
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                        @mac_socket.write(packet)
         
     | 
| 
       31 
31 
     | 
    
         
             
                        @mac_socket.read(16)
         
     | 
| 
         @@ -34,15 +34,23 @@ module Analyzers 
     | 
|
| 
       34 
34 
     | 
    
         
             
                      def verify(message,tag)
         
     | 
| 
       35 
35 
     | 
    
         
             
                        connect unless @verify_socket
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                         
     | 
| 
       38 
     | 
    
         
            -
                        # NOTE: check why chars instead of bytes.map does not work here
         
     | 
| 
       39 
     | 
    
         
            -
                        packet = (message.length.to_crypt_buffer + message + tag.split("") + [0] ).bytes.map(&:chr).join("")
         
     | 
| 
      
 37 
     | 
    
         
            +
                        packet = assemble_verify_message(message,tag)
         
     | 
| 
       40 
38 
     | 
    
         | 
| 
       41 
39 
     | 
    
         
             
                        @verify_socket.write(packet)
         
     | 
| 
       42 
40 
     | 
    
         
             
                        @verify_socket.read(2).to_i
         
     | 
| 
       43 
41 
     | 
    
         
             
                      end
         
     | 
| 
       44 
42 
     | 
    
         | 
| 
      
 43 
     | 
    
         
            +
            	  private
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                      # Message-length + message-chars + tag-chars + 0
         
     | 
| 
      
 46 
     | 
    
         
            +
                      # NOTE: check why chars instead of bytes.map does not work here
         
     | 
| 
      
 47 
     | 
    
         
            +
            	  def assemble_verify_message(message,tag)
         
     | 
| 
      
 48 
     | 
    
         
            +
                        (message.length.to_crypt_buffer + message + tag.split("") + [0] ).str
         
     | 
| 
      
 49 
     | 
    
         
            +
            	  end
         
     | 
| 
       45 
50 
     | 
    
         | 
| 
      
 51 
     | 
    
         
            +
            	  def assemble_mac_message(message)
         
     | 
| 
      
 52 
     | 
    
         
            +
                        ( message.length.to_crypt_buffer + message + [0] ).str
         
     | 
| 
      
 53 
     | 
    
         
            +
            	  end
         
     | 
| 
       46 
54 
     | 
    
         
             
                    end
         
     | 
| 
       47 
55 
     | 
    
         
             
                  end
         
     | 
| 
       48 
56 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'ffi/hunspell'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'ffi/aspell'
         
     | 
| 
      
 2 
     | 
    
         
            +
            #require 'ffi/aspell'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            module Analyzers
         
     | 
| 
       5 
5 
     | 
    
         
             
              module Utils
         
     | 
| 
         @@ -7,7 +7,7 @@ module Analyzers 
     | 
|
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(dict_lang="en_US")
         
     | 
| 
       9 
9 
     | 
    
         
             
                    @dict = FFI::Hunspell.dict(dict_lang)
         
     | 
| 
       10 
     | 
    
         
            -
                    @dict2 = FFI::Aspell::Speller.new(dict_lang)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    # @dict2 = FFI::Aspell::Speller.new(dict_lang)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  end
         
     | 
| 
       12 
12 
     | 
    
         
             
            =begin
         
     | 
| 
       13 
13 
     | 
    
         
             
            NOTE: About spelling error rates and language detection:
         
     | 
| 
         @@ -76,7 +76,7 @@ if numbers or single char words are taken into account 
     | 
|
| 
       76 
76 
     | 
    
         
             
                  # which makes it slower than hunspell.
         
     | 
| 
       77 
77 
     | 
    
         
             
                  # Thus we stick with hunspell for correctness and speed.
         
     | 
| 
       78 
78 
     | 
    
         
             
                  def check?(input)
         
     | 
| 
       79 
     | 
    
         
            -
                    @dict.check?(input)
         
     | 
| 
      
 79 
     | 
    
         
            +
                    @dict.check?(input) rescue false
         
     | 
| 
       80 
80 
     | 
    
         
             
                    # @dict2.correct?(input.gsub(/[^a-zA-Z]/,""))
         
     | 
| 
       81 
81 
     | 
    
         
             
                  end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
         @@ -44,7 +44,18 @@ module CryptoChallanges 
     | 
|
| 
       44 
44 
     | 
    
         
             
                end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
                def solve8(ciphers)
         
     | 
| 
       47 
     | 
    
         
            -
                   
     | 
| 
      
 47 
     | 
    
         
            +
                  ciphers.map.with_index do |c,i|
         
     | 
| 
      
 48 
     | 
    
         
            +
                    if c.chunks_of(16).map(&:bytes).uniq.length < c.chunks_of(16).length
         
     | 
| 
      
 49 
     | 
    
         
            +
                      [i,c]
         
     | 
| 
      
 50 
     | 
    
         
            +
                    else
         
     | 
| 
      
 51 
     | 
    
         
            +
                      nil
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end
         
     | 
| 
      
 53 
     | 
    
         
            +
                    # only resturn the first none nil value => compact.first
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end.compact.first
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                def solve9(input)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  CryptBuffer(input).pad(4).str
         
     | 
| 
       48 
59 
     | 
    
         
             
                end
         
     | 
| 
       49 
60 
     | 
    
         
             
              end
         
     | 
| 
       50 
61 
     | 
    
         
             
            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.5
         
     | 
| 
       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-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: aes
         
     |