From 888eb192536345fbad41685957acab399804ee54 Mon Sep 17 00:00:00 2001 From: kares Date: Fri, 13 Dec 2024 14:57:03 +0100 Subject: [PATCH] [refactor] move _compat23.rb left-overs to native --- lib/jopenssl/_compat23.rb | 30 ------------------- lib/jopenssl/load.rb | 2 -- .../java/org/jruby/ext/openssl/PKeyDH.java | 17 +++++++++++ 3 files changed, 17 insertions(+), 32 deletions(-) delete mode 100644 lib/jopenssl/_compat23.rb diff --git a/lib/jopenssl/_compat23.rb b/lib/jopenssl/_compat23.rb deleted file mode 100644 index f2a61c29..00000000 --- a/lib/jopenssl/_compat23.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: false - -module OpenSSL - - module PKey - - class DH - - def set_key(pub_key, priv_key) - self.pub_key = pub_key - self.priv_key = priv_key - self - end - - def set_pqg(p, q, g) - self.p = p - if respond_to?(:q=) - self.q = q - else - OpenSSL.warn "JRuby-OpenSSL does not support setting q param on #{inspect}" if q - end - self.g = g - self - end - - end - - end - -end diff --git a/lib/jopenssl/load.rb b/lib/jopenssl/load.rb index 9fae0dda..6d38b8a7 100644 --- a/lib/jopenssl/load.rb +++ b/lib/jopenssl/load.rb @@ -69,5 +69,3 @@ def self.secure_compare(a, b) OpenSSL.fixed_length_secure_compare(hashed_a, hashed_b) && a == b end end - -load 'jopenssl/_compat23.rb' diff --git a/src/main/java/org/jruby/ext/openssl/PKeyDH.java b/src/main/java/org/jruby/ext/openssl/PKeyDH.java index df88cae8..159ef832 100644 --- a/src/main/java/org/jruby/ext/openssl/PKeyDH.java +++ b/src/main/java/org/jruby/ext/openssl/PKeyDH.java @@ -381,6 +381,16 @@ public IRubyObject q(final ThreadContext context) { return context.nil; } + @JRubyMethod + public IRubyObject set_pqg(final ThreadContext context, IRubyObject p, IRubyObject q, IRubyObject g) { + set_p(p); + if (!q.isNil()) { + OpenSSL.warn(context, "JRuby-OpenSSL does not support setting q param on " + inspect()); + } + set_g(g); + return this; + } + // don't need synchronized as value is volatile @JRubyMethod(name = "pub_key") public IRubyObject pub_key() { @@ -421,6 +431,13 @@ public synchronized IRubyObject set_priv_key(IRubyObject arg) { return arg; } + @JRubyMethod + public IRubyObject set_key(final ThreadContext context, IRubyObject pub_key, IRubyObject priv_key) { + set_pub_key(pub_key); + set_priv_key(priv_key); + return this; + } + private IRubyObject newBN(BigInteger value) { if (value == null) return getRuntime().getNil(); return BN.newBN(getRuntime(), value);