Change algo variant numbers.
This commit is contained in:
parent
95f48fd058
commit
d2fd43ca03
12 changed files with 378 additions and 139 deletions
|
@ -16,12 +16,13 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|||
add_executable(cryptonight_app ${SOURCES}
|
||||
cryptonight.c
|
||||
../../algo/cryptonight/cryptonight_av1_aesni.c
|
||||
../../algo/cryptonight/cryptonight_av2_aesni_wolf.c
|
||||
../../algo/cryptonight/cryptonight_av3_aesni_alt.c
|
||||
../../algo/cryptonight/cryptonight_av5_aesni_stak.c
|
||||
../../algo/cryptonight/cryptonight_av6_aesni_experimental.c
|
||||
../../algo/cryptonight/cryptonight_av6_aesni_stak_no_prefetch.c
|
||||
../../algo/cryptonight/cryptonight_av7_aesni_experimental.c
|
||||
)
|
||||
|
||||
target_link_libraries(cryptonight_app unity cryptonight_av3_aesni_bmi2)
|
||||
target_link_libraries(cryptonight_app unity cryptonight_av2_aesni_bmi2)
|
||||
else()
|
||||
add_executable(cryptonight_app ${SOURCES}
|
||||
cryptonight32.c
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -mbmi2")
|
||||
include_directories(../../..)
|
||||
add_library(cryptonight_av3_aesni_bmi2 STATIC ../../../algo/cryptonight/cryptonight_av3_aesni_bmi2.c)
|
||||
add_library(cryptonight_av2_aesni_bmi2 STATIC ../../../algo/cryptonight/cryptonight_av2_aesni_bmi2.c)
|
||||
|
|
|
@ -5,22 +5,30 @@
|
|||
|
||||
|
||||
void cryptonight_av1_aesni(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av2_aesni_wolf(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av3_aesni_bmi2(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av2_aesni_bmi2(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av3_aesni_alt(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av4_softaes(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av5_aesni_stak(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av6_aesni_experimental(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av6_aesni_stak_no_prefetch(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av7_aesni_experimental(void* output, const void* input, const char *memory, struct cryptonight_ctx* ctx);
|
||||
|
||||
|
||||
char hash[32];
|
||||
char data[76];
|
||||
|
||||
#define RESULT "1a3ffbee909b420d91f7be6e5fb56db71b3110d886011e877ee5786afd080100"
|
||||
|
||||
|
||||
char *bin2hex(const unsigned char *p, size_t len)
|
||||
{
|
||||
int i;
|
||||
char *s = malloc((len * 2) + 1);
|
||||
if (!s)
|
||||
if (!s) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
for (int i = 0; i < len; i++) {
|
||||
sprintf(s + (i * 2), "%02x", (unsigned int) p[i]);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -52,87 +60,62 @@ bool hex2bin(unsigned char *p, const char *hexstr, size_t len)
|
|||
|
||||
|
||||
void test_cryptonight_av1_should_CalcHash(void) {
|
||||
char hash[32];
|
||||
char data[76];
|
||||
|
||||
hex2bin((unsigned char *) &data, "0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601", 76);
|
||||
|
||||
uint8_t *memory = (uint8_t *) malloc(MEMORY);
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*) malloc(sizeof(struct cryptonight_ctx));
|
||||
|
||||
cryptonight_av1_aesni(&hash, data, memory, ctx);
|
||||
|
||||
free(memory);
|
||||
free(ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("1a3ffbee909b420d91f7be6e5fb56db71b3110d886011e877ee5786afd080100", bin2hex(hash, 32));
|
||||
TEST_ASSERT_EQUAL_STRING(RESULT, bin2hex(hash, 32));
|
||||
}
|
||||
|
||||
|
||||
void test_cryptonight_av2_should_CalcHash(void)
|
||||
{
|
||||
char hash[32];
|
||||
char data[76];
|
||||
|
||||
hex2bin((unsigned char *) &data, "0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601", 76);
|
||||
|
||||
uint8_t *memory = (uint8_t *) malloc(MEMORY);
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
|
||||
cryptonight_av2_aesni_wolf(&hash, data, memory, ctx);
|
||||
cryptonight_av2_aesni_bmi2(&hash, data, memory, ctx);
|
||||
|
||||
free(memory);
|
||||
free(ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("1a3ffbee909b420d91f7be6e5fb56db71b3110d886011e877ee5786afd080100", bin2hex(hash, 32));
|
||||
TEST_ASSERT_EQUAL_STRING(RESULT, bin2hex(hash, 32));
|
||||
}
|
||||
|
||||
|
||||
void test_cryptonight_av3_should_CalcHash(void)
|
||||
{
|
||||
char hash[32];
|
||||
char data[76];
|
||||
|
||||
hex2bin((unsigned char *) &data, "0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601", 76);
|
||||
|
||||
uint8_t *memory = (uint8_t *) malloc(MEMORY);
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*) malloc(sizeof(struct cryptonight_ctx));
|
||||
|
||||
cryptonight_av3_aesni_bmi2(&hash, data, memory, ctx);
|
||||
cryptonight_av3_aesni_alt(&hash, data, memory, ctx);
|
||||
|
||||
free(memory);
|
||||
free(ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("1a3ffbee909b420d91f7be6e5fb56db71b3110d886011e877ee5786afd080100", bin2hex(hash, 32));
|
||||
TEST_ASSERT_EQUAL_STRING(RESULT, bin2hex(hash, 32));
|
||||
}
|
||||
|
||||
|
||||
void test_cryptonight_av4_should_CalcHash(void)
|
||||
{
|
||||
char hash[32];
|
||||
char data[76];
|
||||
|
||||
hex2bin((unsigned char *) &data, "0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601", 76);
|
||||
|
||||
uint8_t *memory = (uint8_t *) malloc(MEMORY);
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*) malloc(sizeof(struct cryptonight_ctx));
|
||||
|
||||
cryptonight_av4_softaes(&hash, data, memory, ctx);
|
||||
|
||||
free(memory);
|
||||
free(ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("1a3ffbee909b420d91f7be6e5fb56db71b3110d886011e877ee5786afd080100", bin2hex(hash, 32));
|
||||
TEST_ASSERT_EQUAL_STRING(RESULT, bin2hex(hash, 32));
|
||||
}
|
||||
|
||||
|
||||
void test_cryptonight_av5_should_CalcHash(void)
|
||||
{
|
||||
char hash[32];
|
||||
char data[76];
|
||||
|
||||
hex2bin((unsigned char *) &data, "0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601", 76);
|
||||
|
||||
uint8_t *memory = (uint8_t *) malloc(MEMORY);
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
|
||||
|
@ -141,31 +124,42 @@ void test_cryptonight_av5_should_CalcHash(void)
|
|||
free(memory);
|
||||
free(ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("1a3ffbee909b420d91f7be6e5fb56db71b3110d886011e877ee5786afd080100", bin2hex(hash, 32));
|
||||
TEST_ASSERT_EQUAL_STRING(RESULT, bin2hex(hash, 32));
|
||||
}
|
||||
|
||||
|
||||
void test_cryptonight_av6_should_CalcHash(void)
|
||||
{
|
||||
char hash[32];
|
||||
char data[76];
|
||||
|
||||
hex2bin((unsigned char *) &data, "0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601", 76);
|
||||
|
||||
uint8_t *memory = (uint8_t *) malloc(MEMORY);
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
|
||||
cryptonight_av6_aesni_experimental(&hash, data, memory, ctx);
|
||||
cryptonight_av6_aesni_stak_no_prefetch(&hash, data, memory, ctx);
|
||||
|
||||
free(memory);
|
||||
free(ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("1a3ffbee909b420d91f7be6e5fb56db71b3110d886011e877ee5786afd080100", bin2hex(hash, 32));
|
||||
TEST_ASSERT_EQUAL_STRING(RESULT, bin2hex(hash, 32));
|
||||
}
|
||||
|
||||
|
||||
void test_cryptonight_av7_should_CalcHash(void)
|
||||
{
|
||||
uint8_t *memory = (uint8_t *) malloc(MEMORY);
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*)malloc(sizeof(struct cryptonight_ctx));
|
||||
|
||||
cryptonight_av7_aesni_experimental(&hash, data, memory, ctx);
|
||||
|
||||
free(memory);
|
||||
free(ctx);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(RESULT, bin2hex(hash, 32));
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
hex2bin((unsigned char *) &data, "0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601", 76);
|
||||
|
||||
UNITY_BEGIN();
|
||||
|
||||
RUN_TEST(test_cryptonight_av1_should_CalcHash);
|
||||
|
@ -174,6 +168,7 @@ int main(void)
|
|||
RUN_TEST(test_cryptonight_av4_should_CalcHash);
|
||||
RUN_TEST(test_cryptonight_av5_should_CalcHash);
|
||||
RUN_TEST(test_cryptonight_av6_should_CalcHash);
|
||||
RUN_TEST(test_cryptonight_av7_should_CalcHash);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue