Giter Site home page Giter Site logo

elliotwutingfeng / balloon-hashing Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 64 KB

Balloon Hashing implemented in Ruby.

Home Page: https://crypto.stanford.edu/balloon

License: BSD 3-Clause "New" or "Revised" License

Ruby 100.00%
crypto kdf-algorithm key-derivation-function password hacktoberfest cryptography hash ruby ruby-language

balloon-hashing's Introduction

Balloon Hashing

Ruby Coveralls GitHub license

Balloon Hashing implemented in Ruby. 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

require './lib/balloon.rb'

password = 'buildmeupbuttercup'
salt = 'JqMcHqUcjinFhQKJ'
balloon_hash(password, salt) # OUTPUT: 2ec8d833db5f88e584ab793950ecfb21657a3816edea8d9e73ea23c13ba2b740

delta = 5
time_cost = 18
space_cost = 24
bs = balloon(password, salt, space_cost, time_cost, delta)
bs.unpack1('H*') # OUTPUT: 69f86890cef40a7ec5f70daff1ce8e2cde233a15bffa785e7efdb5143af51bfb

Testing

gem install bundler
bundle install
bundle exec rspec -r spec_helper

Formatting

gem install bundler
bundle install
rubocop -a

References

balloon-hashing's People

Contributors

elliotwutingfeng avatar renovate[bot] avatar

Stargazers

 avatar

balloon-hashing's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

bundler
Gemfile
  • rspec undefined
  • rubocop undefined
  • rubocop-rspec undefined
  • simplecov undefined
  • simplecov-cobertura undefined
github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • ruby/setup-ruby v1
  • coverallsapp/github-action v2
  • actions/checkout v4
  • actions/checkout v4
  • ruby/setup-ruby v1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.