tls_mbedtls.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "iec_include.h"
  2. struct sTLSConfiguration {
  3. mbedtls_entropy_context entropy;
  4. mbedtls_ctr_drbg_context ctr_drbg;
  5. mbedtls_x509_crt ownCertificate;
  6. mbedtls_pk_context ownKey;
  7. mbedtls_x509_crt cacerts;
  8. mbedtls_x509_crl crl;
  9. mbedtls_ssl_config conf;
  10. LinkedList /* <mbedtls_x509_crt*> */ allowedCertificates;
  11. /* session cache for server */
  12. mbedtls_ssl_cache_context cache;
  13. /* client side cached session */
  14. mbedtls_ssl_session* savedSession;
  15. uint64_t savedSessionTime;
  16. bool chainValidation;
  17. bool allowOnlyKnownCertificates;
  18. /* TLS session renegotiation interval in milliseconds */
  19. int renegotiationTimeInMs;
  20. /* TLS minimum version allowed (default: TLS_VERSION_TLS_1_0) */
  21. TLSConfigVersion minVersion;
  22. /* TLS minimum version allowed (default: TLS_VERSION_TLS_1_2) */
  23. TLSConfigVersion maxVersion;
  24. TLSConfiguration_EventHandler eventHandler;
  25. void* eventHandlerParameter;
  26. /* time of the last CRL update */
  27. uint64_t crlUpdated;
  28. bool setupComplete;
  29. bool useSessionResumption;
  30. int sessionResumptionInterval; /* session resumption interval in seconds */
  31. };
  32. struct sTLSSocket {
  33. mbedtls_ssl_context ssl;
  34. Socket socket;
  35. mbedtls_ssl_config conf;
  36. TLSConfiguration tlsConfig;
  37. bool storePeerCert;
  38. uint8_t* peerCert;
  39. int peerCertLength;
  40. /* time of last session renegotiation (used to calculate next renegotiation time) */
  41. uint64_t lastRenegotiationTime;
  42. /* time of the last CRL update */
  43. uint64_t crlUpdated;
  44. };