XilinxProcessorIPLib/drivers/hdcp22_rx/src/xhdcp22_rx_crypt.c
void XHdcp22Rx_ComputeMPrime(const u8 *StreamIdType, const u8 *SeqNumM,
       const u8 *Km, const u8 *Rrx, const u8 *Rtx, u8 *MPrime)
{
	int Idx = 0;
	u8 HashInput[XHDCP22_RX_STREAMID_SIZE + XHDCP22_RX_SEQNUMM_SIZE];
	u8 HashKey[XHDCP22_RX_HASH_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(StreamIdType != NULL);
	Xil_AssertVoid(SeqNumM != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(MPrime != NULL);

	/* HashInput = StreamIdType || SeqNumM */
	memcpy(HashInput, StreamIdType, XHDCP22_RX_STREAMID_SIZE);
	Idx += XHDCP22_RX_STREAMID_SIZE;
	memcpy(&HashInput[Idx], SeqNumM, XHDCP22_RX_SEQNUMM_SIZE);

	/* 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 = SHA256(Kd) */
	XHdcp22Cmn_Sha256Hash(Kd, XHDCP22_RX_KD_SIZE, HashKey);

	/* VPrime = HMAC-SHA256(HashInput, Kd) */
	XHdcp22Cmn_HmacSha256Hash(HashInput, sizeof(HashInput), HashKey, XHDCP22_RX_HASH_SIZE, MPrime);
}
/*****************************************************************************/
/**
* This function computes VPrime used during HDCP 2.2 repeater
* authentication.
*
* Reference: HDCP v2.2, section 2.3
*
* @param  StreamIdType is the 16-bit field in the RepeaterAuth_Send_ReceiverID_List
* 			  message.
* @param  SeqNumM is the 24-bit field in the RepeaterAuth_Stream_Manage
* 			  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  MPrime is the 256-bit value generated for repeater stream
*         management ready.
*
* @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_ComputeMPrime(const u8 *StreamIdType, const u8 *SeqNumM,
       const u8 *Km, const u8 *Rrx, const u8 *Rtx, u8 *MPrime)
{
	int Idx = 0;
	u8 HashInput[XHDCP22_RX_STREAMID_SIZE + XHDCP22_RX_SEQNUMM_SIZE];
	u8 HashKey[XHDCP22_RX_HASH_SIZE];
	u8 Ctr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
	u8 Kd[2 * XHDCP22_RX_AES_SIZE]; 
	Xil_AssertVoid(StreamIdType != NULL);
	Xil_AssertVoid(SeqNumM != NULL);
	Xil_AssertVoid(Km != NULL);
	Xil_AssertVoid(Rrx != NULL);
	Xil_AssertVoid(Rtx != NULL);
	Xil_AssertVoid(MPrime != NULL);
	memcpy(HashInput, StreamIdType, XHDCP22_RX_STREAMID_SIZE);
	Idx += XHDCP22_RX_STREAMID_SIZE;
	memcpy(&HashInput[Idx], SeqNumM, XHDCP22_RX_SEQNUMM_SIZE);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, NULL, Kd);
	XHdcp22Rx_ComputeDKey(Rrx, Rtx, Km, NULL, Ctr, Kd+XHDCP22_RX_AES_SIZE);
	XHdcp22Cmn_Sha256Hash(Kd, XHDCP22_RX_KD_SIZE, HashKey);
	XHdcp22Cmn_HmacSha256Hash(HashInput, sizeof(HashInput), HashKey, XHDCP22_RX_HASH_SIZE, MPrime);
}
void XHdcp22Rx_ComputeMPrime ( const u8 * StreamIdType , const u8 * SeqNumM , const u8 * Km , const u8 * Rrx , const u8 * Rtx , u8 * MPrime ) { int Idx = 0 ; u8 HashInput [ XHDCP22_RX_STREAMID_SIZE + XHDCP22_RX_SEQNUMM_SIZE ] ; u8 HashKey [ XHDCP22_RX_HASH_SIZE ] ; u8 Ctr [ ] = { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 } ; u8 Kd [ 2 * XHDCP22_RX_AES_SIZE ] ; Xil_AssertVoid ( StreamIdType != NULL ) ; Xil_AssertVoid ( SeqNumM != NULL ) ; Xil_AssertVoid ( Km != NULL ) ; Xil_AssertVoid ( Rrx != NULL ) ; Xil_AssertVoid ( Rtx != NULL ) ; Xil_AssertVoid ( MPrime != NULL ) ; memcpy ( HashInput , StreamIdType , XHDCP22_RX_STREAMID_SIZE ) ; Idx += XHDCP22_RX_STREAMID_SIZE ; memcpy ( & HashInput [ Idx ] , SeqNumM , XHDCP22_RX_SEQNUMM_SIZE ) ; XHdcp22Rx_ComputeDKey ( Rrx , Rtx , Km , NULL , NULL , Kd ) ; XHdcp22Rx_ComputeDKey ( Rrx , Rtx , Km , NULL , Ctr , Kd + XHDCP22_RX_AES_SIZE ) ; XHdcp22Cmn_Sha256Hash ( Kd , XHDCP22_RX_KD_SIZE , HashKey ) ; XHdcp22Cmn_HmacSha256Hash ( HashInput , sizeof ( HashInput ) , HashKey , XHDCP22_RX_HASH_SIZE , MPrime ) ; }
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 */ /* HashInput = StreamIdType || SeqNumM */ /* Generate derived keys dkey0 and dkey1
	   HashKey Kd = dkey0 || dkey1 */ /* Hashkey = SHA256(Kd) */ /* VPrime = HMAC-SHA256(HashInput, Kd) */