diff --git a/src/ossh.c b/src/ossh.c index 96f8316ee..b78d982ec 100644 --- a/src/ossh.c +++ b/src/ossh.c @@ -736,9 +736,6 @@ int IdentifyOpenSshKey(const byte* in, word32 inSz, void* heap) if (ret == WS_SUCCESS) { ret = key->keyId; } - else if (key->keyId == ID_UNKNOWN) { - ret = WS_UNIMPLEMENTED_E; - } wolfSSH_KEY_clean(key); WFREE(key, heap, DYNTYPE_PRIVKEY); diff --git a/tests/unit.c b/tests/unit.c index 4f078dd6a..fc85f4fd8 100644 --- a/tests/unit.c +++ b/tests/unit.c @@ -1514,6 +1514,35 @@ static int test_OpenSshFormatNonCompositeRejected(void) #endif /* !WOLFSSH_NO_ECDSA_SHA2_NISTP256 */ +#ifdef WOLFSSH_TEST_INTERNAL +/* An OpenSSH private key whose key-type name wolfSSH does not know is + * WS_UNIMPLEMENTED_E, straight from GetOpenSshKey(). */ +static int test_IdentifyOpenSshKeyUnknownName(void) +{ + static const byte blob[] = { + 'o', 'p', 'e', 'n', 's', 's', 'h', '-', 'k', 'e', 'y', '-', + 'v', '1', 0x00, + 0x00, 0x00, 0x00, 0x04, 'n', 'o', 'n', 'e', /* ciphername */ + 0x00, 0x00, 0x00, 0x04, 'n', 'o', 'n', 'e', /* kdfname */ + 0x00, 0x00, 0x00, 0x00, /* kdfoptions */ + 0x00, 0x00, 0x00, 0x01, /* key count */ + 0x00, 0x00, 0x00, 0x00, /* public key */ + 0x00, 0x00, 0x00, 0x13, /* private list */ + 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, /* checkints */ + 0x00, 0x00, 0x00, 0x07, 's', 's', 'h', '-', 'f', 'o', 'o' + }; + int ret; + + ret = IdentifyOpenSshKey(blob, (word32)sizeof(blob), NULL); + if (ret != WS_UNIMPLEMENTED_E) { + printf("IdentifyOpenSshKeyUnknownName: wrong result %d\n", ret); + return -120; + } + return 0; +} +#endif /* WOLFSSH_TEST_INTERNAL */ + + #if defined(WOLFSSH_TEST_INTERNAL) && \ (!defined(WOLFSSH_NO_HMAC_SHA1) || \ !defined(WOLFSSH_NO_HMAC_SHA1_96) || \ @@ -27125,6 +27154,12 @@ int wolfSSH_UnitTest(int argc, char** argv) (unitResult == 0 ? "SUCCESS" : "FAILED")); testResult = testResult || unitResult; #endif +#ifdef WOLFSSH_TEST_INTERNAL + unitResult = test_IdentifyOpenSshKeyUnknownName(); + printf("IdentifyOpenSshKeyUnknownName: %s\n", + (unitResult == 0 ? "SUCCESS" : "FAILED")); + testResult = testResult || unitResult; +#endif #if defined(WOLFSSH_TEST_INTERNAL) && !defined(NO_WOLFSSH_SERVER) unitResult = test_ShutdownPeerChannelId();