0
有這個Ruby代碼:紅寶石OpenSSL的錯誤時嘗試解密用鑰匙假RSA私鑰
require 'openssl'
require 'securerandom'
class AuthRsa
def initialize(public_key, private_key)
@public_key = OpenSSL::PKey::RSA.new(public_key)
@private_key = OpenSSL::PKey::RSA.new(private_key)
@key = SecureRandom.base64(16)
end
def valid?
crypt_key = @public_key.public_encrypt(@key)
return @key == @private_key.private_decrypt(crypt_key)
end
end
當測試與正確的公鑰和私鑰類是一切ok,但是當提交僞造證書測試失敗,出現此錯誤:OpenSSL :: PKey :: RSA錯誤:填充檢查失敗
是否可以將private_decrypt方法設置爲返回false而不是錯誤?
謝謝,現在的作品,希望誤差僅與假的。質子交換膜和不理他,不影響安全? – byterussian