From 6ca0b19bbc420892f4d78f0200289e6009d739a6 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 10 Aug 2021 23:13:37 +0500 Subject: [PATCH] Lol, fix my fuckup --- blkstuff/aes.c | 23 +++++++++++++++++++++++ blkstuff/main.cpp | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/blkstuff/aes.c b/blkstuff/aes.c index 553b4d1..eef23a4 100644 --- a/blkstuff/aes.c +++ b/blkstuff/aes.c @@ -338,3 +338,26 @@ void oqs_aes128_dec_c(const uint8_t *ciphertext, const void *_schedule, uint8_t // Reverse the first Round xor_round_key(plaintext, schedule, 0); } + +// It's not enc nor dec, it's something in between +void oqs_mhy128_enc_c(const uint8_t *plaintext, const void *_schedule, uint8_t *ciphertext) { + const uint8_t *schedule = (const uint8_t *) _schedule; + int i; // To count the rounds + + // First Round + memcpy(ciphertext, plaintext, 16); + xor_round_key(ciphertext, schedule, 0); + + // Middle rounds + for (i = 0; i < 9; i++) { + sub_bytes_inv(ciphertext, 16); + shift_rows_inv(ciphertext); + mix_cols_inv(ciphertext); + xor_round_key(ciphertext, schedule, i + 1); + } + + // Final Round + sub_bytes_inv(ciphertext, 16); + shift_rows_inv(ciphertext); + xor_round_key(ciphertext, schedule, 10); +} diff --git a/blkstuff/main.cpp b/blkstuff/main.cpp index b3b10b8..11f47c6 100644 --- a/blkstuff/main.cpp +++ b/blkstuff/main.cpp @@ -144,7 +144,7 @@ void kinda_expand_round_keys(uint8_t* round_keys) } // This function is not exported, so hackaround it -extern "C" void oqs_aes128_enc_c(const uint8_t *plaintext, const void *_schedule, uint8_t *ciphertext); +extern "C" void oqs_mhy128_enc_c(const uint8_t *plaintext, const void *_schedule, uint8_t *ciphertext); void key_scramble2(uint8_t* key) { uint8_t round_keys[11*16] = {0}; @@ -153,7 +153,7 @@ void key_scramble2(uint8_t* key) { uint8_t chip[16]; - oqs_aes128_enc_c(key, round_keys, chip); + oqs_mhy128_enc_c(key, round_keys, chip); memcpy(key, chip, 16); }