/** * @brief Read the SSL data stream. * @param ssl [in] An SSL object reference. * @param in_data [out] After a successful read, the decrypted data * will be here. It will be null otherwise. * @return The number of decrypted bytes: * - if > 0, then the handshaking is complete and we are returning the * number of decrypted bytes. * - SSL_OK if the handshaking stage is successful (but not yet * complete). * - < 0 if an error. * @see ssl.h for the error code list. * @note Use in_data before doing any successive ssl calls. */ public int Read(SSL ssl, out byte[] in_data) { IntPtr ptr = IntPtr.Zero; int ret = axtls.ssl_read(ssl.m_ssl, ref ptr); if (ret > axtls.SSL_OK) { in_data = new byte[ret]; Marshal.Copy(ptr, in_data, 0, ret); } else { in_data = null; } return(ret); }
/** * @brief Force the client to perform its handshake again. * * For a client this involves sending another "client hello" message. * For the server is means sending a "hello request" message. * * This is a blocking call on the client (until the handshake * completes). * @param ssl [in] An SSL object reference. * @return SSL_OK if renegotiation instantiation was ok */ public int Renegotiate(SSL ssl) { return(axtls.ssl_renegotiate(ssl.m_ssl)); }
/** * @brief Authenticate a received certificate. * * This call is usually made by a client after a handshake is complete * and the context is in SSL_SERVER_VERIFY_LATER mode. * @param ssl [in] An SSL object reference. * @return SSL_OK if the certificate is verified. */ public int VerifyCert(SSL ssl) { return(axtls.ssl_verify_cert(ssl.m_ssl)); }
/** * @brief Write to the SSL data stream. * @param ssl [in] An SSL obect reference. * @param out_data [in] The data to be written * @param out_len [in] The number of bytes to be written * @return The number of bytes sent, or if < 0 if an error. * @see ssl.h for the error code list. */ public int Write(SSL ssl, byte[] out_data, int out_len) { return(axtls.ssl_write(ssl.m_ssl, out_data, out_len)); }
/** * @brief Write to the SSL data stream. * @param ssl [in] An SSL obect reference. * @param out_data [in] The data to be written * @return The number of bytes sent, or if < 0 if an error. * @see ssl.h for the error code list. */ public int Write(SSL ssl, byte[] out_data) { return(axtls.ssl_write(ssl.m_ssl, out_data, out_data.Length)); }
/** * @brief Force the client to perform its handshake again. * * For a client this involves sending another "client hello" message. * For the server is means sending a "hello request" message. * * This is a blocking call on the client (until the handshake * completes). * @param ssl [in] An SSL object reference. * @return SSL_OK if renegotiation instantiation was ok */ public int Renegotiate(SSL ssl) { return axtls.ssl_renegotiate(ssl.m_ssl); }
/** * @brief Authenticate a received certificate. * * This call is usually made by a client after a handshake is complete * and the context is in SSL_SERVER_VERIFY_LATER mode. * @param ssl [in] An SSL object reference. * @return SSL_OK if the certificate is verified. */ public int VerifyCert(SSL ssl) { return axtls.ssl_verify_cert(ssl.m_ssl); }
/** * @brief Write to the SSL data stream. * @param ssl [in] An SSL obect reference. * @param out_data [in] The data to be written * @param out_len [in] The number of bytes to be written * @return The number of bytes sent, or if < 0 if an error. * @see ssl.h for the error code list. */ public int Write(SSL ssl, byte[] out_data, int out_len) { return axtls.ssl_write(ssl.m_ssl, out_data, out_len); }
/** * @brief Write to the SSL data stream. * @param ssl [in] An SSL obect reference. * @param out_data [in] The data to be written * @return The number of bytes sent, or if < 0 if an error. * @see ssl.h for the error code list. */ public int Write(SSL ssl, byte[] out_data) { return axtls.ssl_write(ssl.m_ssl, out_data, out_data.Length); }
/** * @brief Read the SSL data stream. * @param ssl [in] An SSL object reference. * @param in_data [out] After a successful read, the decrypted data * will be here. It will be null otherwise. * @return The number of decrypted bytes: * - if > 0, then the handshaking is complete and we are returning the * number of decrypted bytes. * - SSL_OK if the handshaking stage is successful (but not yet * complete). * - < 0 if an error. * @see ssl.h for the error code list. * @note Use in_data before doing any successive ssl calls. */ public int Read(SSL ssl, out byte[] in_data) { IntPtr ptr = IntPtr.Zero; int ret = axtls.ssl_read(ssl.m_ssl, ref ptr); if (ret > axtls.SSL_OK) { in_data = new byte[ret]; Marshal.Copy(ptr, in_data, 0, ret); } else { in_data = null; } return ret; }