• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    C
  • License
    Creative Commons ...
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

Fast PBKDF2 implementation in C

fastpbkdf2

This is a fast PBKDF2-HMAC-{SHA1,SHA256,SHA512} implementation in C.

It uses OpenSSL's hash functions, but out-performs OpenSSL's own PBKDF2 thanks to various optimisations in the inner loop.

Build Status

Interface

void fastpbkdf2_hmac_sha1(const uint8_t *pw, size_t npw,
                          const uint8_t *salt, size_t nsalt,
                          uint32_t iterations,
                          uint8_t *out, size_t nout);

void fastpbkdf2_hmac_sha256(const uint8_t *pw, size_t npw,
                            const uint8_t *salt, size_t nsalt,
                            uint32_t iterations,
                            uint8_t *out, size_t nout);

void fastpbkdf2_hmac_sha512(const uint8_t *pw, size_t npw,
                            const uint8_t *salt, size_t nsalt,
                            uint32_t iterations,
                            uint8_t *out, size_t nout);

Please see the header file for details and constraints.

Performance

These values are wall time, output from the bench tool.

AMD64

Hash OpenSSL fastpbkdf2 (comparison)
SHA1 11.84s 3.07s x3.86
SHA256 16.54s 7.45s x2.22
SHA512 21.90s 9.33s x2.34

222 iterations, 1.86GHz Intel Atom N2800, amd64.

ARM

Hash OpenSSL fastpbkdf2 (comparison)
SHA1 30.4s 4.43s x6.86
SHA256 36.52s 7.04s x5.19
SHA512 77.44s 28.1s x2.76

220 iterations, Raspberry Pi - 700MHz ARM11.

Requirements

  • OpenSSL's libcrypto.
  • C compiler supporting C99.

Building and testing

Run 'make test' to build and run tests.

The program bench provides a very basic performance comparison between OpenSSL and fastpbkdf2.

The implementation has one header and one translation unit. This is intended for easy integration into your project.

Optional parallelisation of outer loop

PBKDF2 is misdesigned and you should avoid asking for more than your hash function's output length. In other words, nout should be <= 20 for fastpbkdf2_hmac_sha1, <= 32 for fastpbkdf2_hmac_sha256 and <= 64 for fastpbkdf2_hmac_sha512.

If you can't avoid this (for compatibility reasons, say) compile everything with -fopenmp and -DWITH_OPENMP to have this computation done in parallel. Note that this has non-zero overhead.

The program multibench provides a basic performance comparison for using this option.

Windows

Details on building for Windows.

License

CC0.

Language bindings

Author

Joseph Birr-Pixton [email protected]

More Repositories

1

cifra

A collection of cryptographic primitives targeted at embedded use.
C
337
star
2

graviola

Rust
33
star
3

sgx-pwenclave

Using SGX to harden password hashing
C
33
star
4

keccak

Pure python keccak implementation
Python
27
star
5

tee-checker

Detection of TEEs on Android devices
Java
26
star
6

cryptopals

cryptopals answers
Python
24
star
7

u2f-secret-storage

Abusing U2F to 'store' a stable secret
Python
16
star
8

go-fastpbkdf2

Golang bindings for fastpbkdf2
C
16
star
9

rust-fastpbkdf2

Rust binding for fastpbkdf2
Rust
15
star
10

id115-firmware-dump

Dumping firmware from an ID115 fitness band
Ruby
14
star
11

bignum

Basic bignum library (do not use!)
C
9
star
12

tls-hacking

assorted tls experimentation
Python
7
star
13

openssl-bench

OpenSSL benchmarking tools
C++
7
star
14

flashover

Flash decompilation website source (abandoned)
Python
7
star
15

ti-sensortag-android

TI SensorTag app for Android
Java
6
star
16

groestl

Pure python implementation of GrΓΈstl
Python
6
star
17

hpke-py

RFC9180 HPKE in python on top of cryptography.io
Python
5
star
18

talks

various talks and slides
TeX
4
star
19

android-lens-blur

Lens blur viewer app
Java
4
star
20

anagramic

Word game for Android
Java
3
star
21

pytls

Python TLS stack
Python
2
star
22

ctz.github.com

new temporary website
HTML
2
star
23

deadweight

entry for ludum dare 20
Java
2
star
24

defcon-uhcc

Underhanded Crypto Competition (defcon challenge) 2015 entry
C
2
star
25

wasmrs

Rust
1
star
26

rustls-embedded-demo

Demo for embedded use of rustls
Rust
1
star
27

azure-ci-test

Rust
1
star
28

crap

miscellany
C
1
star
29

advent-2020

Python
1
star
30

brokenmalloc

brokenmalloc is a simple malloc wrapper which can be made to fail on demand
C
1
star
31

junk-drawer

collection of random scripts and detritus
Rust
1
star