File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -302,7 +302,7 @@ def encrypt(message)
302302 encrypted_data = cipher . update ( serialized_payload ) << cipher . final
303303
304304 data << cipher_iv
305- data << cipher . auth_tag ( 16 )
305+ data << auth_tag_from ( cipher )
306306 data << encrypted_data
307307
308308 Base64 . strict_encode64 ( data )
@@ -327,6 +327,21 @@ def message_secret_from_salt(salt)
327327 def set_cipher_key ( cipher , key )
328328 cipher . key = key
329329 end
330+
331+ if RUBY_ENGINE == 'jruby'
332+ # JRuby's OpenSSL implementation doesn't currently support passing
333+ # an argument to #auth_tag. Here we work around that.
334+ def auth_tag_from ( cipher )
335+ tag = cipher . auth_tag
336+ raise Error , 'the auth tag must be 16 bytes long' if tag . bytesize != 16
337+
338+ tag
339+ end
340+ else
341+ def auth_tag_from ( cipher )
342+ cipher . auth_tag ( 16 )
343+ end
344+ end
330345 end
331346
332347 def initialize ( secret , opts = { } )
You can’t perform that action at this time.
0 commit comments