Skip to content

Commit f6f2765

Browse files
Merge pull request wolfSSL#10495 from LinuxJedi/PIC32MZ-Sim
Add PIC32MZ emulator tests
2 parents 9fa5db5 + f60dc63 commit f6f2765

2 files changed

Lines changed: 91 additions & 5 deletions

File tree

.github/workflows/pic32mz-sim.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: PIC32MZ simulator test
2+
3+
# START OF COMMON SECTION
4+
on:
5+
push:
6+
branches: [ 'master', 'main', 'release/**' ]
7+
pull_request:
8+
branches: [ '*' ]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
# END OF COMMON SECTION
14+
15+
# Build the PIC32MZ software simulator (https://github.com/wolfSSL/simulators,
16+
# PIC32MZSim/ subdirectory) and run the wolfCrypt test suite on emulated
17+
# PIC32MZ EC (no FPU, CE ignores OUT_SWAP) and EF (FPU + OUT_SWAP) parts,
18+
# through both the direct-register PIC32 port and the MPLAB Harmony 3 driver
19+
# port.
20+
#
21+
# Like stm32-sim.yml, the Dockerfiles read wolfSSL from /opt/wolfssl at
22+
# runtime via a bind mount, so no Dockerfile patching is required - the PR
23+
# checkout is mounted directly.
24+
25+
jobs:
26+
pic32mz_sim:
27+
name: wolfCrypt on PIC32MZ ${{ matrix.chip_label }} (${{ matrix.port_label }})
28+
if: github.repository_owner == 'wolfssl'
29+
runs-on: ubuntu-24.04
30+
timeout-minutes: 30
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- port_label: direct
36+
chip_label: EC
37+
dockerfile: Dockerfile.wolfcrypt-direct
38+
image_tag: pic32mz-wolfcrypt-direct:ci
39+
script: run-wolfcrypt-direct-ec.sh
40+
cache_scope: pic32mz-direct
41+
- port_label: direct
42+
chip_label: EF
43+
dockerfile: Dockerfile.wolfcrypt-direct
44+
image_tag: pic32mz-wolfcrypt-direct:ci
45+
script: run-wolfcrypt-direct-ef.sh
46+
cache_scope: pic32mz-direct
47+
- port_label: harmony
48+
chip_label: EC
49+
dockerfile: Dockerfile.wolfcrypt-harmony
50+
image_tag: pic32mz-wolfcrypt-harmony:ci
51+
script: run-wolfcrypt-harmony-ec.sh
52+
cache_scope: pic32mz-harmony
53+
- port_label: harmony
54+
chip_label: EF
55+
dockerfile: Dockerfile.wolfcrypt-harmony
56+
image_tag: pic32mz-wolfcrypt-harmony:ci
57+
script: run-wolfcrypt-harmony-ef.sh
58+
cache_scope: pic32mz-harmony
59+
steps:
60+
- name: Checkout wolfSSL (PR source)
61+
uses: actions/checkout@v4
62+
with:
63+
path: wolfssl
64+
65+
- name: Clone PIC32MZ simulator
66+
run: git clone --depth 1 https://github.com/wolfSSL/simulators simulators
67+
68+
- uses: docker/setup-buildx-action@v3
69+
70+
- name: Build ${{ matrix.image_tag }} image
71+
uses: docker/build-push-action@v5
72+
with:
73+
context: simulators/PIC32MZSim
74+
file: simulators/PIC32MZSim/${{ matrix.dockerfile }}
75+
push: false
76+
load: true
77+
tags: ${{ matrix.image_tag }}
78+
cache-from: type=gha,scope=${{ matrix.cache_scope }}
79+
cache-to: type=gha,mode=max,scope=${{ matrix.cache_scope }}
80+
81+
- name: Run wolfCrypt tests on PIC32MZ ${{ matrix.chip_label }} (${{ matrix.port_label }})
82+
run: |
83+
docker run --rm \
84+
-v "${{ github.workspace }}/wolfssl:/opt/wolfssl:ro" \
85+
${{ matrix.image_tag }} \
86+
/app/scripts/${{ matrix.script }}

wolfcrypt/src/port/pic32/pic32mz-crypt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,9 @@ static int wc_Pic32HashFinal(hashUpdCache* cache, byte* stdBuf,
657657
return ret;
658658
}
659659

660-
static void wc_Pic32HashFree(hashUpdCache* cache, void* heap)
660+
static void wc_Pic32HashFree(hashUpdCache* cache, void* stdBuf, void* heap)
661661
{
662-
if (cache && cache->buf && !cache->isCopy) {
662+
if (cache && cache->buf && cache->buf != stdBuf && !cache->isCopy) {
663663
XFREE(cache->buf, heap, DYNAMIC_TYPE_HASH_TMP);
664664
cache->buf = NULL;
665665
}
@@ -713,7 +713,7 @@ static void wc_Pic32HashFree(hashUpdCache* cache, void* heap)
713713
void wc_Md5Pic32Free(wc_Md5* md5)
714714
{
715715
if (md5) {
716-
wc_Pic32HashFree(&md5->cache, md5->heap);
716+
wc_Pic32HashFree(&md5->cache, (byte*)md5->buffer, md5->heap);
717717
}
718718
}
719719
#endif /* !NO_MD5 */
@@ -764,7 +764,7 @@ static void wc_Pic32HashFree(hashUpdCache* cache, void* heap)
764764
void wc_ShaPic32Free(wc_Sha* sha)
765765
{
766766
if (sha) {
767-
wc_Pic32HashFree(&sha->cache, sha->heap);
767+
wc_Pic32HashFree(&sha->cache, (byte*)sha->buffer, sha->heap);
768768
}
769769
}
770770
#endif /* !NO_SHA */
@@ -815,7 +815,7 @@ static void wc_Pic32HashFree(hashUpdCache* cache, void* heap)
815815
void wc_Sha256Pic32Free(wc_Sha256* sha256)
816816
{
817817
if (sha256) {
818-
wc_Pic32HashFree(&sha256->cache, sha256->heap);
818+
wc_Pic32HashFree(&sha256->cache, (byte*)sha256->buffer, sha256->heap);
819819
}
820820
}
821821
#endif /* !NO_SHA256 */

0 commit comments

Comments
 (0)