Used port.h macros

pull/754/head
aidan garske 2025-04-01 21:58:49 -07:00
parent 77c8db6cc2
commit 69e266178f
2 changed files with 21 additions and 21 deletions

View File

@ -85,22 +85,23 @@ jobs:
run: |
# Generate key with default password
cd wolftpm
./examples/keygen/keygen keyblob.bin -rsa -t -pem -eh
./examples/keygen/keygen keyblob1.bin -rsa -t -pem -eh
cp key.pem key1.pem # Save the key for first test
# Convert key to SSH format
ssh-keygen -f key.pem -i -m PKCS8 > ../wolfssh/key.ssh
ssh-keygen -f key1.pem -i -m PKCS8 > ../wolfssh/key1.ssh
cd ..
# Start echoserver and wait for it to be ready
cd wolfssh
./examples/echoserver/echoserver -1 -s key.ssh &
./examples/echoserver/echoserver -1 -s key1.ssh &
echo "Echoserver started with PID: $!"
sleep 2
cd ..
# Test client connection with default password
cd wolfssh
./examples/client/client -i ../wolftpm/keyblob.bin -u hansel -K ThisIsMyKeyAuth
./examples/client/client -i ../wolftpm/keyblob1.bin -u hansel -K ThisIsMyKeyAuth
cd ..
# Test the TPM SSH Custom Password
@ -109,14 +110,15 @@ jobs:
# Test with custom password
cd wolftpm
./examples/keygen/keygen keyblob2.bin -rsa -t -pem -eh -auth=custompassword
cp key.pem key2.pem # Save the key for second test
# Convert key to SSH format
ssh-keygen -f key.pem -i -m PKCS8 > ../wolfssh/key.ssh
ssh-keygen -f key2.pem -i -m PKCS8 > ../wolfssh/key2.ssh
cd ..
# Start echoserver and wait for it to be ready
cd wolfssh
./examples/echoserver/echoserver -1 -s key.ssh &
./examples/echoserver/echoserver -1 -s key2.ssh &
echo "Echoserver started with PID: $!"
sleep 2
cd ..
@ -126,10 +128,6 @@ jobs:
./examples/client/client -i ../wolftpm/keyblob2.bin -u hansel -K custompassword
cd ..
# Cleanup
pkill -f tpm_server
sleep 2
# Archive artifacts for debugging
- name: Archive test artifacts
if: always()
@ -137,7 +135,9 @@ jobs:
with:
name: test-artifacts
path: |
wolftpm/keyblob.bin
wolftpm/keyblob1.bin
wolftpm/keyblob2.bin
wolftpm/key.pem
wolfssh/key.ssh
wolftpm/key1.pem
wolftpm/key2.pem
wolfssh/key1.ssh
wolfssh/key2.ssh

View File

@ -41,6 +41,7 @@
#include <wolfssh/internal.h>
#include <wolfssh/wolfsftp.h>
#include <wolfssh/agent.h>
#include <wolfssh/port.h>
#include <wolfssh/test.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include <wolfssl/wolfcrypt/logging.h>
@ -2101,25 +2102,24 @@ static int LoadPubKeyList(StrList* strList, int format, PwMapList* mapList)
#ifdef WOLFSSH_TPM
static char* LoadTpmSshKey(const char* keyFile)
{
FILE* file;
WFILE* file = NULL;
char* buffer = NULL;
char* ret = NULL;
long length;
file = fopen(keyFile, "rb");
if (!file) {
if (WFOPEN(NULL, &file, keyFile, "rb") != 0) {
fprintf(stderr,
"Failed to open TPM key file: %s\n", keyFile);
return NULL;
}
fseek(file, 0, SEEK_END);
length = ftell(file);
fseek(file, 0, SEEK_SET);
WFSEEK(NULL, file, 0, SEEK_END);
length = WFTELL(NULL, file);
WFSEEK(NULL, file, 0, SEEK_SET);
buffer = (char*)WMALLOC(length + 8 + 1, NULL, DYNTYPE_BUFFER);
if (buffer) {
if (fread(buffer, 1, length, file) == (size_t)length) {
if (WFREAD(NULL, buffer, 1, length, file) == (size_t)length) {
while (length > 0 && (buffer[length-1] == '\n' ||
buffer[length-1] == '\r')) {
length--;
@ -2133,7 +2133,7 @@ static char* LoadTpmSshKey(const char* keyFile)
}
}
fclose(file);
WFCLOSE(NULL, file);
return ret;
}
#endif