Skip to content

Commit

Permalink
Rekey Callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ejohnstown committed Sep 18, 2024
1 parent 958cfac commit 72dc369
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
32 changes: 31 additions & 1 deletion src/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -3032,7 +3032,37 @@ size_t wolfSSH_GetText(WOLFSSH *ssh, WS_Text id, char *str, size_t strSz)
return ret < 0 ? 0 : (size_t)ret;
}

void wolfSSH_SetKeyingCompletionCb(WOLFSSH_CTX* ctx, WS_CallbackKeyingCompletion cb)

int wolfSSH_SetKeyingCb(WOLFSSH_CTX* ctx, WS_CallbackKeying cb)
{
int ret = WS_SSH_CTX_NULL_E;

WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetKeyingCb()");

if (ctx != NULL) {
ctx->keyingCb = cb;
ret = WS_SUCCESS;
}

return ret;
}

int wolfSSH_SetKeyingCtx(WOLFSSH* ssh, void* ctx)
{
int ret = WS_SSH_NULL_E;

WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetKeyingCtx()");

if (ssh) {
ssh->keyingCtx = ctx;
ret = WS_SUCCESS;
}

return ret;
}

void wolfSSH_SetKeyingCompletionCb(WOLFSSH_CTX* ctx,
WS_CallbackKeyingCompletion cb)
{
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetKeyingCompletionCb()");

Expand Down
6 changes: 4 additions & 2 deletions wolfssh/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ struct WOLFSSH_CTX {
void* heap; /* heap hint */
WS_CallbackIORecv ioRecvCb; /* I/O Receive Callback */
WS_CallbackIOSend ioSendCb; /* I/O Send Callback */
WS_CallbackKeying keyingCb; /* Keying begin callback */
WS_CallbackKeyingCompletion keyingCompletionCb; /* Keying complete */
WS_CallbackUserAuth userAuthCb; /* User Authentication Callback */
WS_CallbackUserAuthTypes userAuthTypesCb; /* Authentication Types Allowed */
WS_CallbackUserAuthResult userAuthResultCb; /* User Authentication Result */
Expand Down Expand Up @@ -549,7 +551,6 @@ struct WOLFSSH_CTX {
#ifdef WOLFSSH_AGENT
byte agentEnabled;
#endif /* WOLFSSH_AGENT */
WS_CallbackKeyingCompletion keyingCompletionCb;
};


Expand Down Expand Up @@ -676,6 +677,8 @@ struct WOLFSSH {
void* globalReqCtx; /* Global Request CB context */
void* reqSuccessCtx; /* Global Request Sucess CB context */
void* reqFailureCtx; /* Global Request Failure CB context */
void* keyingCtx; /* Keying begin CB context */
void* keyingCompletionCtx; /* Keying completion CB context */
void* channelOpenCtx; /* Channel Open CB context */
void* channelReqCtx; /* Channel Request CB context */
void* channelEofCtx; /* Channel EOF CB context */
Expand Down Expand Up @@ -876,7 +879,6 @@ struct WOLFSSH {
#if defined(WOLFSSH_TERM) || defined(WOLFSSH_SHELL)
word32 exitStatus;
#endif
void* keyingCompletionCtx;
};


Expand Down
11 changes: 7 additions & 4 deletions wolfssh/ssh.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,14 @@ typedef enum WS_Text {
WOLFSSH_API size_t wolfSSH_GetText(WOLFSSH *ssh, WS_Text id, char *str,
size_t strSz);

typedef void (*WS_CallbackKeying)(void *ctx, int rekey);
WOLFSSH_API int wolfSSH_SetKeyingCb(WOLFSSH_CTX* ctx, WS_CallbackKeying cb);
WOLFSSH_API int wolfSSH_SetKeyingCtx(WOLFSSH* ssh, void* ctx);

typedef void (*WS_CallbackKeyingCompletion)(void *);
WOLFSSH_API void wolfSSH_SetKeyingCompletionCb(WOLFSSH_CTX*,
WS_CallbackKeyingCompletion);
WOLFSSH_API void wolfSSH_SetKeyingCompletionCbCtx(WOLFSSH*,
void*);
WOLFSSH_API void wolfSSH_SetKeyingCompletionCb(WOLFSSH_CTX* ctx,
WS_CallbackKeyingCompletion cb);
WOLFSSH_API void wolfSSH_SetKeyingCompletionCbCtx(WOLFSSH* ssh, void* ctx);

#define WS_CHANNEL_ID_SELF 0
#define WS_CHANNEL_ID_PEER 1
Expand Down

0 comments on commit 72dc369

Please sign in to comment.