Skip to content

Erlang port driver for Colin Percival's "scrypt" function.

License

Notifications You must be signed in to change notification settings

KonnexionsGmbH/erlscrypt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

erlscrypt: Port driver for Colin Percival's "scrypt" function

scrypt, a Password-Based Key Derivation Function from Colin Percival, from version 1.1.6 of his library.

For general background on what scrypt is, and why it's useful, see these slides (PDF) and Colin Percival's page on scrypt.

Windows environment setup x64

  1. Install C++ build tools from https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15
  2. Select Build Tools and C++ CLI option and execute the installation
  3. Add environment variable INCLUDE with value C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt;
  4. Add environment variable LIB with value C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x64;
  5. Add C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\bin\Hostx64\x64 to environment vairiable PATH
  6. If while compiling there is an error while linking, execute which link verify if this is pointing to visual studio build tools folder. If not rename the other linker that is being fetched from the path.

Using the library

The entry points are erlscrypt:scrypt/6 and erlscrypt:scrypt/7.

erlscrypt:scrypt([nif], Passwd, Salt, N, R, P, Buflen)

Atom nif can be passed as optional first parameter to gain some marginal speed over port.

Both Passwd and Salt must be binaries. N, R, and P control the complexity of the password-derivation process. Buflen is the number of bytes of key material to generate.

For some good choices for N, R and P, see the paper.

Example:

1> erlscrypt:scrypt(<<"pleaseletmein">>, <<"SodiumChloride">>, 16384, 8, 1, 64).
<<112,35,189,203,58,253,115,72,70,28,6,205,129,253,56,235,
  253,168,251,186,144,79,142,62,169,181,67,246,84,...>>
2> erlscrypt:scrypt(nif,<<"pleaseletmein">>, <<"SodiumChloride">>, 16384, 8, 1, 64).
<<112,35,189,203,58,253,115,72,70,28,6,205,129,253,56,235,
  253,168,251,186,144,79,142,62,169,181,67,246,84,...>>

License

Please see LICENSE for more details

About

Erlang port driver for Colin Percival's "scrypt" function.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 62.4%
  • Erlang 19.1%
  • C 18.5%