Saturday, January 12, 2013

Tiny Encryption Algorithm (TEA)

TEA is an algorithm with a couple weaknesses. Still, the algorithm is a block cipher notable for its simplicity of description and a C implementation of just a few lines of code.

It was designed by David Wheeler and Roger Needham of the Cambridge Computer Laboratory, first presented at the Fast Software Encryption workshop in Leuven in 1994, and first published in the proceedings of that workshop.

It's an ideal algorithm for testing new frameworks and modes of operation. The first caveat is to make sure your installation produces the proper outputs to reference inputs. Then you can build your framework around it confident that if your output breaks, it's the framework at fault.

The authors suggest in its reference notes that anything you can do with or to DES will work just as well with TEA.

TEA operates on two 32-bit unsigned integers, uses a 128-bit key, and chunks out similar 32-bit unsigned integers. Conveniently you can feed it pointers to character strings of this size and it will cast them to longs.

The original reference implementation accepts three pointers (input,output, key) which makes the necessary CBC mode adapters easier to attach.

Standard usage calls for 64 Feistel rounds which is 32 cycles of the algorithm.
Make n = 32.

The effective key size is 126 bits which is plenty for keeping my diary secure.

Here is the ANSI C implementation I use :
void encipher(unsigned long *const v,unsigned long *const w,
   const unsigned long *const k){

   register unsigned long 
     y=v[0],z=v[1],n=32,
     sum=0,delta=0x9E3779B9,
     a=k[0],b=k[1],c=k[2],d=k[3];

   while(n-->0) {
      sum += delta;
      y += (z << 4)+a ^ z+sum ^ (z >> 5)+b;
      z += (y << 4)+c ^ y+sum ^ (y >> 5)+d;
   }
   w[0]=y; w[1]=z;
}

void decipher(unsigned long *const v,unsigned long *const w,
   const unsigned long *const k){

   register unsigned long 
     y=v[0],z=v[1],n=32,
     sum=0xC6EF3720,delta=0x9E3779B9,
     a=k[0],b=k[1], c=k[2],d=k[3];

   while(n-->0) {
      z -= (y << 4)+c ^ y+sum ^ (y >> 5)+d;
      y -= (z << 4)+a ^ z+sum ^ (z >> 5)+b;
      sum -= delta;
   }
   w[0]=y; w[1]=z;
}


Test Vectors :

Plain Text :

Cipher Key :

Cipher Text :


Tuesday, January 08, 2013

Secure Hash Algorithms (SHA-1 and SHA-256)

Secure Hash Algorithms (SHA-1 and SHA-256)

Secure Hash Algorithms, a form of symmetric encryption, is also included in VIA processors based on the ‘Esther' core.

Implementing the SHA-1 and SHA-256 variants of secure hash, the VIA Padlock SHA engine can deliver real-time data encryption peaking at 5 gigabits per second.

This algorithm is again endorsed and used at all levels of the U.S. Government and operates by compressing the data needed and encrypting it into message digests. Each message digest is created so that the information inside is computationally infeasible to be read by an outside party.

Table: An example of the message digests produced by SHA-1:

Original String SHA-1 Hash Digest
Hello World z7R8yBtZz0+eqead7UEYzPvVFjw=
VB L1SHP0uzGbMUpT4z0zlAdEzfPE=
Vb e0cnhoZRmuoC/Ed51RrW71x1CDw=
Vb e3Pa1F6tMmhPGUfGg1nrfdV31+1=
VB gzt6my3YlrzJiTiucvqBTgM6LtM=

By studying the contents of each SHA-1 secure hash digest it becomes immediately evident that a change of character case on the same word produces a completely different encrypted message.

In fact a change of just one bit within a message causes a completely different secure hash message digest to be created. This allows easy detection of message manipulation, as a message cannot be decrypted, altered even slightly and re-encrypted without producing an entirely different message digest. This is why most governments and organizations in the world now use a implementation of the secure hash algorithm.

SHA-256 is a more secure version of SHA-1, using a 256bit hash algorithm (SHA-1 uses a 160 bit algorithm), and is currently considered completely unbreakable.

Despite this advantage, SHA-1 and SHA-256 secure hash algorithms suffer from one drawback: they all require enormous consumption of processor cycles in the computation of digests, especially when a high throughput is required.

However, VIA has solved this problem by integrating the computation of secure hash algorithms SHA-1 and SHA-256 directly onto the processor die.

By incorporating secure hash into the VIA PadLock Security Engine, VIA has effectively shifted the computational process of large-scale number crunching away from the main processor to the PadLock engine.

Thus, a developer can include real-time secure hash encryption in their applications without worrying that the process will significantly affect other applications or processes running concurrently.


RSA Algorithms and VIA Padlock Montgomery Multiplier

RSA Algorithms and VIA Padlock Montgomery Multiplier

VIA processors featuring the ‘Esther' core include a powerful Montgomery Multiplier, supporting key sizes up to 32K in length, used to accelerate the computational throughput of public key cryptography, such as RSA algorithms.

Used the by U.S. Government, RSA Algorithms are an encryption mechanism based on the asymmetric encryption method, or public key encryption. Public key encryption allows transmission of secure information across unsecured mediums.

Encryption under this system requires that the sender and receiver both have two keys; a private key and a public key. To initiate secure communication under a RSA system the sender asks for the receiver's public key. This key can either be attained by a direct request to the receiver or by looking up a central database of keys. Using the receiver's public key the sender encrypts the information to be sent across the unsecured medium.

When the receiver gets the communiqué they use their private key to decrypt the secured information.

To send information back to the original sender the receiver uses the sender's public key to encrypt the response.

This public key-private key process provides ultra-secure one-to-one communication across unsecured mediums.

VIA's PadLock Montgomery Multiplier expedites this process while at the same time reducing significantly the processor load during the key construction and data encryption by eliminating the processor taxing exercise of the large number division required to perform this type of encryption.



Public Key Cryptography

wiki


GNU Privacy Guard

Wiki


Disk Encryption

Wiki Link


AES - Advanced Encryption Standard


Symmetric-Key Algorithm : Vintage - 2001

AES is based on a design principle known as a substitution-permutation network, and is fast in both software and hardware. AES does not use a Feistel network.

High speed and low RAM requirements were criteria of the AES selection process. Thus AES performs well on a wide variety of hardware, from 8-bit smart cards to high-performance computers.

The design and strength of all key lengths of the AES algorithm (i.e., 128, 192 and 256) are sufficient to protect classified information up to the SECRET level. TOP SECRET information will require use of either the 192 or 256 key lengths.

AES has a block size of 128 bits (16 bytes) and three available key lengths of 128, 192, 256 bits.

Give the algorithm a key, and then feed it 16 byte blocks and get back 16 byte blocks.

It works the same way for either encrypt or decrypt.