Skip to content

Commit 43fe6c7

Browse files
committed
remove cancellation API
1 parent d3dc8dc commit 43fe6c7

12 files changed

Lines changed: 104 additions & 606 deletions

src/wh_client.c

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ int wh_Client_Init(whClientContext* c, const whClientConfig* config)
7676
}
7777

7878
memset(c, 0, sizeof(*c));
79-
#ifdef WOLFHSM_CFG_CANCEL_API
80-
/* register the cancel callback */
81-
c->cancelCb = config->cancelCb;
82-
#endif
8379

8480
rc = wh_CommClient_Init(c->comm, config->comm);
8581

@@ -472,73 +468,6 @@ int wh_Client_CommClose(whClientContext* c)
472468
return rc;
473469
}
474470

475-
#ifdef WOLFHSM_CFG_CANCEL_API
476-
int wh_Client_EnableCancel(whClientContext* c)
477-
{
478-
if (c == NULL)
479-
return WH_ERROR_BADARGS;
480-
c->cancelable = 1;
481-
return 0;
482-
}
483-
484-
int wh_Client_DisableCancel(whClientContext* c)
485-
{
486-
if (c == NULL)
487-
return WH_ERROR_BADARGS;
488-
c->cancelable = 0;
489-
return 0;
490-
}
491-
492-
int wh_Client_CancelRequest(whClientContext* c)
493-
{
494-
if (c == NULL) {
495-
return WH_ERROR_BADARGS;
496-
}
497-
498-
if (c->cancelCb == NULL) {
499-
return WH_ERROR_ABORTED;
500-
}
501-
502-
/* Since we aren't sending this request through the standard transport, we
503-
* need to update the client context's last sent "kind" to prevent the Comm
504-
* Client receive function from discarding the next response as an
505-
* out-of-order/corrupted message. No need to update the sequence number/ID
506-
* as it will not have been incremented by the cancel operation, as it is
507-
* out-of-band */
508-
c->last_req_kind = WH_MESSAGE_KIND(WH_MESSAGE_GROUP_CANCEL, 0);
509-
510-
return c->cancelCb(c->comm->seq);
511-
}
512-
513-
int wh_Client_CancelResponse(whClientContext* c)
514-
{
515-
int ret = 0;
516-
uint16_t group;
517-
uint16_t action;
518-
uint16_t size;
519-
uint8_t* buf;
520-
if (c == NULL)
521-
return WH_ERROR_BADARGS;
522-
/* check if the request was canceled */
523-
buf = wh_CommClient_GetDataPtr(c->comm);
524-
ret = wh_Client_RecvResponse(c, &group, &action, &size, buf);
525-
if (ret == 0 && group != WH_MESSAGE_GROUP_CANCEL)
526-
return WH_ERROR_CANCEL_LATE;
527-
return ret;
528-
}
529-
530-
int wh_Client_Cancel(whClientContext* c)
531-
{
532-
int ret;
533-
ret = wh_Client_CancelRequest(c);
534-
if (ret == 0) {
535-
do {
536-
ret = wh_Client_CancelResponse(c);
537-
} while (ret == WH_ERROR_NOTREADY);
538-
}
539-
return ret;
540-
}
541-
#endif /* WOLFHSM_CFG_CANCEL_API */
542471

543472
int wh_Client_EchoRequest(whClientContext* c, uint16_t size, const void* data)
544473
{

src/wh_client_crypto.c

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,13 +3678,6 @@ int wh_Client_Cmac(whClientContext* ctx, Cmac* cmac, CmacType type,
36783678
cmac->aes.keylen = keyLen;
36793679
}
36803680

3681-
#ifdef WOLFHSM_CFG_CANCEL_API
3682-
/* if the client marked they may want to cancel, handle the
3683-
* response in a separate call */
3684-
if (ctx->cancelable) {
3685-
return ret;
3686-
}
3687-
#endif
36883681

36893682
uint16_t res_len = 0;
36903683
do {
@@ -3719,63 +3712,6 @@ int wh_Client_Cmac(whClientContext* ctx, Cmac* cmac, CmacType type,
37193712

37203713
#endif /* !NO_AES */
37213714

3722-
#ifdef WOLFHSM_CFG_CANCEL_API
3723-
int wh_Client_CmacCancelableResponse(whClientContext* c, Cmac* cmac,
3724-
uint8_t* out, uint16_t* outSz)
3725-
{
3726-
whMessageCrypto_CmacResponse* res = NULL;
3727-
uint8_t* dataPtr = NULL;
3728-
int ret;
3729-
uint16_t group;
3730-
uint16_t action;
3731-
uint16_t dataSz;
3732-
3733-
if (c == NULL || cmac == NULL) {
3734-
return WH_ERROR_BADARGS;
3735-
}
3736-
3737-
/* Get data pointer */
3738-
dataPtr = (uint8_t*)wh_CommClient_GetDataPtr(c->comm);
3739-
if (dataPtr == NULL) {
3740-
return WH_ERROR_BADARGS;
3741-
}
3742-
3743-
do {
3744-
ret = wh_Client_RecvResponse(c, &group, &action, &dataSz,
3745-
(uint8_t*)dataPtr);
3746-
} while (ret == WH_ERROR_NOTREADY);
3747-
3748-
/* check for out of sequence action */
3749-
if (ret == 0 &&
3750-
(group != WH_MESSAGE_GROUP_CRYPTO || action != WC_ALGO_TYPE_CMAC)) {
3751-
ret = WH_ERROR_ABORTED;
3752-
}
3753-
if (ret == 0) {
3754-
/* Setup generic header and get pointer to response data */
3755-
ret = _getCryptoResponse(dataPtr, WC_ALGO_TYPE_CMAC, (uint8_t**)&res);
3756-
/* wolfCrypt allows positive error codes on success in some scenarios */
3757-
if (ret >= 0) {
3758-
/* Restore non-sensitive state from server response */
3759-
memcpy(cmac->buffer, res->resumeState.buffer, AES_BLOCK_SIZE);
3760-
memcpy(cmac->digest, res->resumeState.digest, AES_BLOCK_SIZE);
3761-
cmac->bufferSz = res->resumeState.bufferSz;
3762-
cmac->totalSz = res->resumeState.totalSz;
3763-
3764-
if (out != NULL && outSz != NULL) {
3765-
if (res->outSz > *outSz) {
3766-
ret = WH_ERROR_BUFFER_SIZE;
3767-
}
3768-
else {
3769-
uint8_t* packOut = (uint8_t*)(res + 1);
3770-
memcpy(out, packOut, res->outSz);
3771-
*outSz = res->outSz;
3772-
}
3773-
}
3774-
}
3775-
}
3776-
return ret;
3777-
}
3778-
#endif /* WOLFHSM_CFG_CANCEL_API */
37793715

37803716
#ifdef WOLFHSM_CFG_DMA
37813717
int wh_Client_CmacDma(whClientContext* ctx, Cmac* cmac, CmacType type,

src/wh_server.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,6 @@ int wh_Server_GetConnected(whServerContext *server,
170170
return WH_ERROR_OK;
171171
}
172172

173-
#ifdef WOLFHSM_CFG_CANCEL_API
174-
int wh_Server_GetCanceledSequence(whServerContext* server, uint16_t* outSeq)
175-
{
176-
if (server == NULL || outSeq == NULL)
177-
return WH_ERROR_BADARGS;
178-
*outSeq = server->cancelSeq;
179-
server->cancelSeq = 0;
180-
return 0;
181-
}
182-
183-
int wh_Server_SetCanceledSequence(whServerContext* server, uint16_t cancelSeq)
184-
{
185-
if (server == NULL) {
186-
return WH_ERROR_BADARGS;
187-
}
188-
server->cancelSeq = cancelSeq;
189-
return WH_ERROR_OK;
190-
}
191-
#endif /* WOLFHSM_CFG_CANCEL_API */
192173

193174
static int _wh_Server_HandleCommRequest(whServerContext* server,
194175
uint16_t magic, uint16_t action, uint16_t seq,
@@ -418,16 +399,6 @@ int wh_Server_HandleRequestMessage(whServerContext* server)
418399
* contains the error code for the client in the resp.rc field. */
419400
handlerRc = rc;
420401

421-
/* Handle cancellation by modifying response kind */
422-
#ifdef WOLFHSM_CFG_CANCEL_API
423-
if (handlerRc == WH_ERROR_CANCEL) {
424-
/* notify the client that their request was canceled */
425-
kind = WH_MESSAGE_KIND(WH_MESSAGE_GROUP_CANCEL, 0);
426-
size = 0;
427-
data = NULL;
428-
}
429-
#endif
430-
431402
/* Always send the response to the client, regardless of handler error.
432403
* The response packet contains the operational error code for the
433404
* client in the resp.rc field. */

0 commit comments

Comments
 (0)