ssl_code.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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_mode() -- supported mode when using BIO */
  22. #define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L
  23. #define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L
  24. /* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
  25. # define SSL_SENT_SHUTDOWN 1
  26. # define SSL_RECEIVED_SHUTDOWN 2
  27. # define SSL_VERIFY_NONE 0x00
  28. # define SSL_VERIFY_PEER 0x01
  29. # define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
  30. # define SSL_VERIFY_CLIENT_ONCE 0x04
  31. /*
  32. * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you
  33. * should not need these
  34. */
  35. # define SSL_ST_READ_HEADER 0xF0
  36. # define SSL_ST_READ_BODY 0xF1
  37. # define SSL_ST_READ_DONE 0xF2
  38. # define SSL_NOTHING 1
  39. # define SSL_WRITING 2
  40. # define SSL_READING 3
  41. # define SSL_X509_LOOKUP 4
  42. # define SSL_ASYNC_PAUSED 5
  43. # define SSL_ASYNC_NO_JOBS 6
  44. # define SSL_ERROR_NONE 0
  45. # define SSL_ERROR_SSL 1
  46. # define SSL_ERROR_WANT_READ 2
  47. # define SSL_ERROR_WANT_WRITE 3
  48. # define SSL_ERROR_WANT_X509_LOOKUP 4
  49. # define SSL_ERROR_SYSCALL 5/* look at error stack/return value/errno */
  50. # define SSL_ERROR_ZERO_RETURN 6
  51. # define SSL_ERROR_WANT_CONNECT 7
  52. # define SSL_ERROR_WANT_ACCEPT 8
  53. # define SSL_ERROR_WANT_ASYNC 9
  54. # define SSL_ERROR_WANT_ASYNC_JOB 10
  55. /* Message flow states */
  56. typedef enum {
  57. /* No handshake in progress */
  58. MSG_FLOW_UNINITED,
  59. /* A permanent error with this connection */
  60. MSG_FLOW_ERROR,
  61. /* We are about to renegotiate */
  62. MSG_FLOW_RENEGOTIATE,
  63. /* We are reading messages */
  64. MSG_FLOW_READING,
  65. /* We are writing messages */
  66. MSG_FLOW_WRITING,
  67. /* Handshake has finished */
  68. MSG_FLOW_FINISHED
  69. } MSG_FLOW_STATE;
  70. /* SSL subsystem states */
  71. typedef enum {
  72. TLS_ST_BEFORE,
  73. TLS_ST_OK,
  74. DTLS_ST_CR_HELLO_VERIFY_REQUEST,
  75. TLS_ST_CR_SRVR_HELLO,
  76. TLS_ST_CR_CERT,
  77. TLS_ST_CR_CERT_STATUS,
  78. TLS_ST_CR_KEY_EXCH,
  79. TLS_ST_CR_CERT_REQ,
  80. TLS_ST_CR_SRVR_DONE,
  81. TLS_ST_CR_SESSION_TICKET,
  82. TLS_ST_CR_CHANGE,
  83. TLS_ST_CR_FINISHED,
  84. TLS_ST_CW_CLNT_HELLO,
  85. TLS_ST_CW_CERT,
  86. TLS_ST_CW_KEY_EXCH,
  87. TLS_ST_CW_CERT_VRFY,
  88. TLS_ST_CW_CHANGE,
  89. TLS_ST_CW_NEXT_PROTO,
  90. TLS_ST_CW_FINISHED,
  91. TLS_ST_SW_HELLO_REQ,
  92. TLS_ST_SR_CLNT_HELLO,
  93. DTLS_ST_SW_HELLO_VERIFY_REQUEST,
  94. TLS_ST_SW_SRVR_HELLO,
  95. TLS_ST_SW_CERT,
  96. TLS_ST_SW_KEY_EXCH,
  97. TLS_ST_SW_CERT_REQ,
  98. TLS_ST_SW_SRVR_DONE,
  99. TLS_ST_SR_CERT,
  100. TLS_ST_SR_KEY_EXCH,
  101. TLS_ST_SR_CERT_VRFY,
  102. TLS_ST_SR_NEXT_PROTO,
  103. TLS_ST_SR_CHANGE,
  104. TLS_ST_SR_FINISHED,
  105. TLS_ST_SW_SESSION_TICKET,
  106. TLS_ST_SW_CERT_STATUS,
  107. TLS_ST_SW_CHANGE,
  108. TLS_ST_SW_FINISHED
  109. } OSSL_HANDSHAKE_STATE;
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif