forked from peigen-sboxes/PEIGEN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd35097
commit 3d995ce
Showing
44 changed files
with
18,456 additions
and
16 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
CC=g++ -fopenmp | ||
CFLAGS= -mavx2 -std=c++14 -O3 -Wall -Wextra -pedantic | ||
LDFLAGS= | ||
EXEC=evaluate evaluate_single search_GC_n3 search_GC_n4 search_depth_n3 search_depth_n4 filter_n3 filter_n4 gen_n3 gen_n4 | ||
|
||
all: $(EXEC) | ||
|
||
evaluate: evaluate.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DEVA | ||
|
||
evaluate.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DEVA | ||
|
||
evaluate_single: evaluate_single.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DEVA_Single | ||
|
||
evaluate_single.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DEVA_Single | ||
|
||
search_GC_n3: search_GC_n3.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DGC -DSIZEINBIT=3 | ||
|
||
search_GC_n3.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DGC -DSIZEINBIT=3 | ||
|
||
search_GC_n4: search_GC_n4.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DGC -DSIZEINBIT=4 | ||
|
||
search_GC_n4.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DGC -DSIZEINBIT=4 | ||
|
||
|
||
search_depth_n3: search_depth_n3.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DDEPTH -DSIZEINBIT=3 | ||
|
||
search_depth_n3.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DDEPTH -DSIZEINBIT=3 | ||
|
||
search_depth_n4: search_depth_n4.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DDEPTH -DSIZEINBIT=4 | ||
|
||
search_depth_n4.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DDEPTH -DSIZEINBIT=4 | ||
|
||
|
||
filter_n3: filter_n3.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DFILTER -DSIZEINBIT=3 | ||
|
||
filter_n3.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DFILTER -DSIZEINBIT=3 | ||
|
||
filter_n4: filter_n4.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DFILTER -DSIZEINBIT=4 | ||
|
||
filter_n4.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DFILTER -DSIZEINBIT=4 | ||
|
||
|
||
gen_n3: gen_n3.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DGEN -DSIZEINBIT=3 | ||
|
||
gen_n3.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DGEN -DSIZEINBIT=3 | ||
|
||
gen_n4: gen_n4.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -DGEN -DSIZEINBIT=4 | ||
|
||
gen_n4.o: main.cpp | ||
$(CC) -o $@ -c $< $(CFLAGS) -DGEN -DSIZEINBIT=4 | ||
|
||
|
||
clean: | ||
rm -rf *.o | ||
|
||
mrproper: clean | ||
rm -rf $(EXEC) | ||
rm test_faster | ||
rm test_lighter | ||
|
||
gencheck: | ||
find ./R -maxdepth 1 -name "*.c" -print > results.c | ||
$(CC) $(CFLAGS) genTest.cpp -o genTest && ./genTest | ||
|
||
checkfaster: | ||
$(CC) $(CFLAGS) faster_test.cpp -o test_faster && ./test_faster | ||
|
||
checklighter: | ||
$(CC) $(CFLAGS) faster_test.cpp -o test_lighter && ./test_lighter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# To build, rename this file as Makefile | ||
# Compile inside the Sage shell: sage -sh -c make | ||
# Then start Sage: from peigen import Lighter | ||
# : A = Lighter() | ||
# : A.evaluate_4bit() | ||
# Similiar for Faster: from peigen import Faster | ||
CC= g++ | ||
CXXFLAGS= -fopenmp -mavx2 -std=c++14 -O3 -fPIC -fwrapv -fno-strict-aliasing \ | ||
-Wall -Wextra -pedantic -g -pg \ | ||
-I$(SAGE_LOCAL)/include \ | ||
-I$(SAGE_LOCAL)/include/python2.7 | ||
LDFLAGS = -fopenmp -lm -lstdc++ | ||
|
||
OUTPUT_OPTION = -MMD -MP -o $@ | ||
-include $(DEP) | ||
|
||
EXEC = peigen | ||
|
||
SRC = peigen.cpp | ||
OBJ = $(SRC:.cpp=.o) | ||
DEP = $(SRC:.cpp=.d) | ||
|
||
all: peigen.so | ||
|
||
peigen.cpp: peigen.pyx peigen.pxd | ||
cython --cplus $< | ||
|
||
$(OBJ):$(SRC) | ||
|
||
peigen.so: $(OBJ) | ||
$(CC) -shared -pthread -o peigen.so $^ $(LDFLAGS) | ||
|
||
$(EXEC): $(OBJ) | ||
$(CC) $(LDFLAGS) $^ -o $@ | ||
|
||
clean: | ||
rm -f $(OBJ) $(DEP) $(EXEC) | ||
|
||
.PHONY: clean | ||
|
||
-include $(DEP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* PEIGEN: a Platform for Evaluation, Implementation, and Generation of S-boxes | ||
* | ||
* Copyright 2019 by | ||
* Zhenzhen Bao <baozhenzhen10[at]gmail.com> | ||
* Jian Guo <guojian[at]ntu.edu.sg> | ||
* San Ling <lingsan[at]ntu.edu.sg> | ||
* Yu Sasaki <yu[dot]sasaki[dot][email protected]> | ||
* | ||
* This platform is developed based on the open source application | ||
* <http://jeremy.jean.free.fr/pub/fse2018_layer_implementations.tar.gz> | ||
* Optimizing Implementations of Lightweight Building Blocks | ||
* | ||
* Copyright 2017 by | ||
* Jade Tourteaux <Jade[dot]Tourteaux[at]gmail.com> | ||
* Jérémy Jean <Jean[dot]Jeremy[at]gmail.com> | ||
* | ||
* We follow the same copyright policy. | ||
* | ||
* This file is part of some open source application. | ||
* | ||
* Some open source application is free software: you can redistribute | ||
* it and/or modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation, either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* Some open source application is distributed in the hope that it will | ||
* be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> | ||
*/ | ||
|
||
#ifndef GSBOXES_H__ | ||
#define GSBOXES_H__ | ||
|
||
#define OPTIMAL_G4_N 16 | ||
|
||
const ALIGNED_TYPE_(uint8_t, 16) G4[OPTIMAL_G4_N][16] = { | ||
/* Optimal_S0 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 12, 9, 3, 14, 10, 5}, | ||
/* Optimal_S1 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 14, 3, 5, 9, 10, 12}, | ||
/* Optimal_S2 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 11, 14, 3, 10, 12, 5, 9}, | ||
/* Optimal_S3 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 12, 5, 3, 10, 14, 11, 9}, | ||
/* Optimal_S4 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 12, 9, 11, 10, 14, 5, 3}, | ||
/* Optimal_S5 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 12, 11, 9, 10, 14, 3, 5}, | ||
/* Optimal_S6 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 12, 11, 9, 10, 14, 5, 3}, | ||
/* Optimal_S7 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 12, 14, 11, 10, 9, 3, 5}, | ||
/* Optimal_S8 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 14, 9, 5, 10, 11, 3, 12}, | ||
/* Optimal_S9 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 14, 11, 3, 5, 9, 10, 12}, | ||
/* Optimal_S10 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 14, 11, 5, 10, 9, 3, 12}, | ||
/* Optimal_S11 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 14, 11, 10, 5, 9, 12, 3}, | ||
/* Optimal_S12 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 14, 11, 10, 9, 3, 12, 5}, | ||
/* Optimal_S13 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 14, 12, 9, 5, 11, 10, 3}, | ||
/* Optimal_S14 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 14, 12, 11, 3, 9, 5, 10}, | ||
/* Optimal_S15 */ {0, 1, 2, 13, 4, 7, 15, 6, 8, 14, 12, 11, 9, 3, 10, 5} | ||
}; | ||
|
||
#endif //GSBOXES_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
not1_cost=0.5 | ||
and2_cost=1.5 | ||
nand2_cost=1.00 | ||
or2_cost=1.5 | ||
nor2_cost=1.00 | ||
xor2_cost=2.00 | ||
xnor2_cost=2.00 | ||
maoi1_cost=2.50 | ||
moai1_cost=2.50 | ||
nand3_cost=1.5 | ||
nor3_cost=1.5 | ||
and3_cost=2 | ||
or3_cost=2 | ||
andn2_cost=1.5 | ||
orn2_cost=1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
not1_cost=0.5 | ||
and2_cost=1.5 | ||
nand2_cost=1.00 | ||
or2_cost=1.5 | ||
nor2_cost=1.00 | ||
xor2_cost=3.00 | ||
xnor2_cost=3.00 | ||
maoi1_cost=2.50 | ||
moai1_cost=2.50 | ||
nand3_cost=1.5 | ||
nor3_cost=1.5 | ||
and3_cost=2 | ||
or3_cost=2 | ||
andn2_cost=1.5 | ||
orn2_cost=1.5 | ||
#not1_cost=0.5 | ||
#and2_cost=1.5 | ||
#nand2_cost=1.00 | ||
#or2_cost=1.5 | ||
#nor2_cost=1.00 | ||
#xor2_cost=2.00 | ||
#xnor2_cost=2.00 | ||
#maoi1_cost=2.50 | ||
#moai1_cost=2.50 | ||
#nand3_cost=1.5 | ||
#nor3_cost=1.5 | ||
#and3_cost=2 | ||
#or3_cost=2 | ||
#andn2_cost=1.5 | ||
#orn2_cost=1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
not1_cost=0.67 | ||
and2_cost=1.33 | ||
nand2_cost=1.00 | ||
or2_cost=1.33 | ||
nor2_cost=1.00 | ||
xor2_cost=3.00 | ||
xnor2_cost=3.00 | ||
maoi1_cost=2.67 | ||
moai1_cost=2.00 | ||
nand3_cost=1.33 | ||
nor3_cost=1.33 | ||
and3_cost=2.33 | ||
or3_cost=2.33 | ||
andn2_cost=1.67 | ||
orn2_cost=1.67 |
Oops, something went wrong.