Skip to content

Commit

Permalink
Cleanup remove unnecessary convert function
Browse files Browse the repository at this point in the history
  • Loading branch information
aidangarske committed Dec 12, 2024
1 parent e6e6740 commit a8665fe
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 54 deletions.
2 changes: 1 addition & 1 deletion examples/echoserver/echoserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ static const char samplePublicKeyEccBuffer[] =
#endif
#endif

/* TODO: extract correct sample key from tpm */

#ifndef WOLFSSH_NO_RSA
static const char samplePublicKeyRsaBuffer[] =
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCARKEyqdqx7v+5IFa70l971cdQP2u+kK"
Expand Down
50 changes: 0 additions & 50 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -13858,56 +13858,6 @@ static int BuildUserAuthRequestEd25519(WOLFSSH* ssh,

#if !defined(WOLFSSH_NO_RSA) || !defined(WOLFSSH_NO_ECDSA) \
|| !defined(WOLFSSH_NO_ED25519)
int wolfSSH_ConvertASN1toSSH(WS_KeySignature* keySig,
const WS_UserAuthData* authData, byte** outKey, word32* outKeySz)
{
int ret = WS_SUCCESS;
byte* newKey = NULL;
word32 newSz = 0, idx = 0, sz;

/* Retrieve the type and size */
const char* userPublicKeyType = keySig->name;
word32 userPublicKeyTypeSz = keySig->nameSz;

/* Retrieve the public key and its size from authData */
const byte* userPublicKey = authData->sf.publicKey.publicKey;
word32 userPublicKeySz = authData->sf.publicKey.publicKeySz;

/* Calculate base64 encoded size of the public key */
(void)Base64_Encode_NoNl(userPublicKey, userPublicKeySz,
NULL, &newSz);
/* Total size = key type size + space + base64 key size */
newSz += userPublicKeyTypeSz + 2 /* space + null term */;

/* get size of converted key */
if (*outKey == NULL) {
newKey = (byte*)WMALLOC(newSz, NULL, DYNTYPE_PRIVKEY);
} else {
newKey = *outKey;
}

/* Convert to openssh style key */
XMEMCPY(&newKey[idx], userPublicKeyType, userPublicKeyTypeSz);
idx += userPublicKeyTypeSz;
newKey[idx++] = ' ';

/* Base64 encode the public key */
sz = newSz - idx;
if (Base64_Encode_NoNl(userPublicKey, userPublicKeySz, &newKey[idx],
&sz) != WS_SUCCESS) {
WLOG(WS_LOG_DEBUG, "Base64 encode of ASN.1 public key failed!");
return WS_BUFFER_E;
}

/* Update index and final result */
idx += sz;
*outKey = newKey;
*outKeySz = idx;

return ret;
}


static int PrepareUserAuthRequestPublicKey(WOLFSSH* ssh, word32* payloadSz,
WS_UserAuthData* authData, WS_KeySignature* keySig)
{
Expand Down
3 changes: 0 additions & 3 deletions wolfssh/ssh.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ WOLFSSH_API int wolfSSH_KDF(byte, byte, byte*, word32, const byte*, word32,
#ifdef USE_WINDOWS_API
WOLFSSH_API int wolfSSH_ConvertConsole(WOLFSSH*, WOLFSSH_HANDLE, byte*, word32);
#endif
typedef struct WS_KeySignature WS_KeySignature;
WOLFSSH_API int wolfSSH_ConvertASN1toSSH(WS_KeySignature* keySig,
const WS_UserAuthData* authData, byte** outKey, word32* outKeySz);

WOLFSSH_API int wolfSSH_DoModes(const byte* modes, word32 modesSz, int fd);
WOLFSSH_API WS_SessionType wolfSSH_GetSessionType(const WOLFSSH*);
Expand Down

0 comments on commit a8665fe

Please sign in to comment.