From 8e678a60978a4ba7742a8f28725e6bcf5c4e6884 Mon Sep 17 00:00:00 2001 From: technorama Date: Thu, 5 Apr 2007 05:59:22 +0000 Subject: * ext/openssl/ossl_pkcs5.c: New module. * ext/openssl/ossl_{cipher,digest,pkcs7,pkcs12}.c: Remove redundant module namespace. * ext/openssl/lib/openssl/{cipher,digest}.rb Add backwards compatibile classes for rearranged classes. * ext/openssl/ossl_{pkcs7,pkcs12}.c: Add documentation. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/lib/openssl/cipher.rb | 37 ++++++++++++++++++++----------------- ext/openssl/lib/openssl/digest.rb | 7 ++++++- 2 files changed, 26 insertions(+), 18 deletions(-) (limited to 'ext/openssl/lib') diff --git a/ext/openssl/lib/openssl/cipher.rb b/ext/openssl/lib/openssl/cipher.rb index 45cf6ac93..290e9c1d2 100644 --- a/ext/openssl/lib/openssl/cipher.rb +++ b/ext/openssl/lib/openssl/cipher.rb @@ -19,7 +19,7 @@ #require 'openssl' module OpenSSL - module Cipher + class Cipher %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name| klass = Class.new(Cipher){ define_method(:initialize){|*args| @@ -41,22 +41,25 @@ module OpenSSL const_set("AES#{keylen}", klass) } - class Cipher - # Generate, set, and return a random key. - # You must call cipher.encrypt or cipher.decrypt before calling this method. - def random_key - str = OpenSSL::Random.random_bytes(self.key_len) - self.key = str - return str - end - - # Generate, set, and return a random iv. - # You must call cipher.encrypt or cipher.decrypt before calling this method. - def random_iv - str = OpenSSL::Random.random_bytes(self.iv_len) - self.iv = str - return str - end + # Generate, set, and return a random key. + # You must call cipher.encrypt or cipher.decrypt before calling this method. + def random_key + str = OpenSSL::Random.random_bytes(self.key_len) + self.key = str + return str + end + + # Generate, set, and return a random iv. + # You must call cipher.encrypt or cipher.decrypt before calling this method. + def random_iv + str = OpenSSL::Random.random_bytes(self.iv_len) + self.iv = str + return str + end + + # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future. + class Cipher < Cipher + # add warning end end # Cipher end # OpenSSL diff --git a/ext/openssl/lib/openssl/digest.rb b/ext/openssl/lib/openssl/digest.rb index b3e448480..8d7df73b5 100644 --- a/ext/openssl/lib/openssl/digest.rb +++ b/ext/openssl/lib/openssl/digest.rb @@ -19,7 +19,7 @@ #require 'openssl' module OpenSSL - module Digest + class Digest alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1) if OPENSSL_VERSION_NUMBER > 0x00908000 @@ -44,6 +44,11 @@ module OpenSSL const_set(name, klass) } + # This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future. + class Digest < Digest + # add warning + end + end # Digest end # OpenSSL -- cgit