Skip to content

Commit

Permalink
cipher: use lower-case cipher name in OpenSSL::Cipher::*.new
Browse files Browse the repository at this point in the history
AES-GCM ciphers don't have upper-case sn.
  • Loading branch information
rhenium committed Jul 24, 2016
1 parent c0548c9 commit 2ed10db
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/openssl/cipher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ class Cipher
klass = Class.new(Cipher){
define_method(:initialize){|*args|
cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
super(cipher_name)
super(cipher_name.downcase)
}
}
const_set(name, klass)
}

%w(128 192 256).each{|keylen|
klass = Class.new(Cipher){
define_method(:initialize){|mode|
mode ||= "CBC"
cipher_name = "AES-#{keylen}-#{mode}"
super(cipher_name)
define_method(:initialize){|mode = "CBC"|
super("aes-#{keylen}-#{mode}".downcase)
}
}
const_set("AES#{keylen}", klass)
Expand Down

0 comments on commit 2ed10db

Please sign in to comment.