From 72cdb4a536100eaad978f03fb026a76fceba343c Mon Sep 17 00:00:00 2001 From: Joao Fernandes Date: Wed, 17 Jan 2024 11:00:55 +0000 Subject: [PATCH] No need to keep checking RUBY_ENGINE --- lib/rack/session/encryptor.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/rack/session/encryptor.rb b/lib/rack/session/encryptor.rb index 565c5df..a7f041a 100644 --- a/lib/rack/session/encryptor.rb +++ b/lib/rack/session/encryptor.rb @@ -328,15 +328,17 @@ def set_cipher_key(cipher, key) cipher.key = key end - def auth_tag_from(cipher) - if RUBY_ENGINE == 'jruby' - # JRuby's OpenSSL implementation doesn't currently support passing - # an argument to #auth_tag. Here we work around that. + if RUBY_ENGINE == 'jruby' + # JRuby's OpenSSL implementation doesn't currently support passing + # an argument to #auth_tag. Here we work around that. + def auth_tag_from(cipher) tag = cipher.auth_tag raise Error, 'the auth tag must be 16 bytes long' if tag.bytesize != 16 tag - else + end + else + def auth_tag_from(cipher) cipher.auth_tag(16) end end