XilinxProcessorIPLib/drivers/hdcp22_rx/src/xhdcp22_rx_crypt.c
void XHdcp22Rx_ComputeVPrime(const u8 *ReceiverIdList, u32 ReceiverIdListSize,
       const u8 *RxInfo, const u8 *SeqNumV, const u8 *Km, const u8 *Rrx,
       const u8 *Rtx, u8 *VPrime)
{
	int Idx = 0;
	u8 HashInput[XHDCP22_RX_SEQNUMV_SIZE +
					XHDCP22_RX_RXINFO_SIZE +
					(XHDCP22_RX_MAX_DEVICE_COUNT*XHDCP22_RX_RCVID_SIZE)];
	int HashInputSize = (ReceiverIdListSize*XHDCP22_RX_RCVID_SIZE) +
					XHDCP22_RX_SEQNUMV_SIZE + XHDCP22_RX_RXINFO_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(ReceiverIdList != NULL);
	Xil_AssertVoid(ReceiverIdListSize > 0);
	Xil_AssertVoid(RxInfo != NULL);
	Xil_AssertVoid(SeqNumV != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(VPrime != 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 = ReceiverIdList || RxInfo || SeqNumV */
	memcpy(HashInput, ReceiverIdList, ReceiverIdListSize*XHDCP22_RX_RCVID_SIZE);
	Idx += ReceiverIdListSize*XHDCP22_RX_RCVID_SIZE;
	memcpy(&HashInput[Idx], RxInfo, XHDCP22_RX_RXINFO_SIZE);
	Idx += XHDCP22_RX_RXINFO_SIZE;
	memcpy(&HashInput[Idx], SeqNumV, XHDCP22_RX_SEQNUMV_SIZE);

	/* VPrime = HMAC-SHA256(HashInput, Kd) */
	XHdcp22Cmn_HmacSha256Hash(HashInput, HashInputSize, Kd, XHDCP22_RX_KD_SIZE, VPrime);
}
/*****************************************************************************/
/**
* This function computes VPrime used during HDCP 2.2 repeater
* authentication.
*
* Reference: HDCP v2.2, section 2.3
*
* @param  ReceiverIdList is a list of downstream receivers IDs in big-endian
*         order. Each receiver ID is 5 Bytes.
* @param  ReceiverIdListSize is the number of receiver Ids in ReceiverIdList.
*         There can be between 1 and 31 devices in the list.
* @param  RxInfo is the 16-bit field in the RepeaterAuth_Send_ReceiverID_List
*         message.
* @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  VPrime is the 256-bit value generated for repeater authentication.
*
* @return None.
*
* @note   None.
******************************************************************************/
This function computes VPrime used during HDCP 2.2 repeater
authentication.


This function computes VPrime used during HDCP 2 . 2 repeater authentication .
void XHdcp22Rx_ComputeVPrime(const u8 *ReceiverIdList, u32 ReceiverIdListSize,
       const u8 *RxInfo, const u8 *SeqNumV, const u8 *Km, const u8 *Rrx,
       const u8 *Rtx, u8 *VPrime)
{
	int Idx = 0;
	u8 HashInput[XHDCP22_RX_SEQNUMV_SIZE +
					XHDCP22_RX_RXINFO_SIZE +
					(XHDCP22_RX_MAX_DEVICE_COUNT*XHDCP22_RX_RCVID_SIZE)];
	int HashInputSize = (ReceiverIdListSize*XHDCP22_RX_RCVID_SIZE) +
					XHDCP22_RX_SEQNUMV_SIZE + XHDCP22_RX_RXINFO_SIZE;
	u8 Ctr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
	u8 Kd[2 * XHDCP22_RX_AES_SIZE]; 
	Xil_AssertVoid(ReceiverIdList != NULL);
	Xil_AssertVoid(ReceiverIdListSize > 0);
	Xil_AssertVoid(RxInfo != NULL);
	Xil_AssertVoid(SeqNumV != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(VPrime != NULL);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, NULL, Kd);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, Ctr, Kd+XHDCP22_RX_AES_SIZE);
	memcpy(HashInput, ReceiverIdList, ReceiverIdListSize*XHDCP22_RX_RCVID_SIZE);
	Idx += ReceiverIdListSize*XHDCP22_RX_RCVID_SIZE;
	memcpy(&HashInput[Idx], RxInfo, XHDCP22_RX_RXINFO_SIZE);
	Idx += XHDCP22_RX_RXINFO_SIZE;
	memcpy(&HashInput[Idx], SeqNumV, XHDCP22_RX_SEQNUMV_SIZE);
	XHdcp22Cmn_HmacSha256Hash(HashInput, HashInputSize, Kd, XHDCP22_RX_KD_SIZE, VPrime);
}
void XHdcp22Rx_ComputeVPrime ( const u8 * ReceiverIdList , u32 ReceiverIdListSize , const u8 * RxInfo , const u8 * SeqNumV , const u8 * Km , const u8 * Rrx , const u8 * Rtx , u8 * VPrime ) { int Idx = 0 ; u8 HashInput [ XHDCP22_RX_SEQNUMV_SIZE + XHDCP22_RX_RXINFO_SIZE + ( XHDCP22_RX_MAX_DEVICE_COUNT * XHDCP22_RX_RCVID_SIZE ) ] ; int HashInputSize = ( ReceiverIdListSize * XHDCP22_RX_RCVID_SIZE ) + XHDCP22_RX_SEQNUMV_SIZE + XHDCP22_RX_RXINFO_SIZE ; u8 Ctr [ ] = { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 } ; u8 Kd [ 2 * XHDCP22_RX_AES_SIZE ] ; Xil_AssertVoid ( ReceiverIdList != NULL ) ; Xil_AssertVoid ( ReceiverIdListSize > 0 ) ; Xil_AssertVoid ( RxInfo != NULL ) ; Xil_AssertVoid ( SeqNumV != NULL ) ; Xil_AssertVoid ( Km != NULL ) ; Xil_AssertVoid ( Rrx != NULL ) ; Xil_AssertVoid ( Rtx != NULL ) ; Xil_AssertVoid ( VPrime != NULL ) ; XHdcp22Rx_ComputeDKey ( Rrx , Rtx , Km , NULL , NULL , Kd ) ; XHdcp22Rx_ComputeDKey ( Rrx , Rtx , Km , NULL , Ctr , Kd + XHDCP22_RX_AES_SIZE ) ; memcpy ( HashInput , ReceiverIdList , ReceiverIdListSize * XHDCP22_RX_RCVID_SIZE ) ; Idx += ReceiverIdListSize * XHDCP22_RX_RCVID_SIZE ; memcpy ( & HashInput [ Idx ] , RxInfo , XHDCP22_RX_RXINFO_SIZE ) ; Idx += XHDCP22_RX_RXINFO_SIZE ; memcpy ( & HashInput [ Idx ] , SeqNumV , XHDCP22_RX_SEQNUMV_SIZE ) ; XHdcp22Cmn_HmacSha256Hash ( HashInput , HashInputSize , Kd , XHDCP22_RX_KD_SIZE , VPrime ) ; }
This function computes VPrime used during HDCP 2.2 repeater
authentication.
This function computes VPrime used during HDCP 2 . 2 repeater authentication .
/* dkey0 || dkey 1 */ /* Verify arguments */ /* Generate derived keys dkey0 and dkey1
	   HashKey Kd = dkey0 || dkey1 */ /* HashInput = ReceiverIdList || RxInfo || SeqNumV */ /* VPrime = HMAC-SHA256(HashInput, Kd) */