Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added phism-runner and the encrypt example #42

Merged
merged 1 commit into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions example/encrypt/encrypt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>

#define M 1024
#define N 16

void encrypt(int Sbox[M][N], int statemt[M]) {
int ret[M];

for (int i = 1; i <= 4; ++i) {
for (int j = 0; j < N; j++)
statemt[j * 4] = Sbox[statemt[j * 4] >> 4][statemt[j * 4] & 0xf];

for (int j = 0; j < M - 1; ++j) {
ret[j] = (statemt[j] << 1);
if ((ret[j] >> 8) == 1)
ret[j] ^= 283;
int x = statemt[1 + j];
x ^= (x << 1);
if ((x >> 8) == 1)
ret[j] ^= (x ^ 283);
else
ret[j] ^= x;
}

for (int j = 0; j < M; ++j)
statemt[j] = ret[j];
}
}

int main() {
int Sbox[M][N], statemt[M];

for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++)
Sbox[i][j] = (i + j) % M;
statemt[i] = i;
}

encrypt(Sbox, statemt);

for (int i = 0; i < M; ++i)
fprintf(stderr, "%08x\n", statemt[i]);

return 0;
}
Empty file.
13 changes: 13 additions & 0 deletions pyphism/phism_runner/options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from dataclasses import dataclass


@dataclass
class PhismRunnerOptions:
source_file: str = "" # input source file
work_dir: str = "" # temporary workdir
dry_run: bool = False # only print out the commands to run
sanity_check: bool = True # run in sanity check mode
top_func: str = "" # top function name
polymer: bool = False # run with polymer
loop_transforms: bool = False # run phism loop transform
fold_if: bool = False # run phism fold if
Loading