Skip to content

Commit

Permalink
Lol, fix my fuckup
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex committed Aug 10, 2021
1 parent b4480d0 commit 6ca0b19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions blkstuff/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions blkstuff/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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);
}
Expand Down

0 comments on commit 6ca0b19

Please sign in to comment.