lib/sw_services/xilskey/examples/xilskey_puf_regeneration_example.c
u32 XilSKey_Puf_Decrypt_data()
{
	u32 Status;
	u32 DataOut;
	XCsuDma_Configure ConfigurValues = {0};

	/* Initialize AES engine */
	xPuf_printf(XPUF_DEBUG_GENERAL, "App: AES initialize \n\r");
	Status = XSecure_AesInitialize(&AesInstance, &CsuDma,
				XSK_PUF_DEVICE_KEY,
				(u32*)&PufIV[0], NULL);

	if (Status != XST_SUCCESS) {
		Status = XPUF_AES_INIT_FAILED_ERROR;
		xPuf_printf(XPUF_DEBUG_GENERAL,
			"App: AES Initialize failed \n\r");
		goto ENDDECRYPT;
	}
	/* Set the data endianness for IV */
	XCsuDma_GetConfig(&CsuDma, XCSUDMA_SRC_CHANNEL,
				&ConfigurValues);
	ConfigurValues.EndianType = 1U;
	XCsuDma_SetConfig(&CsuDma, XCSUDMA_SRC_CHANNEL,
					&ConfigurValues);

	/* Enable CSU DMA Dst channel for byte swapping.*/
	XCsuDma_GetConfig(&CsuDma, XCSUDMA_DST_CHANNEL,
			&ConfigurValues);
	ConfigurValues.EndianType = 1U;
	XCsuDma_SetConfig(&CsuDma, XCSUDMA_DST_CHANNEL,
			&ConfigurValues);

	/* Request to decrypt the data using PUF Key	 */
	xPuf_printf(XPUF_DEBUG_GENERAL, "App: AES decryption \r\n");

	Status = XSecure_AesDecryptData(&AesInstance, &DecOutput[0],
			&EncOutput[0], XSK_DATA_LEN_IN_BYTES,
			&EncOutput[XSK_DATA_LEN_IN_BYTES]);
	if (Status != XST_SUCCESS) {
		xPuf_printf(XPUF_DEBUG_GENERAL,
			"App: AES decrypt failed with error :%08x !!!\r\n",
			Status);
		goto ENDDECRYPT;
	}
	xPuf_printf(XPUF_DEBUG_GENERAL, "App: Decrypted data generated\r\n");

	for (DataOut = 0; DataOut < XSK_DATA_LEN_IN_BYTES ; DataOut++) {
		xPuf_printf(XPUF_DEBUG_GENERAL,
			"%02x", DecOutput[DataOut]);
	}
	xPuf_printf(XPUF_DEBUG_GENERAL, "\r\n");

ENDDECRYPT:
	return Status;
}
/*****************************************************************************/
/**
 * Decrypts the encrypted data blob using PUF key.
 *
 * @return
 *		- XST_SUCCESS encryption was successful.
 *		- ERROR if encryption was unsuccessful.
 *
 ******************************************************************************/
Decrypts the encrypted data blob using PUF key.
@return
- XST_SUCCESS encryption was successful.
- ERROR if encryption was unsuccessful.
Decrypts the encrypted data blob using PUF key . @return - XST_SUCCESS encryption was successful . - ERROR if encryption was unsuccessful .
u32 XilSKey_Puf_Decrypt_data()
{
	u32 Status;
	u32 DataOut;
	XCsuDma_Configure ConfigurValues = {0};
	xPuf_printf(XPUF_DEBUG_GENERAL, "App: AES initialize \n\r");
	Status = XSecure_AesInitialize(&AesInstance, &CsuDma,
				XSK_PUF_DEVICE_KEY,
				(u32*)&PufIV[0], NULL);
	if (Status != XST_SUCCESS) {
		Status = XPUF_AES_INIT_FAILED_ERROR;
		xPuf_printf(XPUF_DEBUG_GENERAL,
			"App: AES Initialize failed \n\r");
		goto ENDDECRYPT;
	}
	XCsuDma_GetConfig(&CsuDma, XCSUDMA_SRC_CHANNEL,
				&ConfigurValues);
	ConfigurValues.EndianType = 1U;
	XCsuDma_SetConfig(&CsuDma, XCSUDMA_SRC_CHANNEL,
					&ConfigurValues);
	XCsuDma_GetConfig(&CsuDma, XCSUDMA_DST_CHANNEL,
			&ConfigurValues);
	ConfigurValues.EndianType = 1U;
	XCsuDma_SetConfig(&CsuDma, XCSUDMA_DST_CHANNEL,
			&ConfigurValues);
	xPuf_printf(XPUF_DEBUG_GENERAL, "App: AES decryption \r\n");
	Status = XSecure_AesDecryptData(&AesInstance, &DecOutput[0],
			&EncOutput[0], XSK_DATA_LEN_IN_BYTES,
			&EncOutput[XSK_DATA_LEN_IN_BYTES]);
	if (Status != XST_SUCCESS) {
		xPuf_printf(XPUF_DEBUG_GENERAL,
			"App: AES decrypt failed with error :%08x !!!\r\n",
			Status);
		goto ENDDECRYPT;
	}
	xPuf_printf(XPUF_DEBUG_GENERAL, "App: Decrypted data generated\r\n");
	for (DataOut = 0; DataOut < XSK_DATA_LEN_IN_BYTES ; DataOut++) {
		xPuf_printf(XPUF_DEBUG_GENERAL,
			"%02x", DecOutput[DataOut]);
	}
	xPuf_printf(XPUF_DEBUG_GENERAL, "\r\n");
ENDDECRYPT:
	return Status;
}
u32 XilSKey_Puf_Decrypt_data ( ) { u32 Status ; u32 DataOut ; XCsuDma_Configure ConfigurValues = { 0 } ; xPuf_printf ( XPUF_DEBUG_GENERAL , " \n \r " ) ; Status = XSecure_AesInitialize ( & AesInstance , & CsuDma , XSK_PUF_DEVICE_KEY , ( u32 * ) & PufIV [ 0 ] , NULL ) ; if ( Status != XST_SUCCESS ) { Status = XPUF_AES_INIT_FAILED_ERROR ; xPuf_printf ( XPUF_DEBUG_GENERAL , " \n \r " ) ; goto ENDDECRYPT ; } XCsuDma_GetConfig ( & CsuDma , XCSUDMA_SRC_CHANNEL , & ConfigurValues ) ; ConfigurValues . EndianType = 1U ; XCsuDma_SetConfig ( & CsuDma , XCSUDMA_SRC_CHANNEL , & ConfigurValues ) ; XCsuDma_GetConfig ( & CsuDma , XCSUDMA_DST_CHANNEL , & ConfigurValues ) ; ConfigurValues . EndianType = 1U ; XCsuDma_SetConfig ( & CsuDma , XCSUDMA_DST_CHANNEL , & ConfigurValues ) ; xPuf_printf ( XPUF_DEBUG_GENERAL , " \r \n " ) ; Status = XSecure_AesDecryptData ( & AesInstance , & DecOutput [ 0 ] , & EncOutput [ 0 ] , XSK_DATA_LEN_IN_BYTES , & EncOutput [ XSK_DATA_LEN_IN_BYTES ] ) ; if ( Status != XST_SUCCESS ) { xPuf_printf ( XPUF_DEBUG_GENERAL , " \r \n " , Status ) ; goto ENDDECRYPT ; } xPuf_printf ( XPUF_DEBUG_GENERAL , " \r \n " ) ; for ( DataOut = 0 ; DataOut < XSK_DATA_LEN_IN_BYTES ; DataOut ++ ) { xPuf_printf ( XPUF_DEBUG_GENERAL , " " , DecOutput [ DataOut ] ) ; } xPuf_printf ( XPUF_DEBUG_GENERAL , " \r \n " ) ; ENDDECRYPT : return Status ; }
Decrypts the encrypted data blob using PUF key.
Decrypts the encrypted data blob using PUF key .
/* Initialize AES engine */ /* Set the data endianness for IV */ /* Enable CSU DMA Dst channel for byte swapping.*/ /* Request to decrypt the data using PUF Key	 */