Skip to content

Commit 7ca8743

Browse files
committed
[refactor] EC (field) bit length internal helper
1 parent 7ea9e50 commit 7ca8743

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main/java/org/jruby/ext/openssl/PKeyEC.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,10 @@ EllipticCurve getCurve() {
841841
return getParamSpec().getCurve();
842842
}
843843

844+
int getBitLength() {
845+
return getParamSpec().getOrder().bitLength();
846+
}
847+
844848
@JRubyMethod
845849
public RubySymbol point_conversion_form(final ThreadContext context) {
846850
return context.runtime.newSymbol(this.conversionForm.toRubyString());
@@ -900,7 +904,6 @@ public Point(Ruby runtime, RubyClass type) {
900904
}
901905

902906
private ECPoint point;
903-
//private int bitLength;
904907
private Group group;
905908

906909
Point(Ruby runtime, ECPublicKey publicKey, Group group) {
@@ -978,11 +981,6 @@ private ECPoint asECPoint() {
978981
return point; // return publicKey.getW();
979982
}
980983

981-
private int bitLength() {
982-
assert group != null;
983-
return group.getParamSpec().getOrder().bitLength();
984-
}
985-
986984
private PointConversion getPointConversionForm() {
987985
if (group == null) return null;
988986
return group.conversionForm;
@@ -1007,7 +1005,8 @@ private byte[] encodePoint(final PointConversion conversionForm) {
10071005
final byte[] encoded;
10081006
switch (conversionForm) {
10091007
case UNCOMPRESSED:
1010-
encoded = encodeUncompressed(bitLength(), point);
1008+
assert group != null;
1009+
encoded = encodeUncompressed(group.getBitLength(), point);
10111010
break;
10121011
case COMPRESSED:
10131012
encoded = encodeCompressed(point);

0 commit comments

Comments
 (0)