AES

来源:互联网 发布:java string int 编辑:程序博客网 时间:2024/05/18 09:17

Encrypt / Decrypt Demos

Encryption:

openssl aes-256-cbc -in attack-plan.txt -out message.enc    oropenssl aes-256-cbc -in attack-plan.txt -a

or

┌─[✗]─[lab@core]─[/tmp]└──╼ aescrypt -husage: aescrypt {-e|-d} [ { -p <password> | -k <keyfile> } ] { [-o <output filename>] <file> | <file> [<file> ...] }┌─[lab@core]─[/tmp]└──╼ aescrypt -e -p password demo.py ┌─[lab@core]─[/tmp]└──╼ file demo.py.aes demo.py.aes: data

Decryption:

openssl aes-256-cbc -d -in message.enc -out plain-text.txt

or

┌─[lab@core]─[/tmp]└──╼ aescrypt -d -p password demo.py.aes

Encryption process

  • Plaintext: The data to be encrypted.

  • IV: A block of bits that is used to randomize the encryption and hence to produce distinct ciphertexts even if the same plaintext is encrypted multiple times.

  • Key: Used by symmetric encryption algorithms like AES, Blowfish, DES, Triple DES, etc.

  • Ciphertext: The data encrypted.

An important point here is that CBC works on a fixed-length group of bits called a block. In this blog, we will use blocks of 16 bytes each.

Since I hate mathematical formulas, below are mine:

Ciphertext-0 = Encrypt(Plaintext XOR IV)—Just for the first block.....Ciphertext-N= Encrypt(Plaintext XOR Ciphertext-N-1)—For second and remaining blocks.

Note: As you can see, the ciphertext of the previous block is used to generate the next one.


Decryption Process

Plaintext-0 = Decrypt(Ciphertext) XOR IV—Just for the first block.Plaintext-N= Decrypt(Ciphertext) XOR Ciphertext-N-1—For second and remaining blocks.

References

https://en.wikipedia.org/wiki/Advanced_Encryption_Standard
https://www.aescrypt.com/download/
http://askubuntu.com/questions/60712/how-do-i-quickly-encrypt-a-file-with-aes
http://resources.infosecinstitute.com/cbc-byte-flipping-attack-101-approach/

0 0
原创粉丝点击