Guest User

Untitled

a guest
Nov 5th, 2016
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. #define DEBUG_LEVEL 0
  2.  
  3. #include "mbed.h"
  4. #include "NetworkStack.h"
  5. #include "EthernetInterface.h"
  6. #include "TCPSocket.h"
  7. #include <string>
  8. #include "mbedtls/platform.h"
  9. #include "mbedtls/ssl.h"
  10. #include "mbedtls/entropy.h"
  11. #include "mbedtls/ctr_drbg.h"
  12. #include "mbedtls/net_sockets.h"
  13. #include "mbedtls/error.h"
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #if DEBUG_LEVEL > 0
  17. #include "mbedtls/debug.h"
  18. #endif
  19. #if defined(MBEDTLS_SSL_CACHE_C)
  20. #include "mbedtls/ssl_cache.h"
  21. #endif
  22. #if !defined(MBEDTLS_CONFIG_FILE)
  23. #include "mbedtls/config.h"
  24. #else
  25. #include MBEDTLS_CONFIG_FILE
  26. #endif
  27. #define mbedtls_time       time
  28. #define mbedtls_time_t     time_t
  29. #define mbedtls_fprintf    fprintf
  30. #define mbedtls_printf printf
  31.  
  32. #define RESPONSE "WINWINWIN"
  33.  
  34.  
  35.  
  36. static void my_debug( void *ctx, int level,
  37.                       const char *file, int line,
  38.                       const char *str )
  39. {
  40.     ((void) level);
  41.  
  42.     mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
  43.     fflush(  (FILE *) ctx  );
  44. }
  45.  
  46. void server_func(void)
  47. {
  48.     int ret, len;
  49.     mbedtls_net_context listen_fd, client_fd;
  50.     unsigned char buf[1024];
  51.     const char *pers = "ssl_server";
  52.  
  53.     mbedtls_entropy_context entropy;
  54.     mbedtls_ctr_drbg_context ctr_drbg;
  55.     mbedtls_ssl_context ssl;
  56.     mbedtls_ssl_config conf;
  57.     mbedtls_x509_crt srvcert;
  58.     mbedtls_pk_context pkey;
  59. #if defined(MBEDTLS_SSL_CACHE_C)
  60.     mbedtls_ssl_cache_context cache;
  61. #endif
  62.     mbedtls_net_init( &listen_fd );
  63.     mbedtls_net_init( &client_fd );
  64.     mbedtls_ssl_init( &ssl );
  65.     mbedtls_ssl_config_init( &conf );
  66. #if defined(MBEDTLS_SSL_CACHE_C)
  67.     mbedtls_ssl_cache_init( &cache );
  68. #endif
  69.     mbedtls_x509_crt_init( &srvcert );
  70.     mbedtls_pk_init( &pkey );
  71.     mbedtls_entropy_init( &entropy );
  72.     mbedtls_ctr_drbg_init( &ctr_drbg );
  73.    
  74.    
  75.  
  76.    
  77. }
Advertisement
Add Comment
Please, Sign In to add comment