Skip to content

Commit 08ae555

Browse files
committed
avoid ByteList#length() usage for forward (JRuby 9.2) compatibility
1 parent f76ec2f commit 08ae555

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ public IRubyObject set_key(final ThreadContext context, final IRubyObject key) {
834834
debugStackTrace(runtime, e);
835835
throw newCipherError(runtime, e);
836836
}
837-
if ( keyBytes.length() < keyLength ) {
837+
if ( keyBytes.getRealSize() < keyLength ) {
838838
throw newCipherError(context.runtime, "key length too short");
839839
}
840840

@@ -856,7 +856,7 @@ public IRubyObject set_iv(final ThreadContext context, final IRubyObject iv) {
856856
debugStackTrace(runtime, e);
857857
throw newCipherError(runtime, e);
858858
}
859-
if ( ivBytes.length() < ivLength ) {
859+
if ( ivBytes.getRealSize() < ivLength ) {
860860
throw newCipherError(context.runtime, "iv length too short");
861861
}
862862
// EVP_CipherInit_ex uses leading IV length of given sequence.
@@ -1102,7 +1102,7 @@ public IRubyObject update(final ThreadContext context, final IRubyObject arg) {
11021102
checkAuthTag(runtime);
11031103

11041104
final ByteList data = arg.asString().getByteList();
1105-
final int length = data.length();
1105+
final int length = data.getRealSize();
11061106
if ( length == 0 ) {
11071107
throw runtime.newArgumentError("data must not be empty");
11081108
}
@@ -1221,7 +1221,7 @@ private ByteList do_final_with_auth(final Ruby runtime) throws GeneralSecurityEx
12211221
final byte[] out;
12221222
if ( auth_tag != null ) {
12231223
final byte[] tag = auth_tag.getUnsafeBytes();
1224-
out = cipher.doFinal(tag, auth_tag.begin(), auth_tag.length());
1224+
out = cipher.doFinal(tag, auth_tag.getBegin(), auth_tag.getRealSize());
12251225
}
12261226
else {
12271227
out = cipher.doFinal();
@@ -1303,7 +1303,7 @@ private boolean updateAuthData(final Ruby runtime) {
13031303
if ( auth_data == null ) return false; // only to be set if auth-mode
13041304
//try {
13051305
final byte[] data = auth_data.getUnsafeBytes();
1306-
cipher.updateAAD(data, auth_data.begin(), auth_data.length());
1306+
cipher.updateAAD(data, auth_data.getBegin(), auth_data.getRealSize());
13071307
//}
13081308
//catch (RuntimeException e) {
13091309
// debugStackTrace( runtime, e );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static void createOpenSSL(final Ruby runtime) {
106106
final byte[] JRuby_OpenSSL_ = { 'J','R','u','b','y','-','O','p','e','n','S','S','L',' ' };
107107
final int OPENSSL_VERSION_NUMBER = 999999999; // NOTE: smt more useful?
108108

109-
ByteList OPENSSL_VERSION = new ByteList( jVERSION.getByteList().length() + JRuby_OpenSSL_.length );
109+
ByteList OPENSSL_VERSION = new ByteList( jVERSION.getByteList().getRealSize() + JRuby_OpenSSL_.length );
110110
OPENSSL_VERSION.setEncoding( jVERSION.getEncoding() );
111111
OPENSSL_VERSION.append( JRuby_OpenSSL_ );
112112
OPENSSL_VERSION.append( jVERSION.getByteList() );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ private DEROctetString parseSubjectKeyIdentifier(final ThreadContext context, fi
573573
i++;
574574
}
575575
}
576-
final byte[] hexBytes = new byte[hex.length()];
576+
final byte[] hexBytes = new byte[hex.getRealSize()];
577577
System.arraycopy(hex.getUnsafeBytes(), hex.getBegin(), hexBytes, 0, hexBytes.length);
578578
return new DEROctetString(hexBytes);
579579
}

0 commit comments

Comments
 (0)