Esempio n. 1
0
/* First client_hello is a special case, because of SSL v2 compatibility */
int ssl_decode_first_client_hello( DSSL_Session* sess, u_char* data, uint32_t len, uint32_t* processed )
{
	int rc = DSSL_RC_OK;
	
	if( data[0] & 0x80 && len >= 3 && data[2] == SSL2_MT_CLIENT_HELLO )
	{
		int hdrLen = SSL20_CLIENT_HELLO_HDR_LEN;
		uint32_t recLen = len - hdrLen;

		rc = ssl2_decode_handshake( sess, ePacketDirFromClient, data + hdrLen, recLen, processed );

		if( rc == DSSL_RC_OK )
		{
			if( sess->version >= SSL3_VERSION && sess->version <= TLS1_2_VERSION )
			{
				ssl3_init_handshake_digests( sess );
				ssl3_update_handshake_digests( sess, data + hdrLen, recLen );
			}

			*processed += hdrLen;
		}
	}
	else if( data[0] == SSL3_RT_HANDSHAKE && len > 6 && 
		data[1] == SSL3_VERSION_MAJOR && data[5] == SSL3_MT_CLIENT_HELLO )
	{
		uint32_t recLen = 0;
		u_char* org_data;

		data += SSL3_HEADER_LEN;
		recLen = (((int32_t)data[1]) << 16) | (((int32_t)data[2]) << 8) | data[3];
		org_data = data;

		data += SSL3_HANDSHAKE_HEADER_LEN;
		len -= SSL3_HANDSHAKE_HEADER_LEN;
		
		rc = ssl3_decode_client_hello( sess, data, recLen );
		if( rc == DSSL_RC_OK )
		{
			*processed = recLen + SSL3_HANDSHAKE_HEADER_LEN + SSL3_HEADER_LEN;
			ssl3_init_handshake_digests( sess );
			ssl3_update_handshake_digests( sess, org_data, recLen + SSL3_HANDSHAKE_HEADER_LEN );
		}
	}
	else
	{
		rc = NM_ERROR( DSSL_E_SSL_UNKNOWN_VERSION );
	}

	return rc;
}
Esempio n. 2
0
int ssl2_handshake_record_decode_wrapper( dssl_decoder_stack* stack, NM_PacketDir dir,
								 u_char* data, uint32_t len, uint32_t* processed )
{
	return ssl2_decode_handshake( stack->sess, dir, data, len, processed );
}