mirror of
https://github.com/wownero/wownerujo.git
synced 2026-11-15 04:34:08 +01:00
Fixes "Invalid Password" although password correct (#289)
* don't log warning * fix cn_slow_hash variant&prehash cn_slow_hash signature was changed in monero-core but the linker didn't notice - also added code to support wallets created with variant & prehash enabled
This commit is contained in:
@@ -697,16 +697,21 @@ Java_com_m2049r_xmrwallet_model_Wallet_isSynchronized(JNIEnv *env, jobject insta
|
||||
|
||||
//void cn_slow_hash(const void *data, size_t length, char *hash); // from crypto/hash-ops.h
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_com_m2049r_xmrwallet_util_KeyStoreHelper_cnSlowHash(JNIEnv *env, jobject clazz,
|
||||
jbyteArray data) {
|
||||
Java_com_m2049r_xmrwallet_util_KeyStoreHelper_slowHash(JNIEnv *env, jobject clazz,
|
||||
jbyteArray data, jboolean broken) {
|
||||
char hash[HASH_SIZE];
|
||||
jsize size = env->GetArrayLength(data);
|
||||
if (broken && (size < 200 /*sizeof(union hash_state)*/)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
jbyte *buffer = env->GetByteArrayElements(data, NULL);
|
||||
jsize size = env->GetArrayLength(data);
|
||||
char hash[HASH_SIZE];
|
||||
cn_slow_hash(buffer, (size_t) size, hash);
|
||||
|
||||
if (broken) {
|
||||
slow_hash_broken(buffer, hash);
|
||||
} else {
|
||||
slow_hash(buffer, (size_t) size, hash);
|
||||
}
|
||||
env->ReleaseByteArrayElements(data, buffer, JNI_ABORT); // do not update java byte[]
|
||||
|
||||
jbyteArray result = env->NewByteArray(HASH_SIZE);
|
||||
env->SetByteArrayRegion(result, 0, HASH_SIZE, (jbyte *) hash);
|
||||
return result;
|
||||
|
||||
@@ -60,7 +60,15 @@ enum {
|
||||
HASH_DATA_AREA = 136
|
||||
};
|
||||
|
||||
void cn_slow_hash(const void *data, size_t length, char *hash);
|
||||
void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed);
|
||||
|
||||
inline void slow_hash(const void *data, const size_t length, char *hash) {
|
||||
cn_slow_hash(data, length, hash, 0 /* variant */, 0/*prehashed*/);
|
||||
}
|
||||
|
||||
inline void slow_hash_broken(const void *data, char *hash) {
|
||||
cn_slow_hash(data, 200 /*sizeof(union hash_state)*/, hash, 1 /* variant */, 1 /*prehashed*/);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user