Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrett committed Oct 30, 2024
1 parent 7e8b7e5 commit ca85bdc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 3 additions & 2 deletions hal/aurix_tc3xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ static int _connectCb(void* context, whCommConnected connect)

int hal_hsm_init_connect(void)
{
int rc = 0;
int rc = 0;
size_t i;

/* init shared memory buffers */
uint32_t* req = (uint32_t*)hsmShmCore0CommBuf;
Expand Down Expand Up @@ -625,7 +626,7 @@ int hal_hsm_init_connect(void)
}

/* init shared memory buffers */
for (size_t i=0; i<HSM_SHM_CORE0_COMM_BUF_WORDS; i++) {
for (i = 0; i < HSM_SHM_CORE0_COMM_BUF_WORDS; i++) {
hsmShmCore0CommBuf[i] = 0;
}

Expand Down
3 changes: 3 additions & 0 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ static void wolfBoot_verify_signature_ecc(uint8_t key_slot,
size_t tmpSigSz = sizeof(tmpSigBuf);

#if defined(WOLFBOOT_USE_WOLFHSM_PUBKEY_ID)
(void)key_slot;

/* hardcoded, since not using keystore */
const int point_sz = ECC_IMAGE_SIGNATURE_SIZE / 2;

Expand Down Expand Up @@ -396,6 +398,7 @@ static void wolfBoot_verify_signature_rsa(uint8_t key_slot,
return;
}
#if defined(WOLFBOOT_USE_WOLFHSM_PUBKEY_ID)
(void)key_slot;
/* public key is stored on server at hsmClientKeyIdPubKey*/
ret = wh_Client_RsaSetKeyId(&rsa, hsmClientKeyIdPubKey);
if (ret != 0) {
Expand Down
27 changes: 17 additions & 10 deletions tools/keytools/keygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,22 +358,27 @@ static int generated_keypairs_type[MAX_KEYPAIRS];
static uint32_t generated_keypairs_id_mask[MAX_KEYPAIRS];
static int n_generated = 0;

static char *append_pub_to_fname(const char *filename) {
const char pubSuffix[] = "_pub";
static char* append_pub_to_fname(const char* filename)
{
const char pubSuffix[] = "_pub";
const size_t pubSuffixLength = strlen(pubSuffix);
const char* dotPosition;
size_t prefixLength;
char* newFilename;
size_t newFilenameLength;

const char *dotPosition = strchr(filename, '.');

size_t prefixLength;
dotPosition = strchr(filename, '.');
if (dotPosition != NULL) {
prefixLength = dotPosition - filename;
} else {
}
else {
prefixLength = strlen(filename);
}

size_t newFilenameLength = prefixLength + pubSuffixLength + (dotPosition ? strlen(dotPosition) : 0) + 1;
newFilenameLength = prefixLength + pubSuffixLength +
(dotPosition ? strlen(dotPosition) : 0) + 1;

char *newFilename = (char *)malloc(newFilenameLength);
newFilename = (char*)malloc(newFilenameLength);
if (newFilename == NULL) {
return NULL;
}
Expand All @@ -387,8 +392,10 @@ static char *append_pub_to_fname(const char *filename) {
/* Append the rest of the original filename if a period was found */
if (dotPosition != NULL) {
strcpy(newFilename + prefixLength + pubSuffixLength, dotPosition);
} else {
newFilename[prefixLength + pubSuffixLength] = '\0'; /* Null-terminate the string if no period */
}
else {
/* Null-terminate the string if no period */
newFilename[prefixLength + pubSuffixLength] = '\0';
}

return newFilename;
Expand Down

0 comments on commit ca85bdc

Please sign in to comment.