• Stars
    star
    334
  • Rank 126,264 (Top 3 %)
  • Language Verilog
  • License
    BSD 2-Clause "Sim...
  • Created almost 11 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Verilog implementation of the symmetric block cipher AES (Advanced Encryption Standard) as specified in NIST FIPS 197. This implementation supports 128 and 256 bit keys.

build-openlane-sky130

aes

Verilog implementation of the symmetric block cipher AES (NIST FIPS 197).

Status

The core is completed, has been used in several FPGA and ASIC designs. The core is well tested and mature.

Introduction

This implementation supports 128 and 256 bit keys. The implementation is iterative and process one 128 block at a time. Blocks are processed on a word level with 4 S-boxes in the data path. The S-boxes for encryption are shared with the key expansion and the core can thus not do key update in parallel with block processing.

The encipher and decipher block processing datapaths are separated and basically self contained given access to a set of round keys and a block. This makes it possible to hard wire the core to only encipher or decipher operation. This allows the synthesis/build tools to optimize away the other functionality which will reduce the size to about 50%. This has been tested to verify that decryption is removed and the core still works.

For cipher modes such as CTR, CCM, CMAC, GCM the decryption functionality in the AES core will never be used and thus the decipher block processing can be removed.

This is a fairly compact implementation. Further reduction could be achived by just having a single S-box. Similarly the performane can be increased by having 8 or even 16 S-boxes which would reduce the number of cycles to two cycles for each round.

Branches

There are several branches available that provides different versions of the core. The branches are not planned to be merged into master. The branches available that provides versions of the core are:

on-the-fly-keygen

This version of AES implements the key expansion using an on-the-fly mechanism. This allows the initial key expansion to be removed. This saves a number of cycles and also remove almost 1800 registers needed to store the round keys. Note that this version of AES only supports encryption. On-the-fly key generation does not work with decryption. Decryption must be handled by the block cipher mode - for example CTR.

dual-keys

This version of AES supports two separate banks of expanded keys to allow fast key switching between two keys. This is useful for example in an AEAD mode with CBC + CMAC implemented using a single AES core.

cmt-sbox

An experimental version of the core in which the S-box is implemented using circuit minimized logic functions of a ROM table. The specific table used is the 113 gate circuit by the CMT team at Yale.

Some area and performance results using the cmt_sbox compared to master.

Altera

  • Tool: Quartus Prime 19.1.0

  • Device: Cyclone V (5CGXFC7C7F23C8)

  • master (S-box implemented with a table)

    • ALMs: 2599
    • Regs: 3184
    • Fmax: 93 MHz
    • aes_sbox: 160 ALUTs
  • cmt_sbox

    • ALMs: 2759
    • Regs: 3147
    • Fmax: 69 MHz
    • aes_sbox: 363 ALUTs

Xilinx

  • Tool: Vivado 2019.2

  • Device: Kintex-7 (7k70tfbv676-1)

  • master:

    • LUTs: 3020
    • FFs: 2992
    • Fmax: 125 MHz
  • cmt_sbox:

    • LUTs: 2955
    • FFs: 2992
    • Fmax: 105 MHz

Core Usage

Usage sequence:

  1. Load the key to be used by writing to the key register words.
  2. Set the key length by writing to the config register.
  3. Initialize key expansion by writing a one to the init bit in the control register.
  4. Wait for the ready bit in the status register to be cleared and then to be set again. This means that the key expansion has been completed.
  5. Write the cleartext block to the block registers.
  6. Start block processing by writing a one to the next bit in the control register.
  7. Wait for the ready bit in the status register to be cleared and then to be set again. This means that the data block has been processed.
  8. Read out the ciphertext block from the result registers.

FuseSoC

This core is supported by the FuseSoC core package manager and build system. Some quick FuseSoC instructions:

install FuseSoC

pip install fusesoc

Create and enter a new workspace

mkdir workspace && cd workspace

Register aes as a library in the workspace

fusesoc library add aes /path/to/aes

...if repo is available locally or... ...to get the upstream repo

fusesoc library add aes https://github.com/secworks/aes

To run lint

fusesoc run --target=lint secworks:crypto:aes

Run tb_aes testbench

fusesoc run --target=tb_aes secworks:crypto:aes

Run with modelsim instead of default tool (icarus)

fusesoc run --target=tb_aes --tool=modelsim secworks:crypto:aes

List all targets

fusesoc core show secworks:crypto:aes

Implementation results - ASIC

The core has been implemented in standard cell ASIC processes.

TSMC 180 nm

Target frequency: 20 MHz Complete flow from RTL to placed gates. Automatic clock gating and scan insertion.

  • 8 kCells
  • Aera: 520 x 520 um
  • Good timing margin with no big cells and buffers.

Implementation results - FPGA

The core has been implemented in Altera and Xilinx FPGA devices.

Altera Cyclone V GX

  • 2624 ALMs
  • 3123 Regs
  • 96 MHz
  • 46 cycles/block

Altera Cyclone IV GX

  • 7426 LEs
  • 2994 Regs
  • 96 MHz fmax
  • 46 cycles/block

This means that we can do more than 2 Mblocks/s or 256 Mbps performance.

Removing the decipher module yields:

  • 5497 LEs
  • 2855 Regs
  • 106 MHz fmax
  • 46 cycles/block

Microchip IGLOO 2

  • Tool: Libero v 12.4
  • Device: M2GL090TS-1FG484I
  • LUTs: 6335
  • SLEs: 1376
  • BRAMs: 8
  • Fmax: 98.5 MHz

Xilinx Spartan6LX-3

  • 2576 slices
  • 3000 regs
  • 100 MHz
  • 46 cycles/block

Xilinx Artix 7 200T-3

  • 2298 slices
  • 2989 regs
  • 97 MHz
  • 46 cycles/block

More Repositories

1

sha256

Hardware implementation of the SHA-256 cryptographic hash function
Verilog
316
star
2

trng

True Random Number Generator core implemented in Verilog.
Verilog
72
star
3

sha1

Verilog implementation of the SHA-1 cryptgraphic hash function
Verilog
51
star
4

chacha

Verilog 2001 implementation of the ChaCha stream cipher.
Verilog
38
star
5

sha512

Verilog implementation of the SHA-512 hash function.
Verilog
33
star
6

blake2

Hardware implementation of the blake2 hash function
Verilog
25
star
7

blake2s

Verilog implementation of the 32-bit version of the Blake2 hash function
Verilog
20
star
8

sha3

FIPS 202 compliant SHA-3 core in Verilog
Verilog
17
star
9

modexp

Modular Exponentiation core written i Verilog. Supports key lengths between 32 and 8192 bits.
Verilog
17
star
10

siphash

Hardware implementation of the SipHash short-inout PRF
Verilog
16
star
11

cmac

Implementation of the CMAC keyed hash function using AES as block cipher.
Verilog
12
star
12

chacha_testvectors

Generator and Internet Draft (I-D) documenting test vectors for the stream cipher ChaCha.
C
10
star
13

uart

A Universal asynchronous receiver/transmitter (UART) implemented in Verilog.
Verilog
8
star
14

ChaCha20-Poly1305

Hardware implementation of the ChaCha20-Poly1305 AEAD construction
Verilog
8
star
15

gift

Hardware implementation of the GIFT-128 lightweight block cipher
Verilog
8
star
16

poly1305

Hardware implementation of the poly1305 message authentication function.
Verilog
8
star
17

rosc_entropy

Entropy source based on jitter between multiple, digital ring oscillators.
Verilog
7
star
18

6502

Verilog implementation of a MOS6502 compatible CPU core.
Verilog
7
star
19

prince

The Prince lightweight block cipher in Verilog.
Verilog
7
star
20

ed25519

ed25519 public key signature implemented in Verilog.
Verilog
7
star
21

md5

Hardware implementation of the hash function md5
Verilog
6
star
22

figaro

Implementation of the FiGaRO TRNG for FPGAs
Verilog
6
star
23

cbc

CBC block cipher mode of operation for AES.
Verilog
6
star
24

verilator_template

(Hopefully) simple template for a Verilator SystemVerilog project with a usable testbench
Verilog
6
star
25

ascon

Verilog implementation of the ASCON lightweight authenticated encryption and hashing algorithm
Verilog
6
star
26

gcm

Galois Couter Mode implementation in Verilog.
Verilog
5
star
27

rc4

An experimental RC4 hardware implementation with one cycle/iteration performance.
Verilog
5
star
28

aes_6502

My attempt at making a fast AES-128 implementation on MOS 6502
Verilog
5
star
29

aes_mask

Experimental core for performing masking of AES by generating noise.
Verilog
5
star
30

curve25519

Verilog 2001 of the Curve25519 elliptic curve based function.
Verilog
5
star
31

hmac

HMAC-SHA-256 in Verilog 2001
Verilog
4
star
32

xtea

Verilog implementation of the xtea block cipher
Verilog
4
star
33

avalanche_entropy

Entropy collector and provider for an external avalanche noise based entropy source.
Verilog
4
star
34

grain128

Hardware implementation of the Grain128AEAD stream cipher
Verilog
4
star
35

ccm

ccm mode hardware implementation
Verilog
4
star
36

view_rnd

A simple program for viewing random values as an image.
Python
3
star
37

vga

vga
Verilog
3
star
38

tracegen

A tool for generating synthetic traces with side-channel leakage.
Python
3
star
39

hc

Hardware implementation of the HC stream cipher.
Verilog
3
star
40

salsa20

Sals20 Stream Cipher core in Verilog
Verilog
3
star
41

r5

A simple Verilog implementation of RISC-V.
Verilog
3
star
42

extract_ev_data

Pure Python program used to extract EV data from Mozilla CA roots. Used to generate EV validation data in sslyze.
Python
3
star
43

fpga_eth_filter

FPGA based Ethernet traffic filter and manipulator for the TerasIC ETHERNET-HSMC Card
Verilog
3
star
44

bigmath

Project for testing and developing HW-implementations of integer operations. mult, mod, add, div etc.
Verilog
2
star
45

chaskey

Verilog implementation of the Chaskey lightweight message authentication code (MAC) function.
Verilog
2
star
46

online_tester

Online tester/monitor of random number generators. Based om AIS31 but modular.
Verilog
2
star
47

blake3

Hardware implementation of the Blake3 hash function
2
star
48

snow5

Hardware implementation of the SNOW-V stream cipher.
Verilog
2
star
49

aead_aes_siv_cmac

Hardware implementation of the AEAD_AES_SIV_CMAC
Verilog
2
star
50

fltfpga

FairLight FPGA demo board based on TerasIC G5C
Verilog
2
star
51

random_tools

A collection of tools used to analyze random number data files, extract entropy etc.
Python
2
star
52

tang_nano_rng

Implementation of a high quality random number generator on the Tang Nano FPGA board
2
star
53

coretest

Test structure for cores developed as part of the Cryptech Open HSM project
Verilog
2
star
54

siphash_6502

Implementation of the SipHash keyed hash function in MOS 6502 assembler
Assembly
2
star
55

Tweetnacl

Python implementation of the TweetNaCl cryptograhic library
Python
2
star
56

pyat88ck590

Python program to talk to the Atmel AT88CK590 Crypto Authentication Evaulation Kit.
Python
1
star
57

stanford_cryptography1

Solutions to programming problems and assignments in the Cryptography 1 course
1
star
58

keywrap

RFC 3394 keywrap cipher mode implemented in Verilog 2001.
Verilog
1
star
59

ubbefpga

Very simple HW design to test FPGA development using the Terasic DE0-Nano board
Verilog
1
star
60

blabla

Implementation of the BlaBla version of the ChaCha stream cipher
Verilog
1
star
61

vndecorrelator

A Verilog implementation of a von Neumann decorrelator
Verilog
1
star
62

robber_language

Hardware implementation of a decoder/encoder for the Robber language
Verilog
1
star
63

ca_prng

Cellular Automata based PRNG
Verilog
1
star
64

mkmif

interface to external master key memory.
Verilog
1
star
65

fpga_entropy

Test implementation of FPGA-internal entropy source.
Verilog
1
star
66

coretest_bp_entropy

Coretest system for testing the FPGA based entropy source by Berndt Paysan.
Verilog
1
star
67

verilogtest

Repo for test of HW implementations written in Verilog.
Verilog
1
star
68

rc4_6502

MOS 6502 implementation of the old RC4 stream cipher. Yes, it is broken.
1
star
69

advent_of_code_2019

Solutions to Adevent of Code 2019
Python
1
star
70

test_core

A very simple test core.
Verilog
1
star
71

huffman

Python implementation of Huffman encoding and decoding. Just for fun.
Python
1
star
72

coretest_test_core

The coretest module combined with the test_core as a test module.
Verilog
1
star
73

xchacha

Hardware implementation of the extended-nonce ChaCha stream cipher
Verilog
1
star
74

qarma

Verilog implementation of the lightweight block cipher QARMA
Verilog
1
star
75

ocb

Verilog implementation of the OCB authenticated encryption mode.
Verilog
1
star