XilinxProcessorIPLib/drivers/hdcp22_rx/src/xhdcp22_rx_crypt.c
int XHdcp22Rx_RsaesOaepEncrypt(const XHdcp22_Rx_KpubRx *KpubRx, const u8 *Message,
	const u32 MessageLen, const u8 *MaskingSeed, u8 *EncryptedMessage)
{
	/* Verify arguments */
	Xil_AssertNonvoid(KpubRx != NULL);
	Xil_AssertNonvoid(Message != NULL);
	Xil_AssertNonvoid(MessageLen > 0);
	Xil_AssertNonvoid(MaskingSeed != NULL);
	Xil_AssertNonvoid(EncryptedMessage != NULL);

	u8 em[XHDCP22_RX_N_SIZE];
	int Status;

	/* Step 1: Length checking */
	if(MessageLen > (XHDCP22_RX_N_SIZE - 2*XHDCP22_RX_HASH_SIZE - 2))
	{
		return XST_FAILURE;
	}

	/* Step 2: EME-OAEP Encoding */
	Status = XHdcp22Rx_Pkcs1EmeOaepEncode(Message, MessageLen, MaskingSeed, em);
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Step 3: RSA encryption */
	Status = XHdcp22Rx_Pkcs1Rsaep(KpubRx, em, EncryptedMessage);
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}
/****************************************************************************/
/**
* This function implements the RSAES-OAEP-Encrypt operation. The message
* is encoded using EME-OAEP and then encrypted with the public key
* using RSAEP.
*
* Reference: PKCS#1 v2.1, Section 7.1.1
*
* @param	KpubRx is the RSA public key structure containing the 1024 bit
* 			modulus and 24 bit public exponent.
* @param	Message is the octet string to be encrypted.
* @param	MessageLen is the length of octet string to be encrypted and
* 			must be less than or equal to (nLen - 2*hLen - 2)
* @param	MaskingSeed is the random octet string seed of length hLen
* 			used by EME-OAEP encoding function.
*
* @return	XST_SUCCESS or XST_FAILURE.
*
* @note		None.
*****************************************************************************/
This function implements the RSAES-OAEP-Encrypt operation. The message
is encoded using EME-OAEP and then encrypted with the public key
using RSAEP.


This function implements the RSAES - OAEP - Encrypt operation . The message is encoded using EME - OAEP and then encrypted with the public key using RSAEP .
int XHdcp22Rx_RsaesOaepEncrypt(const XHdcp22_Rx_KpubRx *KpubRx, const u8 *Message,
	const u32 MessageLen, const u8 *MaskingSeed, u8 *EncryptedMessage)
{
	Xil_AssertNonvoid(KpubRx != NULL);
	Xil_AssertNonvoid(Message != NULL);
	Xil_AssertNonvoid(MessageLen > 0);
	Xil_AssertNonvoid(MaskingSeed != NULL);
	Xil_AssertNonvoid(EncryptedMessage != NULL);
	u8 em[XHDCP22_RX_N_SIZE];
	int Status;
	if(MessageLen > (XHDCP22_RX_N_SIZE - 2*XHDCP22_RX_HASH_SIZE - 2))
	{
		return XST_FAILURE;
	}
	Status = XHdcp22Rx_Pkcs1EmeOaepEncode(Message, MessageLen, MaskingSeed, em);
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XHdcp22Rx_Pkcs1Rsaep(KpubRx, em, EncryptedMessage);
	if(Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
int XHdcp22Rx_RsaesOaepEncrypt ( const XHdcp22_Rx_KpubRx * KpubRx , const u8 * Message , const u32 MessageLen , const u8 * MaskingSeed , u8 * EncryptedMessage ) { Xil_AssertNonvoid ( KpubRx != NULL ) ; Xil_AssertNonvoid ( Message != NULL ) ; Xil_AssertNonvoid ( MessageLen > 0 ) ; Xil_AssertNonvoid ( MaskingSeed != NULL ) ; Xil_AssertNonvoid ( EncryptedMessage != NULL ) ; u8 em [ XHDCP22_RX_N_SIZE ] ; int Status ; if ( MessageLen > ( XHDCP22_RX_N_SIZE - 2 * XHDCP22_RX_HASH_SIZE - 2 ) ) { return XST_FAILURE ; } Status = XHdcp22Rx_Pkcs1EmeOaepEncode ( Message , MessageLen , MaskingSeed , em ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XHdcp22Rx_Pkcs1Rsaep ( KpubRx , em , EncryptedMessage ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } return XST_SUCCESS ; }
This function implements the RSAES-OAEP-Encrypt operation.
This function implements the RSAES - OAEP - Encrypt operation .
/* Verify arguments */ /* Step 1: Length checking */ /* Step 2: EME-OAEP Encoding */ /* Step 3: RSA encryption */