Commit 3580bb9d authored by SHIVAM SOOD's avatar SHIVAM SOOD

Init commit

parents
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
AES:
AES always works on 128 bit blocks.
A 128 bits key is expanded into 11 round keys of size 128 bits.
A 192 bits key is expanded into 13 round keys of size 128 bits.
A 256 bits key is expanded into 15 round keys of size 128 bits.
For AES, increasing key size increases security, but the cipher text size remains same for same plain text because it still uses 128 bits as block length. Cipher text size is independent of the key size.
On changing IV, the cipher text will change for a given plain text and key. If IV is greater than required the excess IV is ignored.
Padding is added to plain text to make it a multiple of 128 bits. If plain text is already a multiple of 128, extra 128 bits are padded.
----------------------------------------------------------------------------------------------------------------------------
DES:
DES actually has a key length of 64 bits, however 8 bits are used for parity, therefore the effective key length is 56 bits.
In 3DES keys are 128 (Option 1) or 192 bits (Option 2) long. However, 1 out of 8 bits is used for redundancy and do not contribute to security. The effective key length is respectively 112 or 168 bits.
On changing key size(for both DES and 3DES), only the difficulty of cracking increases or decreases; Cipher text size stays the same.
----------------------------------------------------------------------------------------------------------------------------
The disadvantage of ECB mode is a lack of diffusion. Because ECB encrypts identical plain text blocks into identical cipher text blocks, it does not hide data patterns well. In some senses, it doesn't provide serious message confidentiality, and it is not recommended for use in cryptographic protocols at all.
A striking example of the degree to which ECB can leave plain text data patterns in the cipher text can be seen when ECB mode is used to encrypt a bitmap image which uses large areas of uniform color. While the color of each individual pixel is encrypted, the overall image may still be discerned, as the pattern of identically colored pixels in the original remains in the encrypted version.
The other modes (CBC, OFB, CFB) arose mainly to address the shortcomings of ECB. The chaining helps avoid this leak of information.
----------------------------------------------------------------------------------------------------------------------------
1 bit change in cipher text results in:
ECB: affects the current block (for AES-128, this is 16 bytes)
CBC: affects the current block and next block
CFB: affects the current block and next block
OFB: affects 1 bit in current block
----------------------------------------------------------------------------------------------------------------------------
For ECB, 1 bit change in cipher text affects the current block in plain text, which is 16 bytes long.
For CBC, 1 bit change in cipher text affects the current block and 1 bit of next block, this results in 17 bytes of corruption.
\ No newline at end of file
man openssl
man enc
openssl enc -aes-128-cbc -e -in plain.txt -out cipher.bin -K 00112233445566778889aabbccddeeff -iv 0102030405060708;
The key (-K) and IV (-iv) to be used are also specified, expressed in hexadecimal.
Openssl does provide an option "-nopad", in this case, the padding is not removed.
----------------------------------------------------------------------------------------------------------------------------
Extra Commands:
To view files as characters.
hexdump -c decryptext.txt or xxd decryptext.txt
To view file as hexadecimals(4bits)
hexdump decryptext.txt
To get 54B from plain.bmp and remaining bytes after 54 from cipher.bmp and concatenate it to new.bmp
"head -c 54 plain.bmp > header" ; "tail -c +55 cipher.bmp > body" ; "cat header body > new.bmp"
Run this (After editing):
openssl enc -aes-128-cfb -e -in original.bmp -out original-aes-128-cfb.bin -K 00112233445566778889aabbccddeeff -iv 0102030405060708; head -c 54 original.bmp > header; tail -c +55 original-aes-128-cfb.bin > body ; cat header body > new-cfb.bmp
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment