tls/m_tls_ctx_common.c
/* Openssl inverse, protocol to disable. */
Openssl inverse, protocol to disable.
Openssl inverse protocol to disable .
static M_bool M_tls_protocols_to_openssl(int protocols, unsigned long *no_protocols)
{
	unsigned long     disabled = 0;
	M_tls_protocols_t min      = M_TLS_PROTOCOL_TLSv1_0;
	M_tls_protocols_t max      = M_TLS_PROTOCOL_TLSv1_2;
	if (protocols == M_TLS_PROTOCOL_TLSv1_3)
		return M_FALSE;
	if (protocols & M_TLS_PROTOCOL_TLSv1_0) {
		min = M_TLS_PROTOCOL_TLSv1_0;
	} else if (protocols & M_TLS_PROTOCOL_TLSv1_1) {
		min = M_TLS_PROTOCOL_TLSv1_1;
	} else if (protocols & M_TLS_PROTOCOL_TLSv1_2) {
		min = M_TLS_PROTOCOL_TLSv1_2;
	} else {
		return M_FALSE;
	}
	if (protocols & M_TLS_PROTOCOL_TLSv1_2) {
		max = M_TLS_PROTOCOL_TLSv1_2;
	} else if (protocols & M_TLS_PROTOCOL_TLSv1_1) {
		max = M_TLS_PROTOCOL_TLSv1_1;
	} else if (protocols & M_TLS_PROTOCOL_TLSv1_0) {
		max = M_TLS_PROTOCOL_TLSv1_0;
	} else {
		return M_FALSE;
	}
	if (min > max)
		return M_FALSE;
	protocols = min;
	while (protocols < max) { 
		protocols |= protocols << 1;
	}
	if (!(protocols & M_TLS_PROTOCOL_TLSv1_0))
		disabled |= SSL_OP_NO_TLSv1;
	if (!(protocols & M_TLS_PROTOCOL_TLSv1_1))
		disabled |= SSL_OP_NO_TLSv1_1;
	if (!(protocols & M_TLS_PROTOCOL_TLSv1_2))
		disabled |= SSL_OP_NO_TLSv1_2;
	*no_protocols  = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
	*no_protocols |= disabled;
	return M_TRUE;
}
static M_bool M_tls_protocols_to_openssl ( int protocols , unsigned long * no_protocols ) { unsigned long disabled = 0 ; M_tls_protocols_t min = M_TLS_PROTOCOL_TLSv1_0 ; M_tls_protocols_t max = M_TLS_PROTOCOL_TLSv1_2 ; if ( protocols == M_TLS_PROTOCOL_TLSv1_3 ) return M_FALSE ; if ( protocols & M_TLS_PROTOCOL_TLSv1_0 ) { min = M_TLS_PROTOCOL_TLSv1_0 ; } else if ( protocols & M_TLS_PROTOCOL_TLSv1_1 ) { min = M_TLS_PROTOCOL_TLSv1_1 ; } else if ( protocols & M_TLS_PROTOCOL_TLSv1_2 ) { min = M_TLS_PROTOCOL_TLSv1_2 ; } else { return M_FALSE ; } if ( protocols & M_TLS_PROTOCOL_TLSv1_2 ) { max = M_TLS_PROTOCOL_TLSv1_2 ; } else if ( protocols & M_TLS_PROTOCOL_TLSv1_1 ) { max = M_TLS_PROTOCOL_TLSv1_1 ; } else if ( protocols & M_TLS_PROTOCOL_TLSv1_0 ) { max = M_TLS_PROTOCOL_TLSv1_0 ; } else { return M_FALSE ; } if ( min > max ) return M_FALSE ; protocols = min ; while ( protocols < max ) { protocols |= protocols << 1 ; } if ( ! ( protocols & M_TLS_PROTOCOL_TLSv1_0 ) ) disabled |= SSL_OP_NO_TLSv1 ; if ( ! ( protocols & M_TLS_PROTOCOL_TLSv1_1 ) ) disabled |= SSL_OP_NO_TLSv1_1 ; if ( ! ( protocols & M_TLS_PROTOCOL_TLSv1_2 ) ) disabled |= SSL_OP_NO_TLSv1_2 ; * no_protocols = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 ; * no_protocols |= disabled ; return M_TRUE ; }
Openssl inverse, protocol to disable.
Openssl inverse protocol to disable .
/* INVALID! Only 1.3 enabled and not supported by this openssl version. */ /* Find the min protocol. */ /* Find the max protocol. */ /* Ensure the range is valid. */ /* Fill in the gaps. */ /* Max will be included in result. */ /* Disable anything before min and after max. */ /* Always disable SSLv2 and SSLv3 */