kht

package module
v0.0.0-...-0ac8bc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2014 License: MIT Imports: 4 Imported by: 0

README

kht

Build Status

A Go implementation of keyed hash trees.

For documentation, check godoc.

Documentation

Overview

Package kht provides an implementation of a keyed hash tree.

A keyed hash tree is a hash tree which uses a keyed hash algorithm (e.g., HMAC), used to derive block-level keys for encrypting large files.

The notion of a keyed hash tree comes from Rajendran, Li, et al's papers on Horus, a large-scale encrypted storage system (http://www.ssrc.ucsc.edu/pub/rajendran11-pdsw.html and https://www.usenix.org/conference/fast13/technical-sessions/presentation/li_yan).

A keyed hash tree with a branching factor of 2 has log2(maxSize/blockSize) levels, each with increasing numbers of keys.

+-----------------------------------------------------------------------+
|                                K(0,0)                                 |
+-----------------------------------+-----------------------------------+
|              K(1,0)               |              K(1,1)               |
+-----------------+-----------------+-----------------+-----------------+
|      K(2,0)     |     K(2,1)            K(2,3)      |     K(2,4)      |
+--------+--------+--------+--------+--------+--------+--------+--------+
| K(3,0) | K(3,1) | K(3,2) | K(3,3) | K(3,4) | K(3,5) | K(3,6) | K(3,7) |
+--------+--------+--------+--------+--------+--------+--------+--------+

The root node (the top of the diagram) uses the tree's root key, and the leaf nodes (the bottom of the diagram) contain the keys used to encrypt the corresponding blocks of data. The nodes are not materialized, which means a keyed hash table takes a very small amount of memory (~100 bytes), and deriving block keys is very fast (~8μs for each 1KiB block of a 2GiB tree with a branching factor of 1024 using HMAC-SHA-256).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyedHash

type KeyedHash func(key []byte) hash.Hash

A KeyedHash is a hash algorithm which depends on a secret key.

func HMAC

func HMAC(alg func() hash.Hash) KeyedHash

HMAC returns a keyed hash implementation using the HMAC of the given hash algorithm.

type KeyedHashTree

type KeyedHashTree struct {
	// contains filtered or unexported fields
}

A KeyedHashTree is a tree of keyed hashes, used to derive keys.

func New

func New(key []byte, alg KeyedHash, blockSize, maxSize uint64, factor float64) *KeyedHashTree

New returns a KeyedHashTree with the given root key, keyed hash algorithm, block size, maximum size, and branching factor.

func (*KeyedHashTree) Key

func (t *KeyedHashTree) Key(offset uint64) []byte

Key returns the derived key at the given offset.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL