我使用Ruby 2.0.0 Openssl module作为我的加密/解密逻辑之一。它在我的Mac上完美运行,但是当我在我的企业SUSE服务器上使用相同的代码时,它会抛出以下错误。
irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> cipher = OpenSSL::Cipher.new 'AES-128-CBC'
=> #<OpenSSL::Cipher:0x007f240fb07888>
irb(main):003:0> cipher.encrypt
=> #<OpenSSL::Cipher:0x007f240fb07888>
irb(main):004:0> iv = cipher.random_iv
=> "\x84R\xCF\x97.\x17\xD1h2\xBB{6\xB8\"\xD1\xC5"
irb(main):005:0>
irb(main):006:0* pwd = 'some hopefully not to easily guessable password'
=> "some hopefully not to easily guessable password"
irb(main):007:0> salt = OpenSSL::Random.random_bytes 16
=> "#\xBCB\x05\xDE=\x83\xE8IOxR'\xBFRa"
irb(main):008:0> iter = 20000
=> 20000
irb(main):009:0> key_len = cipher.key_len
=> 16
irb(main):010:0> digest = OpenSSL::Digest::SHA256.new
=> #<OpenSSL::Digest::SHA256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>
irb(main):011:0>
irb(main):012:0* key = OpenSSL::PKCS5.pbkdf2_hmac(pwd, salt, iter, key_len, digest)
NotImplementedError: pbkdf2_hmac() function is unimplemented on this machine
from (irb):12:in `pbkdf2_hmac'
from (irb):12
提前致谢!
答案 0 :(得分:0)
您可能需要升级libssl。它一定不是最新的。 进一步了解:
PKCS5支持基于OpenSSL :: Digest :: SHA1的PBKDF2 HMAC,或任意Digest,如果是OpenSSL的底层版本 已经支持它(&gt; = 0.9.4)。