benchmark_main.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* benchmark_main.c
  2. *
  3. * Copyright (C) 2006-2014 wolfSSL Inc.
  4. *
  5. * This file is part of CyaSSL.
  6. *
  7. * CyaSSL 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. * CyaSSL 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-1301, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <cyassl/ctaocrypt/settings.h>
  25. #if defined(CYASSL_MICROCHIP_PIC32MZ)
  26. #define MICROCHIP_PIC32
  27. #include <xc.h>
  28. #include "MZ-configBits.h"
  29. #include "PIC32MZ-serial.h"
  30. #define SYSTEMConfigPerformance /* void out SYSTEMConfigPerformance(); */
  31. #else
  32. #define PIC32_STARTER_KIT
  33. #include <p32xxxx.h>
  34. #include <plib.h>
  35. #include <sys/appio.h>
  36. #define init_serial() /* void out init_serial() ; */
  37. #endif
  38. void bench_des(void);
  39. void bench_arc4(void);
  40. void bench_hc128(void);
  41. void bench_rabbit(void);
  42. void bench_aes(int);
  43. void bench_aesgcm(void);
  44. void bench_md5(void);
  45. void bench_sha(void);
  46. void bench_sha256(void);
  47. void bench_sha512(void);
  48. void bench_ripemd(void);
  49. void bench_rsa(void);
  50. void bench_rsaKeyGen(void);
  51. void bench_dh(void);
  52. #ifdef HAVE_ECC
  53. void bench_eccKeyGen(void);
  54. void bench_eccKeyAgree(void);
  55. #endif
  56. /*
  57. * Main driver for CTaoCrypt benchmarks.
  58. */
  59. int main(int argc, char** argv) {
  60. volatile int i ;
  61. int j ;
  62. PRECONbits.PFMWS = 2;
  63. PRECONbits.PREFEN = 0b11;
  64. init_serial() ; /* initialize PIC32MZ serial I/O */
  65. SYSTEMConfigPerformance(80000000);
  66. DBINIT();
  67. for(j=0; j<100; j++) {
  68. for(i=0; i<10000000; i++);
  69. printf("time=%f\n", current_time(0)) ;
  70. }
  71. printf("wolfCrypt Benchmark:\n");
  72. #ifndef NO_AES
  73. bench_aes(0);
  74. bench_aes(1);
  75. #endif
  76. #ifdef HAVE_AESGCM
  77. bench_aesgcm();
  78. #endif
  79. #ifndef NO_RC4
  80. bench_arc4();
  81. #endif
  82. #ifdef HAVE_HC128
  83. bench_hc128();
  84. #endif
  85. #ifndef NO_RABBIT
  86. bench_rabbit();
  87. #endif
  88. #ifndef NO_DES3
  89. bench_des();
  90. #endif
  91. printf("\n");
  92. #ifndef NO_MD5
  93. bench_md5();
  94. #endif
  95. bench_sha();
  96. #ifndef NO_SHA256
  97. bench_sha256();
  98. #endif
  99. #ifdef CYASSL_SHA512
  100. bench_sha512();
  101. #endif
  102. #ifdef CYASSL_RIPEMD
  103. bench_ripemd();
  104. #endif
  105. printf("\n");
  106. #ifndef NO_RSA
  107. bench_rsa();
  108. #endif
  109. #ifndef NO_DH
  110. bench_dh();
  111. #endif
  112. #if defined(CYASSL_KEY_GEN) && !defined(NO_RSA)
  113. bench_rsaKeyGen();
  114. #endif
  115. #ifdef HAVE_ECC
  116. bench_eccKeyGen();
  117. bench_eccKeyAgree();
  118. #endif
  119. printf("End of wolfCrypt Benchmark:\n");
  120. return 0;
  121. }