XilinxProcessorIPLib/drivers/hdcp22_rx/src/xhdcp22_rx_crypt.c
void XHdcp22Rx_ComputeHPrime(const u8* Rrx, const u8 *RxCaps, const u8* Rtx,
	const u8 *TxCaps, const u8 *Km, u8 *HPrime)
{
	u8 HashInput[XHDCP22_RX_RTX_SIZE + XHDCP22_RX_RXCAPS_SIZE + XHDCP22_RX_TXCAPS_SIZE];
	int Idx = 0;
	u8 Ctr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
	u8 Kd[2 * XHDCP22_RX_AES_SIZE]; /* dkey0 || dkey 1 */


	/* Verify arguments */
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(RxCaps != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(TxCaps != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(HPrime != NULL);

	/* Generate derived keys dkey0 and dkey1
	   HashKey Kd = dkey0 || dkey1 */
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, NULL, Kd);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, Ctr, Kd+XHDCP22_RX_AES_SIZE);

	/* HashInput = Rtx || RxCaps || TxCaps */
	memcpy(HashInput, Rtx, XHDCP22_RX_RTX_SIZE);
	Idx += XHDCP22_RX_RTX_SIZE;
	memcpy(&HashInput[Idx], RxCaps, XHDCP22_RX_RXCAPS_SIZE);
	Idx += XHDCP22_RX_RXCAPS_SIZE;
	memcpy(&HashInput[Idx], TxCaps, XHDCP22_RX_TXCAPS_SIZE);

	/* Compute H' = HMAC-SHA256(HashInput, Kd) */
	XHdcp22Cmn_HmacSha256Hash(HashInput, sizeof(HashInput), Kd, XHDCP22_RX_KD_SIZE, HPrime);
}
/*****************************************************************************/
/**
* This function computes HPrime used during HDCP 2.2 authentication and key
* exchange.
*
* Reference: HDCP v2.2, section 2.2
*
* @param	Rrx is the Rx random generated value.
* @param	RxCaps are the capabilities of the receiver.
* @param	Rtx is the Tx random generated value.
* @param	TxCaps are the capabilities of the receiver.
* @param	Km is the master key generated by tx.
* @param	HPrime is a pointer to the HPrime hash from the HDCP2.2 receiver.
*
* @return	None.
*
* @note		None.
******************************************************************************/
This function computes HPrime used during HDCP 2.2 authentication and key
exchange.


This function computes HPrime used during HDCP 2 . 2 authentication and key exchange .
void XHdcp22Rx_ComputeHPrime(const u8* Rrx, const u8 *RxCaps, const u8* Rtx,
	const u8 *TxCaps, const u8 *Km, u8 *HPrime)
{
	u8 HashInput[XHDCP22_RX_RTX_SIZE + XHDCP22_RX_RXCAPS_SIZE + XHDCP22_RX_TXCAPS_SIZE];
	int Idx = 0;
	u8 Ctr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
	u8 Kd[2 * XHDCP22_RX_AES_SIZE]; 
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(RxCaps != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(TxCaps != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(HPrime != NULL);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, NULL, Kd);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, Ctr, Kd+XHDCP22_RX_AES_SIZE);
	memcpy(HashInput, Rtx, XHDCP22_RX_RTX_SIZE);
	Idx += XHDCP22_RX_RTX_SIZE;
	memcpy(&HashInput[Idx], RxCaps, XHDCP22_RX_RXCAPS_SIZE);
	Idx += XHDCP22_RX_RXCAPS_SIZE;
	memcpy(&HashInput[Idx], TxCaps, XHDCP22_RX_TXCAPS_SIZE);
	XHdcp22Cmn_HmacSha256Hash(HashInput, sizeof(HashInput), Kd, XHDCP22_RX_KD_SIZE, HPrime);
}
void XHdcp22Rx_ComputeHPrime ( const u8 * Rrx , const u8 * RxCaps , const u8 * Rtx , const u8 * TxCaps , const u8 * Km , u8 * HPrime ) { u8 HashInput [ XHDCP22_RX_RTX_SIZE + XHDCP22_RX_RXCAPS_SIZE + XHDCP22_RX_TXCAPS_SIZE ] ; int Idx = 0 ; u8 Ctr [ ] = { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 } ; u8 Kd [ 2 * XHDCP22_RX_AES_SIZE ] ; Xil_AssertVoid ( Rrx != NULL ) ; Xil_AssertVoid ( RxCaps != NULL ) ; Xil_AssertVoid ( Rtx != NULL ) ; Xil_AssertVoid ( TxCaps != NULL ) ; Xil_AssertVoid ( Km != NULL ) ; Xil_AssertVoid ( HPrime != NULL ) ; XHdcp22Rx_ComputeDKey ( Rrx , Rtx , Km , NULL , NULL , Kd ) ; XHdcp22Rx_ComputeDKey ( Rrx , Rtx , Km , NULL , Ctr , Kd + XHDCP22_RX_AES_SIZE ) ; memcpy ( HashInput , Rtx , XHDCP22_RX_RTX_SIZE ) ; Idx += XHDCP22_RX_RTX_SIZE ; memcpy ( & HashInput [ Idx ] , RxCaps , XHDCP22_RX_RXCAPS_SIZE ) ; Idx += XHDCP22_RX_RXCAPS_SIZE ; memcpy ( & HashInput [ Idx ] , TxCaps , XHDCP22_RX_TXCAPS_SIZE ) ; XHdcp22Cmn_HmacSha256Hash ( HashInput , sizeof ( HashInput ) , Kd , XHDCP22_RX_KD_SIZE , HPrime ) ; }
This function computes HPrime used during HDCP 2.2 authentication and key
exchange.
This function computes HPrime used during HDCP 2 . 2 authentication and key exchange .
/* dkey0 || dkey 1 */ /* Verify arguments */ /* Generate derived keys dkey0 and dkey1
	   HashKey Kd = dkey0 || dkey1 */ /* HashInput = Rtx || RxCaps || TxCaps */ /* Compute H' = HMAC-SHA256(HashInput, Kd) */