ssl_code.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _SSL_CODE_H_
  14. #define _SSL_CODE_H_
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "ssl3.h"
  19. #include "tls1.h"
  20. #include "x509_vfy.h"
  21. /* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
  22. # define SSL_SENT_SHUTDOWN 1
  23. # define SSL_RECEIVED_SHUTDOWN 2
  24. # define SSL_VERIFY_NONE 0x00
  25. # define SSL_VERIFY_PEER 0x01
  26. # define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
  27. # define SSL_VERIFY_CLIENT_ONCE 0x04
  28. /*
  29. * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you
  30. * should not need these
  31. */
  32. # define SSL_ST_READ_HEADER 0xF0
  33. # define SSL_ST_READ_BODY 0xF1
  34. # define SSL_ST_READ_DONE 0xF2
  35. # define SSL_NOTHING 1
  36. # define SSL_WRITING 2
  37. # define SSL_READING 3
  38. # define SSL_X509_LOOKUP 4
  39. # define SSL_ASYNC_PAUSED 5
  40. # define SSL_ASYNC_NO_JOBS 6
  41. # define SSL_ERROR_NONE 0
  42. # define SSL_ERROR_SSL 1
  43. # define SSL_ERROR_WANT_READ 2
  44. # define SSL_ERROR_WANT_WRITE 3
  45. # define SSL_ERROR_WANT_X509_LOOKUP 4
  46. # define SSL_ERROR_SYSCALL 5/* look at error stack/return value/errno */
  47. # define SSL_ERROR_ZERO_RETURN 6
  48. # define SSL_ERROR_WANT_CONNECT 7
  49. # define SSL_ERROR_WANT_ACCEPT 8
  50. # define SSL_ERROR_WANT_ASYNC 9
  51. # define SSL_ERROR_WANT_ASYNC_JOB 10
  52. /* Message flow states */
  53. typedef enum {
  54. /* No handshake in progress */
  55. MSG_FLOW_UNINITED,
  56. /* A permanent error with this connection */
  57. MSG_FLOW_ERROR,
  58. /* We are about to renegotiate */
  59. MSG_FLOW_RENEGOTIATE,
  60. /* We are reading messages */
  61. MSG_FLOW_READING,
  62. /* We are writing messages */
  63. MSG_FLOW_WRITING,
  64. /* Handshake has finished */
  65. MSG_FLOW_FINISHED
  66. } MSG_FLOW_STATE;
  67. /* SSL subsystem states */
  68. typedef enum {
  69. TLS_ST_BEFORE,
  70. TLS_ST_OK,
  71. DTLS_ST_CR_HELLO_VERIFY_REQUEST,
  72. TLS_ST_CR_SRVR_HELLO,
  73. TLS_ST_CR_CERT,
  74. TLS_ST_CR_CERT_STATUS,
  75. TLS_ST_CR_KEY_EXCH,
  76. TLS_ST_CR_CERT_REQ,
  77. TLS_ST_CR_SRVR_DONE,
  78. TLS_ST_CR_SESSION_TICKET,
  79. TLS_ST_CR_CHANGE,
  80. TLS_ST_CR_FINISHED,
  81. TLS_ST_CW_CLNT_HELLO,
  82. TLS_ST_CW_CERT,
  83. TLS_ST_CW_KEY_EXCH,
  84. TLS_ST_CW_CERT_VRFY,
  85. TLS_ST_CW_CHANGE,
  86. TLS_ST_CW_NEXT_PROTO,
  87. TLS_ST_CW_FINISHED,
  88. TLS_ST_SW_HELLO_REQ,
  89. TLS_ST_SR_CLNT_HELLO,
  90. DTLS_ST_SW_HELLO_VERIFY_REQUEST,
  91. TLS_ST_SW_SRVR_HELLO,
  92. TLS_ST_SW_CERT,
  93. TLS_ST_SW_KEY_EXCH,
  94. TLS_ST_SW_CERT_REQ,
  95. TLS_ST_SW_SRVR_DONE,
  96. TLS_ST_SR_CERT,
  97. TLS_ST_SR_KEY_EXCH,
  98. TLS_ST_SR_CERT_VRFY,
  99. TLS_ST_SR_NEXT_PROTO,
  100. TLS_ST_SR_CHANGE,
  101. TLS_ST_SR_FINISHED,
  102. TLS_ST_SW_SESSION_TICKET,
  103. TLS_ST_SW_CERT_STATUS,
  104. TLS_ST_SW_CHANGE,
  105. TLS_ST_SW_FINISHED
  106. } OSSL_HANDSHAKE_STATE;
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110. #endif