2
0

Fix JNI native symbol names after refactor.

This commit is contained in:
Maarten Billemont 2020-04-14 20:07:21 -04:00
parent 9a362f13a3
commit b79ed1ca0b
3 changed files with 16 additions and 16 deletions

View File

@ -84,8 +84,8 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
return JNI_VERSION_1_6; return JNI_VERSION_1_6;
} }
/* native int _masterKey(final String fullName, final byte[] masterPassword, final Version version) */ /* native byte[] _masterKey(final String fullName, final byte[] masterPassword, final int algorithmVersion) */
JNIEXPORT jbyteArray JNICALL Java_com_lyndir_masterpassword_impl_MPAlgorithmV0__1masterKey(JNIEnv *env, jobject obj, JNIEXPORT jbyteArray JNICALL Java_com_lyndir_masterpassword_MPAlgorithm_00024Version__1masterKey(JNIEnv *env, jobject obj,
jstring fullName, jbyteArray masterPassword, jint algorithmVersion) { jstring fullName, jbyteArray masterPassword, jint algorithmVersion) {
if (!fullName || !masterPassword) if (!fullName || !masterPassword)
@ -108,9 +108,9 @@ JNIEXPORT jbyteArray JNICALL Java_com_lyndir_masterpassword_impl_MPAlgorithmV0__
return masterKey; return masterKey;
} }
/* native int _siteKey(final byte[] masterKey, final String siteName, final long siteCounter, /* native byte[] _siteKey(final byte[] masterKey, final String siteName, final long siteCounter,
final MPKeyPurpose keyPurpose, @Nullable final String keyContext, final Version version) */ final int keyPurpose, @Nullable final String keyContext, final int version) */
JNIEXPORT jbyteArray JNICALL Java_com_lyndir_masterpassword_impl_MPAlgorithmV0__1siteKey(JNIEnv *env, jobject obj, JNIEXPORT jbyteArray JNICALL Java_com_lyndir_masterpassword_MPAlgorithm_00024Version__1siteKey(JNIEnv *env, jobject obj,
jbyteArray masterKey, jstring siteName, jlong siteCounter, jint keyPurpose, jstring keyContext, jint algorithmVersion) { jbyteArray masterKey, jstring siteName, jlong siteCounter, jint keyPurpose, jstring keyContext, jint algorithmVersion) {
if (!masterKey || !siteName) if (!masterKey || !siteName)
@ -138,9 +138,9 @@ JNIEXPORT jbyteArray JNICALL Java_com_lyndir_masterpassword_impl_MPAlgorithmV0__
} }
/* native String _siteResult(final byte[] masterKey, final byte[] siteKey, final String siteName, final long siteCounter, /* native String _siteResult(final byte[] masterKey, final byte[] siteKey, final String siteName, final long siteCounter,
final MPKeyPurpose keyPurpose, @Nullable final String keyContext, final int keyPurpose, @Nullable final String keyContext,
final MPResultType resultType, @Nullable final String resultParam, final Version version) */ final int resultType, @Nullable final String resultParam, final int algorithmVersion) */
JNIEXPORT jstring JNICALL Java_com_lyndir_masterpassword_impl_MPAlgorithmV0__1siteResult(JNIEnv *env, jobject obj, JNIEXPORT jstring JNICALL Java_com_lyndir_masterpassword_MPAlgorithm_00024Version__1siteResult(JNIEnv *env, jobject obj,
jbyteArray masterKey, jbyteArray siteKey, jstring siteName, jlong siteCounter, jint keyPurpose, jstring keyContext, jbyteArray masterKey, jbyteArray siteKey, jstring siteName, jlong siteCounter, jint keyPurpose, jstring keyContext,
jint resultType, jstring resultParam, jint algorithmVersion) { jint resultType, jstring resultParam, jint algorithmVersion) {
@ -173,9 +173,9 @@ JNIEXPORT jstring JNICALL Java_com_lyndir_masterpassword_impl_MPAlgorithmV0__1si
} }
/* native String _siteState(final byte[] masterKey, final byte[] siteKey, final String siteName, final long siteCounter, /* native String _siteState(final byte[] masterKey, final byte[] siteKey, final String siteName, final long siteCounter,
final MPKeyPurpose keyPurpose, @Nullable final String keyContext, final int keyPurpose, @Nullable final String keyContext,
final MPResultType resultType, final String resultParam, final Version version) */ final int resultType, final String resultParam, final int algorithmVersion) */
JNIEXPORT jstring JNICALL Java_com_lyndir_masterpassword_impl_MPAlgorithmV0__1siteState(JNIEnv *env, jobject obj, JNIEXPORT jstring JNICALL Java_com_lyndir_masterpassword_MPAlgorithm_00024Version__1siteState(JNIEnv *env, jobject obj,
jbyteArray masterKey, jbyteArray siteKey, jstring siteName, jlong siteCounter, jint keyPurpose, jstring keyContext, jbyteArray masterKey, jbyteArray siteKey, jstring siteName, jlong siteCounter, jint keyPurpose, jstring keyContext,
jint resultType, jstring resultParam, jint algorithmVersion) { jint resultType, jstring resultParam, jint algorithmVersion) {

View File

@ -227,7 +227,8 @@ public interface MPAlgorithm {
private static final int AES_BLOCKSIZE = 128 /* bit */; private static final int AES_BLOCKSIZE = 128 /* bit */;
static { static {
Native.load( MPAlgorithm.class, "mpw" ); if (!Native.load( MPAlgorithm.class, "mpw" ))
Logger.get( MPAlgorithm.class ).err( "Native mpw library unavailable." );
} }
protected final Logger logger = Logger.get( getClass() ); protected final Logger logger = Logger.get( getClass() );

View File

@ -74,9 +74,9 @@ public final class Native {
// Write the library resource to a temporary file. // Write the library resource to a temporary file.
libraryFile = File.createTempFile( libraryName, libraryExtension ); libraryFile = File.createTempFile( libraryName, libraryExtension );
libraryFile.deleteOnExit();
FileOutputStream libraryFileStream = new FileOutputStream( libraryFile ); FileOutputStream libraryFileStream = new FileOutputStream( libraryFile );
try { try {
libraryFile.deleteOnExit();
ByteStreams.copy( libraryStream, libraryFileStream ); ByteStreams.copy( libraryStream, libraryFileStream );
} }
finally { finally {
@ -91,8 +91,7 @@ public final class Native {
catch (@SuppressWarnings("ErrorNotRethrown") final IOException | UnsatisfiedLinkError e) { catch (@SuppressWarnings("ErrorNotRethrown") final IOException | UnsatisfiedLinkError e) {
logger.wrn( e, "Couldn't load library: %s", libraryResource ); logger.wrn( e, "Couldn't load library: %s", libraryResource );
if (libraryFile != null) if (libraryFile != null && libraryFile.exists() && !libraryFile.delete())
if (libraryFile.exists() && !libraryFile.delete())
logger.wrn( "Couldn't clean up library file: %s", libraryFile ); logger.wrn( "Couldn't clean up library file: %s", libraryFile );
libraryFile = null; libraryFile = null;
} }