Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Jun 24, 2008


Feedback


Yes No

Related Categories

Technology

Related Links - Developer Zone

Related Links - Products and Services

Extended Tiny Encryption Algorithm (XTEA) for LabVIEW FPGA

0 ratings | 0.00 out of 5
Print | PDF

Overview

The Extended Tiny Encryption Algorithm (XTEA) is a block cipher encryption algorithm that is very simple to implement, has fast execution time, and takes minimal storage space. It was designed to improve on weaknesses of the XTEA algorithm. The included example is to be compiled and used on a LabVIEW FPGA target.

Algorithm and Uses

XTEA was designed David Wheeler and Roger Needhamof the Cambridge University Computer Laboratory and made available in 1996.  It is designed to encrypt data through many iteration cycles rather than memory consuming arrays of data.   XTEA is not subject to any patents.

The encrypt routine, written in C, is described below from the author’s paper on XTEA and assumes 32 bit word size.  Additionally, the Key is stored as k[0…3] and the data is v[0] and v[1].

void encipher(unsigned int num_rounds, unsigned long* v, unsigned long* k) {

    unsigned long v0=v[0], v1=v[1], i;

    unsigned long sum=0, delta=0x9E3779B9;

    for(i=0; i<num_rounds; i++) {

       v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]);

        sum += delta;

        v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]);

    }

    v[0]=v0; v[1]=v1;

}

Because of the small size, the algorithm is ideal for embedded applications and can easily be implemented in hardware, such as an FPGA.  Additional security can be added by increasing the number of iterations.  The default number of iterations is 32, but can be configurable and should be multiples of 32.

LabVIEW Design

The code for LabVIEW FPGA has been created using 2 VIs – Encrpt.vi and Decrypt.vi.

To use the Encrypt VI, the inputs are two 32-bit U32 data values, the number of iterations to run the VI and the 128-bit key value.  The key is represented as a four 32-bit hexadecimal values.  Key values can be created using a 128-bit key generator.  The output from the system is two 32 bit values that are the encrypted version of the input.

                                                                                                             

Encrpt.vi

To use the decrypt VI the inputs are two 32-bit U32 data values, the number of iterations, and the 128-bit key value.  The key is represented as four 32-bit hexadecimal values.  The input data should be the encrypted data from the Encrypt.vi and the same 128-bit key value used in for encryption.

Decrypt.vi

An additional sub-VI folder is included in the project and is used to implement the logic of the algorithms.  No modifications are necessary.

Usage Example Code

Add the Encrypt, Decrypt VIs and subVI folder to the FPGA Target.

The following Block Diagram illustrates how the Encrypt and Decrypt algorithms can be used in a project.

 

References

David Wheeler and Roger Needham Publication

Wikipedia – Extended Tiny Encryption Algorithm

 Tiny Encryption Algorithm (TEA) for LabVIEW FPGA

Downloads

xtea.zip

0 ratings | 0.00 out of 5
Print | PDF

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).