Showing posts with label SBC. Show all posts
Showing posts with label SBC. Show all posts

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

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.

 

Thursday, February 10, 2011

RC-2

RC-2(w)


Key length: Minimum 0; maximum 1024, multiple of 8 bits; default 128 bits.
Block size: 8 bytes.

IDEA

IDEA(w)

Block size: 8 bytes.
Key length: 128 bits.

DES

DES(w)

Block size: 8 bytes
Key length: 64 bits as encoded; 56 bits excluding parity bits.

RC-6

RC-6(w)

In cryptography, RC6 is a symmetric key block cipher derived from RC5.

RC6 proper has a block size of 128 bits and supports key sizes of 128, 192 and 256 bits, but, like RC5, it can be parameterized to support a wide variety of word-lengths, key sizes and number of rounds.

CAST5

CAST5

Block size: 8 bytes.
Key length: Minimum 40, maximum 128, multiple of 8 bits; default 128 bits.

Skipjack

Skipjack(w)

Block size: 8 bytes.
Key length: 80 bits.

Serpent

Serpent(w)

Block size: 16 bytes.
Key length: Minimum 0, maximum 256, multiple of 8 bits; default 128 bits.

Twofish

Twofish(w)

In cryptography, Twofish is a symmetric key block cipher with a block size of 128 bits and key sizes up to 256 bits. It was one of the five finalists of the Advanced Encryption Standard contest, but was not selected for standardisation. Twofish is related to the earlier block cipher Blowfish.

On most software platforms Twofish is slightly slower than Rijndael (the chosen algorithm for Advanced Encryption Standard) for 128-bit keys, but somewhat faster for 256-bit keys.

Twofish has a 128-bit block size, a key size ranging from 128 to 256 bits, and is optimized for 32-bit CPUs. Currently there is no successful cryptanalysis of Twofish.

Block sizes : 128 bits
Key sizes : 128, 192 or 256 bits

Blowfish

Blowfish

Blowfish is a keyed, symmetric block cipher, designed in 1993 by Bruce Schneier and included in a large number of cipher suites and encryption products. Blowfish provides a good encryption rate in software and no effective cryptanalysis of it has been found to date. Blowfish is a fast block cipher, except when changing keys.

Bruce Schneier notes that while Blowfish is still in use, he recommends using the more recent Twofish algorithm instead.

Block Size : 64 bits
Key Sizes : 32–448 bits in steps of 8 bits