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

Fix tlcp client; refactor SM2&SM3&SM4; Add about page #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
33 changes: 24 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ jobs:
run: |
clang-format-15 --Werror --dry-run *.cpp *.h

build-on-linux:
runs-on: ubuntu-latest
unix:
strategy:
fail-fast: false
matrix:
os: [
macos-12,
macos-13,
ubuntu-20.04,
ubuntu-22.04,
]
runs-on: ${{ matrix.os }}
steps:
- name: checkout tongsuo
uses: actions/checkout@v3
Expand All @@ -37,24 +46,30 @@ jobs:
- name: build Tongsuo
working-directory: ./Tongsuo
run: |
./config --banner=Configured --prefix=${RUNNER_TEMP}/tongsuo enable-ntls
./config --banner=Configured --prefix=${RUNNER_TEMP}/tongsuo --libdir=${RUNNER_TEMP}/tongsuo/lib enable-ntls
make -s -j4
make install

- uses: actions/checkout@v3
- name: install QT
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
with:
version: 6.2.4
version: 6.5.3

- name: build tsapp
run: |
TONGSUO_HOME=${RUNNER_TEMP}/tongsuo PREFIX=${RUNNER_TEMP}/tsapp qmake
make -s -j4
make install

build-on-windows:
runs-on: windows-latest
windows:
strategy:
fail-fast: false
matrix:
os:
- windows-2019
- windows-2022
runs-on: ${{ matrix.os }}
steps:
- uses: ilammy/msvc-dev-cmd@v1
with:
Expand Down Expand Up @@ -82,9 +97,9 @@ jobs:

- uses: actions/checkout@v3
- name: install QT
uses: jurplel/install-qt-action@v3
uses: jurplel/install-qt-action@v4
with:
version: 6.2.4
version: 6.5.3

- name: build tsapp
shell: cmd
Expand Down
169 changes: 169 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
name: release

on:
workflow_dispatch:
tags:
- '*'
env:
TONGSUO_VERSION: 8.4.0

permissions:
contents: write

jobs:
new_release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release
- First Change
- Second Change
draft: true
prerelease: true

build_linux_macos:
runs-on: ${{ matrix.os}}
needs: [new_release]
strategy:
matrix:
os: [macos-latest, ubuntu-20.04]
name: "build-${{ matrix.os }}"
steps:
- name: build Tongsuo
run: |
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${TONGSUO_VERSION}.tar.gz"
tar zxf "${TONGSUO_VERSION}.tar.gz"
pushd "Tongsuo-${TONGSUO_VERSION}"
./config --prefix=${RUNNER_TEMP}/tongsuo --libdir=${RUNNER_TEMP}/tongsuo/lib no-shared no-dso enable-ntls --release
make -s -j4
make install
popd
- uses: actions/checkout@v3
- name: install QT
uses: jurplel/install-qt-action@v4
with:
version: 6.5.3

- name: build tsapp
run: |
TONGSUO_HOME=${RUNNER_TEMP}/tongsuo PREFIX=${RUNNER_TEMP}/tsapp qmake
make -s -j4
make install
find ${RUNNER_TEMP}/tsapp

- name: package for macos
run: |
macdeployqt tsapp.app -qmldir=. -verbose=1 -dmg
if: ${{ matrix.os == 'macos-latest' }}

- name: upload artifact for macos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.new_release.outputs.upload_url }}
asset_path: tsapp.dmg
asset_name: tsapp-${{ runner.os }}.dmg
asset_content_type: application/octet-stream
if: ${{ matrix.os == 'macos-latest' }}

- name: install linuxdeployqt and package for linux
run: |
wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
chmod +x linuxdeployqt-continuous-x86_64.AppImage
cp linuxdeployqt-continuous-x86_64.AppImage /usr/local/bin/linuxdeployqt
mkdir -p ${RUNNER_TEMP}/Install/tsapp/
cp ${RUNNER_TEMP}/tsapp/tsapp ${RUNNER_TEMP}/Install/tsapp/
cd ${RUNNER_TEMP}/Install/tsapp/
linuxdeployqt tsapp -appimage -no-copy-copyright-files -no-plugins -no-translations || echo
cd ..
tar czf tsapp.tgz tsapp
if: ${{ matrix.os == 'ubuntu-20.04' }}

- name: upload artifact for linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.new_release.outputs.upload_url }}
asset_path: ${{ runner.temp }}/Install/tsapp.tgz
asset_name: tsapp-${{ runner.os }}.tgz
asset_content_type: application/x-compressed-tar
if: ${{ matrix.os == 'ubuntu-20.04' }}

build_windows:
runs-on: windows-latest
needs: [new_release]
steps:
- run: choco install -y winrar
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: win64
- uses: ilammy/setup-nasm@v1
with:
platform: win64
- uses: shogo82148/actions-setup-perl@v1
- name: Download Tongsuo source
run: |
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${env:TONGSUO_VERSION}.tar.gz" -OutFile "${env:TONGSUO_VERSION}.tar.gz"
shell: powershell
- run: |
"C:\Program Files\WinRAR\WinRAR.exe" -INUL x %TONGSUO_VERSION%.tar.gz
shell: cmd
- name: build Tongsuo
shell: cmd
run: |
pushd "Tongsuo-%TONGSUO_VERSION%"
mkdir _build
pushd _build
perl ..\Configure no-makedepend no-shared enable-ntls VC-WIN64A --prefix=%RUNNER_TEMP%\tongsuo
nmake /S
nmake install_sw
popd
popd
- uses: actions/checkout@v3
- name: install QT
uses: jurplel/install-qt-action@v4
with:
version: 6.5.3

- name: build tsapp
shell: cmd
run: |
set TONGSUO_HOME=%RUNNER_TEMP%\tongsuo
set PREFIX=%RUNNER_TEMP%\tsapp
qmake
nmake /S
nmake install

- name: package
shell: cmd
run: |
set PKG_DIR=tsapp-WIN64
mkdir %PKG_DIR%
cp %RUNNER_TEMP%\tsapp\tsapp.exe %PKG_DIR%\
windeployqt --qmldir . %PKG_DIR%\tsapp.exe
"C:\Program Files\WinRAR\WinRAR.exe" a tsapp.zip %PKG_DIR%\
cd
dir

- name: upload artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.new_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}\tsapp.zip
asset_name: tsapp-${{ runner.os }}.zip
asset_content_type: application/zip

21 changes: 21 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

tsapp CHANGES
-------------

Changes with 1.0.0 [xx XXX xxxx]

*) 支持随机数生成器

*) 支持SM2密钥对生成

*) 支持SM2签名和验签

*) 支持SM2加密和解密

*) 支持SM3杂凑

*) 支持SM4加解密,模式包括CBC、ECB、CFB、OFB、CTR

*) 支持双证书签发

*) 支持TLCP客户端
30 changes: 16 additions & 14 deletions TongsuoToolbox_v01.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ CONFIG += c++17
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

TARGET=tsapp

SOURCES += \
home.cpp \
about.cpp \
main.cpp \
mainwindow.cpp \
randnum.cpp \
sm2.cpp \
sm2cert.cpp \
sm2encrypt.cpp \
sm2key.cpp \
Expand All @@ -25,37 +28,37 @@ SOURCES += \
tserror.cpp

HEADERS += \
home.h \
about.h \
mainwindow.h \
randnum.h \
sm2.h \
sm2cert.h \
sm2encrypt.h \
sm2key.h \
sm2signverify.h \
sm3hash.h \
sm4encrypt.h \
tlcpclient.h \
tserror.h
tserror.h \
version.h

# Default rules for deployment.
target.path = $$(PREFIX)
!isEmpty(target.path): INSTALLS += target

win32: LIBS += -ladvapi32 -lcrypt32 -lgdi32 -luser32 -lws2_32 -L$$(TONGSUO_HOME)/lib -llibcrypto
else:unix: LIBS += -L$$(TONGSUO_HOME)/lib64 -lcrypto

win32: LIBS += -ladvapi32 -lcrypt32 -lgdi32 -luser32 -lws2_32 -L$$(TONGSUO_HOME)/lib -llibssl
else:unix: LIBS += -L$$(TONGSUO_HOME)/lib64 -lssl
win32: LIBS += -ladvapi32 -lcrypt32 -lgdi32 -luser32 -lws2_32 -L$$(TONGSUO_HOME)/lib -llibssl -llibcrypto
else:unix: LIBS += -L$$(TONGSUO_HOME)/lib -lssl -lcrypto

INCLUDEPATH += $$(TONGSUO_HOME)/include
DEPENDPATH += $$(TONGSUO_HOME)/include

win32-g++: PRE_TARGETDEPS += $$(TONGSUO_HOME)/lib/libcrypto.lib.a
else:win32:!win32-g++: PRE_TARGETDEPS += $$(TONGSUO_HOME)/lib/libcrypto.lib
else:unix: PRE_TARGETDEPS += $$(TONGSUO_HOME)/lib64/libcrypto.a
win32-g++: PRE_TARGETDEPS += $$(TONGSUO_HOME)/lib/libcrypto.lib.a $$(TONGSUO_HOME)/lib/libssl.lib.a
else:win32:!win32-g++: PRE_TARGETDEPS += $$(TONGSUO_HOME)/lib/libcrypto.lib $$(TONGSUO_HOME)/lib/libssl.lib
else:unix: PRE_TARGETDEPS += $$(TONGSUO_HOME)/lib/libssl.a $$(TONGSUO_HOME)/lib/libcrypto.a

FORMS += \
home.ui \
about.ui \
mainwindow.ui \
randnum.ui \
sm2cert.ui \
sm2encrypt.ui \
Expand All @@ -66,7 +69,6 @@ FORMS += \
tlcpclient.ui

RESOURCES += \
certs.qrc \
images.qrc
certs.qrc

DISTFILES +=
26 changes: 26 additions & 0 deletions about.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "about.h"
#include "ui_about.h"
#include "version.h"

About::About(QWidget *parent)
: QDialog(parent)
, ui(new Ui::About)
{
ui->setupUi(this);

QString text = ui->textBrowser->toHtml();

text.replace("|version|", version);

ui->textBrowser->setHtml(text);
}

About::~About()
{
delete ui;
}

void About::on_pushButton_clicked()
{
this->close();
}
25 changes: 25 additions & 0 deletions about.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef ABOUT_H
#define ABOUT_H

#include <QDialog>

namespace Ui {
class About;
}

class About : public QDialog
{
Q_OBJECT

public:
explicit About(QWidget *parent = nullptr);
~About();

private slots:
void on_pushButton_clicked();

private:
Ui::About *ui;
};

#endif // ABOUT_H
Loading
Loading