Skip to content

Commit 5ac5385

Browse files
authored
Merge pull request #330 from JacobBarthelmeh/CI
spelling fix and demo test case fix
2 parents 29c2888 + 325d76d commit 5ac5385

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

docs/src/chapter07.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ The data payload is a fixed size data buffer that the client can use in any way
248248
```c
249249
/* request message to the custom server callback */
250250
typedef struct {
251-
uint32_t id; /* indentifier of registered callback */
251+
uint32_t id; /* identifier of registered callback */
252252
uint32_t type; /* whMessageCustomCb_Type */
253253
whMessageCustomCb_Data data;
254254
} whMessageCustomCb_Request;
255255

256256
/* response message from the custom server callback */
257257
typedef struct {
258-
uint32_t id; /* indentifier of registered callback */
258+
uint32_t id; /* identifier of registered callback */
259259
uint32_t type; /* whMessageCustomCb_Type */
260260
int32_t rc; /* Return code from custom callback. Invalid if err != 0 */
261261
int32_t err; /* wolfHSM-specific error. If err != 0, rc is invalid */

examples/demo/client/wh_demo_client_crypto.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,16 @@ int wh_DemoClient_CryptoEcc(whClientContext* clientContext)
494494
WC_RNG rng[1];
495495
byte sharedOne[32];
496496
byte sharedTwo[32];
497-
const char plainMessage[16] = "message example";
498-
byte message[sizeof(plainMessage)];
497+
/* Pre-computed SHA-256 digest of "message example" */
498+
/* Canned SHA-256 digest to use for sign/verify demo */
499+
byte message[32] = {
500+
0x48, 0x0E, 0x66, 0x2E, 0x59, 0x0A, 0x79, 0x6E,
501+
0xE5, 0x00, 0xE1, 0xA0, 0xB7, 0xE1, 0x2C, 0x4E,
502+
0xD0, 0x39, 0x1D, 0x67, 0x56, 0x2F, 0x6E, 0xE0,
503+
0x48, 0x9C, 0x00, 0xB9, 0xA9, 0x37, 0x21, 0x00
504+
};
499505
byte signature[128];
500506

501-
/* Set the message to the test string */
502-
strncpy((char*)message, plainMessage, sizeof(message)-1);
503-
message[sizeof(message)-1] = '\0';
504-
505507
/* Initialize the rng to make the ecc keys */
506508
ret = wc_InitRng_ex(rng, NULL, WH_DEV_ID);
507509
if (ret != 0) {
@@ -624,15 +626,17 @@ int wh_DemoClient_CryptoEccImport(whClientContext* clientContext)
624626
WC_RNG rng[1];
625627
byte sharedOne[32];
626628
byte sharedTwo[32];
627-
const char plainMessage[16] = "message example";
628-
byte message[sizeof(plainMessage)];
629+
/* Pre-computed SHA-256 digest of "message example" */
630+
/* Canned SHA-256 digest to use for sign/verify demo */
631+
byte message[32] = {
632+
0x48, 0x0E, 0x66, 0x2E, 0x59, 0x0A, 0x79, 0x6E,
633+
0xE5, 0x00, 0xE1, 0xA0, 0xB7, 0xE1, 0x2C, 0x4E,
634+
0xD0, 0x39, 0x1D, 0x67, 0x56, 0x2F, 0x6E, 0xE0,
635+
0x48, 0x9C, 0x00, 0xB9, 0xA9, 0x37, 0x21, 0x00
636+
};
629637
byte signature[128];
630638
uint8_t keyBuf[256];
631639

632-
/* Set the message to the test string */
633-
strncpy((char*)message, plainMessage, sizeof(message)-1);
634-
message[sizeof(message)-1] = '\0';
635-
636640
/* Initialize the rng for signature signing */
637641
ret = wc_InitRng_ex(rng, NULL, WH_DEV_ID);
638642
if (ret != 0) {

src/wh_server_cert.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,10 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
746746
(void)WH_SERVER_NVM_UNLOCK(server);
747747
} /* WH_SERVER_NVM_LOCK() */
748748

749-
/* Signature confirmation error is not an error for the server, so
749+
/* Signature verification error is not an error for the server, so
750750
* propagate this error to the client in the response, otherwise
751751
* return the error code from the verify action */
752-
if (rc == ASN_SIG_CONFIRM_E) {
752+
if (rc == ASN_SIG_CONFIRM_E || rc == ASN_SIG_OID_E) {
753753
resp.rc = WH_ERROR_CERT_VERIFY;
754754
rc = WH_ERROR_OK;
755755
}
@@ -794,10 +794,10 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
794794
(void)WH_SERVER_NVM_UNLOCK(server);
795795
} /* WH_SERVER_NVM_LOCK() */
796796

797-
/* Signature confirmation error is not an error for the server,
797+
/* Signature verification error is not an error for the server,
798798
* so propagate this error to the client in the response,
799799
* otherwise return the error code from the verify action */
800-
if (rc == ASN_SIG_CONFIRM_E) {
800+
if (rc == ASN_SIG_CONFIRM_E || rc == ASN_SIG_OID_E) {
801801
resp.rc = WH_ERROR_CERT_VERIFY;
802802
rc = WH_ERROR_OK;
803803
}

0 commit comments

Comments
 (0)