Skip to content

Commit fae59c7

Browse files
committed
No need for tpm specific return code will refactor passes test/unit.test
1 parent 436cd91 commit fae59c7

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

examples/client/common.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ static int readKeyBlob(const char* filename, WOLFTPM2_KEYBLOB* key)
816816
WLOG(WS_LOG_DEBUG, "Leaving readKeyBlob(), rc = %d", rc);
817817
return rc;
818818
}
819-
819+
// make rc check cleanup at end and get rid of uneeded returns
820820
static int wolfSSH_TPM_InitKey(WOLFTPM2_DEV* dev, const char* name,
821821
WOLFTPM2_KEY* pTpmKey)
822822
{
@@ -832,7 +832,7 @@ static int wolfSSH_TPM_InitKey(WOLFTPM2_DEV* dev, const char* name,
832832
#ifdef DEBUG_WOLFSSH
833833
printf("TPM 2.0 Device initialization failed\n");
834834
#endif
835-
return WOLFSSH_TPM_FAILED_INIT;
835+
return WS_ERROR;
836836
}
837837

838838
/* TPM 2.0 keys live under a Primary Key, acquire such key */
@@ -841,7 +841,7 @@ static int wolfSSH_TPM_InitKey(WOLFTPM2_DEV* dev, const char* name,
841841
#ifdef DEBUG_WOLFSSH
842842
printf("Acquiring a Primary TPM 2.0 Key failed\n");
843843
#endif
844-
return WOLFSSH_TPM_FAILED_LOAD_PRIMARY;
844+
return WS_BAD_ARGUMENT;
845845
}
846846

847847
/* Load the TPM 2.0 key blob from disk */
@@ -850,7 +850,7 @@ static int wolfSSH_TPM_InitKey(WOLFTPM2_DEV* dev, const char* name,
850850
#ifdef DEBUG_WOLFSSH
851851
printf("Reading key blob from disk failed\n");
852852
#endif
853-
return WOLFSSH_TPM_FAILED_READ_KEYBLOB;
853+
return WS_DECRYPT_E;
854854
}
855855

856856
/* TODO: workaround until password can be supplied */
@@ -866,7 +866,7 @@ static int wolfSSH_TPM_InitKey(WOLFTPM2_DEV* dev, const char* name,
866866
#ifdef DEBUG_WOLFSSH
867867
printf("wolfTPM2_LoadKey failed\n");
868868
#endif
869-
return WOLFSSH_TPM_FAILED_LOAD_KEY;
869+
return WS_BAD_ARGUMENT;
870870
}
871871
#ifdef DEBUG_WOLFSSH
872872
printf("Loaded key to 0x%x\n", (word32)tpmKeyBlob.handle.hndl);
@@ -880,7 +880,7 @@ static int wolfSSH_TPM_InitKey(WOLFTPM2_DEV* dev, const char* name,
880880
#ifdef DEBUG_WOLFSSH
881881
printf("Exporting TPM key failed\n");
882882
#endif
883-
return WOLFSSH_TPM_FAILED_EXPORT_KEY;
883+
return WS_MEMORY_E;
884884
}
885885

886886
/* Read public key from the buffer and convert the key to OpenSSH format */
@@ -891,7 +891,7 @@ static int wolfSSH_TPM_InitKey(WOLFTPM2_DEV* dev, const char* name,
891891
#ifdef DEBUG_WOLFSSH
892892
printf("Reading public key failed returned: %d\n", rc);
893893
#endif
894-
return WOLFSSH_TPM_FAILED_READ_PUBLIC_KEY;
894+
return WS_PUBKEY_REJECTED_E;
895895
}
896896
userPublicKey = p;
897897

src/ssh.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,11 @@ static int DoPemKey(const byte* in, word32 inSz, byte** out,
18071807
ret = wc_KeyPemToDer(in, inSz, newKey, newKeySz, NULL);
18081808
}
18091809
else {
1810+
#ifdef WOLFSSH_TPM
18101811
ret = wc_PubKeyPemToDer(in, inSz, newKey, newKeySz);
1812+
#else
1813+
ret = NOT_COMPILED_IN;
1814+
#endif
18111815
}
18121816
if (ret > 0) {
18131817
newKeySz = (word32)ret;

wolfssh/error.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,7 @@ enum WS_ErrorCodes {
137137
WS_AUTH_PENDING = -1096, /* User authentication still pending */
138138
WS_KDF_E = -1097, /* KDF error*/
139139

140-
/* TODO: Fix names and add hard coded value */
141-
WOLFSSH_TPM_FAILED_INIT,
142-
WOLFSSH_TPM_FAILED_LOAD_PRIMARY,
143-
WOLFSSH_TPM_FAILED_READ_KEYBLOB,
144-
WOLFSSH_TPM_FAILED_EXPORT_KEY,
145-
WOLFSSH_TPM_FAILED_LOAD_KEY,
146-
WOLFSSH_TPM_FAILED_READ_PUBLIC_KEY,
147-
148-
WS_LAST_E = WOLFSSH_TPM_FAILED_READ_PUBLIC_KEY /* Update this to indicate last error */
140+
WS_LAST_E = WS_KDF_E /* Update this to indicate last error */
149141
};
150142

151143

0 commit comments

Comments
 (0)