From 125072a30e2465b6a77d9b4342ac14b62b3468c3 Mon Sep 17 00:00:00 2001
From: XMRig <support@xmrig.com>
Date: Tue, 13 Mar 2018 01:29:31 +0700
Subject: [PATCH] Added test hashes for AEON.

---
 src/crypto/CryptoNight.cpp    | 14 ++++++++++----
 src/crypto/CryptoNight_test.h | 33 +++++++++++++++++++++------------
 src/net/Job.cpp               |  4 ++++
 3 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/src/crypto/CryptoNight.cpp b/src/crypto/CryptoNight.cpp
index 1d71d1cd2..996622c47 100644
--- a/src/crypto/CryptoNight.cpp
+++ b/src/crypto/CryptoNight.cpp
@@ -167,16 +167,22 @@ bool CryptoNight::selfTest(int algo) {
 
     cryptonight_hash_ctx(test_input, 76, output, ctx, 0);
 
+    const bool doubleHash = Options::i()->doubleHash();
+
 #   ifndef XMRIG_NO_AEON
-    bool rc = memcmp(output, algo == xmrig::ALGO_CRYPTONIGHT_LITE ? test_output1 : test_output0, (Options::i()->doubleHash() ? 64 : 32)) == 0;
+    bool rc = memcmp(output, algo == xmrig::ALGO_CRYPTONIGHT_LITE ? test_output_v0_lite : test_output_v0, (doubleHash ? 64 : 32)) == 0;
 #   else
-    bool rc = memcmp(output, test_output0, (Options::i()->doubleHash() ? 64 : 32)) == 0;
+    bool rc = memcmp(output, test_output_v0, (doubleHash ? 64 : 32)) == 0;
 #   endif
 
-    if (rc && algo == xmrig::ALGO_CRYPTONIGHT) {
+    if (rc) {
         cryptonight_hash_ctx(test_input, 76, output, ctx, 1);
 
-        rc = memcmp(output, test_output2, (Options::i()->doubleHash() ? 64 : 32)) == 0;
+#       ifndef XMRIG_NO_AEON
+        rc = memcmp(output, algo == xmrig::ALGO_CRYPTONIGHT_LITE ? test_output_v1_lite : test_output_v1, (doubleHash ? 64 : 32)) == 0;
+#       else
+        rc = memcmp(output, test_output_v1, (doubleHash ? 64 : 32)) == 0;
+#       endif
     }
 
     _mm_free(ctx->memory);
diff --git a/src/crypto/CryptoNight_test.h b/src/crypto/CryptoNight_test.h
index 65200f755..0f7feda11 100644
--- a/src/crypto/CryptoNight_test.h
+++ b/src/crypto/CryptoNight_test.h
@@ -40,7 +40,7 @@ const static uint8_t test_input[152] = {
 };
 
 
-const static uint8_t test_output0[64] = {
+const static uint8_t test_output_v0[64] = {
     0x1B, 0x60, 0x6A, 0x3F, 0x4A, 0x07, 0xD6, 0x48, 0x9A, 0x1B, 0xCD, 0x07, 0x69, 0x7B, 0xD1, 0x66,
     0x96, 0xB6, 0x1C, 0x8A, 0xE9, 0x82, 0xF6, 0x1A, 0x90, 0x16, 0x0F, 0x4E, 0x52, 0x82, 0x8A, 0x7F,
     0x1A, 0x3F, 0xFB, 0xEE, 0x90, 0x9B, 0x42, 0x0D, 0x91, 0xF7, 0xBE, 0x6E, 0x5F, 0xB5, 0x6D, 0xB7,
@@ -48,18 +48,8 @@ const static uint8_t test_output0[64] = {
 };
 
 
-#ifndef XMRIG_NO_AEON
-const static uint8_t test_output1[64] = {
-    0x28, 0xA2, 0x2B, 0xAD, 0x3F, 0x93, 0xD1, 0x40, 0x8F, 0xCA, 0x47, 0x2E, 0xB5, 0xAD, 0x1C, 0xBE,
-    0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD,
-    0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E,
-    0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88,
-};
-#endif
-
-
 // Monero v7
-const static uint8_t test_output2[64] = {
+const static uint8_t test_output_v1[64] = {
     0xC9, 0xFA, 0xE8, 0x42, 0x5D, 0x86, 0x88, 0xDC, 0x23, 0x6B, 0xCD, 0xBC, 0x42, 0xFD, 0xB4, 0x2D,
     0x37, 0x6C, 0x6E, 0xC1, 0x90, 0x50, 0x1A, 0xA8, 0x4B, 0x04, 0xA4, 0xB4, 0xCF, 0x1E, 0xE1, 0x22,
     0xF2, 0x2D, 0x3D, 0x62, 0x03, 0xD2, 0xA0, 0x8B, 0x41, 0xD9, 0x02, 0x72, 0x78, 0xD8, 0xBC, 0xC9,
@@ -67,4 +57,23 @@ const static uint8_t test_output2[64] = {
 };
 
 
+#ifndef XMRIG_NO_AEON
+const static uint8_t test_output_v0_lite[64] = {
+    0x28, 0xA2, 0x2B, 0xAD, 0x3F, 0x93, 0xD1, 0x40, 0x8F, 0xCA, 0x47, 0x2E, 0xB5, 0xAD, 0x1C, 0xBE,
+    0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD,
+    0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E,
+    0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88
+};
+
+
+// AEON v2
+const static uint8_t test_output_v1_lite[64] = {
+    0x87, 0xC4, 0xE5, 0x70, 0x65, 0x3E, 0xB4, 0xC2, 0xB4, 0x2B, 0x7A, 0x0D, 0x54, 0x65, 0x59, 0x45,
+    0x2D, 0xFA, 0xB5, 0x73, 0xB8, 0x2E, 0xC5, 0x2F, 0x15, 0x2B, 0x7F, 0xF9, 0x8E, 0x79, 0x44, 0x6F,
+    0x6D, 0x8C, 0xDC, 0x44, 0x4E, 0x9B, 0xBB, 0xFD, 0x68, 0xFC, 0x43, 0xFC, 0xD4, 0x85, 0x5B, 0x22,
+    0x8C, 0x8A, 0x1B, 0xD9, 0x1D, 0x9D, 0x00, 0x28, 0x5B, 0xEC, 0x02, 0xB7, 0xCA, 0x2D, 0x67, 0x41
+};
+#endif
+
+
 #endif /* __CRYPTONIGHT_TEST_H__ */
diff --git a/src/net/Job.cpp b/src/net/Job.cpp
index c8331fb9b..b9d7372c0 100644
--- a/src/net/Job.cpp
+++ b/src/net/Job.cpp
@@ -173,11 +173,15 @@ int Job::variant() const
 
     const uint8_t version = m_blob[0];
 
+#   if !defined(XMRIG_NO_AEON)
     if (m_algo == xmrig::ALGO_CRYPTONIGHT) {
         return version > 6 ? 1 : 0;
     }
 
     return version > 1 ? 1 : 0;
+#   else
+    return version > 6 ? 1 : 0;
+#   endif
 }