Skip to content

Commit 69e2661

Browse files
committed
Used port.h macros
1 parent 77c8db6 commit 69e2661

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

.github/workflows/tpm-ssh.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,23 @@ jobs:
8585
run: |
8686
# Generate key with default password
8787
cd wolftpm
88-
./examples/keygen/keygen keyblob.bin -rsa -t -pem -eh
88+
./examples/keygen/keygen keyblob1.bin -rsa -t -pem -eh
89+
cp key.pem key1.pem # Save the key for first test
8990
9091
# Convert key to SSH format
91-
ssh-keygen -f key.pem -i -m PKCS8 > ../wolfssh/key.ssh
92+
ssh-keygen -f key1.pem -i -m PKCS8 > ../wolfssh/key1.ssh
9293
cd ..
9394
9495
# Start echoserver and wait for it to be ready
9596
cd wolfssh
96-
./examples/echoserver/echoserver -1 -s key.ssh &
97+
./examples/echoserver/echoserver -1 -s key1.ssh &
9798
echo "Echoserver started with PID: $!"
9899
sleep 2
99100
cd ..
100101
101102
# Test client connection with default password
102103
cd wolfssh
103-
./examples/client/client -i ../wolftpm/keyblob.bin -u hansel -K ThisIsMyKeyAuth
104+
./examples/client/client -i ../wolftpm/keyblob1.bin -u hansel -K ThisIsMyKeyAuth
104105
cd ..
105106
106107
# Test the TPM SSH Custom Password
@@ -109,14 +110,15 @@ jobs:
109110
# Test with custom password
110111
cd wolftpm
111112
./examples/keygen/keygen keyblob2.bin -rsa -t -pem -eh -auth=custompassword
113+
cp key.pem key2.pem # Save the key for second test
112114
113115
# Convert key to SSH format
114-
ssh-keygen -f key.pem -i -m PKCS8 > ../wolfssh/key.ssh
116+
ssh-keygen -f key2.pem -i -m PKCS8 > ../wolfssh/key2.ssh
115117
cd ..
116118
117119
# Start echoserver and wait for it to be ready
118120
cd wolfssh
119-
./examples/echoserver/echoserver -1 -s key.ssh &
121+
./examples/echoserver/echoserver -1 -s key2.ssh &
120122
echo "Echoserver started with PID: $!"
121123
sleep 2
122124
cd ..
@@ -126,18 +128,16 @@ jobs:
126128
./examples/client/client -i ../wolftpm/keyblob2.bin -u hansel -K custompassword
127129
cd ..
128130
129-
# Cleanup
130-
pkill -f tpm_server
131-
sleep 2
132-
133131
# Archive artifacts for debugging
134132
- name: Archive test artifacts
135133
if: always()
136134
uses: actions/upload-artifact@v4
137135
with:
138136
name: test-artifacts
139137
path: |
140-
wolftpm/keyblob.bin
138+
wolftpm/keyblob1.bin
141139
wolftpm/keyblob2.bin
142-
wolftpm/key.pem
143-
wolfssh/key.ssh
140+
wolftpm/key1.pem
141+
wolftpm/key2.pem
142+
wolfssh/key1.ssh
143+
wolfssh/key2.ssh

examples/echoserver/echoserver.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <wolfssh/internal.h>
4242
#include <wolfssh/wolfsftp.h>
4343
#include <wolfssh/agent.h>
44+
#include <wolfssh/port.h>
4445
#include <wolfssh/test.h>
4546
#include <wolfssl/wolfcrypt/ecc.h>
4647
#include <wolfssl/wolfcrypt/logging.h>
@@ -2101,25 +2102,24 @@ static int LoadPubKeyList(StrList* strList, int format, PwMapList* mapList)
21012102
#ifdef WOLFSSH_TPM
21022103
static char* LoadTpmSshKey(const char* keyFile)
21032104
{
2104-
FILE* file;
2105+
WFILE* file = NULL;
21052106
char* buffer = NULL;
21062107
char* ret = NULL;
21072108
long length;
21082109

2109-
file = fopen(keyFile, "rb");
2110-
if (!file) {
2110+
if (WFOPEN(NULL, &file, keyFile, "rb") != 0) {
21112111
fprintf(stderr,
21122112
"Failed to open TPM key file: %s\n", keyFile);
21132113
return NULL;
21142114
}
21152115

2116-
fseek(file, 0, SEEK_END);
2117-
length = ftell(file);
2118-
fseek(file, 0, SEEK_SET);
2116+
WFSEEK(NULL, file, 0, SEEK_END);
2117+
length = WFTELL(NULL, file);
2118+
WFSEEK(NULL, file, 0, SEEK_SET);
21192119

21202120
buffer = (char*)WMALLOC(length + 8 + 1, NULL, DYNTYPE_BUFFER);
21212121
if (buffer) {
2122-
if (fread(buffer, 1, length, file) == (size_t)length) {
2122+
if (WFREAD(NULL, buffer, 1, length, file) == (size_t)length) {
21232123
while (length > 0 && (buffer[length-1] == '\n' ||
21242124
buffer[length-1] == '\r')) {
21252125
length--;
@@ -2133,7 +2133,7 @@ static char* LoadTpmSshKey(const char* keyFile)
21332133
}
21342134
}
21352135

2136-
fclose(file);
2136+
WFCLOSE(NULL, file);
21372137
return ret;
21382138
}
21392139
#endif

0 commit comments

Comments
 (0)