Fix gcc build for real this time

This commit is contained in:
lilmayofuksu
2022-07-06 20:11:44 +03:00
parent dd56af8fcb
commit 6124d6949c
4 changed files with 32 additions and 28 deletions

View File

@@ -3,12 +3,17 @@ fn main() {
.include("mhycrypto")
.cpp(true)
.file("mhycrypto/aes.cpp")
.file("mhycrypto/memecrypto.cpp")
.file("mhycrypto/metadata.cpp")
.file("mhycrypto/metadatastringdec.cpp")
.compile("mhycrypto");
cc::Build::new()
.include("mhycrypto")
.file("mhycrypto/aes.c")
.compile("mhycrypto-aes");
tauri_build::build()
}

View File

@@ -318,28 +318,6 @@ void oqs_aes128_enc_c(const uint8_t *plaintext, const void *_schedule, uint8_t *
xor_round_key(ciphertext, schedule, 10);
}
// 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);
}
void oqs_aes128_dec_c(const uint8_t *ciphertext, const void *_schedule, uint8_t *plaintext) {
const uint8_t *schedule = (const uint8_t *) _schedule;
@@ -363,6 +341,29 @@ void oqs_aes128_dec_c(const uint8_t *ciphertext, const void *_schedule, uint8_t
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);
}
void oqs_mhy128_dec_c(const uint8_t *ciphertext, const void *_schedule, uint8_t *plaintext) {
const uint8_t *schedule = (const uint8_t *) _schedule;
int i; // To count the rounds

View File

@@ -63,4 +63,4 @@ void OQS_AES128_ECB_enc_sch(const uint8_t *plaintext, const size_t plaintext_len
*/
void OQS_AES128_ECB_dec_sch(const uint8_t *ciphertext, const size_t ciphertext_len, const void *schedule, uint8_t *plaintext);
#endif
#endif

View File

@@ -3,7 +3,8 @@
#include <cstring>
#include <stdio.h>
#include "aes.h"
extern "C" void oqs_mhy128_enc_c(const uint8_t *plaintext, const void *_schedule, uint8_t *ciphertext);
extern "C" void oqs_mhy128_dec_c(const uint8_t *ciphertext, const void *_schedule, uint8_t *plaintext);
static uint8_t dexor16(const uint8_t *c) {
uint8_t ret = 0;
@@ -17,9 +18,6 @@ void memecrypto_prepare_key(const uint8_t *in, uint8_t *out) {
out[i] = dexor16(&in[0x10 * i]);
}
extern "C" void oqs_mhy128_enc_c(const uint8_t *plaintext, const void *_schedule, uint8_t *ciphertext);
extern "C" void oqs_mhy128_dec_c(const uint8_t *ciphertext, const void *_schedule, uint8_t *plaintext);
void memecrypto_decrypt(const uint8_t *key, uint8_t *data) {
uint8_t plaintext[16];
oqs_mhy128_enc_c(data, key, plaintext);