Skip to content

Commit 4a48fb3

Browse files
committed
Peer review cleanups.
1 parent 53b043d commit 4a48fb3

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/tpm2_wrap.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,10 @@ int wolfTPM2_GetKeyBlobAsBuffer(byte *buffer, word32 bufferSz,
347347
if ((int)bufferSz < sz) {
348348
return BUFFER_E;
349349
}
350-
sz = 0;
351350

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

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

@@ -430,7 +428,7 @@ int wolfTPM2_GetKeyBlobAsSeparateBuffers(byte* pubBuffer, word32* pubBufferSz,
430428
TPM2_PrintBin(privBuffer, *privBufferSz);
431429
#endif
432430

433-
return sz;
431+
return TPM_RC_SUCCESS;
434432
}
435433

436434
int wolfTPM2_SetKeyBlobFromBuffer(WOLFTPM2_KEYBLOB* key, byte *buffer,

wolftpm/tpm2_wrap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3171,7 +3171,7 @@ WOLFTPM_API int wolfTPM2_GetKeyBlobAsBuffer(byte *buffer, word32 bufferSz,
31713171
cycling. If either buffer is NULL then the size will be returned for
31723172
each part.
31733173
3174-
\return Positive integer (size of the output)
3174+
\return TPM_RC_SUCCESS: successful
31753175
\return BUFFER_E: insufficient space in provided buffer
31763176
\return BAD_FUNC_ARG: check the provided arguments
31773177
\return LENGTH_ONLY_E: Returning length only (when either of the buffers is NULL)

0 commit comments

Comments
 (0)