Skip to content

jvelilla/aes-eiffel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aes-eiffel

aes-eiffel is an Eiffel implementation of the Advanced Encryption Standard (AES) algorithm, based on the tiny-AES-c C implementation. This library provides a simple and efficient way to perform AES encryption and decryption in Eiffel applications.

Features

  • Supports AES-128, AES-192 and AES-256 encryption and decryption.
  • Implements three modes of operation:
    • ECB (Electronic Codebook)
    • CBC (Cipher Block Chaining)
    • CTR (Counter)
  • Provides string-based operations for easy encryption and decryption of text
  • Includes PKCS7 padding for block alignment
  • Designed for simplicity and ease of use

Usage

The library provides three main methods for each mode of operation:

  1. ECB Mode:

    • ecb_encoding_string(plaintext, key): STRING
    • ecb_decoding_string(ciphertext, key): STRING
  2. CBC Mode:

    • cbc_encoding_string(plaintext, key, iv): STRING
    • cbc_decoding_string(ciphertext, key, iv): STRING
  3. CTR Mode:

    • ctr_encoding_string(plaintext, key, nonce): STRING
    • ctr_decoding_string(ciphertext, key, nonce): STRING

Example usage:

    local
        aes: AES
        key, plaintext, encrypted, decrypted: STRING
    do
        create aes.make
        key := "Sixteen byte key"
        plaintext := "Hello, World!"
        encrypted := aes.ecb_encoding_string(plaintext, key)
        decrypted := aes.ecb_decoding_string(encrypted, key)
        check plaintext.is_equal(decrypted) end
    end

Security Considerations

  • CTR (Counter) mode is generally considered more secure and preferable compared to ECB and CBC modes.1
  • ECB mode is the least secure and should be avoided for most use cases, especially for data larger than a single block.3
  • CTR mode offers advantages over CBC:
    • Better performance on multi-core systems due to easier parallelization.1
    • No risks associated with padding.4
  • Key security considerations:
    • Proper key management is crucial for all modes.5
    • CTR mode requires unique nonces (IVs) for each encryption operation.6
    • For maximum security, authenticated encryption modes like GCM (which builds on CTR) are recommended.7
  • While CTR is generally more secure than CBC or ECB, combining CTR with a proper authentication mechanism or using an authenticated encryption mode like GCM is the most secure approach.8
  • Always use a secure method to generate keys and IVs/nonces.9

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages