⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssl.h

📁 it is know of https implement source code
💻 H
📖 第 1 页 / 共 2 页
字号:
#endifextern int ssl_default_ciphers[];/** * \brief          Initialize an SSL context * * \param ssl      SSL context * * \return         0 if successful, or 1 if memory allocation failed */int ssl_init( ssl_context *ssl );/** * \brief          Set the current endpoint type * * \param ssl      SSL context * \param endpoint must be SSL_IS_CLIENT or SSL_IS_SERVER */void ssl_set_endpoint( ssl_context *ssl, int endpoint );/** * \brief          Set the certificate verification mode * * \param ssl      SSL context * \param mode     can be: * *  SSL_VERIFY_NONE:      peer certificate is not checked (default), *                        this is insecure and SHOULD be avoided. * *  SSL_VERIFY_OPTIONAL:  peer certificate is checked, however the *                        handshake continues even if verification failed; *                        ssl_get_verify_result() can be called after the *                        handshake is complete. * *  SSL_VERIFY_REQUIRED:  peer *must* present a valid certificate, *                        handshake is aborted if verification failed. */void ssl_set_authmode( ssl_context *ssl, int authmode );/** * \brief          Set the random number generator callback * * \param ssl      SSL context * \param f_rng    RNG function * \param p_rng    RNG parameter */void ssl_set_rng( ssl_context *ssl,                  int (*f_rng)(void *),                  void *p_rng );/** * \brief          Set the debug callback * * \param ssl      SSL context * \param f_dbg    debug function * \param p_dbg    debug parameter */void ssl_set_dbg( ssl_context *ssl,                  void (*f_dbg)(void *, int, char *),                  void  *p_dbg );/** * \brief          Set the underlying BIO read and write callbacks * * \param ssl      SSL context * \param f_recv   read callback * \param p_recv   read parameter * \param f_send   write callback * \param p_send   write parameter */void ssl_set_bio( ssl_context *ssl,        int (*f_recv)(void *, unsigned char *, int), void *p_recv,        int (*f_send)(void *, unsigned char *, int), void *p_send );/** * \brief          Set the session callbacks (server-side only) * * \param ssl      SSL context * \param s_get    session get callback * \param s_set    session set callback */void ssl_set_scb( ssl_context *ssl,                  int (*s_get)(ssl_context *),                  int (*s_set)(ssl_context *) );/** * \brief          Set the session resuming flag, timeout and data * * \param ssl      SSL context * \param resume   if 0 (default), the session will not be resumed * \param timeout  session timeout in seconds, or 0 (no timeout) * \param session  session context */void ssl_set_session( ssl_context *ssl, int resume, int timeout,                      ssl_session *session );/** * \brief          Set the list of allowed ciphersuites * * \param ssl      SSL context * \param ciphers  0-terminated list of allowed ciphers */void ssl_set_ciphers( ssl_context *ssl, int *ciphers );/** * \brief          Set the data required to verify peer certificate * * \param ssl      SSL context * \param ca_chain trusted CA chain * \param peer_cn  expected peer CommonName (or NULL) * * \note           TODO: add two more parameters: depth and crl */void ssl_set_ca_chain( ssl_context *ssl, x509_cert *ca_chain,                       char *peer_cn );/** * \brief          Set own certificate and private key * * \param ssl      SSL context * \param own_cert own public certificate * \param rsa_key  own private RSA key */void ssl_set_own_cert( ssl_context *ssl, x509_cert *own_cert,                       rsa_context *rsa_key );/** * \brief          Set the Diffie-Hellman public P and G values, *                 read as hexadecimal strings (server-side only) * * \param ssl      SSL context * \param dhm_P    Diffie-Hellman-Merkle modulus * \param dhm_G    Diffie-Hellman-Merkle generator * * \return         0 if successful */int ssl_set_dh_param( ssl_context *ssl, char *dhm_P, char *dhm_G );/** * \brief          Set hostname for ServerName TLS Extension *                  * * \param ssl      SSL context * \param hostname the server hostname * * \return         0 if successful */int ssl_set_hostname( ssl_context *ssl, char *hostname );/** * \brief          Return the number of data bytes available to read * * \param ssl      SSL context * * \return         how many bytes are available in the read buffer */int ssl_get_bytes_avail( ssl_context *ssl );/** * \brief          Return the result of the certificate verification * * \param ssl      SSL context * * \return         0 if successful, or a combination of: *                      BADCERT_EXPIRED *                      BADCERT_REVOKED *                      BADCERT_CN_MISMATCH *                      BADCERT_NOT_TRUSTED */int ssl_get_verify_result( ssl_context *ssl );/** * \brief          Return the name of the current cipher * * \param ssl      SSL context * * \return         a string containing the cipher name */char *ssl_get_cipher( ssl_context *ssl );/** * \brief          Perform the SSL handshake * * \param ssl      SSL context * * \return         0 if successful, XYSSL_ERR_NET_TRY_AGAIN, *                 or a specific SSL error code. */int ssl_handshake( ssl_context *ssl );/** * \brief          Read at most 'len' application data bytes * * \param ssl      SSL context * \param buf      buffer that will hold the data * \param len      how many bytes must be read * * \return         This function returns the number of bytes read, *                 or a negative error code. */int ssl_read( ssl_context *ssl, unsigned char *buf, int len );/** * \brief          Write exactly 'len' application data bytes * * \param ssl      SSL context * \param buf      buffer holding the data * \param len      how many bytes must be written * * \return         This function returns the number of bytes written, *                 or a negative error code. * * \note           When this function returns XYSSL_ERR_NET_TRY_AGAIN, *                 it must be called later with the *same* arguments, *                 until it returns a positive value. */int ssl_write( ssl_context *ssl, unsigned char *buf, int len );/** * \brief          Notify the peer that the connection is being closed */int ssl_close_notify( ssl_context *ssl );/** * \brief          Free an SSL context */void ssl_free( ssl_context *ssl );/* * Internal functions (do not call directly) */int ssl_handshake_client( ssl_context *ssl );int ssl_handshake_server( ssl_context *ssl );int ssl_derive_keys( ssl_context *ssl );void ssl_calc_verify( ssl_context *ssl, unsigned char hash[36] );int ssl_read_record( ssl_context *ssl );int ssl_fetch_input( ssl_context *ssl, int nb_want );int ssl_write_record( ssl_context *ssl );int ssl_flush_output( ssl_context *ssl );int ssl_parse_certificate( ssl_context *ssl );int ssl_write_certificate( ssl_context *ssl );int ssl_parse_change_cipher_spec( ssl_context *ssl );int ssl_write_change_cipher_spec( ssl_context *ssl );int ssl_parse_finished( ssl_context *ssl );int ssl_write_finished( ssl_context *ssl );#ifdef __cplusplus}#endif#endif /* ssl.h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -