XilinxProcessorIPLib/drivers/hdcp22_tx/src/xhdcp22_tx_crypt.c
static int XHdcp22Tx_Mgf1(const u8 *Seed, unsigned int Seedlen,
                          u8 *Mask, unsigned int MaskLen)
{
	/* Verify arguments */
	Xil_AssertNonvoid(Seed != NULL);
	Xil_AssertNonvoid(Seedlen > 0);
	Xil_AssertNonvoid(Mask != NULL);
	Xil_AssertNonvoid(MaskLen > 0);

	u8  Hash[XHDCP22_TX_SHA256_HASH_SIZE];
	u8  HashData[XHDCP22_TX_CERT_PUB_KEY_N_SIZE];	// Seedlen+4
	u32 C;
	u8  Cbig[4];
	u8  T[XHDCP22_TX_CERT_PUB_KEY_N_SIZE]; 		// MaskLen + XHDCP22_TX_SHA256_HASH_SIZE

	/* Step 2: Clear T */
	memset(T, 0x00, sizeof(T));

	/* Step 3: T = T || SHA256(mgfSeed || C) */
	memcpy(HashData, Seed, Seedlen);

	for(C=0; (C*XHDCP22_TX_SHA256_HASH_SIZE) < MaskLen; C++)
	{
		/* Convert counter value to big endian */
		Cbig[0] = ((C >> 24) & 0xFF);
		Cbig[1] = ((C >> 16) & 0xFF);
		Cbig[2] = ((C >> 8) & 0xFF);
		Cbig[3] = (C & 0xFF);

		/* Constructing Hash Input */
		memcpy(HashData+Seedlen, &Cbig, 4);

		/* Computing Hash */
		XHdcp22Cmn_Sha256Hash(HashData, Seedlen+4, Hash);

		/* Appending Hash to T */
		memcpy(T+C*XHDCP22_TX_SHA256_HASH_SIZE, Hash, XHDCP22_TX_SHA256_HASH_SIZE);
	}

	/* Step 4: Output leading maskLen octets of T */
	memcpy(Mask, T, MaskLen);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function is the RSA OAEP masking function.
*
* @param  Seed is the masking seed to use.
* @param  Seedlen is the size of the masking seed .
* @param  Mask is the output mask.
* @param  MaskLen is size of the mask.
*
* @return XST_SUCCESS
*
* @note   None.
*
******************************************************************************/
This function is the RSA OAEP masking function.
This function is the RSA OAEP masking function .
static int XHdcp22Tx_Mgf1(const u8 *Seed, unsigned int Seedlen,
                          u8 *Mask, unsigned int MaskLen)
{
	Xil_AssertNonvoid(Seed != NULL);
	Xil_AssertNonvoid(Seedlen > 0);
	Xil_AssertNonvoid(Mask != NULL);
	Xil_AssertNonvoid(MaskLen > 0);
	u8  Hash[XHDCP22_TX_SHA256_HASH_SIZE];
	u8  HashData[XHDCP22_TX_CERT_PUB_KEY_N_SIZE];	
	u32 C;
	u8  Cbig[4];
	u8  T[XHDCP22_TX_CERT_PUB_KEY_N_SIZE]; 		
	memset(T, 0x00, sizeof(T));
	memcpy(HashData, Seed, Seedlen);
	for(C=0; (C*XHDCP22_TX_SHA256_HASH_SIZE) < MaskLen; C++)
	{
		Cbig[0] = ((C >> 24) & 0xFF);
		Cbig[1] = ((C >> 16) & 0xFF);
		Cbig[2] = ((C >> 8) & 0xFF);
		Cbig[3] = (C & 0xFF);
		memcpy(HashData+Seedlen, &Cbig, 4);
		XHdcp22Cmn_Sha256Hash(HashData, Seedlen+4, Hash);
		memcpy(T+C*XHDCP22_TX_SHA256_HASH_SIZE, Hash, XHDCP22_TX_SHA256_HASH_SIZE);
	}
	memcpy(Mask, T, MaskLen);
	return XST_SUCCESS;
}
static int XHdcp22Tx_Mgf1 ( const u8 * Seed , unsigned int Seedlen , u8 * Mask , unsigned int MaskLen ) { Xil_AssertNonvoid ( Seed != NULL ) ; Xil_AssertNonvoid ( Seedlen > 0 ) ; Xil_AssertNonvoid ( Mask != NULL ) ; Xil_AssertNonvoid ( MaskLen > 0 ) ; u8 Hash [ XHDCP22_TX_SHA256_HASH_SIZE ] ; u8 HashData [ XHDCP22_TX_CERT_PUB_KEY_N_SIZE ] ; u32 C ; u8 Cbig [ 4 ] ; u8 T [ XHDCP22_TX_CERT_PUB_KEY_N_SIZE ] ; memset ( T , 0x00 , sizeof ( T ) ) ; memcpy ( HashData , Seed , Seedlen ) ; for ( C = 0 ; ( C * XHDCP22_TX_SHA256_HASH_SIZE ) < MaskLen ; C ++ ) { Cbig [ 0 ] = ( ( C >> 24 ) & 0xFF ) ; Cbig [ 1 ] = ( ( C >> 16 ) & 0xFF ) ; Cbig [ 2 ] = ( ( C >> 8 ) & 0xFF ) ; Cbig [ 3 ] = ( C & 0xFF ) ; memcpy ( HashData + Seedlen , & Cbig , 4 ) ; XHdcp22Cmn_Sha256Hash ( HashData , Seedlen + 4 , Hash ) ; memcpy ( T + C * XHDCP22_TX_SHA256_HASH_SIZE , Hash , XHDCP22_TX_SHA256_HASH_SIZE ) ; } memcpy ( Mask , T , MaskLen ) ; return XST_SUCCESS ; }
This function is the RSA OAEP masking function.
This function is the RSA OAEP masking function .
/* Verify arguments */ // Seedlen+4 // MaskLen + XHDCP22_TX_SHA256_HASH_SIZE /* Step 2: Clear T */ /* Step 3: T = T || SHA256(mgfSeed || C) */ /* Convert counter value to big endian */ /* Constructing Hash Input */ /* Computing Hash */ /* Appending Hash to T */ /* Step 4: Output leading maskLen octets of T */