benchmark_main.c 2.9 KB

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