XilinxProcessorIPLib/drivers/hdcp22_rx/src/xhdcp22_rx_crypt.c
static void XHdcp22Rx_ComputeDKey(const u8* Rrx, const u8* Rtx, const u8 *Km,
	const u8 *Rn, u8 *Ctr, u8 *DKey)
{
	u8 Aes_Iv[XHDCP22_RX_AES_SIZE];
	u8 Aes_Key[XHDCP22_RX_AES_SIZE];

	/* Verify arguments */
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(DKey != NULL);

	/* AES Key = Km xor Rn */
	memcpy(Aes_Key, Km, XHDCP22_RX_AES_SIZE);
	if(Rn != NULL)
	{
		XHdcp22Rx_Xor(Aes_Key+XHDCP22_RX_RN_SIZE, Km+XHDCP22_RX_RN_SIZE, Rn, XHDCP22_RX_RN_SIZE);
	}

	/* AES Input = Rtx || (Rrx xor Ctr) */
	memcpy(Aes_Iv, Rtx, XHDCP22_RX_RTX_SIZE);
	if(Ctr == NULL)
	{
		memcpy(&Aes_Iv[XHDCP22_RX_RRX_SIZE], Rrx, XHDCP22_RX_RRX_SIZE);
	}
	else
	{
		XHdcp22Rx_Xor(Aes_Iv+XHDCP22_RX_RTX_SIZE, Rrx, Ctr, XHDCP22_RX_RRX_SIZE);
	}

	XHdcp22Cmn_Aes128Encrypt(Aes_Iv, Aes_Key, DKey);
}
/*****************************************************************************/
/**
* This function computes the derived keys used during HDCP 2.2 authentication
* and key exchange.
*
* Reference: HDCP v2.2, section 2.7
*
* @param	Rrx is the Rx random generated value.
* @param	Rtx is the Tx random generated value.
* @param	Km is the master key generated by tx.
* @param	Rn is the 64-bit psuedo-random nonce generated by the transmitter.
* @param	Ctr is the 64-bit AES counter value.
* @param	DKey is the 128-bit derived key.
*
* @return	None.
*
* @note		None.
******************************************************************************/
This function computes the derived keys used during HDCP 2.2 authentication
and key exchange.


This function computes the derived keys used during HDCP 2 . 2 authentication and key exchange .
static void XHdcp22Rx_ComputeDKey(const u8* Rrx, const u8* Rtx, const u8 *Km,
	const u8 *Rn, u8 *Ctr, u8 *DKey)
{
	u8 Aes_Iv[XHDCP22_RX_AES_SIZE];
	u8 Aes_Key[XHDCP22_RX_AES_SIZE];
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(DKey != NULL);
	memcpy(Aes_Key, Km, XHDCP22_RX_AES_SIZE);
	if(Rn != NULL)
	{
		XHdcp22Rx_Xor(Aes_Key+XHDCP22_RX_RN_SIZE, Km+XHDCP22_RX_RN_SIZE, Rn, XHDCP22_RX_RN_SIZE);
	}
	memcpy(Aes_Iv, Rtx, XHDCP22_RX_RTX_SIZE);
	if(Ctr == NULL)
	{
		memcpy(&Aes_Iv[XHDCP22_RX_RRX_SIZE], Rrx, XHDCP22_RX_RRX_SIZE);
	}
	else
	{
		XHdcp22Rx_Xor(Aes_Iv+XHDCP22_RX_RTX_SIZE, Rrx, Ctr, XHDCP22_RX_RRX_SIZE);
	}
	XHdcp22Cmn_Aes128Encrypt(Aes_Iv, Aes_Key, DKey);
}
static void XHdcp22Rx_ComputeDKey ( const u8 * Rrx , const u8 * Rtx , const u8 * Km , const u8 * Rn , u8 * Ctr , u8 * DKey ) { u8 Aes_Iv [ XHDCP22_RX_AES_SIZE ] ; u8 Aes_Key [ XHDCP22_RX_AES_SIZE ] ; Xil_AssertVoid ( Rrx != NULL ) ; Xil_AssertVoid ( Rtx != NULL ) ; Xil_AssertVoid ( Km != NULL ) ; Xil_AssertVoid ( DKey != NULL ) ; memcpy ( Aes_Key , Km , XHDCP22_RX_AES_SIZE ) ; if ( Rn != NULL ) { XHdcp22Rx_Xor ( Aes_Key + XHDCP22_RX_RN_SIZE , Km + XHDCP22_RX_RN_SIZE , Rn , XHDCP22_RX_RN_SIZE ) ; } memcpy ( Aes_Iv , Rtx , XHDCP22_RX_RTX_SIZE ) ; if ( Ctr == NULL ) { memcpy ( & Aes_Iv [ XHDCP22_RX_RRX_SIZE ] , Rrx , XHDCP22_RX_RRX_SIZE ) ; } else { XHdcp22Rx_Xor ( Aes_Iv + XHDCP22_RX_RTX_SIZE , Rrx , Ctr , XHDCP22_RX_RRX_SIZE ) ; } XHdcp22Cmn_Aes128Encrypt ( Aes_Iv , Aes_Key , DKey ) ; }
This function computes the derived keys used during HDCP 2.2 authentication
and key exchange.
This function computes the derived keys used during HDCP 2 . 2 authentication and key exchange .
/* Verify arguments */ /* AES Key = Km xor Rn */ /* AES Input = Rtx || (Rrx xor Ctr) */