Skip to content

Commit 07885ce

Browse files
committed
run clang-format
1 parent b6203a7 commit 07885ce

File tree

6 files changed

+196
-189
lines changed

6 files changed

+196
-189
lines changed

src/wh_client_crypto.c

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,8 +2531,8 @@ int wh_Client_Sha256Dma(whClientContext* ctx, wc_Sha256* sha, const uint8_t* in,
25312531
uint16_t respSz = 0;
25322532
uint16_t group = WH_MESSAGE_GROUP_CRYPTO_DMA;
25332533
uint8_t* dataPtr = NULL;
2534-
whMessageCrypto_Sha2DmaRequest* req = NULL;
2535-
whMessageCrypto_Sha2DmaResponse* resp = NULL;
2534+
whMessageCrypto_Sha2DmaRequest* req = NULL;
2535+
whMessageCrypto_Sha2DmaResponse* resp = NULL;
25362536

25372537
/* Get data pointer from the context to use as request/response storage */
25382538
dataPtr = (uint8_t*)wh_CommClient_GetDataPtr(ctx->comm);
@@ -2629,13 +2629,13 @@ static int _xferSha224BlockAndUpdateDigest(whClientContext* ctx,
26292629
wc_Sha224* sha224,
26302630
uint32_t isLastBlock)
26312631
{
2632-
uint16_t group = WH_MESSAGE_GROUP_CRYPTO;
2633-
uint16_t action = WH_MESSAGE_ACTION_NONE;
2634-
int ret = 0;
2635-
uint16_t dataSz = 0;
2636-
whMessageCrypto_Sha256Request* req = NULL;
2637-
whMessageCrypto_Sha2Response* res = NULL;
2638-
uint8_t* dataPtr = NULL;
2632+
uint16_t group = WH_MESSAGE_GROUP_CRYPTO;
2633+
uint16_t action = WH_MESSAGE_ACTION_NONE;
2634+
int ret = 0;
2635+
uint16_t dataSz = 0;
2636+
whMessageCrypto_Sha256Request* req = NULL;
2637+
whMessageCrypto_Sha2Response* res = NULL;
2638+
uint8_t* dataPtr = NULL;
26392639

26402640
/* Get data buffer */
26412641
dataPtr = wh_CommClient_GetDataPtr(ctx->comm);
@@ -2660,7 +2660,7 @@ static int _xferSha224BlockAndUpdateDigest(whClientContext* ctx,
26602660
req->isLastBlock = 0;
26612661
}
26622662
memcpy(req->inBlock, sha224->buffer,
2663-
(isLastBlock) ? sha224->buffLen : WC_SHA224_BLOCK_SIZE);
2663+
(isLastBlock) ? sha224->buffLen : WC_SHA224_BLOCK_SIZE);
26642664

26652665
/* Send the hash state - this will be 0 on the first block on a properly
26662666
* initialized sha224 struct */
@@ -2782,11 +2782,11 @@ int wh_Client_Sha224(whClientContext* ctx, wc_Sha224* sha224, const uint8_t* in,
27822782
int wh_Client_Sha224Dma(whClientContext* ctx, wc_Sha224* sha, const uint8_t* in,
27832783
uint32_t inLen, uint8_t* out)
27842784
{
2785-
int ret = WH_ERROR_OK;
2786-
wc_Sha224* sha224 = sha;
2787-
uint16_t respSz = 0;
2788-
uint16_t group = WH_MESSAGE_GROUP_CRYPTO_DMA;
2789-
uint8_t* dataPtr = NULL;
2785+
int ret = WH_ERROR_OK;
2786+
wc_Sha224* sha224 = sha;
2787+
uint16_t respSz = 0;
2788+
uint16_t group = WH_MESSAGE_GROUP_CRYPTO_DMA;
2789+
uint8_t* dataPtr = NULL;
27902790
whMessageCrypto_Sha2DmaRequest* req = NULL;
27912791
whMessageCrypto_Sha2DmaResponse* resp = NULL;
27922792

@@ -2885,13 +2885,13 @@ static int _xferSha384BlockAndUpdateDigest(whClientContext* ctx,
28852885
wc_Sha384* sha384,
28862886
uint32_t isLastBlock)
28872887
{
2888-
uint16_t group = WH_MESSAGE_GROUP_CRYPTO;
2889-
uint16_t action = WH_MESSAGE_ACTION_NONE;
2890-
int ret = 0;
2891-
uint16_t dataSz = 0;
2892-
whMessageCrypto_Sha512Request* req = NULL;
2893-
whMessageCrypto_Sha2Response* res = NULL;
2894-
uint8_t* dataPtr = NULL;
2888+
uint16_t group = WH_MESSAGE_GROUP_CRYPTO;
2889+
uint16_t action = WH_MESSAGE_ACTION_NONE;
2890+
int ret = 0;
2891+
uint16_t dataSz = 0;
2892+
whMessageCrypto_Sha512Request* req = NULL;
2893+
whMessageCrypto_Sha2Response* res = NULL;
2894+
uint8_t* dataPtr = NULL;
28952895

28962896
/* Get data buffer */
28972897
dataPtr = wh_CommClient_GetDataPtr(ctx->comm);
@@ -2916,7 +2916,7 @@ static int _xferSha384BlockAndUpdateDigest(whClientContext* ctx,
29162916
req->isLastBlock = 0;
29172917
}
29182918
memcpy(req->inBlock, sha384->buffer,
2919-
(isLastBlock) ? sha384->buffLen : WC_SHA384_BLOCK_SIZE);
2919+
(isLastBlock) ? sha384->buffLen : WC_SHA384_BLOCK_SIZE);
29202920

29212921
/* Send the hash state - this will be 0 on the first block on a properly
29222922
* initialized sha384 struct */
@@ -3036,11 +3036,11 @@ int wh_Client_Sha384(whClientContext* ctx, wc_Sha384* sha384, const uint8_t* in,
30363036
int wh_Client_Sha384Dma(whClientContext* ctx, wc_Sha384* sha, const uint8_t* in,
30373037
uint32_t inLen, uint8_t* out)
30383038
{
3039-
int ret = WH_ERROR_OK;
3040-
wc_Sha384* sha384 = sha;
3041-
uint16_t respSz = 0;
3042-
uint16_t group = WH_MESSAGE_GROUP_CRYPTO_DMA;
3043-
uint8_t* dataPtr = NULL;
3039+
int ret = WH_ERROR_OK;
3040+
wc_Sha384* sha384 = sha;
3041+
uint16_t respSz = 0;
3042+
uint16_t group = WH_MESSAGE_GROUP_CRYPTO_DMA;
3043+
uint8_t* dataPtr = NULL;
30443044
whMessageCrypto_Sha2DmaRequest* req = NULL;
30453045
whMessageCrypto_Sha2DmaResponse* resp = NULL;
30463046

@@ -3140,13 +3140,13 @@ static int _xferSha512BlockAndUpdateDigest(whClientContext* ctx,
31403140
wc_Sha512* sha512,
31413141
uint32_t isLastBlock)
31423142
{
3143-
uint16_t group = WH_MESSAGE_GROUP_CRYPTO;
3144-
uint16_t action = WH_MESSAGE_ACTION_NONE;
3145-
int ret = 0;
3146-
uint16_t dataSz = 0;
3147-
whMessageCrypto_Sha512Request* req = NULL;
3148-
whMessageCrypto_Sha2Response* res = NULL;
3149-
uint8_t* dataPtr = NULL;
3143+
uint16_t group = WH_MESSAGE_GROUP_CRYPTO;
3144+
uint16_t action = WH_MESSAGE_ACTION_NONE;
3145+
int ret = 0;
3146+
uint16_t dataSz = 0;
3147+
whMessageCrypto_Sha512Request* req = NULL;
3148+
whMessageCrypto_Sha2Response* res = NULL;
3149+
uint8_t* dataPtr = NULL;
31503150

31513151
/* Get data buffer */
31523152
dataPtr = wh_CommClient_GetDataPtr(ctx->comm);
@@ -3171,13 +3171,13 @@ static int _xferSha512BlockAndUpdateDigest(whClientContext* ctx,
31713171
req->isLastBlock = 0;
31723172
}
31733173
memcpy(req->inBlock, sha512->buffer,
3174-
(isLastBlock) ? sha512->buffLen : WC_SHA512_BLOCK_SIZE);
3174+
(isLastBlock) ? sha512->buffLen : WC_SHA512_BLOCK_SIZE);
31753175

31763176
/* Send the hash state - this will be 0 on the first block on a properly
31773177
* initialized sha512 struct */
31783178
memcpy(req->resumeState.hash, sha512->digest, WC_SHA512_DIGEST_SIZE);
3179-
req->resumeState.hiLen = sha512->hiLen;
3180-
req->resumeState.loLen = sha512->loLen;
3179+
req->resumeState.hiLen = sha512->hiLen;
3180+
req->resumeState.loLen = sha512->loLen;
31813181
req->resumeState.hashType = sha512->hashType;
31823182
uint32_t req_len =
31833183
sizeof(whMessageCrypto_GenericRequestHeader) + sizeof(*req);
@@ -3284,7 +3284,7 @@ int wh_Client_Sha512(whClientContext* ctx, wc_Sha512* sha512, const uint8_t* in,
32843284
/* reset the state of the sha context (without blowing away devId and
32853285
* hashType)
32863286
*/
3287-
switch(hashType) {
3287+
switch (hashType) {
32883288
case WC_HASH_TYPE_SHA512_224:
32893289
ret = wc_InitSha512_224_ex(sha512, NULL, sha512->devId);
32903290
break;
@@ -3302,11 +3302,11 @@ int wh_Client_Sha512(whClientContext* ctx, wc_Sha512* sha512, const uint8_t* in,
33023302
int wh_Client_Sha512Dma(whClientContext* ctx, wc_Sha512* sha, const uint8_t* in,
33033303
uint32_t inLen, uint8_t* out)
33043304
{
3305-
int ret = WH_ERROR_OK;
3306-
wc_Sha512* sha512 = sha;
3307-
uint16_t respSz = 0;
3308-
uint16_t group = WH_MESSAGE_GROUP_CRYPTO_DMA;
3309-
uint8_t* dataPtr = NULL;
3305+
int ret = WH_ERROR_OK;
3306+
wc_Sha512* sha512 = sha;
3307+
uint16_t respSz = 0;
3308+
uint16_t group = WH_MESSAGE_GROUP_CRYPTO_DMA;
3309+
uint8_t* dataPtr = NULL;
33103310
whMessageCrypto_Sha2DmaRequest* req = NULL;
33113311
whMessageCrypto_Sha2DmaResponse* resp = NULL;
33123312

src/wh_server_crypto.c

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,8 +1774,8 @@ static int _HandleSha256(whServerContext* ctx, uint16_t magic,
17741774

17751775
/* Translate the response */
17761776
if (ret == 0) {
1777-
ret = wh_MessageCrypto_TranslateSha2Response(magic, &res,
1778-
cryptoDataOut);
1777+
ret =
1778+
wh_MessageCrypto_TranslateSha2Response(magic, &res, cryptoDataOut);
17791779
if (ret == 0) {
17801780
*outSize = sizeof(res);
17811781
}
@@ -1790,10 +1790,10 @@ static int _HandleSha224(whServerContext* ctx, uint16_t magic,
17901790
const void* cryptoDataIn, uint16_t inSize,
17911791
void* cryptoDataOut, uint16_t* outSize)
17921792
{
1793-
int ret = 0;
1794-
wc_Sha224 sha224[1];
1795-
whMessageCrypto_Sha256Request req;
1796-
whMessageCrypto_Sha2Response res;
1793+
int ret = 0;
1794+
wc_Sha224 sha224[1];
1795+
whMessageCrypto_Sha256Request req;
1796+
whMessageCrypto_Sha2Response res;
17971797
(void)inSize;
17981798

17991799
/* Translate the request */
@@ -1839,8 +1839,8 @@ static int _HandleSha224(whServerContext* ctx, uint16_t magic,
18391839

18401840
/* Translate the response */
18411841
if (ret == 0) {
1842-
ret = wh_MessageCrypto_TranslateSha2Response(magic, &res,
1843-
cryptoDataOut);
1842+
ret =
1843+
wh_MessageCrypto_TranslateSha2Response(magic, &res, cryptoDataOut);
18441844
if (ret == 0) {
18451845
*outSize = sizeof(res);
18461846
}
@@ -1855,10 +1855,10 @@ static int _HandleSha384(whServerContext* ctx, uint16_t magic,
18551855
const void* cryptoDataIn, uint16_t inSize,
18561856
void* cryptoDataOut, uint16_t* outSize)
18571857
{
1858-
int ret = 0;
1859-
wc_Sha384 sha384[1];
1860-
whMessageCrypto_Sha512Request req;
1861-
whMessageCrypto_Sha2Response res;
1858+
int ret = 0;
1859+
wc_Sha384 sha384[1];
1860+
whMessageCrypto_Sha512Request req;
1861+
whMessageCrypto_Sha2Response res;
18621862
(void)inSize;
18631863

18641864
/* Translate the request */
@@ -1908,8 +1908,8 @@ static int _HandleSha384(whServerContext* ctx, uint16_t magic,
19081908

19091909
/* Translate the response */
19101910
if (ret == 0) {
1911-
ret = wh_MessageCrypto_TranslateSha2Response(magic, &res,
1912-
cryptoDataOut);
1911+
ret =
1912+
wh_MessageCrypto_TranslateSha2Response(magic, &res, cryptoDataOut);
19131913
if (ret == 0) {
19141914
*outSize = sizeof(res);
19151915
}
@@ -1923,11 +1923,11 @@ static int _HandleSha512(whServerContext* ctx, uint16_t magic,
19231923
const void* cryptoDataIn, uint16_t inSize,
19241924
void* cryptoDataOut, uint16_t* outSize)
19251925
{
1926-
int ret = 0;
1927-
wc_Sha512 sha512[1];
1928-
whMessageCrypto_Sha512Request req;
1929-
whMessageCrypto_Sha2Response res;
1930-
int hashType = WC_HASH_TYPE_SHA512;
1926+
int ret = 0;
1927+
wc_Sha512 sha512[1];
1928+
whMessageCrypto_Sha512Request req;
1929+
whMessageCrypto_Sha2Response res;
1930+
int hashType = WC_HASH_TYPE_SHA512;
19311931
(void)inSize;
19321932

19331933
/* Translate the request */
@@ -1937,7 +1937,7 @@ static int _HandleSha512(whServerContext* ctx, uint16_t magic,
19371937
}
19381938
/* init sha2 struct with devid */
19391939
hashType = req.resumeState.hashType;
1940-
switch(hashType) {
1940+
switch (hashType) {
19411941
case WC_HASH_TYPE_SHA512_224:
19421942
ret = wc_InitSha512_224_ex(sha512, NULL, ctx->crypto->devId);
19431943
break;
@@ -1962,7 +1962,7 @@ static int _HandleSha512(whServerContext* ctx, uint16_t magic,
19621962
ret = wc_Sha512Update(sha512, req.inBlock, req.lastBlockLen);
19631963
}
19641964
if (ret == 0) {
1965-
switch(hashType) {
1965+
switch (hashType) {
19661966
case WC_HASH_TYPE_SHA512_224:
19671967
ret = wc_Sha512_224Final(sha512, res.hash);
19681968
break;
@@ -1985,14 +1985,13 @@ static int _HandleSha512(whServerContext* ctx, uint16_t magic,
19851985
memcpy(res.hash, sha512->digest, WC_SHA512_DIGEST_SIZE);
19861986
res.loLen = sha512->loLen;
19871987
res.hiLen = sha512->hiLen;
1988-
19891988
}
19901989
}
19911990

19921991
/* Translate the response */
19931992
if (ret == 0) {
1994-
ret = wh_MessageCrypto_TranslateSha2Response(magic, &res,
1995-
cryptoDataOut);
1993+
ret =
1994+
wh_MessageCrypto_TranslateSha2Response(magic, &res, cryptoDataOut);
19961995
if (ret == 0) {
19971996
*outSize = sizeof(res);
19981997
}
@@ -2543,7 +2542,7 @@ int wh_Server_HandleCryptoRequest(whServerContext* ctx, uint16_t magic,
25432542
break;
25442543
#endif /* !NO_SHA256 */
25452544
#if defined(WOLFSSL_SHA224)
2546-
case WC_HASH_TYPE_SHA224:
2545+
case WC_HASH_TYPE_SHA224:
25472546
#ifdef DEBUG_CRYPTOCB_VERBOSE
25482547
printf("[server] SHA224 req recv. type:%u\n",
25492548
rqstHeader.algoType);
@@ -2558,7 +2557,7 @@ int wh_Server_HandleCryptoRequest(whServerContext* ctx, uint16_t magic,
25582557
break;
25592558
#endif /* WOLFSSL_SHA224 */
25602559
#if defined(WOLFSSL_SHA384)
2561-
case WC_HASH_TYPE_SHA384:
2560+
case WC_HASH_TYPE_SHA384:
25622561
#ifdef DEBUG_CRYPTOCB_VERBOSE
25632562
printf("[server] SHA384 req recv. type:%u\n",
25642563
rqstHeader.algoType);
@@ -2573,7 +2572,7 @@ int wh_Server_HandleCryptoRequest(whServerContext* ctx, uint16_t magic,
25732572
break;
25742573
#endif /* WOLFSSL_SHA384 */
25752574
#if defined(WOLFSSL_SHA512)
2576-
case WC_HASH_TYPE_SHA512:
2575+
case WC_HASH_TYPE_SHA512:
25772576
#ifdef DEBUG_CRYPTOCB_VERBOSE
25782577
printf("[server] SHA512 req recv. type:%u\n",
25792578
rqstHeader.algoType);
@@ -2640,8 +2639,8 @@ static int _HandleSha256Dma(whServerContext* ctx, uint16_t magic, uint16_t seq,
26402639
(void)inSize;
26412640

26422641
int ret = 0;
2643-
whMessageCrypto_Sha2DmaRequest req;
2644-
whMessageCrypto_Sha2DmaResponse res;
2642+
whMessageCrypto_Sha2DmaRequest req;
2643+
whMessageCrypto_Sha2DmaResponse res;
26452644
wc_Sha256 sha256[1];
26462645
int clientDevId;
26472646

@@ -2761,11 +2760,11 @@ static int _HandleSha224Dma(whServerContext* ctx, uint16_t magic, uint16_t seq,
27612760
{
27622761
(void)seq;
27632762
(void)inSize;
2764-
int ret = 0;
2763+
int ret = 0;
27652764
whMessageCrypto_Sha2DmaRequest req;
27662765
whMessageCrypto_Sha2DmaResponse res;
2767-
wc_Sha224 sha224[1];
2768-
int clientDevId;
2766+
wc_Sha224 sha224[1];
2767+
int clientDevId;
27692768

27702769
/* Translate the request */
27712770
ret = wh_MessageCrypto_TranslateSha2DmaRequest(
@@ -2883,11 +2882,11 @@ static int _HandleSha384Dma(whServerContext* ctx, uint16_t magic, uint16_t seq,
28832882
{
28842883
(void)seq;
28852884
(void)inSize;
2886-
int ret = 0;
2885+
int ret = 0;
28872886
whMessageCrypto_Sha2DmaRequest req;
28882887
whMessageCrypto_Sha2DmaResponse res;
2889-
wc_Sha384 sha384[1];
2890-
int clientDevId;
2888+
wc_Sha384 sha384[1];
2889+
int clientDevId;
28912890

28922891
/* Translate the request */
28932892
ret = wh_MessageCrypto_TranslateSha2DmaRequest(
@@ -3005,12 +3004,12 @@ static int _HandleSha512Dma(whServerContext* ctx, uint16_t magic, uint16_t seq,
30053004
{
30063005
(void)seq;
30073006
(void)inSize;
3008-
int ret = 0;
3007+
int ret = 0;
30093008
whMessageCrypto_Sha2DmaRequest req;
30103009
whMessageCrypto_Sha2DmaResponse res;
3011-
wc_Sha512 sha512[1];
3012-
int clientDevId;
3013-
int hashType = WC_HASH_TYPE_SHA512;
3010+
wc_Sha512 sha512[1];
3011+
int clientDevId;
3012+
int hashType = WC_HASH_TYPE_SHA512;
30143013

30153014
/* Translate the request */
30163015
ret = wh_MessageCrypto_TranslateSha2DmaRequest(
@@ -3060,7 +3059,7 @@ static int _HandleSha512Dma(whServerContext* ctx, uint16_t magic, uint16_t seq,
30603059
printf("[server] wc_Sha512Final: outAddr=%p\n", outAddr);
30613060
printf("[server] hashTpe: %d\n", hashType);
30623061
#endif
3063-
switch(hashType) {
3062+
switch (hashType) {
30643063
case WC_HASH_TYPE_SHA512_224:
30653064
ret = wc_Sha512_224Final(sha512, outAddr);
30663065
break;

test/wh_test_check_struct_padding.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ whMessageCrypto_EccCheckResponse pkEccCheckRes;
115115
whMessageCrypto_RngResponse rngRes;
116116
whMessageCrypto_CmacResponse cmacRes;
117117
whMessageCrypto_Sha256Request hashSha256Req;
118-
whMessageCrypto_Sha512Request hashSha512Req;
119-
whMessageCrypto_Sha2Response hashSha2Res;
118+
whMessageCrypto_Sha512Request hashSha512Req;
119+
whMessageCrypto_Sha2Response hashSha2Res;
120120

121121
/* DMA crypto messages */
122122
#if defined(WOLFHSM_CFG_DMA)

0 commit comments

Comments
 (0)