go>> AES>> 返回
项目作者: iraisali

项目描述 :
AES implementation in C (study project)
高级语言: C
项目地址: git://github.com/iraisali/AES.git
创建时间: 2020-05-15T16:19:59Z
项目社区:https://github.com/iraisali/AES

开源协议:

下载


A command-line tool to encrypt and decrypt files using AES.

AES algorithms are implemented as a standalone C99 library (aes.* files).

Supported features:

  • key sizes: 128, 192, 256-bits
  • mode: ECB, CBC

Installation

1. Compile aes library and commande line interface for encryption/decryption

  1. make

2. Compile and run tests

After compiling the tool, you can compile and run tests with:

  1. make test

These tests are performed for cipher and decipher, and for all size key (Using NIST’s documentation examples).

3. Benchmarks

  1. make bench

Give the encryption runtime (in seconds) and max memory footprints (in bytes) after N=100 iterations for all modes and all sizes key. You can also give an other value to N, for example with 50:

make bench N=50

Usage and help

To see help in shell use: ./AES -h

  1. Usage:
  2. ./AES [-d] [-m MODE] [-k FILE|STR] [-s SIZE] [-v] [-h] FILE
  3. Arguments:
  4. -d, Enable decrypt mode (default is encrypt)
  5. -m, Expects string MODE (default is ECB)
  6. MODE = ECB | CBC
  7. -k, Can be a hex string or path to file that contains hex string
  8. - For example to set a 128-bits use
  9. -k 0102030405060708090A0B0C0D0E0F10
  10. or put the same string in a file and give file path to -k
  11. -s, Create a random key in a file named rkey.key
  12. -v, Enable verbose mode
  13. -h, Show this message and exit

Examples

  • Encrypt the text named alice with the file key256 which countain a 256-bits key with default mode (EBC):
    1. ./AES -k toys/key256 toys/alice
    This command create a new file named cipher which contain the encrypted text.
  • Decryption of previous cipher text:
    1. ./AES -k toys/key256 -d cipher
    This command create a new file named decipher which contain the decrypted text.
  • Using CBC mode with a random 192-bits key:
    • Encryption: ./AES -s 192 -m CBC toys/alice (Create both an I.V. in iv and a random key in rkey.key).
    • Decryption: ./AES -k rkey.key -m CBC -d cipher (Use the previously created iv)