Skip to content

Commit

Permalink
Peer review cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Dec 8, 2023
1 parent 53b043d commit 4a48fb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/tpm2_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,10 @@ int wolfTPM2_GetKeyBlobAsBuffer(byte *buffer, word32 bufferSz,
if ((int)bufferSz < sz) {
return BUFFER_E;
}
sz = 0;

/* Write size marker for the public part */
XMEMCPY(buffer + sz, &key->pub.size, sizeof(key->pub.size));
sz += sizeof(key->pub.size);
XMEMCPY(buffer, &key->pub.size, sizeof(key->pub.size));
sz = sizeof(key->pub.size);

/* Write the public part with bytes aligned */
XMEMCPY(buffer + sz, pubAreaBuffer, sizeof(UINT16) + key->pub.size);
Expand All @@ -373,7 +372,6 @@ int wolfTPM2_GetKeyBlobAsSeparateBuffers(byte* pubBuffer, word32* pubBufferSz,
byte* privBuffer, word32* privBufferSz, WOLFTPM2_KEYBLOB* key)
{
int rc = 0;
int sz = 0;
byte pubAreaBuffer[sizeof(TPM2B_PUBLIC)];
int pubAreaSize;

Expand Down Expand Up @@ -430,7 +428,7 @@ int wolfTPM2_GetKeyBlobAsSeparateBuffers(byte* pubBuffer, word32* pubBufferSz,
TPM2_PrintBin(privBuffer, *privBufferSz);
#endif

return sz;
return TPM_RC_SUCCESS;
}

int wolfTPM2_SetKeyBlobFromBuffer(WOLFTPM2_KEYBLOB* key, byte *buffer,
Expand Down
2 changes: 1 addition & 1 deletion wolftpm/tpm2_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -3171,7 +3171,7 @@ WOLFTPM_API int wolfTPM2_GetKeyBlobAsBuffer(byte *buffer, word32 bufferSz,
cycling. If either buffer is NULL then the size will be returned for
each part.
\return Positive integer (size of the output)
\return TPM_RC_SUCCESS: successful
\return BUFFER_E: insufficient space in provided buffer
\return BAD_FUNC_ARG: check the provided arguments
\return LENGTH_ONLY_E: Returning length only (when either of the buffers is NULL)
Expand Down

0 comments on commit 4a48fb3

Please sign in to comment.