Compatability and benchmark fixes for native code.
This commit is contained in:
@@ -44,6 +44,12 @@ public class NativeCipher implements BungeeCipher
|
||||
|
||||
// Store how many bytes we can cipher
|
||||
int length = in.readableBytes();
|
||||
// Older OpenSSL versions will flip if length <= 0
|
||||
if ( length <= 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// It is important to note that in AES CFB-8 mode, the number of read bytes, is the number of outputted bytes
|
||||
out.ensureWritable( length );
|
||||
|
||||
|
@@ -124,6 +124,7 @@ public class NativeCipherTest
|
||||
for ( int i = 0; i < BENCHMARK_COUNT; i++ )
|
||||
{
|
||||
cipher.cipher( nativePlain, out );
|
||||
nativePlain.readerIndex( 0 );
|
||||
out.clear();
|
||||
}
|
||||
System.out.println( String.format( "Encryption Iteration: %d, Elapsed: %d ms", BENCHMARK_COUNT, System.currentTimeMillis() - start ) );
|
||||
@@ -134,6 +135,7 @@ public class NativeCipherTest
|
||||
for ( int i = 0; i < BENCHMARK_COUNT; i++ )
|
||||
{
|
||||
cipher.cipher( nativeCiphered, out );
|
||||
nativeCiphered.readerIndex( 0 );
|
||||
out.clear();
|
||||
}
|
||||
System.out.println( String.format( "Decryption Iteration: %d, Elapsed: %d ms", BENCHMARK_COUNT, System.currentTimeMillis() - start ) );
|
||||
|
Reference in New Issue
Block a user