mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 19:54:40 +02:00
eliminate XREWIND() macro, add XSEEK_SET definitions, and refactor all XREWIND()s to XFSEEK()s, to fix clang-tidy-17 bugprone-unsafe-functions warning on rewind();
add BENCH_DEVID_COLUMN_HEADER in wolfcrypt/benchmark/benchmark.c:bench_stats_sym_finish() to resolve clang-diagnostic-embedded-directive.
This commit is contained in:
@@ -1429,8 +1429,10 @@ int wolfSSL_BIO_reset(WOLFSSL_BIO *bio)
|
|||||||
switch (bio->type) {
|
switch (bio->type) {
|
||||||
#ifndef NO_FILESYSTEM
|
#ifndef NO_FILESYSTEM
|
||||||
case WOLFSSL_BIO_FILE:
|
case WOLFSSL_BIO_FILE:
|
||||||
XREWIND((XFILE)bio->ptr);
|
if (XFSEEK((XFILE)bio->ptr, 0, XSEEK_SET) != 0)
|
||||||
return 0;
|
return WOLFSSL_BIO_ERROR;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case WOLFSSL_BIO_BIO:
|
case WOLFSSL_BIO_BIO:
|
||||||
|
@@ -1627,7 +1627,10 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz,
|
|||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
XREWIND(file);
|
if(XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
XFCLOSE(file);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
loadBuf = (byte*)XMALLOC(fileSz, NULL, DYNAMIC_TYPE_FILE);
|
loadBuf = (byte*)XMALLOC(fileSz, NULL, DYNAMIC_TYPE_FILE);
|
||||||
if (loadBuf == NULL) {
|
if (loadBuf == NULL) {
|
||||||
|
25
src/ssl.c
25
src/ssl.c
@@ -8629,7 +8629,10 @@ int ProcessFile(WOLFSSL_CTX* ctx, const char* fname, int format, int type,
|
|||||||
return WOLFSSL_BAD_FILE;
|
return WOLFSSL_BAD_FILE;
|
||||||
}
|
}
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if (XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
XFCLOSE(file);
|
||||||
|
return WOLFSSL_BAD_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
||||||
WOLFSSL_MSG("ProcessFile file size error");
|
WOLFSSL_MSG("ProcessFile file size error");
|
||||||
@@ -9102,7 +9105,10 @@ int wolfSSL_CertManagerVerify(WOLFSSL_CERT_MANAGER* cm, const char* fname,
|
|||||||
return WOLFSSL_BAD_FILE;
|
return WOLFSSL_BAD_FILE;
|
||||||
}
|
}
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if(XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
XFCLOSE(file);
|
||||||
|
return WOLFSSL_BAD_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
||||||
WOLFSSL_MSG("CertManagerVerify file size error");
|
WOLFSSL_MSG("CertManagerVerify file size error");
|
||||||
@@ -9564,7 +9570,10 @@ static int wolfSSL_SetTmpDH_file_wrapper(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
|
|||||||
return WOLFSSL_BAD_FILE;
|
return WOLFSSL_BAD_FILE;
|
||||||
}
|
}
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if(XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
XFCLOSE(file);
|
||||||
|
return WOLFSSL_BAD_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
||||||
WOLFSSL_MSG("SetTmpDH file size error");
|
WOLFSSL_MSG("SetTmpDH file size error");
|
||||||
@@ -12245,7 +12254,10 @@ int CM_RestoreCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname)
|
|||||||
return WOLFSSL_BAD_FILE;
|
return WOLFSSL_BAD_FILE;
|
||||||
}
|
}
|
||||||
memSz = (int)XFTELL(file);
|
memSz = (int)XFTELL(file);
|
||||||
XREWIND(file);
|
if(XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
XFCLOSE(file);
|
||||||
|
return WOLFSSL_BAD_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
if (memSz > MAX_WOLFSSL_FILE_SIZE || memSz <= 0) {
|
if (memSz > MAX_WOLFSSL_FILE_SIZE || memSz <= 0) {
|
||||||
WOLFSSL_MSG("CM_RestoreCertCache file size error");
|
WOLFSSL_MSG("CM_RestoreCertCache file size error");
|
||||||
@@ -25746,7 +25758,10 @@ int wolfSSL_cmp_peer_cert_to_file(WOLFSSL* ssl, const char *fname)
|
|||||||
return WOLFSSL_BAD_FILE;
|
return WOLFSSL_BAD_FILE;
|
||||||
}
|
}
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if (XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
XFCLOSE(file);
|
||||||
|
return WOLFSSL_BAD_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
if (sz > MAX_WOLFSSL_FILE_SIZE || sz < 0) {
|
if (sz > MAX_WOLFSSL_FILE_SIZE || sz < 0) {
|
||||||
WOLFSSL_MSG("cmp_peer_cert_to_file size error");
|
WOLFSSL_MSG("cmp_peer_cert_to_file size error");
|
||||||
|
22
src/x509.c
22
src/x509.c
@@ -4647,7 +4647,8 @@ WOLFSSL_X509* wolfSSL_X509_d2i_fp(WOLFSSL_X509** x509, XFILE file)
|
|||||||
if (XFSEEK(file, 0, XSEEK_END) != 0)
|
if (XFSEEK(file, 0, XSEEK_END) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if (XFSEEK(file, 0, XSEEK_SET) != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (sz > MAX_WOLFSSL_FILE_SIZE || sz < 0) {
|
if (sz > MAX_WOLFSSL_FILE_SIZE || sz < 0) {
|
||||||
WOLFSSL_MSG("X509_d2i file size error");
|
WOLFSSL_MSG("X509_d2i file size error");
|
||||||
@@ -4706,7 +4707,10 @@ WOLFSSL_X509* wolfSSL_X509_load_certificate_file(const char* fname, int format)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if (XFSEEK(file, 0, XSEEK_SET) != 0){
|
||||||
|
XFCLOSE(file);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (sz > MAX_WOLFSSL_FILE_SIZE || sz < 0) {
|
if (sz > MAX_WOLFSSL_FILE_SIZE || sz < 0) {
|
||||||
WOLFSSL_MSG("X509_load_certificate_file size error");
|
WOLFSSL_MSG("X509_load_certificate_file size error");
|
||||||
@@ -6624,7 +6628,10 @@ int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP* lookup,
|
|||||||
return WS_RETURN_CODE(WOLFSSL_BAD_FILE,WOLFSSL_FAILURE);
|
return WS_RETURN_CODE(WOLFSSL_BAD_FILE,WOLFSSL_FAILURE);
|
||||||
}
|
}
|
||||||
sz = XFTELL(fp);
|
sz = XFTELL(fp);
|
||||||
XREWIND(fp);
|
if(XFSEEK(fp, 0, XSEEK_SET) != 0) {
|
||||||
|
XFCLOSE(fp);
|
||||||
|
return WS_RETURN_CODE(WOLFSSL_BAD_FILE,WOLFSSL_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
||||||
WOLFSSL_MSG("X509_LOOKUP_load_file size error");
|
WOLFSSL_MSG("X509_LOOKUP_load_file size error");
|
||||||
@@ -7181,7 +7188,9 @@ static void *wolfSSL_d2i_X509_fp_ex(XFILE file, void **x509, int type)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if (XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
if (sz > MAX_WOLFSSL_FILE_SIZE || sz <= 0) {
|
||||||
WOLFSSL_MSG("d2i_X509_fp_ex file size error");
|
WOLFSSL_MSG("d2i_X509_fp_ex file size error");
|
||||||
@@ -7345,7 +7354,10 @@ WOLFSSL_API int wolfSSL_X509_load_cert_crl_file(WOLFSSL_X509_LOOKUP *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XREWIND(fp);
|
if (XFSEEK(fp, 0, XSEEK_SET) != 0) {
|
||||||
|
WOLFSSL_MSG("XFSEEK error");
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
crl = wolfSSL_PEM_read_X509_CRL(fp, NULL, NULL, NULL);
|
crl = wolfSSL_PEM_read_X509_CRL(fp, NULL, NULL, NULL);
|
||||||
if (crl != NULL) {
|
if (crl != NULL) {
|
||||||
if (wolfSSL_X509_STORE_add_crl(ctx->store, crl) ==
|
if (wolfSSL_X509_STORE_add_crl(ctx->store, crl) ==
|
||||||
|
24
tests/api.c
24
tests/api.c
@@ -601,7 +601,7 @@ static int test_fileAccess(void)
|
|||||||
AssertTrue((f = XFOPEN(derfile, "rb")) != XBADFILE);
|
AssertTrue((f = XFOPEN(derfile, "rb")) != XBADFILE);
|
||||||
AssertTrue(XFSEEK(f, 0, XSEEK_END) == 0);
|
AssertTrue(XFSEEK(f, 0, XSEEK_END) == 0);
|
||||||
sz = (size_t) XFTELL(f);
|
sz = (size_t) XFTELL(f);
|
||||||
XREWIND(f);
|
AssertTrue(XFSEEK(f, 0, XSEEK_SET) == 0);
|
||||||
AssertTrue(sz == sizeof_server_cert_der_2048);
|
AssertTrue(sz == sizeof_server_cert_der_2048);
|
||||||
AssertTrue((buff = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE)) != NULL) ;
|
AssertTrue((buff = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE)) != NULL) ;
|
||||||
AssertTrue(XFREAD(buff, 1, sz, f) == sz);
|
AssertTrue(XFREAD(buff, 1, sz, f) == sz);
|
||||||
@@ -34754,7 +34754,7 @@ static int test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
AssertTrue((file != XBADFILE));
|
AssertTrue((file != XBADFILE));
|
||||||
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
AssertTrue(XFSEEK(file, 0, XSEEK_SET) == 0);
|
||||||
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
||||||
if (buf) {
|
if (buf) {
|
||||||
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
||||||
@@ -34781,7 +34781,7 @@ static int test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
AssertTrue((file != XBADFILE));
|
AssertTrue((file != XBADFILE));
|
||||||
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
AssertTrue(XFSEEK(file, 0, XSEEK_SET) == 0);
|
||||||
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
||||||
if (buf)
|
if (buf)
|
||||||
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
||||||
@@ -34828,7 +34828,7 @@ static int test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
AssertTrue((file != XBADFILE));
|
AssertTrue((file != XBADFILE));
|
||||||
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
AssertTrue(XFSEEK(file, 0, XSEEK_SET) == 0);
|
||||||
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
||||||
if (buf)
|
if (buf)
|
||||||
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
||||||
@@ -34867,7 +34867,7 @@ static int test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
AssertTrue((file != XBADFILE));
|
AssertTrue((file != XBADFILE));
|
||||||
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
AssertTrue(XFSEEK(file, 0, XSEEK_SET) == 0);
|
||||||
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
||||||
if (buf)
|
if (buf)
|
||||||
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
||||||
@@ -35473,9 +35473,9 @@ static int test_wolfSSL_PEM_PUBKEY(void)
|
|||||||
|
|
||||||
file = XFOPEN(fname, "rb");
|
file = XFOPEN(fname, "rb");
|
||||||
AssertTrue((file != XBADFILE));
|
AssertTrue((file != XBADFILE));
|
||||||
AssertIntGE(XFSEEK(file, 0, XSEEK_END), 0);
|
AssertIntEQ(XFSEEK(file, 0, XSEEK_END), 0);
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
AssertIntEQ(XFSEEK(file, 0, XSEEK_SET), 0);
|
||||||
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
||||||
if (buf)
|
if (buf)
|
||||||
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
||||||
@@ -44934,7 +44934,7 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void)
|
|||||||
AssertTrue((file != XBADFILE));
|
AssertTrue((file != XBADFILE));
|
||||||
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
AssertTrue(XFSEEK(file, 0, XSEEK_SET) == 0);
|
||||||
AssertNotNull(buf = (byte*)XMALLOC(sz, HEAP_HINT, DYNAMIC_TYPE_FILE));
|
AssertNotNull(buf = (byte*)XMALLOC(sz, HEAP_HINT, DYNAMIC_TYPE_FILE));
|
||||||
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
@@ -44962,7 +44962,7 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void)
|
|||||||
AssertTrue((file != XBADFILE));
|
AssertTrue((file != XBADFILE));
|
||||||
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
AssertTrue(XFSEEK(file, 0, XSEEK_END) == 0);
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
AssertTrue(XFSEEK(file, 0, XSEEK_SET) == 0);
|
||||||
AssertNotNull(buf = (byte*)XMALLOC(sz, HEAP_HINT, DYNAMIC_TYPE_FILE));
|
AssertNotNull(buf = (byte*)XMALLOC(sz, HEAP_HINT, DYNAMIC_TYPE_FILE));
|
||||||
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
AssertIntEQ(XFREAD(buf, 1, sz, file), sz);
|
||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
@@ -50129,7 +50129,7 @@ static int test_wolfSSL_d2i_and_i2d_DSAparams(void)
|
|||||||
AssertTrue(f != XBADFILE);
|
AssertTrue(f != XBADFILE);
|
||||||
AssertTrue(XFSEEK(f, 0, XSEEK_END) == 0);
|
AssertTrue(XFSEEK(f, 0, XSEEK_END) == 0);
|
||||||
derInLen = (int)XFTELL(f);
|
derInLen = (int)XFTELL(f);
|
||||||
XREWIND(f);
|
AssertTrue(XFSEEK(f, 0, XSEEK_SET) == 0);
|
||||||
AssertNotNull(derIn = (byte*)XMALLOC(derInLen, HEAP_HINT,
|
AssertNotNull(derIn = (byte*)XMALLOC(derInLen, HEAP_HINT,
|
||||||
DYNAMIC_TYPE_TMP_BUFFER));
|
DYNAMIC_TYPE_TMP_BUFFER));
|
||||||
AssertIntEQ(XFREAD(derIn, 1, derInLen, f), derInLen);
|
AssertIntEQ(XFREAD(derIn, 1, derInLen, f), derInLen);
|
||||||
@@ -56349,9 +56349,9 @@ static int test_wolfSSL_RSA_verify(void)
|
|||||||
/* read privete key file */
|
/* read privete key file */
|
||||||
fp = XFOPEN(svrKeyFile, "rb");
|
fp = XFOPEN(svrKeyFile, "rb");
|
||||||
AssertTrue((fp != XBADFILE));
|
AssertTrue((fp != XBADFILE));
|
||||||
AssertIntGE(XFSEEK(fp, 0, XSEEK_END), 0);
|
AssertIntEQ(XFSEEK(fp, 0, XSEEK_END), 0);
|
||||||
sz = XFTELL(fp);
|
sz = XFTELL(fp);
|
||||||
XREWIND(fp);
|
AssertIntEQ(XFSEEK(fp, 0, XSEEK_SET), 0);
|
||||||
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
AssertNotNull(buf = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_FILE));
|
||||||
AssertIntEQ(XFREAD(buf, 1, sz, fp), sz);
|
AssertIntEQ(XFREAD(buf, 1, sz, fp), sz);
|
||||||
XFCLOSE(fp);
|
XFCLOSE(fp);
|
||||||
|
@@ -648,7 +648,12 @@ static void test_harness(void* vargs)
|
|||||||
args->return_code = 1;
|
args->return_code = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rewind(file);
|
if (fseek(file, 0, SEEK_SET) < 0) {
|
||||||
|
fprintf(stderr, "error %d fseeking %s\n", errno, fname);
|
||||||
|
fclose(file);
|
||||||
|
args->return_code = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
script = (char*)malloc(sz+1);
|
script = (char*)malloc(sz+1);
|
||||||
if (script == 0) {
|
if (script == 0) {
|
||||||
|
@@ -1796,19 +1796,20 @@ static void bench_stats_sym_finish(const char* desc, int useDeviceID,
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
/* normal CSV */
|
/* normal CSV */
|
||||||
|
#ifdef BENCH_DEVID
|
||||||
|
#define BENCH_DEVID_COLUMN_HEADER "HW/SW,"
|
||||||
|
#else
|
||||||
|
#define BENCH_DEVID_COLUMN_HEADER
|
||||||
|
#endif
|
||||||
#ifdef HAVE_GET_CYCLES
|
#ifdef HAVE_GET_CYCLES
|
||||||
printf("\n\nSymmetric Ciphers:\n\n");
|
printf("\n\nSymmetric Ciphers:\n\n");
|
||||||
printf("Algorithm,"
|
printf("Algorithm,"
|
||||||
#ifdef BENCH_DEVID
|
BENCH_DEVID_COLUMN_HEADER
|
||||||
"HW/SW,"
|
|
||||||
#endif
|
|
||||||
WOLFSSL_FIXED_UNITS_PER_SEC ",Cycles per byte,\n");
|
WOLFSSL_FIXED_UNITS_PER_SEC ",Cycles per byte,\n");
|
||||||
#else
|
#else
|
||||||
printf("\n\nSymmetric Ciphers:\n\n");
|
printf("\n\nSymmetric Ciphers:\n\n");
|
||||||
printf("Algorithm,"
|
printf("Algorithm,"
|
||||||
#ifdef BENCH_DEVID
|
BENCH_DEVID_COLUMN_HEADER
|
||||||
"HW/SW,"
|
|
||||||
#endif
|
|
||||||
WOLFSSL_FIXED_UNITS_PER_SEC ", \n");
|
WOLFSSL_FIXED_UNITS_PER_SEC ", \n");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@@ -23421,9 +23421,14 @@ int wc_PemCertToDer_ex(const char* fileName, DerBuffer** der)
|
|||||||
ret = BUFFER_E;
|
ret = BUFFER_E;
|
||||||
}
|
}
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if (XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
ret = BUFFER_E;
|
||||||
|
}
|
||||||
|
|
||||||
if (sz <= 0) {
|
if (ret < 0) {
|
||||||
|
/* intentionally left empty. */
|
||||||
|
}
|
||||||
|
else if (sz <= 0) {
|
||||||
ret = BUFFER_E;
|
ret = BUFFER_E;
|
||||||
}
|
}
|
||||||
else if (sz > (long)sizeof(staticBuffer)) {
|
else if (sz > (long)sizeof(staticBuffer)) {
|
||||||
@@ -23501,9 +23506,14 @@ int wc_PemPubKeyToDer_ex(const char* fileName, DerBuffer** der)
|
|||||||
if (XFSEEK(file, 0, XSEEK_END) != 0) {
|
if (XFSEEK(file, 0, XSEEK_END) != 0) {
|
||||||
ret = BUFFER_E;
|
ret = BUFFER_E;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
sz = XFTELL(file);
|
sz = XFTELL(file);
|
||||||
XREWIND(file);
|
if (XFSEEK(file, 0, XSEEK_SET) != 0) {
|
||||||
|
ret = BUFFER_E;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
if (sz <= 0) {
|
if (sz <= 0) {
|
||||||
ret = BUFFER_E;
|
ret = BUFFER_E;
|
||||||
}
|
}
|
||||||
@@ -23514,22 +23524,22 @@ int wc_PemPubKeyToDer_ex(const char* fileName, DerBuffer** der)
|
|||||||
else
|
else
|
||||||
dynamic = 1;
|
dynamic = 1;
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
}
|
||||||
if ((size_t)XFREAD(fileBuf, 1, sz, file) != (size_t)sz) {
|
if (ret == 0) {
|
||||||
ret = BUFFER_E;
|
if ((size_t)XFREAD(fileBuf, 1, sz, file) != (size_t)sz) {
|
||||||
}
|
ret = BUFFER_E;
|
||||||
else {
|
|
||||||
ret = PemToDer(fileBuf, sz, PUBLICKEY_TYPE, der,
|
|
||||||
0, NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
XFCLOSE(file);
|
ret = PemToDer(fileBuf, sz, PUBLICKEY_TYPE, der,
|
||||||
if (dynamic) {
|
0, NULL, NULL);
|
||||||
XFREE(fileBuf, NULL, DYNAMIC_TYPE_FILE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file != XBADFILE)
|
||||||
|
XFCLOSE(file);
|
||||||
|
if (dynamic)
|
||||||
|
XFREE(fileBuf, NULL, DYNAMIC_TYPE_FILE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/* load pem public key from file into der buffer, return der size or error */
|
/* load pem public key from file into der buffer, return der size or error */
|
||||||
|
@@ -512,7 +512,11 @@ int wc_FileLoad(const char* fname, unsigned char** buf, size_t* bufLen,
|
|||||||
return BAD_PATH_ERROR;
|
return BAD_PATH_ERROR;
|
||||||
}
|
}
|
||||||
fileSz = XFTELL(f);
|
fileSz = XFTELL(f);
|
||||||
XREWIND(f);
|
if (XFSEEK(f, 0, XSEEK_SET) != 0) {
|
||||||
|
WOLFSSL_MSG("wc_LoadFile file seek error");
|
||||||
|
XFCLOSE(f);
|
||||||
|
return BAD_PATH_ERROR;
|
||||||
|
}
|
||||||
if (fileSz > 0) {
|
if (fileSz > 0) {
|
||||||
*bufLen = fileSz;
|
*bufLen = fileSz;
|
||||||
*buf = (byte*)XMALLOC(*bufLen, heap, DYNAMIC_TYPE_TMP_BUFFER);
|
*buf = (byte*)XMALLOC(*bufLen, heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
@@ -2685,9 +2685,9 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
|
|||||||
return BAD_PATH_ERROR;
|
return BAD_PATH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBCALL_CHECK_RET(fseek(lFile, 0, SEEK_END));
|
LIBCALL_CHECK_RET(XFSEEK(lFile, 0, XSEEK_END));
|
||||||
fileSz = (int)ftell(lFile);
|
fileSz = (int)ftell(lFile);
|
||||||
rewind(lFile);
|
LIBCALL_CHECK_RET(XFSEEK(lFile, 0, XSEEK_SET));
|
||||||
if (fileSz > 0) {
|
if (fileSz > 0) {
|
||||||
*bufLen = (size_t)fileSz;
|
*bufLen = (size_t)fileSz;
|
||||||
*buf = (byte*)malloc(*bufLen);
|
*buf = (byte*)malloc(*bufLen);
|
||||||
|
@@ -427,10 +427,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN(NAME, MODE) vf_open((const char *)NAME, VO_RDONLY, 0)
|
#define XFOPEN(NAME, MODE) vf_open((const char *)NAME, VO_RDONLY, 0)
|
||||||
#define XFSEEK ebsnet_fseek
|
#define XFSEEK ebsnet_fseek
|
||||||
#define XFTELL vf_tell
|
#define XFTELL vf_tell
|
||||||
#define XREWIND vf_rewind
|
|
||||||
#define XFREAD(BUF, SZ, AMT, FD) vf_read(FD, BUF, SZ*AMT)
|
#define XFREAD(BUF, SZ, AMT, FD) vf_read(FD, BUF, SZ*AMT)
|
||||||
#define XFWRITE(BUF, SZ, AMT, FD) vf_write(FD, BUF, SZ*AMT)
|
#define XFWRITE(BUF, SZ, AMT, FD) vf_write(FD, BUF, SZ*AMT)
|
||||||
#define XFCLOSE vf_close
|
#define XFCLOSE vf_close
|
||||||
|
#define XSEEK_SET VSEEK_SET
|
||||||
#define XSEEK_END VSEEK_END
|
#define XSEEK_END VSEEK_END
|
||||||
#define XBADFILE -1
|
#define XBADFILE -1
|
||||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||||
@@ -441,10 +441,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN(NAME, MODE) fs_open((char*)NAME)
|
#define XFOPEN(NAME, MODE) fs_open((char*)NAME)
|
||||||
#define XFSEEK(F, O, W) (void)F
|
#define XFSEEK(F, O, W) (void)F
|
||||||
#define XFTELL(F) (F)->len
|
#define XFTELL(F) (F)->len
|
||||||
#define XREWIND(F) (void)F
|
|
||||||
#define XFREAD(BUF, SZ, AMT, F) fs_read(F, (char*)BUF, SZ*AMT)
|
#define XFREAD(BUF, SZ, AMT, F) fs_read(F, (char*)BUF, SZ*AMT)
|
||||||
#define XFWRITE(BUF, SZ, AMT, F) fs_write(F, (char*)BUF, SZ*AMT)
|
#define XFWRITE(BUF, SZ, AMT, F) fs_write(F, (char*)BUF, SZ*AMT)
|
||||||
#define XFCLOSE fs_close
|
#define XFCLOSE fs_close
|
||||||
|
#define XSEEK_SET 0
|
||||||
#define XSEEK_END 0
|
#define XSEEK_END 0
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||||
@@ -454,10 +454,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN fopen
|
#define XFOPEN fopen
|
||||||
#define XFSEEK fseek
|
#define XFSEEK fseek
|
||||||
#define XFTELL ftell
|
#define XFTELL ftell
|
||||||
#define XREWIND(F) fseek(F, 0, IO_SEEK_SET)
|
|
||||||
#define XFREAD fread
|
#define XFREAD fread
|
||||||
#define XFWRITE fwrite
|
#define XFWRITE fwrite
|
||||||
#define XFCLOSE fclose
|
#define XFCLOSE fclose
|
||||||
|
#define XSEEK_SET IO_SEEK_SET
|
||||||
#define XSEEK_END IO_SEEK_END
|
#define XSEEK_END IO_SEEK_END
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS fgets
|
#define XFGETS fgets
|
||||||
@@ -471,10 +471,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN fs_fopen
|
#define XFOPEN fs_fopen
|
||||||
#define XFSEEK fs_fseek
|
#define XFSEEK fs_fseek
|
||||||
#define XFTELL fs_ftell
|
#define XFTELL fs_ftell
|
||||||
#define XREWIND fs_rewind
|
|
||||||
#define XFREAD fs_fread
|
#define XFREAD fs_fread
|
||||||
#define XFWRITE fs_fwrite
|
#define XFWRITE fs_fwrite
|
||||||
#define XFCLOSE fs_fclose
|
#define XFCLOSE fs_fclose
|
||||||
|
#define XSEEK_SET FS_SEEK_SET
|
||||||
#define XSEEK_END FS_SEEK_END
|
#define XSEEK_END FS_SEEK_END
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||||
@@ -485,10 +485,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN fopen
|
#define XFOPEN fopen
|
||||||
#define XFSEEK fseek
|
#define XFSEEK fseek
|
||||||
#define XFTELL ftell
|
#define XFTELL ftell
|
||||||
#define XREWIND rewind
|
|
||||||
#define XFREAD fread
|
#define XFREAD fread
|
||||||
#define XFWRITE fwrite
|
#define XFWRITE fwrite
|
||||||
#define XFCLOSE fclose
|
#define XFCLOSE fclose
|
||||||
|
#define XSEEK_SET PSEEK_SET
|
||||||
#define XSEEK_END PSEEK_END
|
#define XSEEK_END PSEEK_END
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
|
|
||||||
@@ -499,10 +499,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN mynewt_fopen
|
#define XFOPEN mynewt_fopen
|
||||||
#define XFSEEK mynewt_fseek
|
#define XFSEEK mynewt_fseek
|
||||||
#define XFTELL mynewt_ftell
|
#define XFTELL mynewt_ftell
|
||||||
#define XREWIND mynewt_rewind
|
|
||||||
#define XFREAD mynewt_fread
|
#define XFREAD mynewt_fread
|
||||||
#define XFWRITE mynewt_fwrite
|
#define XFWRITE mynewt_fwrite
|
||||||
#define XFCLOSE mynewt_fclose
|
#define XFCLOSE mynewt_fclose
|
||||||
|
#define XSEEK_SET 0
|
||||||
#define XSEEK_END 2
|
#define XSEEK_END 2
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||||
@@ -521,9 +521,9 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFSEEK fs_seek
|
#define XFSEEK fs_seek
|
||||||
#define XFTELL fs_tell
|
#define XFTELL fs_tell
|
||||||
#define XFREWIND fs_rewind
|
#define XFREWIND fs_rewind
|
||||||
#define XREWIND(F) fs_seek(F, 0, FS_SEEK_SET)
|
|
||||||
#define XFREAD(P,S,N,F) fs_read(F, P, S*N)
|
#define XFREAD(P,S,N,F) fs_read(F, P, S*N)
|
||||||
#define XFWRITE(P,S,N,F) fs_write(F, P, S*N)
|
#define XFWRITE(P,S,N,F) fs_write(F, P, S*N)
|
||||||
|
#define XSEEK_SET FS_SEEK_SET
|
||||||
#define XSEEK_END FS_SEEK_END
|
#define XSEEK_END FS_SEEK_END
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||||
@@ -533,10 +533,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN(NAME, MODE) m2mb_fs_open((NAME), 0, (MODE))
|
#define XFOPEN(NAME, MODE) m2mb_fs_open((NAME), 0, (MODE))
|
||||||
#define XFSEEK(F, O, W) m2mb_fs_lseek((F), (O), (W))
|
#define XFSEEK(F, O, W) m2mb_fs_lseek((F), (O), (W))
|
||||||
#define XFTELL(F) m2mb_fs_lseek((F), 0, M2MB_SEEK_END)
|
#define XFTELL(F) m2mb_fs_lseek((F), 0, M2MB_SEEK_END)
|
||||||
#define XREWIND(F) (void)F
|
|
||||||
#define XFREAD(BUF, SZ, AMT, F) m2mb_fs_read((F), (BUF), (SZ)*(AMT))
|
#define XFREAD(BUF, SZ, AMT, F) m2mb_fs_read((F), (BUF), (SZ)*(AMT))
|
||||||
#define XFWRITE(BUF, SZ, AMT, F) m2mb_fs_write((F), (BUF), (SZ)*(AMT))
|
#define XFWRITE(BUF, SZ, AMT, F) m2mb_fs_write((F), (BUF), (SZ)*(AMT))
|
||||||
#define XFCLOSE m2mb_fs_close
|
#define XFCLOSE m2mb_fs_close
|
||||||
|
#define XSEEK_SET M2MB_SEEK_SET
|
||||||
#define XSEEK_END M2MB_SEEK_END
|
#define XSEEK_END M2MB_SEEK_END
|
||||||
#define XBADFILE -1
|
#define XBADFILE -1
|
||||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||||
@@ -550,10 +550,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN(NAME, MODE) ({ FRESULT res; res = f_open(&curFile, (NAME), (FA_OPEN_ALWAYS | FA_WRITE | FA_READ)); (res == FR_OK) ? &curFile : NULL; })
|
#define XFOPEN(NAME, MODE) ({ FRESULT res; res = f_open(&curFile, (NAME), (FA_OPEN_ALWAYS | FA_WRITE | FA_READ)); (res == FR_OK) ? &curFile : NULL; })
|
||||||
#define XFSEEK(F, O, W) f_lseek((F), (O))
|
#define XFSEEK(F, O, W) f_lseek((F), (O))
|
||||||
#define XFTELL(F) f_tell((F))
|
#define XFTELL(F) f_tell((F))
|
||||||
#define XREWIND(F) f_rewind((F))
|
|
||||||
#define XFREAD(BUF, SZ, AMT, F) ({ FRESULT res; UINT br; res = f_read((F), (BUF), (SZ)*(AMT), &br); (void)br; res; })
|
#define XFREAD(BUF, SZ, AMT, F) ({ FRESULT res; UINT br; res = f_read((F), (BUF), (SZ)*(AMT), &br); (void)br; res; })
|
||||||
#define XFWRITE(BUF, SZ, AMT, F) ({ FRESULT res; UINT written; res = f_write((F), (BUF), (SZ)*(AMT), &written); (void)written; res; })
|
#define XFWRITE(BUF, SZ, AMT, F) ({ FRESULT res; UINT written; res = f_write((F), (BUF), (SZ)*(AMT), &written); (void)written; res; })
|
||||||
#define XFCLOSE(F) f_close((F))
|
#define XFCLOSE(F) f_close((F))
|
||||||
|
#define XSEEK_SET 0
|
||||||
#define XSEEK_END 0
|
#define XSEEK_END 0
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS(b,s,f) f_gets((b), (s), (f))
|
#define XFGETS(b,s,f) f_gets((b), (s), (f))
|
||||||
@@ -565,10 +565,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFDOPEN fdopen
|
#define XFDOPEN fdopen
|
||||||
#define XFSEEK fseek
|
#define XFSEEK fseek
|
||||||
#define XFTELL ftell
|
#define XFTELL ftell
|
||||||
#define XREWIND(F) XFSEEK(F, 0, SEEK_SET)
|
|
||||||
#define XFREAD fread
|
#define XFREAD fread
|
||||||
#define XFWRITE fwrite
|
#define XFWRITE fwrite
|
||||||
#define XFCLOSE fclose
|
#define XFCLOSE fclose
|
||||||
|
#define XSEEK_END SEEK_SET
|
||||||
#define XSEEK_END SEEK_END
|
#define XSEEK_END SEEK_END
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS fgets
|
#define XFGETS fgets
|
||||||
@@ -585,10 +585,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFOPEN FCL_FOPEN
|
#define XFOPEN FCL_FOPEN
|
||||||
#define XFSEEK FCL_FSEEK
|
#define XFSEEK FCL_FSEEK
|
||||||
#define XFTELL FCL_FTELL
|
#define XFTELL FCL_FTELL
|
||||||
#define XREWIND FCL_REWIND
|
|
||||||
#define XFREAD FCL_FREAD
|
#define XFREAD FCL_FREAD
|
||||||
#define XFWRITE FCL_FWRITE
|
#define XFWRITE FCL_FWRITE
|
||||||
#define XFCLOSE FCL_FCLOSE
|
#define XFCLOSE FCL_FCLOSE
|
||||||
|
#define XSEEK_SET SEEK_SET
|
||||||
#define XSEEK_END SEEK_END
|
#define XSEEK_END SEEK_END
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS FCL_FGETS
|
#define XFGETS FCL_FGETS
|
||||||
@@ -624,10 +624,10 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#define XFDOPEN fdopen
|
#define XFDOPEN fdopen
|
||||||
#define XFSEEK fseek
|
#define XFSEEK fseek
|
||||||
#define XFTELL ftell
|
#define XFTELL ftell
|
||||||
#define XREWIND rewind
|
|
||||||
#define XFREAD fread
|
#define XFREAD fread
|
||||||
#define XFWRITE fwrite
|
#define XFWRITE fwrite
|
||||||
#define XFCLOSE fclose
|
#define XFCLOSE fclose
|
||||||
|
#define XSEEK_SET SEEK_SET
|
||||||
#define XSEEK_END SEEK_END
|
#define XSEEK_END SEEK_END
|
||||||
#define XBADFILE NULL
|
#define XBADFILE NULL
|
||||||
#define XFGETS fgets
|
#define XFGETS fgets
|
||||||
|
Reference in New Issue
Block a user