From dd59f740e22a89a7963b793129a4448fc2cb3781 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 11 Jun 2024 12:47:34 -0500 Subject: [PATCH] Add Point#mul --- .../java/org/jruby/ext/openssl/PKeyEC.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/java/org/jruby/ext/openssl/PKeyEC.java b/src/main/java/org/jruby/ext/openssl/PKeyEC.java index 3294a858..ca7ff976 100644 --- a/src/main/java/org/jruby/ext/openssl/PKeyEC.java +++ b/src/main/java/org/jruby/ext/openssl/PKeyEC.java @@ -1073,6 +1073,32 @@ public IRubyObject inspect() { return ObjectSupport.inspect(this, (List) Collections.singletonList(entry)); } + @JRubyMethod(name = "add") + public IRubyObject add(final ThreadContext context, final IRubyObject other) { + Ruby runtime = context.runtime; + + org.bouncycastle.math.ec.ECPoint pointSelf, pointOther, pointResult; + + Group groupV = this.group; + Point result; + + ECCurve selfCurve = EC5Util.convertCurve(groupV.getCurve()); + pointSelf = EC5Util.convertPoint(selfCurve, asECPoint()); + + Point otherPoint = (Point) other; + ECCurve otherCurve = EC5Util.convertCurve(otherPoint.group.getCurve()); + pointOther = EC5Util.convertPoint(otherCurve, otherPoint.asECPoint()); + + pointResult = pointSelf.add(pointOther); + if (pointResult == null) { + newECError(runtime, "EC_POINT_add"); + } + + result = new Point(runtime, EC5Util.convertPoint(pointResult), group); + + return result; + } + @JRubyMethod(name = "mul", required = 1, optional = 2) public IRubyObject mul(final ThreadContext context, final IRubyObject[] args) { Ruby runtime = context.runtime;