~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to ext/openssl/lib/openssl/cipher.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2006-07-13 22:43:47 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060713224347-zgeu5zwr4z6let68
Tags: 1.9.0+20060609-1
* new upstream snapshot. (2006-06-09)
* configure with -fno-strict-aliasing (Bug#370553)
* rdoc1.9 suggests graphviz (Bug#339524)
* debian/copyright: added a note for using libopenssl-ruby1.9.  (Bug#367024)
* debian/README.Debian: updated.  (Closes: #344294)
* added debian/patches/802_mkconfig.dpatch

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
  (See the file 'LICENCE'.)
12
12
 
13
13
= Version
14
 
  $Id: cipher.rb,v 1.2 2005/03/09 10:45:42 gotoyuzo Exp $
 
14
  $Id: cipher.rb,v 1.3 2006/05/08 00:11:59 gotoyuzo Exp $
15
15
=end
16
16
 
17
17
##
20
20
 
21
21
module OpenSSL
22
22
  module Cipher
23
 
    %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|cipher|
24
 
      eval(<<-EOD)
25
 
        class #{cipher} < Cipher
26
 
          def initialize(*args)
27
 
            args = args.join('-')
28
 
            if args.size == 0
29
 
              super(\"#{cipher}\")
30
 
            else
31
 
              super(\"#{cipher}-#\{args\}\")
32
 
            end
33
 
          end
34
 
        end
35
 
      EOD
 
23
    %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
 
24
      klass = Class.new(Cipher){
 
25
        define_method(:initialize){|*args|
 
26
          cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
 
27
          super(cipher_name)
 
28
        }
 
29
      }
 
30
      const_set(name, klass)
 
31
    }
 
32
 
 
33
    %w(128 192 256).each{|keylen|
 
34
      klass = Class.new(Cipher){
 
35
        define_method(:initialize){|mode|
 
36
          mode ||= "CBC"
 
37
          cipher_name = "AES-#{keylen}-#{mode}"
 
38
          super(cipher_name)
 
39
        }
 
40
      }
 
41
      const_set("AES#{keylen}", klass)
36
42
    }
37
43
 
38
44
    class Cipher