{"action":"created","issue":{"url":"https://api.github.com/repos/jruby/jruby/issues/931","labels_url":"https://api.github.com/repos/jruby/jruby/issues/931/labels{/name}","comments_url":"https://api.github.com/repos/jruby/jruby/issues/931/comments","events_url":"https://api.github.com/repos/jruby/jruby/issues/931/events","html_url":"https://github.com/jruby/jruby/issues/931","id":17465880,"number":931,"title":"Cipher \"des-ede\" working differently between JRuby and MRI","user":{"login":"andrenpaes","id":306982,"avatar_url":"https://avatars.githubusercontent.com/u/306982?v=3","gravatar_id":"","url":"https://api.github.com/users/andrenpaes","html_url":"https://github.com/andrenpaes","followers_url":"https://api.github.com/users/andrenpaes/followers","following_url":"https://api.github.com/users/andrenpaes/following{/other_user}","gists_url":"https://api.github.com/users/andrenpaes/gists{/gist_id}","starred_url":"https://api.github.com/users/andrenpaes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrenpaes/subscriptions","organizations_url":"https://api.github.com/users/andrenpaes/orgs","repos_url":"https://api.github.com/users/andrenpaes/repos","events_url":"https://api.github.com/users/andrenpaes/events{/privacy}","received_events_url":"https://api.github.com/users/andrenpaes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jruby/jruby/labels/openssl","name":"openssl","color":"e102d8"},{"url":"https://api.github.com/repos/jruby/jruby/labels/stdlib","name":"stdlib","color":"d7e102"}],"state":"closed","locked":false,"assignee":{"login":"kares","id":45967,"avatar_url":"https://avatars.githubusercontent.com/u/45967?v=3","gravatar_id":"","url":"https://api.github.com/users/kares","html_url":"https://github.com/kares","followers_url":"https://api.github.com/users/kares/followers","following_url":"https://api.github.com/users/kares/following{/other_user}","gists_url":"https://api.github.com/users/kares/gists{/gist_id}","starred_url":"https://api.github.com/users/kares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kares/subscriptions","organizations_url":"https://api.github.com/users/kares/orgs","repos_url":"https://api.github.com/users/kares/repos","events_url":"https://api.github.com/users/kares/events{/privacy}","received_events_url":"https://api.github.com/users/kares/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2013-07-31T17:46:22Z","updated_at":"2015-04-10T10:56:19Z","closed_at":"2015-04-10T10:56:19Z","body":"I'm facing a problem trying to decrypt some data using JRuby. I'm using the 'des-ede' cipher with no padding. The code works fine in MRI.\r\n\r\nHere's an example:\r\n```ruby\r\nrequire 'openssl'\r\nrequire 'base64'\r\n\r\nstr = 'helloooo'\r\nkey = \"WVqcvjGqaD7XBVBlXYbJYw==\\n\"\r\n\r\n%w(des-ede des-ecb des-cbc).each do |cipher_method|\r\n  des = OpenSSL::Cipher::Cipher.new(cipher_method)\r\n  des.encrypt\r\n  des.key = Base64.decode64(key)\r\n  des.padding = 0\r\n  data = des.update(str) + des.final\r\n  enc = Base64.encode64(data)\r\n\r\n  des = OpenSSL::Cipher::Cipher.new(cipher_method)\r\n  des.decrypt\r\n  des.key = Base64.decode64(key)\r\n  des.padding = 0\r\n  dec = des.update(Base64.decode64(enc)) + des.final\r\n\r\n  puts cipher_method\r\n  puts \"'#{str}'\"\r\n  puts \"'#{enc}'\"\r\n  puts \"'#{dec}'\"\r\n  puts '------------'\r\nend\r\n```\r\n\r\nHere's the output in JRuby (1.7.[3,4]):\r\n```\r\n$ jruby des-ede_test.rb \r\ndes-ede\r\n'helloooo'\r\n'Nm3bZL1NQug=\r\n'\r\n'helloooo'\r\n------------\r\ndes-ecb\r\n'helloooo'\r\n'Nm3bZL1NQug=\r\n'\r\n'helloooo'\r\n------------\r\ndes-cbc\r\n'helloooo'\r\n'Nm3bZL1NQug=\r\n'\r\n'helloooo'\r\n------------\r\n```\r\nHere's the output in MRI (1.9.2-p290 and ruby 1.9.3p327):\r\n```\r\ndes-ede\r\n'helloooo'\r\n'7r9gHRoTpGs=\r\n'\r\n'helloooo'\r\n------------\r\ndes-ecb\r\n'helloooo'\r\n'Nm3bZL1NQug=\r\n'\r\n'helloooo'\r\n------------\r\ndes-cbc\r\n'helloooo'\r\n'Nm3bZL1NQug=\r\n'\r\n'helloooo'\r\n------------\r\n```\r\n\r\nIs this a problem, or is it not possible to use 'des-ede' on JRuby? It seems weird that des-ede has the same output of des-cbc\r\nHere's the description from 'des-ede' in OpenSSL: Two key triple DES EDE in ECB mode\r\n"},"comment":{"url":"https://api.github.com/repos/jruby/jruby/issues/comments/91515234","html_url":"https://github.com/jruby/jruby/issues/931#issuecomment-91515234","issue_url":"https://api.github.com/repos/jruby/jruby/issues/931","id":91515234,"user":{"login":"kares","id":45967,"avatar_url":"https://avatars.githubusercontent.com/u/45967?v=3","gravatar_id":"","url":"https://api.github.com/users/kares","html_url":"https://github.com/kares","followers_url":"https://api.github.com/users/kares/followers","following_url":"https://api.github.com/users/kares/following{/other_user}","gists_url":"https://api.github.com/users/kares/gists{/gist_id}","starred_url":"https://api.github.com/users/kares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kares/subscriptions","organizations_url":"https://api.github.com/users/kares/orgs","repos_url":"https://api.github.com/users/kares/repos","events_url":"https://api.github.com/users/kares/events{/privacy}","received_events_url":"https://api.github.com/users/kares/received_events","type":"User","site_admin":false},"created_at":"2015-04-10T10:56:19Z","updated_at":"2015-04-10T10:56:19Z","body":"should be fine on jruby-openssl master (expected to land in 0.9.7), you can test a \"snapshot\" gem from https://oss.sonatype.org/content/repositories/snapshots/rubygems/jruby-openssl/0.9.7.dev-SNAPSHOT/ just make sure it's a snapshot released after *Apr 08 2015*"}}