@@ -785,18 +785,16 @@ public RubyString to_text() {
785
785
final ECParameterSpec spec = getParamSpec ();
786
786
result .append ("Private-Key: (" ).append (spec .getOrder ().bitLength ()).append (" bit)" ).append ('\n' );
787
787
788
- if (privateKey != null ) {
788
+ if (privateKey instanceof ECPrivateKey ) {
789
789
result .append ("priv:" );
790
790
addSplittedAndFormatted (result , ((ECPrivateKey ) privateKey ).getS ());
791
791
}
792
792
793
793
if (publicKey != null ) {
794
794
result .append ("pub:" );
795
- final byte [] pubBytes = encodeUncompressed ( getGroup ( true ). getBitLength (), publicKey .getW ());
795
+ final byte [] pubBytes = encodeCompressed ( publicKey .getW ());
796
796
final StringBuilder hexBytes = new StringBuilder (pubBytes .length * 2 );
797
- for (byte b : pubBytes ) {
798
- hexBytes .append (Integer .toHexString (Byte .toUnsignedInt (b )));
799
- }
797
+ for (byte b : pubBytes ) hexBytes .append (Integer .toHexString (Byte .toUnsignedInt (b )));
800
798
addSplittedAndFormatted (result , hexBytes );
801
799
}
802
800
result .append ("ASN1 OID: " ).append (getCurveName ()).append ('\n' );
@@ -815,12 +813,8 @@ String toRubyString() {
815
813
@ JRubyClass (name = "OpenSSL::PKey::EC::Group" )
816
814
public static final class Group extends RubyObject {
817
815
818
- private static final ObjectAllocator ALLOCATOR = new ObjectAllocator () {
819
- public Group allocate (Ruby runtime , RubyClass klass ) { return new Group (runtime , klass ); }
820
- };
821
-
822
816
static void createGroup (final Ruby runtime , final RubyClass EC , final RubyClass OpenSSLError ) {
823
- RubyClass Group = EC .defineClassUnder ("Group" , runtime .getObject (), ALLOCATOR );
817
+ RubyClass Group = EC .defineClassUnder ("Group" , runtime .getObject (), Group :: new );
824
818
825
819
// OpenSSL::PKey::EC::Group::Error
826
820
Group .defineClassUnder ("Error" , OpenSSLError , OpenSSLError .getAllocator ());
@@ -1006,12 +1000,8 @@ static PointConversion parse_point_conversion_form(final Ruby runtime, final IRu
1006
1000
@ JRubyClass (name = "OpenSSL::PKey::EC::Point" )
1007
1001
public static final class Point extends RubyObject {
1008
1002
1009
- private static final ObjectAllocator ALLOCATOR = new ObjectAllocator () {
1010
- public Point allocate (Ruby runtime , RubyClass klass ) { return new Point (runtime , klass ); }
1011
- };
1012
-
1013
1003
static void createPoint (final Ruby runtime , final RubyClass EC , final RubyClass OpenSSLError ) {
1014
- RubyClass Point = EC .defineClassUnder ("Point" , runtime .getObject (), ALLOCATOR );
1004
+ RubyClass Point = EC .defineClassUnder ("Point" , runtime .getObject (), Point :: new );
1015
1005
1016
1006
// OpenSSL::PKey::EC::Point::Error
1017
1007
Point .defineClassUnder ("Error" , OpenSSLError , OpenSSLError .getAllocator ());
0 commit comments