.

Showing posts with label feedback. Show all posts
Showing posts with label feedback. Show all posts

Friday, March 23, 2012

[C#] OFB (Output Feedback)

          Hello, Reader ^^! Back again with source code. This time is is OFB (Output Feedback) which is made using C# 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 ^^!







[C#] CFB (Cipher Feedback)

          Hello, Reader ^^! Back again with source code. This time is is CFB (Cipher Feedback) which is made using C# programming language. This one, like CBC, also encrypts block per block from previous blocks. The first block uses Initialization Vector. The IV (and the next xor-ed plaintext and Encryption Block), will be encrypted into Encryption Block. After that, it will xor-ed with plaintext which will be the ciphertext. A mistake just a bit can lead mistake also in the encryption and decryption. 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 Fifth row 10001 10001 11011 01110 
Key01011 10101 11111 00000 
Encryption Block (a xor b; a is first row, b is key) 11010001000010001110
Plaintext (in bits)
01011 11111 01010 10000
Xor-ed (Plaintext with third row)  
10001110110111011111


The result of encryption is 10001110110111011111. If you see at the 3rd column, at the 2nd row, you will see the value is taken from 2nd column, 5th row. Yup, that's why it is chaining.

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







Sunday, March 18, 2012

[Ruby] CFB (Cipher Feedback)

          Hello, Reader ^^! Back again with source code. This time is is CFB (Cipher Feedback) which is made using Ruby programming language. This one, like CBC, also encrypts block per block from previous blocks. The first block uses Initialization Vector. The IV (and the next xor-ed plaintext and Encryption Block), will be encrypted into Encryption Block. After that, it will xor-ed with plaintext which will be the ciphertext. A mistake just a bit can lead mistake also in the encryption and decryption. 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 Fifth row 10001 10001 11011 01110 
Key01011 10101 11111 00000 
Encryption Block (a xor b; a is first row, b is key) 11010001000010001110
Plaintext (in bits)
01011 11111 01010 10000
Xor-ed (Plaintext with third row)  
10001110110111011111


The result of encryption is 10001110110111011111. If you see at the 3rd column, at the 2nd row, you will see the value is taken from 2nd column, 5th row. Yup, that's why it is chaining.

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