From 53901e5e17b4e566477642ae0914ca78ed893050 Mon Sep 17 00:00:00 2001 From: kares Date: Fri, 13 Dec 2024 14:49:37 +0100 Subject: [PATCH] [fix] DSA private key should generate after set_key --- lib/jopenssl/_compat23.rb | 10 ---------- src/main/java/org/jruby/ext/openssl/PKeyDSA.java | 8 ++++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/jopenssl/_compat23.rb b/lib/jopenssl/_compat23.rb index 978a8ce0..f2a61c29 100644 --- a/lib/jopenssl/_compat23.rb +++ b/lib/jopenssl/_compat23.rb @@ -25,16 +25,6 @@ def set_pqg(p, q, g) end - class DSA - - def set_key(pub_key, priv_key) - self.pub_key = pub_key - self.priv_key = priv_key - self - end - - end - end end diff --git a/src/main/java/org/jruby/ext/openssl/PKeyDSA.java b/src/main/java/org/jruby/ext/openssl/PKeyDSA.java index 53acd197..aebd1e68 100644 --- a/src/main/java/org/jruby/ext/openssl/PKeyDSA.java +++ b/src/main/java/org/jruby/ext/openssl/PKeyDSA.java @@ -512,6 +512,14 @@ public IRubyObject set_pqg(IRubyObject p, IRubyObject q, IRubyObject g) { return this; } + @JRubyMethod + public IRubyObject set_key(final ThreadContext context, IRubyObject pub_key, IRubyObject priv_key) { + this.dsa_y = BN.getBigInteger(pub_key); + this.dsa_x = BN.getBigInteger(priv_key); + generateKeyInternal(); + return this; + } + @JRubyMethod(name = "priv_key") public synchronized IRubyObject get_priv_key() { DSAPrivateKey key;