Skip to content

Commit 69304ac

Browse files
committed
Edits for typos and minor bug fixes
1 parent a5c78e1 commit 69304ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+270
-433
lines changed

CppProperties.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"configurations": [
3+
{
4+
"inheritEnvironments": [
5+
"msvc_x86"
6+
],
7+
"name": "x86-Debug",
8+
"includePath": [
9+
"${env.INCLUDE}",
10+
"${workspaceRoot}\\**"
11+
],
12+
"defines": [
13+
"WIN32",
14+
"_DEBUG",
15+
"UNICODE",
16+
"_UNICODE"
17+
],
18+
"intelliSenseMode": "windows-msvc-x86"
19+
}
20+
]
21+
}

TPMCmd/Platform/include/PlatformData.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define _PLATFORM_DATA_H_
4040

4141
// From Cancel.c
42-
// Cancel flag. It is initialized as FALSE, which indicate the command is not
42+
// This flag is initialized as FALSE to indicate that the command is not
4343
// being canceled
4444
extern int s_isCanceled;
4545

@@ -75,9 +75,9 @@ extern BOOL s_timerStopped;
7575
// CLOCK_NOMINAL is the number of hardware ticks per mS. A value of 300000 means
7676
// that the nominal clock rate used to drive the hardware clock is 30 MHz. The
7777
// adjustment rates are used to determine the conversion of the hardware ticks to
78-
// internal hardware clock value. In practice, we would expect that there woudl be
79-
// a hardware register will accumulated mS. It would be incremented by the output
80-
// of a pre-scaler. The pre-scaler would divide the ticks from the clock by some
78+
// internal hardware clock value. In practice, we would expect that there would be
79+
// a hardware register with accumulated mS. It would be incremented by the output
80+
// of a prescaler. The prescaler would divide the ticks from the clock by some
8181
// value that would compensate for the difference between clock time and real time.
8282
// The code in Clock does the emulation of this function.
8383
#define CLOCK_NOMINAL 30000

TPMCmd/Platform/include/prototypes/DebugHelpers_fp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void
5959
DebugDumpBuffer(
6060
int size,
6161
unsigned char *buf,
62-
unsigned char *identifier
62+
const char *identifier
6363
);
6464

6565
#endif // _DEBUGHELPERS_FP_H_

TPMCmd/Platform/include/prototypes/Platform_fp.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ _plat__ClockAdjustRate(
147147

148148
//** From DebugHelpers.c
149149

150+
#if CERTIFYX509_DEBUG
151+
150152
//*** DebugFileOpen()
151153
// This function opens the file used to hold the debug data.
152154
// Return Type: int
@@ -166,8 +168,9 @@ void
166168
DebugDumpBuffer(
167169
int size,
168170
unsigned char *buf,
169-
unsigned char *identifier
171+
const char *identifier
170172
);
173+
#endif // CERTIFYX509_DEBUG
171174

172175

173176
//** From Entropy.c

TPMCmd/Platform/platform.vcxproj.filters

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
<ClCompile Include="src\Unique.c">
3232
<Filter>Source Files</Filter>
3333
</ClCompile>
34-
<ClCompile Include="src\DebugHelpers.c" />
34+
<ClCompile Include="src\DebugHelpers.c">
35+
<Filter>Source Files</Filter>
36+
</ClCompile>
3537
</ItemGroup>
3638
<ItemGroup>
3739
<Filter Include="Source Files">

TPMCmd/Platform/src/DebugHelpers.c

+28-24
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,28 @@
4040
//
4141

4242
//** Includes and Local
43-
#include <stdio.h>
44-
#include <time.h>
43+
#include <stdio.h>
44+
#include <time.h>
45+
#include "Platform.h"
4546

46-
FILE *fDebug = NULL;
47-
const char *fn = "DebugFile.txt";
47+
#if CERTIFYX509_DEBUG
4848

49-
static FILE*
49+
FILE *fDebug = NULL;
50+
const char *debugFileName = "DebugFile.txt";
51+
52+
static FILE *
5053
fileOpen(
51-
const char *fname,
52-
const char *mode
54+
const char *fn,
55+
const char *mode
5356
)
5457
{
5558
FILE *f;
56-
#if defined _MSC_VER
57-
if(fopen_s(&f, fname, mode) != 0)
59+
# if defined _MSC_VER
60+
if(fopen_s(&f, fn, mode) != 0)
5861
f = NULL;
59-
#else
62+
# else
6063
f = fopen(fn, "w");
61-
#endif
64+
# endif
6265
return f;
6366
}
6467

@@ -72,21 +75,18 @@ DebugFileOpen(
7275
void
7376
)
7477
{
75-
#if defined _MSC_VER
76-
char timeString[100];
77-
#else
78-
char *timeString;
79-
#endif
80-
time_t t = time(NULL);
78+
time_t t = time(NULL);
8179
//
8280
// Get current date and time.
83-
#if defined _MSC_VER
84-
ctime_s(timeString, sizeof(timeString), &t);
85-
#else
81+
# if defined _MSC_VER
82+
char timeString[100];
83+
ctime_s(timeString, (size_t)sizeof(timeString), &t);
84+
# else
85+
char *timeString;
8686
timeString = ctime(&t);
87-
#endif
87+
# endif
8888
// Try to open the debug file
89-
fDebug = fileOpen(fn, "w");
89+
fDebug = fileOpen(debugFileName, "w");
9090
if(fDebug)
9191
{
9292
fprintf(fDebug, "%s\n", timeString);
@@ -96,6 +96,7 @@ DebugFileOpen(
9696
return -1;
9797
}
9898

99+
//*** DebugFileClose()
99100
void
100101
DebugFileClose(
101102
void
@@ -105,16 +106,17 @@ DebugFileClose(
105106
fclose(fDebug);
106107
}
107108

109+
//*** DebugDumpBuffer()
108110
void
109111
DebugDumpBuffer(
110112
int size,
111113
unsigned char *buf,
112-
unsigned char *identifier
114+
const char *identifier
113115
)
114116
{
115117
int i;
116118
//
117-
FILE *f = fileOpen(fn, "a");
119+
FILE *f = fileOpen(debugFileName, "a");
118120
if(!f)
119121
return;
120122
if(identifier)
@@ -132,3 +134,5 @@ DebugDumpBuffer(
132134
}
133135
fclose(f);
134136
}
137+
138+
#endif // CERTIFYX509_DEBUG

TPMCmd/Platform/src/Entropy.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
// see that two consecutive 32-bit values are not the same because
5151
// (according to FIPS 140-2, annex C
5252
//
53-
// "If each call to a RNG produces blocks of n bits (where n > 15), the first
53+
// "If each call to an RNG produces blocks of n bits (where n > 15), the first
5454
// n-bit block generated after power-up, initialization, or reset shall not be
5555
// used, but shall be saved for comparison with the next n-bit block to be
5656
// generated. Each subsequent generation of an n-bit block shall be compared with

TPMCmd/Simulator/src/TcpServer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ RegularCommandService(
366366
serverSocket = accept(listenSocket,
367367
(struct sockaddr*) &HerAddress,
368368
&length);
369-
if(serverSocket == SOCKET_ERROR)
369+
if(serverSocket == INVALID_SOCKET)
370370
{
371371
printf("Accept error. Error is 0x%x\n", WSAGetLastError());
372372
return -1;

TPMCmd/tpm/Tpm.vcxproj.filters

+11-5
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@
589589
<ClCompile Include="src\X509\X509_ECC.c">
590590
<Filter>Source Files\X509</Filter>
591591
</ClCompile>
592-
<ClCompile Include="src\X509\TpmASN1.c">
592+
<ClCompile Include="src\X509\TpmAsn1.c">
593593
<Filter>Source Files\X509</Filter>
594594
</ClCompile>
595595
</ItemGroup>
@@ -1203,7 +1203,7 @@
12031203
<ClInclude Include="include\X509_RSA.h">
12041204
<Filter>Source Files\X509</Filter>
12051205
</ClInclude>
1206-
<ClInclude Include="include\OIDS.h">
1206+
<ClInclude Include="include\OIDs.h">
12071207
<Filter>Source Files\X509</Filter>
12081208
</ClInclude>
12091209
<ClInclude Include="include\CryptHash.h">
@@ -1317,6 +1317,9 @@
13171317
<ClInclude Include="include\wolf\TpmToWolfSym.h">
13181318
<Filter>Headers\Crypt\wolf</Filter>
13191319
</ClInclude>
1320+
<ClInclude Include="$(SolutionDir)\wolfcrypt\include\user_settings.h">
1321+
<Filter>Headers\Crypt\wolf</Filter>
1322+
</ClInclude>
13201323
<ClInclude Include="include\prototypes\TpmToWolfDesSupport_fp.h">
13211324
<Filter>Headers\prototypes</Filter>
13221325
</ClInclude>
@@ -1326,14 +1329,17 @@
13261329
<ClInclude Include="include\prototypes\TpmToWolfMath_fp.h">
13271330
<Filter>Headers\prototypes</Filter>
13281331
</ClInclude>
1329-
<ClInclude Include="include\TpmProfile.h">
1332+
<ClInclude Include="include\MinMax.h">
13301333
<Filter>Headers</Filter>
13311334
</ClInclude>
13321335
<ClInclude Include="include\TpmAlgorithmDefines.h">
13331336
<Filter>Headers</Filter>
13341337
</ClInclude>
1335-
<ClInclude Include="include\Wolf\user_settings.h">
1336-
<Filter>Headers\Crypt\wolf</Filter>
1338+
<ClInclude Include="include\TpmProfile.h">
1339+
<Filter>Headers</Filter>
1340+
</ClInclude>
1341+
<ClInclude Include="include\TpmAsn1.h">
1342+
<Filter>Headers</Filter>
13371343
</ClInclude>
13381344
</ItemGroup>
13391345
<ItemGroup>

TPMCmd/tpm/include/CryptHash.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ typedef const struct HASH_DEF
239239
(HASH_STATE_EXPORT_METHOD *)&tpmHashStateExport_##HASH, \
240240
(HASH_STATE_IMPORT_METHOD *)&tpmHashStateImport_##HASH, \
241241
}, \
242-
HASH##_BLOCK_SIZE, /* block size */ \
243-
HASH##_DIGEST_SIZE, /* data size */ \
244-
sizeof(tpmHashState##HASH##_t), \
245-
TPM_ALG_##HASH, OID_##HASH \
242+
HASH##_BLOCK_SIZE, /*block size */ \
243+
HASH##_DIGEST_SIZE, /*data size */ \
244+
sizeof(tpmHashState##HASH##_t), \
245+
TPM_ALG_##HASH, OID_##HASH \
246246
PKCS1_OID(HASH) ECDSA_OID(HASH)};
247247

248248
// These definitions are for the types that can be in a hash state structure.
@@ -292,8 +292,7 @@ typedef struct hmacState
292292
} HMAC_STATE, *PHMAC_STATE;
293293

294294
// This is for the external hash state. This implementation assumes that the size
295-
// of the exported hash state is no larger than the internal hash state. There
296-
// is a run time check that makes sure that this i.
295+
// of the exported hash state is no larger than the internal hash state.
297296
typedef struct
298297
{
299298
BYTE buffer[sizeof(HASH_STATE)];

TPMCmd/tpm/include/CryptSym.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ typedef union tpmCryptKeySchedule_t {
7575
// or decrypt with the algorithm chosen by setting a function pointer to select
7676
// the algorithm that is used.
7777

78-
# define ENCRYPT(keySchedule, in, out) \
78+
# define ENCRYPT(keySchedule, in, out) \
7979
encrypt(SWIZZLE(keySchedule, in, out))
8080

81-
# define DECRYPT(keySchedule, in, out) \
81+
# define DECRYPT(keySchedule, in, out) \
8282
decrypt(SWIZZLE(keySchedule, in, out))
8383

8484

TPMCmd/tpm/include/Global.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#define INITIALIZER(_value_) = _value_
6464
#else
6565
#define EXTERN extern
66-
#define INITIALIZER(_name_)
66+
#define INITIALIZER(_value_)
6767
#endif
6868

6969
_REDUCE_WARNING_LEVEL_(2)
@@ -916,9 +916,9 @@ EXTERN ORDERLY_DATA go;
916916
//*** STATE_CLEAR_DATA
917917
//*********************************************************************************
918918
//*********************************************************************************
919-
// This structure contains the data that is saved on Shutdown(STATE).
919+
// This structure contains the data that is saved on Shutdown(STATE)
920920
// and restored on Startup(STATE). The values are set to their default
921-
// settings on any Startup(Clear). In other words the data is only persistent
921+
// settings on any Startup(Clear). In other words, the data is only persistent
922922
// across TPM Resume.
923923
//
924924
// If the comments associated with a parameter indicate a default reset value, the

0 commit comments

Comments
 (0)