Skip to content

Commit 80d8dfe

Browse files
committed
Introduce sm-cipher workflow tests to wolfsm
1 parent 24eeb72 commit 80d8dfe

File tree

3 files changed

+214
-0
lines changed

3 files changed

+214
-0
lines changed

.github/SECURITY.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Security Policy
2+
3+
## Reporting a Vulnerability
4+
5+
If you discover a vulnerability, please report it to [email protected]
6+
7+
1. Include a detailed description
8+
2. Include method to reproduce and/or method of discovery
9+
3. We will evaluate the report promptly and respond to you with findings.
10+
4. We will credit you with the report if you would like.
11+
12+
**Please keep the vulnerability private** until a fix has been released.

.github/workflows/sm-cipher.yml

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
name: SM Cipher Test (2 of 2)
2+
#
3+
# Test fetches wolfssl-examples/Arduino and uses local, latest github master branch wolfssl
4+
#
5+
# These 4 workflows across 3 repos are interdependent for the current $REPO_OWNER:
6+
#
7+
# sm-cipher CI Build 1: https://github.com/$REPO_OWNER/wolfssl # /.github/workflows/sm-cipher.yml
8+
# - Builds SM-enabled library from local clone of wolfssl master branch
9+
# - Fetches examples from https://github.com/$REPO_OWNER/wolfsm
10+
#
11+
# THIS sm-cipher CI Build 2: https://github.com/$REPO_OWNER/wolfsm # /.github/workflows/sm-cipher.yml
12+
# - Builds SM-enabled library from fresh clone of wolfssl master branch here
13+
#
14+
# ** NOTE TO MAINTAINERS **
15+
#
16+
# Consider using winmerge or similar tool to keep the 2 sm-cipher.yml files in relative sync.
17+
# Although there are some specific differences, most of the contents are otherwise identical.
18+
#
19+
20+
# START OF COMMON SECTION
21+
on:
22+
push:
23+
branches: [ '**', 'master', 'main', 'release/**' ]
24+
paths:
25+
- '.github/workflows/sm-cipher.yml'
26+
- './**'
27+
pull_request:
28+
# Run after merge on protected branches
29+
branches: [ "main", "master", "release/**" ]
30+
paths:
31+
- '.github/workflows/sm-cipher.yml'
32+
- './**'
33+
workflow_dispatch:
34+
35+
concurrency:
36+
group: ${{ github.workflow }}-${{ github.ref }}
37+
cancel-in-progress: true
38+
# END OF COMMON SECTION
39+
40+
jobs:
41+
build:
42+
if: github.repository_owner == 'wolfssl'
43+
runs-on: ubuntu-latest
44+
env:
45+
REPO_OWNER: ${{ github.repository_owner }}
46+
steps:
47+
- name: Checkout Repository
48+
uses: actions/checkout@v4
49+
50+
- name: Set job environment variables
51+
run: |
52+
# Script to assign some common environment variables after everything is installed
53+
54+
ICON_OK=$(printf "\xE2\x9C\x85")
55+
ICON_FAIL=$(printf "\xE2\x9D\x8C")
56+
57+
# Show predefined summary:
58+
59+
# For the wolfssl repo, the GITHUB_WORKSPACE is the directory of wolfssl
60+
echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE"
61+
62+
# Show assigned build:env values (e.g. "wolfssl", "gojimmpi" or other owners):
63+
echo "REPO_OWNER = $REPO_OWNER"
64+
65+
# Update environment variables, not available here in this step yet
66+
echo "GITHUB_WORK=$(realpath "$GITHUB_WORKSPACE/../..")" >> "$GITHUB_ENV"
67+
echo "WOLFSM_ROOT=$(realpath "$GITHUB_WORKSPACE/../wolfsm")" >> "$GITHUB_ENV"
68+
echo "WOLFSSL_ROOT=$(realpath "$GITHUB_WORKSPACE/../wolfssl")" >> "$GITHUB_ENV"
69+
70+
echo "GITHUB_ENV=$GITHUB_ENV"
71+
72+
git status
73+
74+
echo "contents..."
75+
# typically "/home/runner/work/wolfssl/wolfssl" contains wolfssl source
76+
pwd
77+
ls
78+
# ** END ** Set job environment variables
79+
80+
- name: Get wolfssl
81+
run: |
82+
# We are in wolfsm repo, fetch wolfssl code
83+
84+
# Show our custom values:
85+
echo "GITHUB_WORK = $GITHUB_WORK"
86+
87+
# WOLFSM_ROOT is the repo root for wolfsm clone
88+
echo "WOLFSM_ROOT = $WOLFSM_ROOT"
89+
90+
echo "Start pwd:"
91+
pwd
92+
# we're typically in $GITHUB_WORKSPACE=/home/runner/work/wolfssl/wolfssl
93+
# goto /home/runner/work to fetch wolfsm
94+
95+
echo "Current pwd for wolfsm clone fetch: $(pwd)"
96+
GITHUB_WORK=$(realpath "$GITHUB_WORKSPACE/../..")
97+
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
98+
99+
100+
pushd ../
101+
echo "Updated pwd for wolfssl clone fetch: $(pwd)"
102+
103+
echo "clone --depth 1 https://github.com/$REPO_OWNER/wolfssl.git wolfssl"
104+
105+
git clone --depth 1 https://github.com/$REPO_OWNER/wolfssl.git wolfssl
106+
107+
cd ./wolfssl
108+
echo "Contents of this path for wolfssl = $(pwd)"
109+
ls
110+
popd
111+
112+
# ** END ** Get wolfssl
113+
114+
- name: Install wolfsm
115+
run: |
116+
# Run the local install.sh install script to install wolfsm code
117+
118+
echo "Current pwd for wolfsm clone fetch: $(pwd)"
119+
GITHUB_WORK=$(realpath "$GITHUB_WORKSPACE/../..")
120+
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
121+
122+
# Typically /home/runner/work
123+
echo "GITHUB_WORK=$GITHUB_WORK"
124+
pwd
125+
echo "pushd $WOLFSM_ROOT"
126+
pushd "$WOLFSM_ROOT"
127+
pwd
128+
ls
129+
130+
echo "wolfssl check"
131+
ls ../wolfssl
132+
133+
echo "Call wolfsm/install.sh to install wolfsm code into $WOLFSSL_ROOT"
134+
./install.sh "$WOLFSSL_ROOT"
135+
popd
136+
137+
echo "contents..."
138+
pwd
139+
ls
140+
141+
# ** END ** Install wolfsm
142+
143+
- name: Compile wolfssl
144+
run: |
145+
# Compile fresh wolfSSL with wolfsm code
146+
147+
cd "$WOLFSSL_ROOT"
148+
echo "Current directory: $PWD"
149+
150+
./autogen.sh
151+
./configure --enable-sm3 --enable-sm4-ecb --enable-sm4-cbc --enable-sm4-ctr --enable-sm4-gcm --enable-sm4-ccm --enable-sm2
152+
make
153+
154+
# ** END ** Compile wolfssl
155+
156+
- name: make check
157+
run: |
158+
# make check
159+
160+
cd "$WOLFSSL_ROOT"
161+
echo "Current directory: $PWD"
162+
163+
make check
164+
165+
# ** END ** make check
166+
167+
- name: Unit test
168+
run: |
169+
# Run unit.test ./tests/test-sm2.conf
170+
171+
cd "$WOLFSSL_ROOT"
172+
echo "Current directory: $PWD"
173+
174+
echo "looking for test-sm2.conf"
175+
ls ./tests/test-sm2.conf
176+
177+
echo "Run unit test: ./tests/unit.test ./tests/test-sm2.conf"
178+
./tests/unit.test ./tests/test-sm2.conf
179+
180+
# ** END ** Unit test
181+
182+
- name: Run SM benchmark
183+
shell: bash
184+
run: |
185+
# Run benchmark from cloned wolfssl directory
186+
187+
cd "$WOLFSSL_ROOT"
188+
echo "Current directory: $PWD"
189+
190+
set -euo pipefail
191+
192+
./wolfcrypt/benchmark/benchmark
193+
194+
# ** END ** un SM benchmark

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Visual Studio
2+
/.vs
3+
4+
# Visual Studio Code Workspace Files
5+
*.vscode
6+
7+
# Backup files
8+
*.bak

0 commit comments

Comments
 (0)