Skip to content

Commit 965a810

Browse files
committed
Add extra unit test coverage for spdm
1 parent 5178d79 commit 965a810

2 files changed

Lines changed: 1064 additions & 28 deletions

File tree

src/spdm/spdm_internal.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -270,78 +270,78 @@ static WC_INLINE void wolfSPDM_BuildIV(byte* iv, const byte* baseIv,
270270

271271
/* ----- Internal Function Declarations - Transcript ----- */
272272

273-
WOLFTPM_LOCAL void wolfSPDM_TranscriptReset(WOLFSPDM_CTX* ctx);
274-
WOLFTPM_LOCAL int wolfSPDM_TranscriptAdd(WOLFSPDM_CTX* ctx, const byte* data, word32 len);
275-
WOLFTPM_LOCAL int wolfSPDM_TranscriptHash(WOLFSPDM_CTX* ctx, byte* hash);
276-
WOLFTPM_LOCAL int wolfSPDM_Sha384Hash(byte* out,
273+
WOLFTPM_API void wolfSPDM_TranscriptReset(WOLFSPDM_CTX* ctx);
274+
WOLFTPM_API int wolfSPDM_TranscriptAdd(WOLFSPDM_CTX* ctx, const byte* data, word32 len);
275+
WOLFTPM_API int wolfSPDM_TranscriptHash(WOLFSPDM_CTX* ctx, byte* hash);
276+
WOLFTPM_API int wolfSPDM_Sha384Hash(byte* out,
277277
const byte* d1, word32 d1Sz,
278278
const byte* d2, word32 d2Sz,
279279
const byte* d3, word32 d3Sz);
280280

281281
/* ----- Internal Function Declarations - Crypto ----- */
282282

283-
WOLFTPM_LOCAL int wolfSPDM_GenerateEphemeralKey(WOLFSPDM_CTX* ctx);
284-
WOLFTPM_LOCAL int wolfSPDM_ExportEphemeralPubKey(WOLFSPDM_CTX* ctx,
283+
WOLFTPM_API int wolfSPDM_GenerateEphemeralKey(WOLFSPDM_CTX* ctx);
284+
WOLFTPM_API int wolfSPDM_ExportEphemeralPubKey(WOLFSPDM_CTX* ctx,
285285
byte* pubKeyX, word32* pubKeyXSz,
286286
byte* pubKeyY, word32* pubKeyYSz);
287-
WOLFTPM_LOCAL int wolfSPDM_ComputeSharedSecret(WOLFSPDM_CTX* ctx,
287+
WOLFTPM_API int wolfSPDM_ComputeSharedSecret(WOLFSPDM_CTX* ctx,
288288
const byte* peerPubKeyX, const byte* peerPubKeyY);
289-
WOLFTPM_LOCAL int wolfSPDM_GetRandom(WOLFSPDM_CTX* ctx, byte* out, word32 outSz);
290-
WOLFTPM_LOCAL int wolfSPDM_SignHash(WOLFSPDM_CTX* ctx, const byte* hash, word32 hashSz,
289+
WOLFTPM_API int wolfSPDM_GetRandom(WOLFSPDM_CTX* ctx, byte* out, word32 outSz);
290+
WOLFTPM_API int wolfSPDM_SignHash(WOLFSPDM_CTX* ctx, const byte* hash, word32 hashSz,
291291
byte* sig, word32* sigSz);
292-
WOLFTPM_LOCAL int wolfSPDM_VerifySignature(WOLFSPDM_CTX* ctx,
292+
WOLFTPM_API int wolfSPDM_VerifySignature(WOLFSPDM_CTX* ctx,
293293
const byte* hash, word32 hashSz,
294294
const byte* sig, word32 sigSz);
295295

296296
/* ----- Internal Function Declarations - Key Derivation ----- */
297297

298-
WOLFTPM_LOCAL int wolfSPDM_DeriveHandshakeKeys(WOLFSPDM_CTX* ctx, const byte* th1Hash);
299-
WOLFTPM_LOCAL int wolfSPDM_DeriveFromHandshakeSecret(WOLFSPDM_CTX* ctx, const byte* th1Hash);
300-
WOLFTPM_LOCAL int wolfSPDM_DeriveAppDataKeys(WOLFSPDM_CTX* ctx);
301-
WOLFTPM_LOCAL int wolfSPDM_HkdfExpandLabel(byte spdmVersion, const byte* secret, word32 secretSz,
298+
WOLFTPM_API int wolfSPDM_DeriveHandshakeKeys(WOLFSPDM_CTX* ctx, const byte* th1Hash);
299+
WOLFTPM_API int wolfSPDM_DeriveFromHandshakeSecret(WOLFSPDM_CTX* ctx, const byte* th1Hash);
300+
WOLFTPM_API int wolfSPDM_DeriveAppDataKeys(WOLFSPDM_CTX* ctx);
301+
WOLFTPM_API int wolfSPDM_HkdfExpandLabel(byte spdmVersion, const byte* secret, word32 secretSz,
302302
const char* label, const byte* context, word32 contextSz,
303303
byte* out, word32 outSz);
304-
WOLFTPM_LOCAL int wolfSPDM_ComputeVerifyData(const byte* finishedKey, const byte* thHash,
304+
WOLFTPM_API int wolfSPDM_ComputeVerifyData(const byte* finishedKey, const byte* thHash,
305305
byte* verifyData);
306306

307307
/* ----- Internal Function Declarations - Message Building ----- */
308308

309-
WOLFTPM_LOCAL int wolfSPDM_BuildGetVersion(byte* buf, word32* bufSz);
310-
WOLFTPM_LOCAL int wolfSPDM_BuildKeyExchange(WOLFSPDM_CTX* ctx, byte* buf, word32* bufSz);
311-
WOLFTPM_LOCAL int wolfSPDM_BuildFinish(WOLFSPDM_CTX* ctx, byte* buf, word32* bufSz);
312-
WOLFTPM_LOCAL int wolfSPDM_BuildEndSession(WOLFSPDM_CTX* ctx, byte* buf, word32* bufSz);
309+
WOLFTPM_API int wolfSPDM_BuildGetVersion(byte* buf, word32* bufSz);
310+
WOLFTPM_API int wolfSPDM_BuildKeyExchange(WOLFSPDM_CTX* ctx, byte* buf, word32* bufSz);
311+
WOLFTPM_API int wolfSPDM_BuildFinish(WOLFSPDM_CTX* ctx, byte* buf, word32* bufSz);
312+
WOLFTPM_API int wolfSPDM_BuildEndSession(WOLFSPDM_CTX* ctx, byte* buf, word32* bufSz);
313313
/* PSK message builders/parsers declared in spdm_psk.h */
314314

315315
/* ----- Internal Function Declarations - Message Parsing ----- */
316316

317-
WOLFTPM_LOCAL int wolfSPDM_ParseVersion(WOLFSPDM_CTX* ctx, const byte* buf, word32 bufSz);
318-
WOLFTPM_LOCAL int wolfSPDM_ParseKeyExchangeRsp(WOLFSPDM_CTX* ctx, const byte* buf, word32 bufSz);
319-
WOLFTPM_LOCAL int wolfSPDM_ParseFinishRsp(WOLFSPDM_CTX* ctx, const byte* buf, word32 bufSz);
320-
WOLFTPM_LOCAL int wolfSPDM_CheckError(const byte* buf, word32 bufSz, int* errorCode);
317+
WOLFTPM_API int wolfSPDM_ParseVersion(WOLFSPDM_CTX* ctx, const byte* buf, word32 bufSz);
318+
WOLFTPM_API int wolfSPDM_ParseKeyExchangeRsp(WOLFSPDM_CTX* ctx, const byte* buf, word32 bufSz);
319+
WOLFTPM_API int wolfSPDM_ParseFinishRsp(WOLFSPDM_CTX* ctx, const byte* buf, word32 bufSz);
320+
WOLFTPM_API int wolfSPDM_CheckError(const byte* buf, word32 bufSz, int* errorCode);
321321

322322
/* ----- Internal Function Declarations - Secured Messaging ----- */
323323

324-
WOLFTPM_LOCAL int wolfSPDM_EncryptInternal(WOLFSPDM_CTX* ctx,
324+
WOLFTPM_API int wolfSPDM_EncryptInternal(WOLFSPDM_CTX* ctx,
325325
const byte* plain, word32 plainSz,
326326
byte* enc, word32* encSz);
327-
WOLFTPM_LOCAL int wolfSPDM_DecryptInternal(WOLFSPDM_CTX* ctx,
327+
WOLFTPM_API int wolfSPDM_DecryptInternal(WOLFSPDM_CTX* ctx,
328328
const byte* enc, word32 encSz,
329329
byte* plain, word32* plainSz);
330330

331331
/* ----- Internal Utility Functions ----- */
332332

333-
WOLFTPM_LOCAL int wolfSPDM_SendReceive(WOLFSPDM_CTX* ctx,
333+
WOLFTPM_API int wolfSPDM_SendReceive(WOLFSPDM_CTX* ctx,
334334
const byte* txBuf, word32 txSz,
335335
byte* rxBuf, word32* rxSz);
336336

337337
#ifdef DEBUG_WOLFTPM
338-
WOLFTPM_LOCAL void wolfSPDM_DebugPrint(WOLFSPDM_CTX* ctx, const char* fmt, ...)
338+
WOLFTPM_API void wolfSPDM_DebugPrint(WOLFSPDM_CTX* ctx, const char* fmt, ...)
339339
#ifdef __GNUC__
340340
__attribute__((format(printf, 2, 3)))
341341
#endif
342342
;
343343

344-
WOLFTPM_LOCAL void wolfSPDM_DebugHex(WOLFSPDM_CTX* ctx, const char* label,
344+
WOLFTPM_API void wolfSPDM_DebugHex(WOLFSPDM_CTX* ctx, const char* label,
345345
const byte* data, word32 len);
346346
#else
347347
#define wolfSPDM_DebugPrint(ctx, fmt, ...) do { (void)(ctx); (void)fmt; } while(0)

0 commit comments

Comments
 (0)