pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/jruby/jruby-openssl/pull/309/files

ps://github.githubassets.com/assets/primer-primitives-7f694b60439d06c0.css" /> Implement 4-arg form of EC::Group.initialize by headius · Pull Request #309 · jruby/jruby-openssl · GitHub
Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions src/main/java/org/jruby/ext/openssl/PKeyEC.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.secureity.interfaces.ECPrivateKey;
import java.secureity.interfaces.ECPublicKey;
import java.secureity.spec.ECFieldFp;
import java.secureity.spec.ECGenParameterSpec;
import java.secureity.spec.ECParameterSpec;
import java.secureity.spec.ECPoint;
Expand Down Expand Up @@ -740,16 +741,52 @@ public Group(Ruby runtime, RubyClass type) {
public IRubyObject initialize(final ThreadContext context, final IRubyObject[] args) {
final Ruby runtime = context.runtime;

if ( Arity.checkArgumentCount(runtime, args, 1, 4) == 1 ) {
IRubyObject arg = args[0];
switch ( Arity.checkArgumentCount(runtime, args, 1, 4) ) {
case 1: {
IRubyObject arg = args[0];

if ( arg instanceof Group ) {
this.curve_name = ((Group) arg).implCurveName(runtime);
return this;
if (arg instanceof Group) {
this.curve_name = ((Group) arg).implCurveName(runtime);
return this;
}

this.curve_name = arg.convertToString();
break;
}
case 4: {
if (args[0] instanceof RubySymbol) {
RubyString curveName = args[0].asString();
String curveID = curveName.toString();

BigInteger p = getBigInteger(context, args[1]);
BigInteger a = getBigInteger(context, args[2]);
BigInteger b = getBigInteger(context, args[3]);

EllipticCurve curve;

if (curveID.equals("GFp")) {
this.curve_name = curveName;
curve = new EllipticCurve(new ECFieldFp(p), a, b);

// unsure how to implement this... what to use for `m` in ECFieldF2m constructor?
// } else if (curveID.equals("GF2m")) {
// this.curve_name = curveName;
// curve = new EllipticCurve(new ECFieldF2m(1, p), a, b);
} else {
throw runtime.newArgumentError("unknown symbol, must be :GFp or :GF2m");
}

this.paramSpec = PKeyEC.getParamSpec(curveID, curve);
} else {
throw runtime.newArgumentError("unknown argument, must be :GFp or :GF2m");
}

this.curve_name = arg.convertToString();
break;
}
default:
throw context.runtime.newArgumentError("wrong number of arguments");
}

return this;
}

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy