.

Monday, March 19, 2012

[Ruby] OFB (Output Feedback)

          Hello, Reader ^^! Back again with source code. This time is is OFB (Output Feedback) which is made using Ruby programming language. This one, like CFB, also encrypts block per block from previous blocks. The first block came from Initialization Vector. The difference is the OFB uses Encryption Block from previous Encryption Block. The Encryption Block used in this example is the simple XOR. You can define your own Encryption Block like doing shift left, shift right, etc. Now, let me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 10101
IV generated : 10001
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000




IV(only 1st block), then from the Third row 10001 001001000100100 
Key10101 10101 10101 10101 
Encryption Block (a xor b; a is IV, b is key) 00100100010010010001
Plaintext (in bits)
01011 11111 01010 10000
Xor-ed (Plaintext with third row)  
01111011100111000001


The result of encryption is 01111011100111000001.

Okay, that's all I can say. Thank you for reading ^^!







No comments:

Post a Comment