XilinxProcessorIPLib/drivers/hdcp22_tx_dp/src/xhdcp22_tx.c
int XHdcp22Tx_LoadRevocationTable(XHdcp22_Tx *InstancePtr, const u8 *SrmPtr)
{
	int Result;
	const u8* KPubDpcPtr = NULL;
	const u8* SrmBlockPtr = NULL;
	u8 SrmId;
	u16 SrmVersion;
	u8 SrmGenNr;
	u32 BlockSize;
	u32 LengthField;
	u16 NumDevices;
	const u8* ReceiverIdPtr;
	XHdcp22_Tx_RevocationList* RevocationListPtr = NULL;

	/* Verify arguments */
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(SrmPtr != NULL);

	SrmBlockPtr = SrmPtr;

	/* byte 1 contains the SRM ID and HDCP2 Indicator field */
	SrmId = SrmBlockPtr[0];
	if (SrmId != 0x91) {
		/* Unknown SRM ID so ignore the SRM */
		return XST_FAILURE;
	}

	/* byte 2 is reserved */

	/* byte 3-4 contain the SRM Version.
	 * Value is in big endian format, Microblaze is little endian */
	SrmVersion  = SrmBlockPtr[2] << 8; // MSB
	SrmVersion |= SrmBlockPtr[3];      // LSB

	/* byte 5 contains the SRM Generation Number */
	SrmGenNr = SrmBlockPtr[4];

	/* byte 6,7,8 contain the length of the first-generation SRM in bytes.
	 * Value is in big endian format, Microblaze is little endian */
	LengthField  = SrmBlockPtr[5] << 16; // MSB
	LengthField |= SrmBlockPtr[6] << 8;
	LengthField |= SrmBlockPtr[7];       // LSB

	/* The size of the first-generation SRM block */
	BlockSize = LengthField + 5;

	KPubDpcPtr = XHdcp22Tx_GetKPubDpc(InstancePtr);

	/* Verify the first-generation SRM block */
	Result = XHdcp22Tx_VerifySRM(SrmBlockPtr,
	                             BlockSize,
	                             KPubDpcPtr, // N
	                             XHDCP22_TX_KPUB_DCP_LLC_N_SIZE,
	                             &KPubDpcPtr[XHDCP22_TX_KPUB_DCP_LLC_N_SIZE], // e
	                             XHDCP22_TX_KPUB_DCP_LLC_E_SIZE);
	if (Result != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Update the SRM Block pointer */
	SrmBlockPtr += BlockSize;

	for (int i = 1; i < SrmGenNr; i++) {
		/* byte 1-2 contain the length of the next-generation SRM in bytes.
		 * Value is in big endian format, Microblaze is little endian */
		LengthField  = SrmBlockPtr[0] << 8; // MSB
		LengthField |= SrmBlockPtr[1];      // LSB

		/* The size of the next-generation SRM block */
		BlockSize = LengthField;

		/* Verify the next-generation SRM block */
		Result = XHdcp22Tx_VerifySRM(SrmBlockPtr,
		                             BlockSize,
		                             KPubDpcPtr, // N
		                             XHDCP22_TX_KPUB_DCP_LLC_N_SIZE,
		                             &KPubDpcPtr[XHDCP22_TX_KPUB_DCP_LLC_N_SIZE], // e
		                             XHDCP22_TX_KPUB_DCP_LLC_E_SIZE);
		if (Result != XST_SUCCESS) {
			return XST_FAILURE;
		}

		/* Update the SRM Block pointer */
		SrmBlockPtr += BlockSize;
	}

	/* SRM has been verified to be correct.
	 * Now extract the revocation information */
	SrmBlockPtr = SrmPtr;

	/* byte 6,7,8 contain the length of the first-generation SRM in bytes.
	 * Value is in big endian format, Microblaze is little endian */
	LengthField  = SrmBlockPtr[5] << 16; // MSB
	LengthField |= SrmBlockPtr[6] << 8;
	LengthField |= SrmBlockPtr[7];       // LSB

	/* The size of the first-generation SRM block */
	BlockSize = LengthField + 5;

	/* byte 9,10 contain the number of devices of the firs-generation SRM block
	 * Value is in big endian format, Microblaze is little endian */
	NumDevices  = SrmBlockPtr[8] << 2; // MSB
	NumDevices |= SrmBlockPtr[9] >> 6; // LSB

	RevocationListPtr = XHdcp22Tx_GetRevocationReceiverIdList(InstancePtr);
	RevocationListPtr->NumDevices = 0;

	/* byte 12 will contain the first byte of the first receiver ID */
	ReceiverIdPtr = &SrmBlockPtr[12];

	for (int i = 0; i < NumDevices; i++) {
		/* Is the revocation list full? */
		if (RevocationListPtr->NumDevices == XHDCP22_TX_REVOCATION_LIST_MAX_DEVICES) {
			return XST_FAILURE;
		}

		memcpy(RevocationListPtr->ReceiverId[RevocationListPtr->NumDevices], ReceiverIdPtr, XHDCP22_TX_SRM_RCVID_SIZE);
		RevocationListPtr->NumDevices++;
		ReceiverIdPtr += XHDCP22_TX_SRM_RCVID_SIZE;
	}

	/* Update the SRM Block pointer */
	SrmBlockPtr += BlockSize;

	for (int j = 1; j < SrmGenNr; j++) {
		/* byte 1-2 contain the length of the next-generation SRM in bytes.
		 * Value is in big endian format, Microblaze is little endian */
		LengthField  = SrmBlockPtr[0] << 8; // MSB
		LengthField |= SrmBlockPtr[1];      // LSB

		/* The size of the next-generation SRM block */
		BlockSize = LengthField;

		/* byte 3,4 contain the number of devices of the next-generation SRM block
		 * Value is in big endian format, Microblaze is little endian */
		NumDevices  = (SrmBlockPtr[2] & 0x3) << 8; // MSB
		NumDevices |=  SrmBlockPtr[3]; // LSB

		/* byte 5 will contain the first byte of the first receiver ID */
		ReceiverIdPtr = &SrmBlockPtr[4];

		for (int i = 0; i < NumDevices; i++) {
			/* Is the revocation list full? */
			if (RevocationListPtr->NumDevices == XHDCP22_TX_REVOCATION_LIST_MAX_DEVICES) {
				return XST_FAILURE;
			}

			memcpy(RevocationListPtr->ReceiverId[RevocationListPtr->NumDevices], ReceiverIdPtr, XHDCP22_TX_SRM_RCVID_SIZE);
			RevocationListPtr->NumDevices++;
			ReceiverIdPtr += XHDCP22_TX_SRM_RCVID_SIZE;
		}

		/* Update the SRM Block pointer */
		SrmBlockPtr += BlockSize;
	}

	InstancePtr->Info.IsRevocationListValid = (TRUE);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function is used to load the system renewability messages (SRMs)
* which carries the Receiver ID revocation list.
*
* @param	InstancePtr is a pointer to the XHdcp22_Tx core instance.
* @param	SrmPtr is a pointer to an array.
*
* @return
*    - XST_SUCCESS if loaded SRM successfully.
*    - XST_FAILURE if SRM signature verification failed.
*
* @note		None.
*
******************************************************************************/
This function is used to load the system renewability messages (SRMs)
which carries the Receiver ID revocation list.
This function is used to load the system renewability messages ( SRMs ) which carries the Receiver ID revocation list .
int XHdcp22Tx_LoadRevocationTable(XHdcp22_Tx *InstancePtr, const u8 *SrmPtr)
{
	int Result;
	const u8* KPubDpcPtr = NULL;
	const u8* SrmBlockPtr = NULL;
	u8 SrmId;
	u16 SrmVersion;
	u8 SrmGenNr;
	u32 BlockSize;
	u32 LengthField;
	u16 NumDevices;
	const u8* ReceiverIdPtr;
	XHdcp22_Tx_RevocationList* RevocationListPtr = NULL;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(SrmPtr != NULL);
	SrmBlockPtr = SrmPtr;
	SrmId = SrmBlockPtr[0];
	if (SrmId != 0x91) {
		return XST_FAILURE;
	}
	SrmVersion  = SrmBlockPtr[2] << 8; 
	SrmVersion |= SrmBlockPtr[3];      
	SrmGenNr = SrmBlockPtr[4];
	LengthField  = SrmBlockPtr[5] << 16; 
	LengthField |= SrmBlockPtr[6] << 8;
	LengthField |= SrmBlockPtr[7];       
	BlockSize = LengthField + 5;
	KPubDpcPtr = XHdcp22Tx_GetKPubDpc(InstancePtr);
	Result = XHdcp22Tx_VerifySRM(SrmBlockPtr,
	                             BlockSize,
	                             KPubDpcPtr, 
	                             XHDCP22_TX_KPUB_DCP_LLC_N_SIZE,
	                             &KPubDpcPtr[XHDCP22_TX_KPUB_DCP_LLC_N_SIZE], 
	                             XHDCP22_TX_KPUB_DCP_LLC_E_SIZE);
	if (Result != XST_SUCCESS) {
		return XST_FAILURE;
	}
	SrmBlockPtr += BlockSize;
	for (int i = 1; i < SrmGenNr; i++) {
		LengthField  = SrmBlockPtr[0] << 8; 
		LengthField |= SrmBlockPtr[1];      
		BlockSize = LengthField;
		Result = XHdcp22Tx_VerifySRM(SrmBlockPtr,
		                             BlockSize,
		                             KPubDpcPtr, 
		                             XHDCP22_TX_KPUB_DCP_LLC_N_SIZE,
		                             &KPubDpcPtr[XHDCP22_TX_KPUB_DCP_LLC_N_SIZE], 
		                             XHDCP22_TX_KPUB_DCP_LLC_E_SIZE);
		if (Result != XST_SUCCESS) {
			return XST_FAILURE;
		}
		SrmBlockPtr += BlockSize;
	}
	SrmBlockPtr = SrmPtr;
	LengthField  = SrmBlockPtr[5] << 16; 
	LengthField |= SrmBlockPtr[6] << 8;
	LengthField |= SrmBlockPtr[7];       
	BlockSize = LengthField + 5;
	NumDevices  = SrmBlockPtr[8] << 2; 
	NumDevices |= SrmBlockPtr[9] >> 6; 
	RevocationListPtr = XHdcp22Tx_GetRevocationReceiverIdList(InstancePtr);
	RevocationListPtr->NumDevices = 0;
	ReceiverIdPtr = &SrmBlockPtr[12];
	for (int i = 0; i < NumDevices; i++) {
		if (RevocationListPtr->NumDevices == XHDCP22_TX_REVOCATION_LIST_MAX_DEVICES) {
			return XST_FAILURE;
		}
		memcpy(RevocationListPtr->ReceiverId[RevocationListPtr->NumDevices], ReceiverIdPtr, XHDCP22_TX_SRM_RCVID_SIZE);
		RevocationListPtr->NumDevices++;
		ReceiverIdPtr += XHDCP22_TX_SRM_RCVID_SIZE;
	}
	SrmBlockPtr += BlockSize;
	for (int j = 1; j < SrmGenNr; j++) {
		LengthField  = SrmBlockPtr[0] << 8; 
		LengthField |= SrmBlockPtr[1];      
		BlockSize = LengthField;
		NumDevices  = (SrmBlockPtr[2] & 0x3) << 8; 
		NumDevices |=  SrmBlockPtr[3]; 
		ReceiverIdPtr = &SrmBlockPtr[4];
		for (int i = 0; i < NumDevices; i++) {
			if (RevocationListPtr->NumDevices == XHDCP22_TX_REVOCATION_LIST_MAX_DEVICES) {
				return XST_FAILURE;
			}
			memcpy(RevocationListPtr->ReceiverId[RevocationListPtr->NumDevices], ReceiverIdPtr, XHDCP22_TX_SRM_RCVID_SIZE);
			RevocationListPtr->NumDevices++;
			ReceiverIdPtr += XHDCP22_TX_SRM_RCVID_SIZE;
		}
		SrmBlockPtr += BlockSize;
	}
	InstancePtr->Info.IsRevocationListValid = (TRUE);
	return XST_SUCCESS;
}
int XHdcp22Tx_LoadRevocationTable ( XHdcp22_Tx * InstancePtr , const u8 * SrmPtr ) { int Result ; const u8 * KPubDpcPtr = NULL ; const u8 * SrmBlockPtr = NULL ; u8 SrmId ; u16 SrmVersion ; u8 SrmGenNr ; u32 BlockSize ; u32 LengthField ; u16 NumDevices ; const u8 * ReceiverIdPtr ; XHdcp22_Tx_RevocationList * RevocationListPtr = NULL ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( SrmPtr != NULL ) ; SrmBlockPtr = SrmPtr ; SrmId = SrmBlockPtr [ 0 ] ; if ( SrmId != 0x91 ) { return XST_FAILURE ; } SrmVersion = SrmBlockPtr [ 2 ] << 8 ; SrmVersion |= SrmBlockPtr [ 3 ] ; SrmGenNr = SrmBlockPtr [ 4 ] ; LengthField = SrmBlockPtr [ 5 ] << 16 ; LengthField |= SrmBlockPtr [ 6 ] << 8 ; LengthField |= SrmBlockPtr [ 7 ] ; BlockSize = LengthField + 5 ; KPubDpcPtr = XHdcp22Tx_GetKPubDpc ( InstancePtr ) ; Result = XHdcp22Tx_VerifySRM ( SrmBlockPtr , BlockSize , KPubDpcPtr , XHDCP22_TX_KPUB_DCP_LLC_N_SIZE , & KPubDpcPtr [ XHDCP22_TX_KPUB_DCP_LLC_N_SIZE ] , XHDCP22_TX_KPUB_DCP_LLC_E_SIZE ) ; if ( Result != XST_SUCCESS ) { return XST_FAILURE ; } SrmBlockPtr += BlockSize ; for ( int i = 1 ; i < SrmGenNr ; i ++ ) { LengthField = SrmBlockPtr [ 0 ] << 8 ; LengthField |= SrmBlockPtr [ 1 ] ; BlockSize = LengthField ; Result = XHdcp22Tx_VerifySRM ( SrmBlockPtr , BlockSize , KPubDpcPtr , XHDCP22_TX_KPUB_DCP_LLC_N_SIZE , & KPubDpcPtr [ XHDCP22_TX_KPUB_DCP_LLC_N_SIZE ] , XHDCP22_TX_KPUB_DCP_LLC_E_SIZE ) ; if ( Result != XST_SUCCESS ) { return XST_FAILURE ; } SrmBlockPtr += BlockSize ; } SrmBlockPtr = SrmPtr ; LengthField = SrmBlockPtr [ 5 ] << 16 ; LengthField |= SrmBlockPtr [ 6 ] << 8 ; LengthField |= SrmBlockPtr [ 7 ] ; BlockSize = LengthField + 5 ; NumDevices = SrmBlockPtr [ 8 ] << 2 ; NumDevices |= SrmBlockPtr [ 9 ] >> 6 ; RevocationListPtr = XHdcp22Tx_GetRevocationReceiverIdList ( InstancePtr ) ; RevocationListPtr -> NumDevices = 0 ; ReceiverIdPtr = & SrmBlockPtr [ 12 ] ; for ( int i = 0 ; i < NumDevices ; i ++ ) { if ( RevocationListPtr -> NumDevices == XHDCP22_TX_REVOCATION_LIST_MAX_DEVICES ) { return XST_FAILURE ; } memcpy ( RevocationListPtr -> ReceiverId [ RevocationListPtr -> NumDevices ] , ReceiverIdPtr , XHDCP22_TX_SRM_RCVID_SIZE ) ; RevocationListPtr -> NumDevices ++ ; ReceiverIdPtr += XHDCP22_TX_SRM_RCVID_SIZE ; } SrmBlockPtr += BlockSize ; for ( int j = 1 ; j < SrmGenNr ; j ++ ) { LengthField = SrmBlockPtr [ 0 ] << 8 ; LengthField |= SrmBlockPtr [ 1 ] ; BlockSize = LengthField ; NumDevices = ( SrmBlockPtr [ 2 ] & 0x3 ) << 8 ; NumDevices |= SrmBlockPtr [ 3 ] ; ReceiverIdPtr = & SrmBlockPtr [ 4 ] ; for ( int i = 0 ; i < NumDevices ; i ++ ) { if ( RevocationListPtr -> NumDevices == XHDCP22_TX_REVOCATION_LIST_MAX_DEVICES ) { return XST_FAILURE ; } memcpy ( RevocationListPtr -> ReceiverId [ RevocationListPtr -> NumDevices ] , ReceiverIdPtr , XHDCP22_TX_SRM_RCVID_SIZE ) ; RevocationListPtr -> NumDevices ++ ; ReceiverIdPtr += XHDCP22_TX_SRM_RCVID_SIZE ; } SrmBlockPtr += BlockSize ; } InstancePtr -> Info . IsRevocationListValid = ( TRUE ) ; return XST_SUCCESS ; }
This function is used to load the system renewability messages (SRMs)
which carries the Receiver ID revocation list.
This function is used to load the system renewability messages ( SRMs ) which carries the Receiver ID revocation list .
/* Verify arguments */ /* byte 1 contains the SRM ID and HDCP2 Indicator field */ /* Unknown SRM ID so ignore the SRM */ /* byte 2 is reserved */ /* byte 3-4 contain the SRM Version.
	 * Value is in big endian format, Microblaze is little endian */ // MSB // LSB /* byte 5 contains the SRM Generation Number */ /* byte 6,7,8 contain the length of the first-generation SRM in bytes.
	 * Value is in big endian format, Microblaze is little endian */ // MSB // LSB /* The size of the first-generation SRM block */ /* Verify the first-generation SRM block */ // N // e /* Update the SRM Block pointer */ /* byte 1-2 contain the length of the next-generation SRM in bytes.
		 * Value is in big endian format, Microblaze is little endian */ // MSB // LSB /* The size of the next-generation SRM block */ /* Verify the next-generation SRM block */ // N // e /* Update the SRM Block pointer */ /* SRM has been verified to be correct.
	 * Now extract the revocation information */ /* byte 6,7,8 contain the length of the first-generation SRM in bytes.
	 * Value is in big endian format, Microblaze is little endian */ // MSB // LSB /* The size of the first-generation SRM block */ /* byte 9,10 contain the number of devices of the firs-generation SRM block
	 * Value is in big endian format, Microblaze is little endian */ // MSB // LSB /* byte 12 will contain the first byte of the first receiver ID */ /* Is the revocation list full? */ /* Update the SRM Block pointer */ /* byte 1-2 contain the length of the next-generation SRM in bytes.
		 * Value is in big endian format, Microblaze is little endian */ // MSB // LSB /* The size of the next-generation SRM block */ /* byte 3,4 contain the number of devices of the next-generation SRM block
		 * Value is in big endian format, Microblaze is little endian */ // MSB // LSB /* byte 5 will contain the first byte of the first receiver ID */ /* Is the revocation list full? */ /* Update the SRM Block pointer */