sha1 hash by JoachimS

sha1

Introduction

Verilog implementation of the SHA-1 cryptgraphic hash function. The functionality follows the specification in NIST FIPS 180-4.

The implementation is iterative with one cycle/round. The initialization takes one cycle. The W memory is based around a sliding window of 16 32-bit registers that are updated in sync with the round processing. The total latency/message block is 82 cycles.

There are top level wrappers that provides interface for easy integration into a System on Chip (SoC). This interface contains mesage block and digest registers to allow a host to load the next block while the current block is being processed.

The implementation also includes a functional model written in Python.

Implementation status

The core has been completed and been used in several designs. It is considered mature. Minor changes are non-functional cleanups of code.

Implementation details

The sha1 design is divided into the following sections.

  • src/rtl - RTL source files
  • src/tb - Testbenches for the RTL files
  • src/model/python - Functional model written in python
  • doc - documentation (currently not done.)
  • toolruns - Where tools are supposed to be run. Includes a Makefile for building and simulating the design using Icarus Verilog

The actual core consists of the following files:

  • sha1_core.v - The core itself with wide interfaces.
  • sha1_w_mem.v - W message block memort and expansion logic.

The top level entity is called sha1_core. This entity has wide interfaces (512 bit block input, 160 bit digest). In order to make it usable you probably want to wrap the core with a bus interface.

Unless you want to provide your own interface you therefore also need to use a top level wrapper. There is one wrapper provided:

  • sha1.v - A wrapper with a 32-bit memory like interface.

The core (sha1_core) will sample all data inputs when given the init or next signal. the wrappers provided contains additional data registers. This allows you to load a new block while the core is processing the previous block.

FPGA-results

Altera Cyclone FPGAs

Implementation results using Altera Quartus-II 13.1.

Altera Cyclone IV E

  • EP4CE6F17C6
  • 2913 LEs
  • 1527 regs
  • 107 MHz

Altera Cyclone IV GX

  • EP4CGX22CF19C6
  • 2814 LEs
  • 1527 regs
  • 105 MHz

Altera Cyclone V

  • 5CGXFC7C7F23C8
  • 1124 ALMs
  • 1527 regs
  • 104 MHz

Xilinx FPGAs

Implementation results using ISE 14.7.

Xilinx Spartan-6

  • xc6slx45-3csg324
  • 1589 LUTs
  • 564 Slices
  • 1592 regs
  • 100 MHz

TODO

  • Documentation
Copyright (c) 2014, Joachim Strömbergson
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
  list of conditions and the following disclaimer in the documentation and/or
  other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Project Meta

  • Registered 11 months ago
  • Started 4 years ago
  • Last commit 11 months ago

Commits

{"labels":[2014,2016,2017,2015,2018],"series":[["109","10","5",null,null]]}

Commits per year

Contributors

{"labels":[2014,2016,2017,2015,2018],"series":[["1","1","1",null,null]]}

Unique contributors per year

Releases

Data not available

Languages

{"labels":["Others","Verilog-SystemVerilog","Python","Markdown","make"],"series":[0,6,1,1,1]}

Share of languages used

Data Sheet
https://github.com/secworks/sha1
Last updated 11 months ago
Language: Verilog-SystemVerilog
124 commits by 1 contributor
Joachim Strömbergson
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

Activity in last 1 year

Updated 11 months ago