Skip to content

Commit e9beae4

Browse files
author
gojimmypi
committed
Introduce sm-cipher workflow tests to wolfsm
1 parent 24eeb72 commit e9beae4

3 files changed

Lines changed: 206 additions & 0 deletions

File tree

.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 support@wolfssl.com
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: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
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+
79+
- name: Get wolfssl
80+
run: |
81+
# We are in wolfsm repo, fetch wolfssl code
82+
83+
# Show our custom values:
84+
echo "GITHUB_WORK = $GITHUB_WORK"
85+
86+
# WOLFSM_ROOT is the repo root for wolfsm clone
87+
echo "WOLFSM_ROOT = $WOLFSM_ROOT"
88+
89+
echo "Start pwd:"
90+
pwd
91+
# we're typically in $GITHUB_WORKSPACE=/home/runner/work/wolfssl/wolfssl
92+
# goto /home/runner/work to fetch wolfsm
93+
94+
echo "Current pwd for wolfsm clone fetch: $(pwd)"
95+
GITHUB_WORK=$(realpath "$GITHUB_WORKSPACE/../..")
96+
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
97+
98+
99+
pushd ../
100+
echo "Updated pwd for wolfssl clone fetch: $(pwd)"
101+
102+
echo "clone --depth 1 https://github.com/$REPO_OWNER/wolfssl.git wolfssl"
103+
104+
git clone --depth 1 https://github.com/$REPO_OWNER/wolfssl.git wolfssl
105+
106+
cd ./wolfssl
107+
echo "Contents of this path for wolfssl = $(pwd)"
108+
ls
109+
popd
110+
111+
# ** END ** Get wolfssl
112+
113+
- name: Install wolfsm
114+
run: |
115+
# Run the local install.sh install script to install wolfsm code
116+
117+
echo "Current pwd for wolfsm clone fetch: $(pwd)"
118+
GITHUB_WORK=$(realpath "$GITHUB_WORKSPACE/../..")
119+
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
120+
121+
# Typically /home/runner/work
122+
echo "GITHUB_WORK=$GITHUB_WORK"
123+
pwd
124+
echo "pushd $WOLFSM_ROOT"
125+
pushd "$WOLFSM_ROOT"
126+
pwd
127+
ls
128+
129+
echo "wolfssl check"
130+
ls ../wolfssl
131+
132+
echo "Call wolfsm/install.sh to install wolfsm code into $WOLFSSL_ROOT"
133+
./install.sh "$WOLFSSL_ROOT"
134+
popd
135+
136+
echo "contents..."
137+
pwd
138+
ls
139+
140+
# Done with install wolfssl
141+
142+
- name: Compile wolfssl
143+
run: |
144+
# Compile fresh wolfSSL with wolfsm code
145+
146+
cd "$WOLFSSL_ROOT"
147+
echo "Current directory: $PWD"
148+
149+
./autogen.sh
150+
./configure --enable-sm3 --enable-sm4-ecb --enable-sm4-cbc --enable-sm4-ctr --enable-sm4-gcm --enable-sm4-ccm --enable-sm2
151+
make
152+
# Done with compile wolfssl
153+
154+
- name: make check
155+
run: |
156+
# make check
157+
158+
cd "$WOLFSSL_ROOT"
159+
echo "Current directory: $PWD"
160+
161+
make check
162+
163+
- name: Unit test
164+
run: |
165+
# Run unit.test ./tests/test-sm2.conf
166+
167+
cd "$WOLFSSL_ROOT"
168+
echo "Current directory: $PWD"
169+
170+
echo "looking for test-sm2.conf"
171+
ls ./tests/test-sm2.conf
172+
173+
echo "Run unit test: ./tests/unit.test ./tests/test-sm2.conf"
174+
./tests/unit.test ./tests/test-sm2.conf
175+
176+
- name: Run SM benchmark
177+
shell: bash
178+
run: |
179+
# Run benchmark from cloned wolfssl directory
180+
181+
cd "$WOLFSSL_ROOT"
182+
echo "Current directory: $PWD"
183+
184+
set -euo pipefail
185+
186+
./wolfcrypt/benchmark/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)