Compatability and benchmark fixes for native code.

This commit is contained in:
md_5 2016-01-16 13:29:50 +11:00
parent 83e27f07e6
commit 7907610eeb
3 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
CXX="g++ -std=c++11 -shared -fPIC -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
CXX="g++ -shared -fPIC -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
$CXX src/main/c/NativeCipherImpl.cpp -o src/main/resources/native-cipher.so -lcrypto
$CXX src/main/c/NativeCompressImpl.cpp -o src/main/resources/native-compress.so -lz

View File

@ -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 );

View File

@ -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 ) );