mirror of
https://github.com/wownero/wownerujo.git
synced 2026-11-15 04:34:08 +01:00
deal with all broken variants (#292)
* remove variant code for arm32 * deal with all broken variants
This commit is contained in:
@@ -698,18 +698,23 @@ 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_slowHash(JNIEnv *env, jobject clazz,
|
||||
jbyteArray data, jboolean broken) {
|
||||
jbyteArray data, jint brokenVariant) {
|
||||
char hash[HASH_SIZE];
|
||||
jsize size = env->GetArrayLength(data);
|
||||
if (broken && (size < 200 /*sizeof(union hash_state)*/)) {
|
||||
if ((brokenVariant > 0) && (size < 200 /*sizeof(union hash_state)*/)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
jbyte *buffer = env->GetByteArrayElements(data, NULL);
|
||||
if (broken) {
|
||||
slow_hash_broken(buffer, hash);
|
||||
} else {
|
||||
slow_hash(buffer, (size_t) size, hash);
|
||||
switch (brokenVariant) {
|
||||
case 1:
|
||||
slow_hash_broken(buffer, hash, 1);
|
||||
break;
|
||||
case 2:
|
||||
slow_hash_broken(buffer, hash, 0);
|
||||
break;
|
||||
default: // not broken
|
||||
slow_hash(buffer, (size_t) size, hash);
|
||||
}
|
||||
env->ReleaseByteArrayElements(data, buffer, JNI_ABORT); // do not update java byte[]
|
||||
jbyteArray result = env->NewByteArray(HASH_SIZE);
|
||||
|
||||
@@ -66,8 +66,8 @@ 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*/);
|
||||
inline void slow_hash_broken(const void *data, char *hash, int variant) {
|
||||
cn_slow_hash(data, 200 /*sizeof(union hash_state)*/, hash, variant, 1 /*prehashed*/);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user