XilinxProcessorIPLib/drivers/hdcp22_rx/src/xhdcp22_rx_crypt.c
void XHdcp22Rx_ComputeLPrime(const u8 *Rn, const u8 *Km, const u8 *Rrx, const u8 *Rtx, u8 *LPrime)
{
	u8 HashKey[XHDCP22_RX_KD_SIZE];
	u8 Ctr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
	u8 Kd[2 * XHDCP22_RX_AES_SIZE]; /* dkey0 || dkey 1 */

	/* Verify arguments */
	Xil_AssertVoid(Rn != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(LPrime != 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);

	/* HashKey = Kd[256:64] || (Kd[63:0] xor Rrx) */
	memcpy(HashKey, Kd, XHDCP22_RX_KD_SIZE);
	XHdcp22Rx_Xor(HashKey+(XHDCP22_RX_KD_SIZE-XHDCP22_RX_RRX_SIZE),
		Kd+(XHDCP22_RX_KD_SIZE-XHDCP22_RX_RRX_SIZE), Rrx, XHDCP22_RX_RRX_SIZE);

	/* LPrime = HMAC-SHA256(Rn, HashKey) */
	XHdcp22Cmn_HmacSha256Hash(Rn, XHDCP22_RX_RN_SIZE, HashKey, XHDCP22_RX_KD_SIZE, LPrime);
}
/*****************************************************************************/
/**
* This function computes LPrime used during HDCP 2.2 locality check.
*
* Reference: HDCP v2.2, section 2.3
*
* @param	Rn is the 64-bit psuedo-random nonce generated by the transmitter.
* @param	Km is the 128-bit master key generated by tx.
* @param	Rrx is the 64-bit pseudo-random number generated by the receiver.
* @param	Rtx is the 64-bit pseudo-random number generated by the transmitter.
* @param	LPrime is the 256-bit value generated for locality check.
*
* @return	None.
*
* @note		None.
******************************************************************************/
This function computes LPrime used during HDCP 2.2 locality check.
This function computes LPrime used during HDCP 2 . 2 locality check .
void XHdcp22Rx_ComputeLPrime(const u8 *Rn, const u8 *Km, const u8 *Rrx, const u8 *Rtx, u8 *LPrime)
{
	u8 HashKey[XHDCP22_RX_KD_SIZE];
	u8 Ctr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
	u8 Kd[2 * XHDCP22_RX_AES_SIZE]; 
	Xil_AssertVoid(Rn != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(LPrime != NULL);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, NULL, Kd);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, Ctr, Kd+XHDCP22_RX_AES_SIZE);
	memcpy(HashKey, Kd, XHDCP22_RX_KD_SIZE);
	XHdcp22Rx_Xor(HashKey+(XHDCP22_RX_KD_SIZE-XHDCP22_RX_RRX_SIZE),
		Kd+(XHDCP22_RX_KD_SIZE-XHDCP22_RX_RRX_SIZE), Rrx, XHDCP22_RX_RRX_SIZE);
	XHdcp22Cmn_HmacSha256Hash(Rn, XHDCP22_RX_RN_SIZE, HashKey, XHDCP22_RX_KD_SIZE, LPrime);
}
void XHdcp22Rx_ComputeLPrime ( const u8 * Rn , const u8 * Km , const u8 * Rrx , const u8 * Rtx , u8 * LPrime ) { u8 HashKey [ XHDCP22_RX_KD_SIZE ] ; u8 Ctr [ ] = { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 } ; u8 Kd [ 2 * XHDCP22_RX_AES_SIZE ] ; Xil_AssertVoid ( Rn != NULL ) ; Xil_AssertVoid ( Km != NULL ) ; Xil_AssertVoid ( Rrx != NULL ) ; Xil_AssertVoid ( Rtx != NULL ) ; Xil_AssertVoid ( LPrime != NULL ) ; XHdcp22Rx_ComputeDKey ( Rrx , Rtx , Km , NULL , NULL , Kd ) ; XHdcp22Rx_ComputeDKey ( Rrx , Rtx , Km , NULL , Ctr , Kd + XHDCP22_RX_AES_SIZE ) ; memcpy ( HashKey , Kd , XHDCP22_RX_KD_SIZE ) ; XHdcp22Rx_Xor ( HashKey + ( XHDCP22_RX_KD_SIZE - XHDCP22_RX_RRX_SIZE ) , Kd + ( XHDCP22_RX_KD_SIZE - XHDCP22_RX_RRX_SIZE ) , Rrx , XHDCP22_RX_RRX_SIZE ) ; XHdcp22Cmn_HmacSha256Hash ( Rn , XHDCP22_RX_RN_SIZE , HashKey , XHDCP22_RX_KD_SIZE , LPrime ) ; }
This function computes LPrime used during HDCP 2.2 locality check.
This function computes LPrime used during HDCP 2 . 2 locality check .
/* dkey0 || dkey 1 */ /* Verify arguments */ /* Generate derived keys dkey0 and dkey1
	   HashKey Kd = dkey0 || dkey1 */ /* HashKey = Kd[256:64] || (Kd[63:0] xor Rrx) */ /* LPrime = HMAC-SHA256(Rn, HashKey) */