Skip to content

Commit 7338ec1

Browse files
author
Andres Amaya Garcia
committed
benchmark: Dont return error on feature unavailable
1 parent 764885a commit 7338ec1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

benchmark/main.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ MBED_NOINLINE static int benchmark_md4()
260260

261261
BENCHMARK_FUNC_CALL("MD4", mbedtls_md4_ret(buf, BUFSIZE, tmp));
262262

263+
ret = 0;
264+
263265
exit:
264266

265267
return ret;
@@ -273,6 +275,8 @@ MBED_NOINLINE static int benchmark_md5()
273275

274276
BENCHMARK_FUNC_CALL("MD5", mbedtls_md5_ret(buf, BUFSIZE, tmp));
275277

278+
ret = 0;
279+
276280
exit:
277281

278282
return ret;
@@ -286,6 +290,8 @@ MBED_NOINLINE static int benchmark_ripemd160()
286290

287291
BENCHMARK_FUNC_CALL("RIPEMD160", mbedtls_ripemd160_ret(buf, BUFSIZE, tmp));
288292

293+
ret = 0;
294+
289295
exit:
290296

291297
return ret;
@@ -299,6 +305,8 @@ MBED_NOINLINE static int benchmark_sha1()
299305

300306
BENCHMARK_FUNC_CALL("SHA-1", mbedtls_sha1_ret(buf, BUFSIZE, tmp));
301307

308+
ret = 0;
309+
302310
exit:
303311

304312
return ret;
@@ -312,6 +320,8 @@ MBED_NOINLINE static int benchmark_sha256()
312320

313321
BENCHMARK_FUNC_CALL("SHA-256", mbedtls_sha256_ret(buf, BUFSIZE, tmp, 0));
314322

323+
ret = 0;
324+
315325
exit:
316326

317327
return ret;
@@ -325,6 +335,8 @@ MBED_NOINLINE static int benchmark_sha512()
325335

326336
BENCHMARK_FUNC_CALL("SHA-512", mbedtls_sha512_ret(buf, BUFSIZE, tmp, 0));
327337

338+
ret = 0;
339+
328340
exit:
329341

330342
return ret;
@@ -344,6 +356,8 @@ MBED_NOINLINE static int benchmark_arc4()
344356
BENCHMARK_FUNC_CALL("ARC4",
345357
mbedtls_arc4_crypt(&arc4, BUFSIZE, buf, buf));
346358

359+
ret = 0;
360+
347361
exit:
348362
mbedtls_arc4_free(&arc4);
349363

@@ -367,6 +381,8 @@ MBED_NOINLINE static int benchmark_des3()
367381
mbedtls_des3_crypt_cbc(&des3, MBEDTLS_DES_ENCRYPT,
368382
BUFSIZE, tmp, buf, buf));
369383

384+
ret = 0;
385+
370386
exit:
371387
mbedtls_des3_free(&des3);
372388

@@ -390,6 +406,8 @@ MBED_NOINLINE static int benchmark_des()
390406
mbedtls_des_crypt_cbc(&des, MBEDTLS_DES_ENCRYPT,
391407
BUFSIZE, tmp, buf, buf));
392408

409+
ret = 0;
410+
393411
exit:
394412
mbedtls_des_free(&des);
395413

@@ -418,6 +436,8 @@ MBED_NOINLINE static int benchmark_des3_cmac()
418436
mbedtls_cipher_cmac(cipher_info, tmp, 192, buf,
419437
BUFSIZE, output));
420438

439+
ret = 0;
440+
421441
exit:
422442
return ret;
423443
}
@@ -459,6 +479,8 @@ MBED_NOINLINE static int benchmark_aes_cbc()
459479
tmp, buf, buf));
460480
}
461481

482+
ret = 0;
483+
462484
exit:
463485
mbedtls_aes_free(&aes);
464486

@@ -504,6 +526,8 @@ MBED_NOINLINE static int benchmark_aes_ctr()
504526
buf));
505527
}
506528

529+
ret = 0;
530+
507531
exit:
508532
mbedtls_aes_free(&aes);
509533

@@ -548,6 +572,8 @@ MBED_NOINLINE static int benchmark_aes_gcm()
548572
0, buf, buf, 16, tmp));
549573
}
550574

575+
ret = 0;
576+
551577
exit:
552578
mbedtls_gcm_free(&gcm);
553579

@@ -591,6 +617,8 @@ MBED_NOINLINE static int benchmark_aes_ccm()
591617
16));
592618
}
593619

620+
ret = 0;
621+
594622
exit:
595623
mbedtls_ccm_free(&ccm);
596624

@@ -638,6 +666,8 @@ MBED_NOINLINE static int benchmark_aes_cmac()
638666
mbedtls_aes_cmac_prf_128(tmp, 16, buf, BUFSIZE,
639667
output));
640668

669+
ret = 0;
670+
641671
exit:
642672

643673
return ret;
@@ -677,6 +707,8 @@ MBED_NOINLINE static int benchmark_camellia()
677707
BUFSIZE, tmp, buf, buf));
678708
}
679709

710+
ret = 0;
711+
680712
exit:
681713
mbedtls_camellia_free(&camellia);
682714

@@ -723,6 +755,8 @@ MBED_NOINLINE static int benchmark_blowfish()
723755
tmp, buf, buf));
724756
}
725757

758+
ret = 0;
759+
726760
exit:
727761
mbedtls_blowfish_free(blowfish);
728762
mbedtls_free(blowfish);
@@ -741,6 +775,8 @@ MBED_NOINLINE static int benchmark_havege()
741775

742776
BENCHMARK_FUNC_CALL("HAVEGE", mbedtls_havege_random(&hs, buf, BUFSIZE));
743777

778+
ret = 0;
779+
744780
exit:
745781
mbedtls_havege_free(&hs);
746782

@@ -783,6 +819,8 @@ MBED_NOINLINE static int benchmark_ctr_drbg()
783819
BENCHMARK_FUNC_CALL(pr_title,
784820
mbedtls_ctr_drbg_random(&ctr_drbg, buf, BUFSIZE));
785821

822+
ret = 0;
823+
786824
exit:
787825
mbedtls_ctr_drbg_free(&ctr_drbg);
788826

@@ -852,6 +890,8 @@ MBED_NOINLINE static int benchmark_hmac_drbg()
852890
mbedtls_hmac_drbg_random(&hmac_drbg, buf, BUFSIZE));
853891
#endif /* MBEDTLS_SHA256_C */
854892

893+
ret = 0;
894+
855895
exit:
856896
mbedtls_hmac_drbg_free(&hmac_drbg);
857897

0 commit comments

Comments
 (0)