XilinxProcessorIPLib/drivers/hdcp22_rx/src/xhdcp22_rx_crypt.c
static int XHdcp22Rx_Pkcs1Rsaep(const XHdcp22_Rx_KpubRx *KpubRx, u8 *Message, u8 *EncryptedMessage)
{
	/* Verify arguments */
	Xil_AssertNonvoid(KpubRx != NULL);
	Xil_AssertNonvoid(Message != NULL);
	Xil_AssertNonvoid(EncryptedMessage != NULL);

	u32 N[XHDCP22_RX_N_SIZE/4];
	u32 E[XHDCP22_RX_N_SIZE/4];
	u32 M[XHDCP22_RX_N_SIZE/4];
	u32 C[XHDCP22_RX_N_SIZE/4];

	/* Convert octet string to integer */
	mpConvFromOctets(N, XHDCP22_RX_N_SIZE/4, KpubRx->N, XHDCP22_RX_N_SIZE);
	mpConvFromOctets(E, XHDCP22_RX_N_SIZE/4, KpubRx->e, 3);
	mpConvFromOctets(M, XHDCP22_RX_N_SIZE/4, Message, XHDCP22_RX_N_SIZE);

	/* Generate cipher text, c = m^e*mod(n) */
	mpModExp(C, M, E, N, XHDCP22_RX_N_SIZE/4);

	/* Convert integer to octet string */
	mpConvToOctets(C, XHDCP22_RX_N_SIZE/4, EncryptedMessage, XHDCP22_RX_N_SIZE);

	return XST_SUCCESS;
}
/****************************************************************************/
/**
* This function implements the RSAEP primitive.
*
* Reference: PKCS#1 v2.1, Section 5.1.1
*
* @param	KpubRx is the RSA public key structure containing the 1024 bit
* 			modulus and 24 bit public exponent.
* @param	Message is the 128 byte octet string to be encrypted.
* @param	EncryptedMessage is the 128 byte octet string after encryption.
*
* @return	XST_SUCCESS or XST_FAILURE.
*
* @note		None.
*****************************************************************************/
This function implements the RSAEP primitive.
This function implements the RSAEP primitive .
static int XHdcp22Rx_Pkcs1Rsaep(const XHdcp22_Rx_KpubRx *KpubRx, u8 *Message, u8 *EncryptedMessage)
{
	Xil_AssertNonvoid(KpubRx != NULL);
	Xil_AssertNonvoid(Message != NULL);
	Xil_AssertNonvoid(EncryptedMessage != NULL);
	u32 N[XHDCP22_RX_N_SIZE/4];
	u32 E[XHDCP22_RX_N_SIZE/4];
	u32 M[XHDCP22_RX_N_SIZE/4];
	u32 C[XHDCP22_RX_N_SIZE/4];
	mpConvFromOctets(N, XHDCP22_RX_N_SIZE/4, KpubRx->N, XHDCP22_RX_N_SIZE);
	mpConvFromOctets(E, XHDCP22_RX_N_SIZE/4, KpubRx->e, 3);
	mpConvFromOctets(M, XHDCP22_RX_N_SIZE/4, Message, XHDCP22_RX_N_SIZE);
	mpModExp(C, M, E, N, XHDCP22_RX_N_SIZE/4);
	mpConvToOctets(C, XHDCP22_RX_N_SIZE/4, EncryptedMessage, XHDCP22_RX_N_SIZE);
	return XST_SUCCESS;
}
static int XHdcp22Rx_Pkcs1Rsaep ( const XHdcp22_Rx_KpubRx * KpubRx , u8 * Message , u8 * EncryptedMessage ) { Xil_AssertNonvoid ( KpubRx != NULL ) ; Xil_AssertNonvoid ( Message != NULL ) ; Xil_AssertNonvoid ( EncryptedMessage != NULL ) ; u32 N [ XHDCP22_RX_N_SIZE / 4 ] ; u32 E [ XHDCP22_RX_N_SIZE / 4 ] ; u32 M [ XHDCP22_RX_N_SIZE / 4 ] ; u32 C [ XHDCP22_RX_N_SIZE / 4 ] ; mpConvFromOctets ( N , XHDCP22_RX_N_SIZE / 4 , KpubRx -> N , XHDCP22_RX_N_SIZE ) ; mpConvFromOctets ( E , XHDCP22_RX_N_SIZE / 4 , KpubRx -> e , 3 ) ; mpConvFromOctets ( M , XHDCP22_RX_N_SIZE / 4 , Message , XHDCP22_RX_N_SIZE ) ; mpModExp ( C , M , E , N , XHDCP22_RX_N_SIZE / 4 ) ; mpConvToOctets ( C , XHDCP22_RX_N_SIZE / 4 , EncryptedMessage , XHDCP22_RX_N_SIZE ) ; return XST_SUCCESS ; }
This function implements the RSAEP primitive.
This function implements the RSAEP primitive .
/* Verify arguments */ /* Convert octet string to integer */ /* Generate cipher text, c = m^e*mod(n) */ /* Convert integer to octet string */