Skip to content

Commit

Permalink
Merge pull request #1 from Jasuf/master
Browse files Browse the repository at this point in the history
Some improvements
  • Loading branch information
khang06 authored Aug 9, 2021
2 parents ed66ac2 + b4480d0 commit 1c62d53
Show file tree
Hide file tree
Showing 6 changed files with 677 additions and 599 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,13 @@ FodyWeavers.xsd
# JetBrains Rider
.idea/
*.sln.iml

# Vim temp files
.*.swp
.*.swo

# Object files
*.o

# Linux binary
blkstuff/blkstuff
11 changes: 11 additions & 0 deletions blkstuff/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CXX=g++
LD=g++
LIBS=-llz4 -lc -lomp
CXXFLAGS=-O2 -std=c++17 -fopenmp -Wall -Wextra
CFLAGS=-O2 -std=c17 -fopenmp -Wall -Wextra

blkstuff: main.o util.o aes.o
$(LD) $(LIBS) $^ -o $@

clean:
-rm main.o util.o blkstuff
340 changes: 340 additions & 0 deletions blkstuff/aes.c

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions blkstuff/aes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* \file aes.h
* \brief Header defining the API for OQS AES
*/

#ifndef __OQS_AES_H
#define __OQS_AES_H

#include <stdint.h>
#include <stdlib.h>

/**
* Function to fill a key schedule given an initial key.
*
* @param key Initial Key.
* @param schedule Abstract data structure for a key schedule.
* @param forEncryption 1 if key schedule is for encryption, 0 if for decryption.
*/
void OQS_AES128_load_schedule(const uint8_t *key, void **schedule, int for_encryption);

/**
* Function to free a key schedule.
*
* @param schedule Schedule generated with OQS_AES128_load_schedule().
*/
void OQS_AES128_free_schedule(void *schedule);

/**
* Function to encrypt blocks of plaintext using ECB mode.
* A schedule based on the key is generated and used internally.
*
* @param plaintext Plaintext to be encrypted.
* @param plaintext_len Length on the plaintext in bytes. Must be a multiple of 16.
* @param key Key to be used for encryption.
* @param ciphertext Pointer to a block of memory which >= in size to the plaintext block. The result will be written here.
*/
void OQS_AES128_ECB_enc(const uint8_t *plaintext, const size_t plaintext_len, const uint8_t *key, uint8_t *ciphertext);

/**
* Function to decrypt blocks of plaintext using ECB mode.
* A schedule based on the key is generated and used internally.
*
* @param ciphertext Ciphertext to be decrypted.
* @param ciphertext_len Length on the ciphertext in bytes. Must be a multiple of 16.
* @param key Key to be used for encryption.
* @param ciphertext Pointer to a block of memory which >= in size to the ciphertext block. The result will be written here.
*/
void OQS_AES128_ECB_dec(const uint8_t *ciphertext, const size_t ciphertext_len, const uint8_t *key, uint8_t *plaintext);

/**
* Same as OQS_AES128_ECB_enc() except a schedule generated by
* OQS_AES128_load_schedule() is passed rather then a key. This is faster
* if the same schedule is used for multiple encryptions since it does
* not have to be regenerated from the key.
*/
void OQS_AES128_ECB_enc_sch(const uint8_t *plaintext, const size_t plaintext_len, const void *schedule, uint8_t *ciphertext);

/**
* Same as OQS_AES128_ECB_dec() except a schedule generated by
* OQS_AES128_load_schedule() is passed rather then a key. This is faster
* if the same schedule is used for multiple encryptions since it does
* not have to be regenerated from the key.
*/
void OQS_AES128_ECB_dec_sch(const uint8_t *ciphertext, const size_t ciphertext_len, const void *schedule, uint8_t *plaintext);

#endif
Loading

0 comments on commit 1c62d53

Please sign in to comment.