Skip to content

elliotwutingfeng/BalloonHashing.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

BalloonHashing.jl

Julia Coveralls

GitHub license

Balloon Hashing implemented in Julia. All credit to Dan Boneh, Henry Corrigan-Gibbs, and Stuart Schechter. For more information see the research paper or their website for this project.

This is a direct port of the Python implementation by nachonavarro.

Warning: Please DO NOT use this code in production! It has not been tested rigorously for security vulnerabilities.

Background

Balloon Hashing is a new hashing function that, according to the paper, is:

  • Built from Standard Primitives: Builds on top of other common hashing functions.
  • Has Proven Memory-Hardness Properties: See paper.
  • Resistant to Cache Attacks: The idea is that an adversary who can observe the memory access patterns of the buffer in the algorithm (for example through cached side-channels) still can't figure out the password being cached.
  • Practical: Is as good as the best hashing functions used in production today.

Algorithm

The algorithm consists of three main parts, as explained in the paper.

The first step is the expansion, in which the system fills up a buffer with pseudorandom bytes derived from the password and salt by computing repeatedly the hash function on a combination of the password and the previous hash.

The second step is mixing, in which the system mixes time_cost number of times the pseudorandom bytes in the buffer. At each step in the for loop, it updates the nth block to be the hash of the n-1th block, the nth block, and delta other blocks chosen at random from the buffer.

In the last step, the extraction, the system outputs as the hash the last element in the buffer.

Usage

include("src/BalloonHashing.jl")

password = "buildmeupbuttercup"
salt = "JqMcHqUcjinFhQKJ"
BalloonHashing.balloon_hash(password, salt)
# OUTPUT: 2ec8d833db5f88e584ab793950ecfb21657a3816edea8d9e73ea23c13ba2b740

delta = 5
time_cost = 18
space_cost = 24
bytes2hex(BalloonHashing.balloon(password, salt, space_cost, time_cost, delta))
# OUTPUT: 69f86890cef40a7ec5f70daff1ce8e2cde233a15bffa785e7efdb5143af51bfb

Testing

In Julia REPL

using Pkg
Pkg.activate(".")
Pkg.test("BalloonHashing")

Formatting

In Julia REPL

using JuliaFormatter
format(".")

References