Skip to content

Commit

Permalink
fixed workflow
Browse files Browse the repository at this point in the history
* removed the old uint320 dependency in the github action workflow
  • Loading branch information
mrdcvlsc committed Jun 6, 2024
1 parent a140045 commit d16ab19
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 79 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ jobs:
- name: install clang
run: sudo apt install clang

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: get updated submodules
run: git submodule update --init --recursive

- name: build and compile the static library.
run: make -f staticlib CC=clang++
run: make -f staticlib CXX=clang++

- name: run the tests for the static library.
run: make -f staticlib static_test CC=clang++
run: make -f staticlib static_test CXX=clang++

- name: clean test executables
run: make clean

- name: install the static library.
run: sudo make -f staticlib install CC=clang++
run: sudo make -f staticlib install CXX=clang++

- name: compile the static sample program for the library.
run: clang++ static-build.cpp -o static-build.out -lchacha20 -fsanitize=address
Expand All @@ -48,7 +51,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: get updated submodules
run: git submodule update --init --recursive

- name: build and compile the static library.
run: make -f staticlib
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ jobs:
- name: install clang
run: sudo apt install clang

- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: get updated submodules
run: git submodule update --init --recursive

- name: compile and run tests in header mode
run: make header_test CC=clang++
run: make header_test CXX=clang++
6 changes: 5 additions & 1 deletion .github/workflows/gcc-gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: get updated submodules
run: git submodule update --init --recursive

- name: compile and run tests in header mode
run: make header_test
7 changes: 6 additions & 1 deletion .github/workflows/mingw64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: get updated submodules
run: git submodule update --init --recursive

- name: compiler architecture
run: gcc -dumpmachine

- name: compile and run tests in header mode
run: make header_test
3 changes: 3 additions & 0 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: get updated submodules
run: git submodule update --init --recursive

- name: Configure test executables
run: cmake -S tests -B tests ${{matrix.platform.flags}}
Expand Down
3 changes: 2 additions & 1 deletion ChaCha20-Poly1305.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef CHACHA20_CPP_mrdcvlsc
#define CHACHA20_CPP_mrdcvlsc
#include "extended-precision-integers/include/epi/epi.hpp"
#include <cstring>
#include <iostream>

#include "extended-precision-integers/include/epi/epi.hpp"

#ifdef _MAKE_LIB
#include "ChaCha20-Poly1305.hpp"
#endif
Expand Down
26 changes: 9 additions & 17 deletions aarch64test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
CC := g++
TESTFLAGS := -g -Og -D_HIDE_WARNING
CXXFLAGS := -std=c++11 -Wall -Wextra
CXX:=g++
TESTFLAGS:=-g -Og -D_HIDE_WARNING
CXXFLAGS:=-std=c++20 -Wall -Wextra

OS := $(shell uname)
OS:=$(shell uname)

SRC := tests
SRC_FILES := $(wildcard $(SRC)/*.cpp)
OBJ := $(patsubst $(SRC)/%.cpp,$(SRC)/%.out,$(SRC_FILES))
SRC:=tests
SRC_FILES:=$(wildcard $(SRC)/*.cpp)
OBJ:=$(patsubst $(SRC)/%.cpp,$(SRC)/%.out,$(SRC_FILES))

# -------------------------- run test programs ---------------------------

Expand All @@ -17,14 +17,6 @@ header_test: $(OBJ)
@./$(SRC)/QuarterRound_test.out
@./$(SRC)/BlockFunction_test.out
@./$(SRC)/Encryption_test.out
@./$(SRC)/constructor.out
@./$(SRC)/comparison.out
@./$(SRC)/leftshifts.out
@./$(SRC)/rightshifts.out
@./$(SRC)/addition.out
@./$(SRC)/subtraction.out
@./$(SRC)/multiplication.out
@./$(SRC)/division.out
@./$(SRC)/poly1305_mac_test.out
@./$(SRC)/poly1305_keygen.out
@./$(SRC)/chacha20_aead_enc_dec.out
Expand Down Expand Up @@ -58,8 +50,8 @@ header_test: $(OBJ)
# -------------------------- test program compilation ---------------------------

$(SRC)/%.out: $(SRC)/%.cpp
@echo "compiling test program - compiler : $(CC)"
@$(CC) $(TESTFLAGS) $(CXXFLAGS) -o $@ $<
@echo "compiling test program - compiler : $(CXX)"
@$(CXX) $(TESTFLAGS) $(CXXFLAGS) -o $@ $<

clean:
ifeq ($(OS), Linux)
Expand Down
28 changes: 10 additions & 18 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
CC := g++
TESTFLAGS := -g -Og -D_HIDE_WARNING
CXXFLAGS := -std=c++20 -Wall -Wextra
CXX:=g++
TESTFLAGS:=-g -Og -D_HIDE_WARNING
CXXFLAGS:=-std=c++20 -Wall -Wextra

OS := $(shell uname)
OS:=$(shell uname)

ifeq ($(OS), Linux)
TESTFLAGS += -fsanitize=address
TESTFLAGS+=-fsanitize=address
endif

SRC := tests
SRC_FILES := $(wildcard $(SRC)/*.cpp)
OBJ := $(patsubst $(SRC)/%.cpp,$(SRC)/%.out,$(SRC_FILES))
SRC:=tests
SRC_FILES:=$(wildcard $(SRC)/*.cpp)
OBJ:=$(patsubst $(SRC)/%.cpp,$(SRC)/%.out,$(SRC_FILES))

# -------------------------- run test programs ---------------------------

Expand All @@ -21,14 +21,6 @@ header_test: $(OBJ)
@./$(SRC)/QuarterRound_test.out
@./$(SRC)/BlockFunction_test.out
@./$(SRC)/Encryption_test.out
@./$(SRC)/constructor.out
@./$(SRC)/comparison.out
@./$(SRC)/leftshifts.out
@./$(SRC)/rightshifts.out
@./$(SRC)/addition.out
@./$(SRC)/subtraction.out
@./$(SRC)/multiplication.out
@./$(SRC)/division.out
@./$(SRC)/poly1305_mac_test.out
@./$(SRC)/poly1305_keygen.out
@./$(SRC)/chacha20_aead_enc_dec.out
Expand Down Expand Up @@ -62,9 +54,9 @@ header_test: $(OBJ)
# -------------------------- test program compilation ---------------------------

$(SRC)/%.out: $(SRC)/%.cpp
# @echo "compiling test program - compiler : $(CC)"
# @echo "compiling test program - compiler : $(CXX)"
# @echo "flags: $<"
$(CC) $(TESTFLAGS) $(CXXFLAGS) -o $@ $<
$(CXX) $(TESTFLAGS) $(CXXFLAGS) -o $@ $<

clean:
ifeq ($(OS), Linux)
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![build](https://github.com/mrdcvlsc/ChaCha20-Poly1305/actions/workflows/build.yml/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)

A from scratch C++ (with slight inline assembly) implementation of ```ChaCha20 & Poly1305``` stream cipher described in [RFC - 8439](https://www.rfc-editor.org/info/rfc8439).
A from scratch C++ implementation of ```ChaCha20 & Poly1305``` stream cipher described in [RFC - 8439](https://www.rfc-editor.org/info/rfc8439).

**tests:**

Expand Down
54 changes: 21 additions & 33 deletions staticlib
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
CC := g++
CXX:=g++
INSTALL_PREFIX=/usr/local/

HEADER_OUT:=build/include
LIB_OUT:=build/lib
LIB_OUTNAME:=libchacha20.a

CXXFLAGS := -std=c++11 -Wall -Wextra
USERFLAGS := -D_MAKE_LIB -D_HIDE_WARNING
TEST_OPTIMIZATION := -g -Og
HEADER_PATHS := -I./$(HEADER_OUT)
LIB_OPTIMIZATION := -O2
LIB_PATHS := -L./$(LIB_OUT)
LIBS := -lchacha20
CXXFLAGS:=-std=c++11 -Wall -Wextra
USERFLAGS:=-D_MAKE_LIB -D_HIDE_WARNING
TEST_OPTIMIZATION:=-g -Og
HEADER_PATHS:=-I./$(HEADER_OUT)
LIB_OPTIMIZATION:=-O2
LIB_PATHS:=-L./$(LIB_OUT)
LIBS:=-lchacha20

OS := $(shell uname)
OS:=$(shell uname)

ifeq ($(OS), Linux)
TEST_OPTIMIZATION += -fsanitize=address
TEST_OPTIMIZATION+=-fsanitize=address
endif

SRC := tests
SRC_FILES := $(wildcard $(SRC)/*.cpp)
OBJ := $(patsubst $(SRC)/%.cpp,$(SRC)/%.out,$(SRC_FILES))
SRC:=tests
SRC_FILES:=$(wildcard $(SRC)/*.cpp)
OBJ:=$(patsubst $(SRC)/%.cpp,$(SRC)/%.out,$(SRC_FILES))

default:
ifeq ($(OS), Linux)
Expand All @@ -30,12 +30,10 @@ ifeq ($(OS), Linux)
@mkdir $(HEADER_OUT)
@mkdir $(LIB_OUT)
@echo "creating static lib"
@echo "compiling uint320..."
@$(CC) -c uint320.cpp $(LIB_OPTIMIZATION) $(USERFLAGS)
@echo "compiling ChaCha20..."
@$(CC) -c ChaCha20-Poly1305.cpp $(LIB_OPTIMIZATION) $(USERFLAGS)
@$(CXX) -c ChaCha20-Poly1305.cpp $(LIB_OPTIMIZATION) $(USERFLAGS)
@echo "compiling $(LIB_OUTNAME)..."
@ar -r $(LIB_OUTNAME) uint320.o ChaCha20-Poly1305.o
@ar -r $(LIB_OUTNAME) ChaCha20-Poly1305.o
@echo "build done : output -> $(LIB_OUTNAME)"
@echo "moving files to build folder"
@mv $(dir $(abspath $(lastword $(MAKEFILE_LIST))))$(LIB_OUTNAME) ./$(LIB_OUT)/
Expand All @@ -46,12 +44,10 @@ else
@mkdir "$(HEADER_OUT)"
@mkdir "$(LIB_OUT)"
@echo "creating static lib"
@echo "compiling uint320..."
@$(CC) -c uint320.cpp $(LIB_OPTIMIZATION) $(USERFLAGS)
@echo "compiling ChaCha20..."
@$(CC) -c ChaCha20-Poly1305.cpp $(LIB_OPTIMIZATION) $(USERFLAGS)
@$(CXX) -c ChaCha20-Poly1305.cpp $(LIB_OPTIMIZATION) $(USERFLAGS)
@echo "compiling $(LIB_OUTNAME)..."
@ar -r $(LIB_OUTNAME) uint320.o ChaCha20.o
@ar -r $(LIB_OUTNAME) ChaCha20.o
@echo "build done : output -> $(LIB_OUTNAME)"
@echo "moving files to build folder"
@move "./$(LIB_OUTNAME)" "$(LIB_OUT)"
Expand All @@ -74,14 +70,14 @@ ifeq ($(OS), Linux)
@echo ""
@echo "running build test"
@cp static-build.cpp build
@$(CC) build/static-build.cpp -o build/static-build.out -I./$(HEADER_OUT)/ -L./$(LIB_OUT) $(LIBS)
@$(CXX) build/static-build.cpp -o build/static-build.out -I./$(HEADER_OUT)/ -L./$(LIB_OUT) $(LIBS)
@./build/static-build.out
else
@echo "==============================="
@echo ""
@echo "running build test"
@copy static-build.cpp build
@$(CC) build/static-build.cpp -o build/static-build.exe -I./$(HEADER_OUT)/ -L./$(LIB_OUT) $(LIBS)
@$(CXX) build/static-build.cpp -o build/static-build.exe -I./$(HEADER_OUT)/ -L./$(LIB_OUT) $(LIBS)
@build/static-build.exe
endif

Expand All @@ -93,14 +89,6 @@ static_test: $(OBJ)
@./$(SRC)/QuarterRound_test.out
@./$(SRC)/BlockFunction_test.out
@./$(SRC)/Encryption_test.out
@./$(SRC)/constructor.out
@./$(SRC)/comparison.out
@./$(SRC)/leftshifts.out
@./$(SRC)/rightshifts.out
@./$(SRC)/addition.out
@./$(SRC)/subtraction.out
@./$(SRC)/multiplication.out
@./$(SRC)/division.out
@./$(SRC)/poly1305_mac_test.out
@./$(SRC)/poly1305_keygen.out
@./$(SRC)/chacha20_aead_enc_dec.out
Expand Down Expand Up @@ -134,8 +122,8 @@ static_test: $(OBJ)
# -------------------------- test program compilation ---------------------------

$(SRC)/%.out: $(SRC)/%.cpp
@echo "compiling test program (static build) - compiler : $(CC)"
@$(CC) $(CXXFLAGS) $(USERFLAGS) $(HEADER_PATHS) -o $@ $< $(LIB_PATHS) $(LIBS) $(TEST_OPTIMIZATION)
@echo "compiling test program (static build) - compiler : $(CXX)"
@$(CXX) $(CXXFLAGS) $(USERFLAGS) $(HEADER_PATHS) -o $@ $< $(LIB_PATHS) $(LIBS) $(TEST_OPTIMIZATION)

install:
ifeq ($(OS), Linux)
Expand Down

0 comments on commit d16ab19

Please sign in to comment.