benchmark_main.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* benchmark_main.c
  2. *
  3. * Copyright (C) 2006-2024 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <wolfssl/wolfcrypt/settings.h>
  25. #include <wolfssl/wolfcrypt/wc_port.h>
  26. #include <wolfcrypt/benchmark/benchmark.h>
  27. #include <stdio.h>
  28. #include "hw.h" /* Needed for 'delay_us' prototype */
  29. typedef struct func_args {
  30. int argc;
  31. char** argv;
  32. int return_code;
  33. } func_args;
  34. static func_args args = { 0 } ;
  35. extern double current_time(int reset);
  36. void main(void)
  37. {
  38. int test_num = 0;
  39. wolfCrypt_Init(); /* required for ksdk_port_init */
  40. do
  41. {
  42. /* Used for testing, must have a delay so no data is missed while serial is initializing */
  43. #ifdef WOLFSSL_FRDM_K64_JENKINS
  44. /* run once */
  45. if(test_num == 1){
  46. printf("\n&&&&&&&&&&&&& done &&&&&&&&&&&&&&&");
  47. delay_us(1000000);
  48. break;
  49. }
  50. delay_us(1000000); /* 1 second */
  51. #endif
  52. printf("\nBenchmark Test %d:\n", test_num);
  53. benchmark_test(&args);
  54. printf("Benchmark Test %d: Return code %d\n", test_num, args.return_code);
  55. test_num++;
  56. } while(args.return_code == 0);
  57. /*Print this again for redundancy*/
  58. #ifdef WOLFSSL_FRDM_K64_JENKINS
  59. printf("\n&&&&&&&&&&&&&& done &&&&&&&&&&&&&\n");
  60. delay_us(1000000);
  61. #endif
  62. wolfCrypt_Cleanup();
  63. }
  64. /*
  65. SAMPLE OUTPUT: Freescale K64 running at 96MHz with no MMCAU:
  66. Benchmark Test 0:
  67. AES 25 kB took 0.073 seconds, 0.334 MB/s
  68. ARC4 25 kB took 0.033 seconds, 0.740 MB/s
  69. RABBIT 25 kB took 0.027 seconds, 0.904 MB/s
  70. 3DES 25 kB took 0.375 seconds, 0.065 MB/s
  71. MD5 25 kB took 0.016 seconds, 1.526 MB/s
  72. SHA 25 kB took 0.044 seconds, 0.555 MB/s
  73. SHA-256 25 kB took 0.119 seconds, 0.205 MB/s
  74. RSA 1024 encryption took 91.000 milliseconds, avg over 1 iterations
  75. RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
  76. DH 1024 key generation 253.000 milliseconds, avg over 1 iterations
  77. DH 1024 key agreement 311.000 milliseconds, avg over 1 iterations
  78. Benchmark Test 0: Return code 0
  79. SAMPLE OUTPUT: Freescale K64 running at 96MHz with MMCAU enabled:
  80. Benchmark Test 0:
  81. AES 25 kB took 0.019 seconds, 1.285 MB/s
  82. ARC4 25 kB took 0.033 seconds, 0.740 MB/s
  83. RABBIT 25 kB took 0.028 seconds, 0.872 MB/s
  84. 3DES 25 kB took 0.026 seconds, 0.939 MB/s
  85. MD5 25 kB took 0.005 seconds, 4.883 MB/s
  86. SHA 25 kB took 0.008 seconds, 3.052 MB/s
  87. SHA-256 25 kB took 0.013 seconds, 1.878 MB/s
  88. RSA 1024 encryption took 89.000 milliseconds, avg over 1 iterations
  89. RSA 1024 decryption took 573.000 milliseconds, avg over 1 iterations
  90. DH 1024 key generation 250.000 milliseconds, avg over 1 iterations
  91. DH 1024 key agreement 308.000 milliseconds, avg over 1 iterations
  92. Benchmark Test 0: Return code 0
  93. SAMPLE OUTPUT: NXP K82 running at 150Mhz w/MMCAU and LTC
  94. Benchmark Test 0:
  95. RNG 25 kB took 0.026 seconds, 0.939 MB/s
  96. AES enc 25 kB took 0.002 seconds, 12.207 MB/s
  97. AES dec 25 kB took 0.002 seconds, 12.207 MB/s
  98. AES-GCM 25 kB took 0.002 seconds, 12.207 MB/s
  99. AES-CTR 25 kB took 0.003 seconds, 8.138 MB/s
  100. AES-CCM 25 kB took 0.004 seconds, 6.104 MB/s
  101. CHACHA 25 kB took 0.008 seconds, 3.052 MB/s
  102. CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
  103. POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
  104. SHA 25 kB took 0.006 seconds, 4.069 MB/s
  105. SHA-256 25 kB took 0.009 seconds, 2.713 MB/s
  106. SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
  107. SHA-512 25 kB took 0.035 seconds, 0.698 MB/s
  108. RSA 2048 public 12.000 milliseconds, avg over 1 iterations
  109. RSA 2048 private 135.000 milliseconds, avg over 1 iterations
  110. ECC 256 key generation 17.400 milliseconds, avg over 5 iterations
  111. EC-DHE key agreement 15.200 milliseconds, avg over 5 iterations
  112. EC-DSA sign time 20.200 milliseconds, avg over 5 iterations
  113. EC-DSA verify time 33.000 milliseconds, avg over 5 iterations
  114. CURVE25519 256 key generation 14.400 milliseconds, avg over 5 iterations
  115. CURVE25519 key agreement 14.400 milliseconds, avg over 5 iterations
  116. ED25519 key generation 14.800 milliseconds, avg over 5 iterations
  117. ED25519 sign time 16.800 milliseconds, avg over 5 iterations
  118. ED25519 verify time 30.400 milliseconds, avg over 5 iterations
  119. Benchmark Test 0: Return code 0
  120. SAMPLE OUTPUT: NXP K82 running at 150Mhz software only
  121. Benchmark Test 0:
  122. RNG 25 kB took 0.035 seconds, 0.698 MB/s
  123. AES enc 25 kB took 0.038 seconds, 0.642 MB/s
  124. AES dec 25 kB took 0.036 seconds, 0.678 MB/s
  125. AES-GCM 25 kB took 0.485 seconds, 0.050 MB/s
  126. AES-CTR 25 kB took 0.038 seconds, 0.642 MB/s
  127. AES-CCM 25 kB took 0.077 seconds, 0.317 MB/s
  128. CHACHA 25 kB took 0.009 seconds, 2.713 MB/s
  129. CHA-POLY 25 kB took 0.013 seconds, 1.878 MB/s
  130. POLY1305 25 kB took 0.003 seconds, 8.138 MB/s
  131. SHA 25 kB took 0.006 seconds, 4.069 MB/s
  132. SHA-256 25 kB took 0.014 seconds, 1.744 MB/s
  133. SHA-384 25 kB took 0.032 seconds, 0.763 MB/s
  134. SHA-512 25 kB took 0.034 seconds, 0.718 MB/s
  135. RSA 1024 encryption took 18.000 milliseconds, avg over 1 iterations
  136. RSA 1024 decryption took 123.000 milliseconds, avg over 1 iterations
  137. RSA 2048 encryption took 63.000 milliseconds, avg over 1 iterations
  138. RSA 2048 decryption took 1011.000 milliseconds, avg over 1 iterations
  139. ECC 256 key generation 180.800 milliseconds, avg over 5 iterations
  140. EC-DHE key agreement 178.600 milliseconds, avg over 5 iterations
  141. EC-DSA sign time 184.600 milliseconds, avg over 5 iterations
  142. EC-DSA verify time 130.200 milliseconds, avg over 5 iterations
  143. CURVE25519 256 key generation 41.800 milliseconds, avg over 5 iterations
  144. CURVE25519 key agreement 41.600 milliseconds, avg over 5 iterations
  145. ED25519 key generation 14.800 milliseconds, avg over 5 iterations
  146. ED25519 sign time 16.600 milliseconds, avg over 5 iterations
  147. ED25519 verify time 48.000 milliseconds, avg over 5 iterations
  148. Benchmark Test 0: Return code 0
  149. */