|
| 1 | +name: TPM SSH Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ '*' ] |
| 6 | + pull_request: |
| 7 | + branches: [ '*' ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test-tpm-ssh: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + path: wolfssh |
| 17 | + |
| 18 | + # Clone dependencies |
| 19 | + - name: Clone wolfSSL |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + repository: wolfSSL/wolfssl |
| 23 | + path: wolfssl |
| 24 | + |
| 25 | + - name: Clone wolfTPM |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + repository: wolfSSL/wolftpm |
| 29 | + path: wolftpm |
| 30 | + |
| 31 | + # Install dependencies |
| 32 | + - name: Install Dependencies |
| 33 | + run: | |
| 34 | + sudo apt-get update |
| 35 | + sudo apt-get install -y libtool automake autoconf |
| 36 | + sudo apt-get install -y build-essential git autoconf-archive \ |
| 37 | + libcmocka-dev libssl-dev uthash-dev libglib2.0-dev \ |
| 38 | + tpm2-tools openssh-client |
| 39 | +
|
| 40 | + # Clone, build, and start TPM Simulator |
| 41 | + - name: Clone and Build TPM Simulator |
| 42 | + run: | |
| 43 | + git clone https://github.com/kgoldman/ibmswtpm2 |
| 44 | + cd ibmswtpm2/src |
| 45 | + make |
| 46 | + ./tpm_server & |
| 47 | + sleep 2 |
| 48 | + cd ../.. |
| 49 | +
|
| 50 | + # Build and install wolfSSL |
| 51 | + - name: Build wolfSSL |
| 52 | + run: | |
| 53 | + cd wolfssl |
| 54 | + ./autogen.sh |
| 55 | + ./configure --enable-wolftpm --enable-wolfssh |
| 56 | + make |
| 57 | + sudo make install |
| 58 | + sudo ldconfig |
| 59 | + cd .. |
| 60 | +
|
| 61 | + # Build and install wolfTPM |
| 62 | + - name: Build wolfTPM |
| 63 | + run: | |
| 64 | + cd wolftpm |
| 65 | + ./autogen.sh |
| 66 | + ./configure --enable-swtpm |
| 67 | + make |
| 68 | + sudo make install |
| 69 | + sudo ldconfig |
| 70 | + cd .. |
| 71 | +
|
| 72 | + # Build wolfSSH |
| 73 | + - name: Build wolfSSH |
| 74 | + run: | |
| 75 | + cd wolfssh |
| 76 | + ./autogen.sh |
| 77 | + ./configure --enable-tpm |
| 78 | + make |
| 79 | + sudo make install |
| 80 | + sudo ldconfig |
| 81 | + cd .. |
| 82 | +
|
| 83 | + # Test TPM SSH Default Password |
| 84 | + - name: Test TPM SSH Default Password |
| 85 | + run: | |
| 86 | + # Generate key with default password |
| 87 | + cd wolftpm |
| 88 | + ./examples/keygen/keygen keyblob1.bin -rsa -t -pem -eh |
| 89 | + cp key.pem key1.pem # Save the key for first test |
| 90 | +
|
| 91 | + # Convert key to SSH format |
| 92 | + ssh-keygen -f key1.pem -i -m PKCS8 > ../wolfssh/key1.ssh |
| 93 | + cd .. |
| 94 | +
|
| 95 | + # Start echoserver and wait for it to be ready |
| 96 | + cd wolfssh |
| 97 | + ./examples/echoserver/echoserver -1 -s key1.ssh & |
| 98 | + echo "Echoserver started with PID: $!" |
| 99 | + sleep 2 |
| 100 | + cd .. |
| 101 | +
|
| 102 | + # Test client connection with default password |
| 103 | + cd wolfssh |
| 104 | + ./examples/client/client -i ../wolftpm/keyblob1.bin -u hansel -K ThisIsMyKeyAuth |
| 105 | + cd .. |
| 106 | +
|
| 107 | + # Test the TPM SSH Custom Password |
| 108 | + - name: Test TPM SSH Custom Password |
| 109 | + run: | |
| 110 | + # Test with custom password |
| 111 | + cd wolftpm |
| 112 | + ./examples/keygen/keygen keyblob2.bin -rsa -t -pem -eh -auth=custompassword |
| 113 | + cp key.pem key2.pem # Save the key for second test |
| 114 | +
|
| 115 | + # Convert key to SSH format |
| 116 | + ssh-keygen -f key2.pem -i -m PKCS8 > ../wolfssh/key2.ssh |
| 117 | + cd .. |
| 118 | +
|
| 119 | + # Start echoserver and wait for it to be ready |
| 120 | + cd wolfssh |
| 121 | + ./examples/echoserver/echoserver -1 -s key2.ssh & |
| 122 | + echo "Echoserver started with PID: $!" |
| 123 | + sleep 2 |
| 124 | + cd .. |
| 125 | +
|
| 126 | + # Test with custom password |
| 127 | + cd wolfssh |
| 128 | + ./examples/client/client -i ../wolftpm/keyblob2.bin -u hansel -K custompassword |
| 129 | + cd .. |
| 130 | +
|
| 131 | + # Archive artifacts for debugging |
| 132 | + - name: Archive test artifacts |
| 133 | + if: always() |
| 134 | + uses: actions/upload-artifact@v4 |
| 135 | + with: |
| 136 | + name: test-artifacts |
| 137 | + path: | |
| 138 | + wolftpm/keyblob1.bin |
| 139 | + wolftpm/keyblob2.bin |
| 140 | + wolftpm/key1.pem |
| 141 | + wolftpm/key2.pem |
| 142 | + wolfssh/key1.ssh |
| 143 | + wolfssh/key2.ssh |
0 commit comments