Skip to content

Commit

Permalink
format source using new style specification
Browse files Browse the repository at this point in the history
Just do `make format`

Signed-off-by: Anjan Roy <[email protected]>
  • Loading branch information
itzmeanjan committed Feb 1, 2024
1 parent 3d30156 commit 5998844
Show file tree
Hide file tree
Showing 17 changed files with 2,890 additions and 2,378 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
all: dut_aes32 dut_aesbitsliced dut_donna dut_donnabad dut_simple

SRC_DIR = src
SOURCES = $(wildcard $(SRC_DIR)/*.h)
EXAMPLE_DIR = examples
EXAMPLE_HEADERS = $(wildcard $(EXAMPLE_DIR)/*/*.h)
EXAMPLE_SOURCES = $(wildcard $(EXAMPLE_DIR)/*/*.c)

OBJS_AES32 = examples/aes32/rijndael-alg-fst.o
OBJS_DONNA = examples/donna/curve25519-donna.o
OBJS_DONNABAD = examples/donnabad/curve25519-donnabad.o
Expand Down Expand Up @@ -43,5 +49,9 @@ dut_simple: examples/simple/example.c
clean:
rm -f $(OBJS_AES32) $(OBJS_AESBITSLICED) $(OBJS_DONNA) $(OBJS_DONNABAD) dudect_* *.exe a.out

format: $(SOURCES) $(EXAMPLE_HEADERS) $(EXAMPLE_SOURCES)
clang-format -i $^


test: all
python test.py
33 changes: 19 additions & 14 deletions examples/aes32/dut_aes32.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "rijndael-alg-fst.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#define DUDECT_IMPLEMENTATION
#include "dudect.h"

static uint32_t rk[44] = {0};
static uint32_t rk[44] = { 0 };

uint8_t do_one_computation(uint8_t *data) {
uint8_t in[16] = {0};
uint8_t out[16] = {0};
uint8_t
do_one_computation(uint8_t* data)
{
uint8_t in[16] = { 0 };
uint8_t out[16] = { 0 };
uint8_t ret = 0;

memcpy(in, data, 16);

rijndaelEncrypt(rk, 10, in, out);

ret ^= out[0];
/* return some computation output to try to tame a clever optimizing compiler */
/* return some computation output to try to tame a clever optimizing compiler
*/
return ret;
}

void prepare_inputs(dudect_config_t *c, uint8_t *input_data, uint8_t *classes) {
void
prepare_inputs(dudect_config_t* c, uint8_t* input_data, uint8_t* classes)
{
randombytes(input_data, c->number_measurements * c->chunk_size);
for (size_t i = 0; i < c->number_measurements; i++) {
classes[i] = randombit();
Expand All @@ -34,18 +39,19 @@ void prepare_inputs(dudect_config_t *c, uint8_t *input_data, uint8_t *classes) {
}
}

int main(int argc, char **argv)
int
main(int argc, char** argv)
{
(void)argc;
(void)argv;

dudect_config_t config = {
.chunk_size = 16,
.number_measurements = 1e6,
.chunk_size = 16,
.number_measurements = 1e6,
};
dudect_ctx_t ctx;

uint8_t cipherKey[16] = {0};
uint8_t cipherKey[16] = { 0 };
rijndaelKeySetupEnc(rk, cipherKey, 128);

dudect_init(&ctx, &config);
Expand All @@ -68,4 +74,3 @@ int main(int argc, char **argv)
dudect_free(&ctx);
return (int)state;
}

2,317 changes: 1,050 additions & 1,267 deletions examples/aes32/rijndael-alg-fst.c

Large diffs are not rendered by default.

Loading

0 comments on commit 5998844

Please sign in to comment.