• Stars
    star
    126
  • Rank 276,342 (Top 6 %)
  • Language
    C
  • License
    Other
  • Created over 8 years ago
  • Updated over 8 years ago

Reviews

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

Repository Details

A C implementation of a dynamically resizeable binary SHA-256 hash tree (Merkle Tree).

Merkle Tree Library

1. Introduction

The Merkle Tree Library is a C library implementing a binary [Merkle (hash) tree] (https://en.wikipedia.org/wiki/Merkle_tree). The library was initially developed for use with the [Secure Block Device] (http://www.iaik.tugraz.at/content/research/opensource/secure_block_device/). As such it has the following properties:

  • Binary hash tree using SHA-256 as hash algorithm
  • Supports variable size data stores
    • max number of elements and max hash tree levels are compile-time parameters
    • hash tree grows automatically when new integrity tags (mt_add() function) are appended
    • hash tree shrinks, when number of integrity tags is truncated (mt_truncate() function)

2. Building the Merkle Tree Library

The library build system is based on make. We currently do not support a configure script, if you want to adapt the library to your needs, adapt the 'src/mt_config.h' header file by yourself.

2.1 Dependencies

CppUnit - We provide a small set of unit test cases using CppUnit. For building and running the tests CppUnit is a dependency.

Valgrind - By default the test suite is run with Valgrind's memcheck tool to help detect memory leaks. Unless use of Valgrind is deactivated, it needs to be installed.

Doxygen - The library is (sparsely) documented. Doxygen is required to create the documentation.

2.2 Building the Merkle Tree Library

Untar the source, change into the library's root directory, and 'make' it. Supported targets are:

  • debug - build with debug information enabled
  • coverage - build with debugging and coverage support
  • release - build optimzed (-O3, no debug) release version
  • doc - build the documentation (as it is) using Doxygen
  • test - run the CppUnit based test suite. Call with 'make VGRUN= test' to deactivate Valgrind.
  • clean - clean up build artifacts

All successful builds create a static library 'libMerkleTree.a' in the 'src' directory, for linking to other applications.

2.3 Comments

This library has so far been tested on ARM (32-bit) and AMD64.

3. Using the Merkle Tree Library

The library's user interface is specified in 'src/merkletree.h'. The 'tests/MerkleTreeTest.cpp' outlines how to use the library. Also the Secure Block Device uses this library to ensure overall data integrity. Typically, a new Merkle Tree instance is created by calling mt_create(). The instance has to be destroyed by a subsequent call to mt_delete(). In between new integrity tags can be appended to the tree as leafs by using mt_add(). An existing leaf can be updated using the mt_update() function. Each addition or update of a leaf will update the root hash of the hash tree, which can be obtained by calling the mg_get_root() function. Finally, to reduce the size of the hash tree, the mt_truncate() function can be used to specify a new last leaf in the tree. All leaves with a higher index will be invalidated and the memory used to store them freed. This is useful for example to support a data store that can shrink and grow in size.

4. Licensing

For details on the licensing see LICENSE. The Merkle Tree Library uses the 'sha.h' and 'sha224-256.c' files from RFC4634 as implementation of the SHA-256 hash.

5. Bibliography

More Repositories

1

meltdown

This repository contains several applications, demonstrating the Meltdown bug.
C
4,092
star
2

ZombieLoad

Proof-of-concept for the ZombieLoad attack
C
812
star
3

rowhammerjs

Rowhammer.js - A Remote Software-Induced Fault Attack in JavaScript
C++
488
star
4

CJAG

CJAG is an open-source implementation of our cache-based jamming agreement.
C
281
star
5

armageddon

This repository contains tools to perform modern cache attacks on ARM.
C
279
star
6

KAISER

Kernel Address Isolation to have Side-channels Efficiently Removed
214
star
7

sgxrop

The code to the SGX-ROP paper
C
183
star
8

transientfail

Website and PoC collection for transient execution attacks
C
160
star
9

drama

This repository contains examples of DRAMA reverse-engineering and side-channel attacks
C++
157
star
10

ChromeZero

Google Chrome extension implementing JavaScript Zero
JavaScript
147
star
11

flush_flush

This repository contains examples of Flush+Flush cache attacks
C
147
star
12

cache_template_attacks

This repository contains several tools to perform Cache Template Attacks
C
131
star
13

sweb

SWEB Educational OS
C++
113
star
14

AEPIC

C
110
star
15

ios-analysis

Automated Binary Analysis on iOS
Shell
103
star
16

Picnic

Optimized implementation of the Picnic signature scheme
C
77
star
17

prefetch

This repository contains several tools to perform Prefetch Side-Channel Attacks
C
56
star
18

jstemplate

JavaScript Template Attack proof-of-concept implementation
HTML
53
star
19

hybrid-HE-framework

C
36
star
20

secure-block-device

The Secure Block Device Library is a software library that applies cryptographic confidentiality and integrity protection, including data freshness, to arbitrary block device like storage mechanisms.
C
34
star
21

flipfloyd

Tools for "Another Flip in the Wall"
C
33
star
22

interruptjs

Practical Keystroke Timing Attacks in Sandboxed JavaScript
HTML
31
star
23

msrevelio

C++
29
star
24

memsec

Framework for building transparent memory encryption and authentication solutions
VHDL
25
star
25

pairings_in_c

C library for bilinear pairings
C
24
star
26

keydrown

Eliminating Keystroke Timing Attacks
C
21
star
27

Chestnut

C
20
star
28

CollidePower

C
20
star
29

gzkbpp

Implementation of the ZKB++ proof system
C++
17
star
30

ascon_hardware

Hardware implementations of the authenticated encryption design ASCON
VHDL
17
star
31

flecc_in_c

FLECC_IN_C is a FLexible Elliptic Curve Cryptography library written IN C
Scilab
17
star
32

ProcHarvester

ProcHarvester - Fully Automated Analysis of Procfs Side-Channel Leaks on Android
Java
17
star
33

coco-alma

CocoAlma is an execution-aware tool for formal verification of masked implementations
Python
16
star
34

Donky

C
14
star
35

drawio2tikz

drawio2tikz - a tool to translate drawio xml files to readable and adaptable tikz code
Python
14
star
36

fish-begol

Implementation of the Fish and Begol signature schemes
C
13
star
37

marvellous-attacks

Attacks on Jarvis and Friday
Python
10
star
38

Jenny

C
10
star
39

halfdouble

C++
10
star
40

SCAnDroid

Java
9
star
41

Memory-Compression-Attacks

Memory Compression Attacks
C
9
star
42

data-gui

DATA GUI
Python
9
star
43

sgxjail

Makefile
8
star
44

wolfSSL-DoS

Proof of concept for denial of service attack on wolfSSL's DTLS server implementation.
C
8
star
45

ios-analysis-llvmslicer

C++
7
star
46

LayeredBinaryTemplating

Layered Binary Templating
Python
7
star
47

CoronaHeatMap

C++
6
star
48

CryptoSlice

Static Analysis of Cryptography in Android Applications
Java
6
star
49

coco-ibex

SystemVerilog
5
star
50

CacheSim

C++
5
star
51

CSIRowhammer

CSI:Rowhammer - Cryptographic Security and Integrity against Rowhammer
C
5
star
52

FLARE

C
5
star
53

CrySIL

JavaScript
4
star
54

CryptoTL

C++
4
star
55

LVI-NULLify

C
4
star
56

contextlight

The PoC for ConTExT-light
C
4
star
57

rebecca

REBECCA is a tool for the formal verification of masked cryptographic hardware implementations that, given the netlist of a masked hardware circuit, determines if a correct separation between shares is preserved throughout the circuit.
Verilog
4
star
58

libdropit

Proof-of-concept implementation of DropIt
C
3
star
59

daps-dl

Short DAPS from ECDSA in OpenSSL
C
3
star
60

TBIBS

Time-bound identity-based signatures (TBIBΣ) for Short-Lived Forward-Secure Delegation in TLS
Java
3
star
61

romulush_collisions

TeX
3
star
62

rainier-signatures

C++
2
star
63

bnpp_helium_signatures

C++
2
star
64

minefield

C++
2
star
65

trusted-location-based-services

Prototype 1, Prototype 2 and base components for Trusted Location Based Services on Android devices.
Java
2
star
66

ios-analysis-dagger

C++
2
star
67

Picnic-FPGA

FPGA implementation of Picnic and LowMC
VHDL
2
star
68

spearv

C
2
star
69

servas

1
star
70

sgxjail-sdk

Implementation of SGXJail in the Linux SGX SDK
C++
1
star
71

banquet-signature-variants

C++
1
star
72

mimc-analysis

mimc-analysis
C++
1
star
73

MPC-Accumulator

Java
1
star