加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Ruby – 不支持的密码算法(AES-256-GCM)

发布时间:2020-12-16 23:10:38 所属栏目:百科 来源:网络整理
导读:我收到错误: unsupported cipher algorithm (AES-256-GCM) (RuntimeError) 但我似乎有所有要求: Ruby版本: $ruby –version ruby 2.1.2p95 OpenSSL确实列出了gcm: $openssl enc -help 21 | grep gcm -aes-128-ecb -aes-128-gcm -aes-128-ofb -aes-192-ec
我收到错误:

unsupported cipher algorithm (AES-256-GCM) (RuntimeError)

但我似乎有所有要求:

Ruby版本:

$ruby –version

ruby 2.1.2p95

OpenSSL确实列出了gcm:

$openssl enc -help 2>&1 | grep gcm

-aes-128-ecb -aes-128-gcm -aes-128-ofb
-aes-192-ecb -aes-192-gcm -aes-192-ofb
-aes-256-ecb -aes-256-gcm -aes-256-ofb

Ruby解释器:

$irb

2.1.2 :001 > require ‘openssl’; puts OpenSSL::VERSION

1.1.0

=> nil

2.1.2 :002 > OpenSSL::Cipher.ciphers.include? “aes-128-gcm”

=> true

但是我在运行这个code时遇到错误:

2.1.2 :001 > require 'openssl'
 => true 
2.1.2 :002 > cipher = OpenSSL::Cipher::AES.new(128,:GCM)
RuntimeError: unsupported cipher algorithm (AES-128-GCM)
    from /home/m/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/cipher.rb:27:in `initialize'
    from /home/m/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/cipher.rb:27:in `block (3 levels) in <class:Cipher>'
    from (irb):2:in `new'
    from (irb):2
    from /home/m/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>'

如何让GCM在ruby中工作?

解决方法

对我有用的是
OpenSSL::Cipher.new('aes-128-gcm')

我不确定为什么你的方法会出错.

编辑:

这可能是一个大/小写的问题.这可能是一个真正的错误.

以下作品:

OpenSSL::Cipher::AES.new(128,:CBC)

因为我们在OpenSSL :: Cipher :: AES.ciphers中找到“AES-128-CBC”(全部大写). AES.new似乎用大写字符搜索其密码.

因此,以下不起作用:

OpenSSL::Cipher::AES.new(128,:GCM)

因为它在密码列表中是“aes-128-gcm”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读