Code Monkey home page Code Monkey logo

rbnacl's Introduction

RbNaCl

Build Status Code Climate

A Ruby binding to the state-of-the-art Networking and Cryptography library by Daniel J. Bernstein. This is NOT Google Native Client. This is a crypto library.

On a completely unrelated topic, RbNaCl is also the empirical formula for Rubidium Sodium Chloride.

Need help with RbNaCl? Join the RbNaCl Google Group

Why NaCl?

NaCl is a different kind of cryptographic library. In the past crypto libraries were kitchen sinks of little bits and pieces, like ciphers, MACs, signature algorithms, and hash functions. To accomplish anything you had to make a lot of decisions about which specific pieces to use, and if any of your decisions were wrong, the result was an insecure system. The choices are also not easy: EAX? GCM? CCM? AES-CTR? CMAC? OMAC1? AEAD? NIST? CBC? CFB? CTR? ECB? OMGWTFBBQ!

NaCl puts cryptography on Rails! Instead of making you choose which cryptographic primitives to use, NaCl provides convention over configuration in the form of expertly-assembled high-level cryptographic APIs that ensure not only the confidentiality of your data, but also detect tampering. These high-level, easy-to-use APIs are designed to be hard to attack by default in ways primitives exposed by libraries like OpenSSL are not.

This approach makes NaCl a lot closer to a system like GPG than it is to the cryptographic primitive APIs in a library like OpenSSL. In addition, NaCl also uses state-of-the-art encryption, including Curve25519 elliptic curves and the XSalsa20 stream cipher. This means with NaCl you not only get a system which is designed to be secure-by-default, you also get one which is extremely fast with comparatively small cryptographic keys.

For more information on NaCl's goals, see Dan Bernstein's presentation Blaming the Cryptographic User

Supported platforms

You can use RbNaCl anywhere you can get libsodium installed (see below). RbNaCl is continuously integration tested on the following Ruby VMs:

  • MRI 1.8 / REE
  • MRI 1.9 (YARV)
  • JRuby 1.7 (in both 1.8/1.9 mode)
  • Rubinius HEAD (in both 1.8/1.9 mode)

In theory Windows should be supported, although there are not yet any reports of successful Windows users.

Installation

libsodium

RbNaCl is implemented as a Ruby FFI binding, which is designed to bind to shared libraries. Unfortunately NaCl does not presently ship a shared library, so RbNaCl cannot take advantage of it via FFI. RbNaCl will support usage with the upstream NaCl once it is able to compile a shared library.

For now, to use RbNaCl, you will need to install libsodium, a portable version of NaCl based upon the reference C code. Please see the libsodium project for information regarding installation:

https://github.com/jedisct1/libsodium

OS X

Unfortunately libsodium is not in homebrew proper yet (I would strongly encourage you to ask for libsodium's inclusion in homebrew), however you can use homebrew's "tap" feature for the time being to install libsodium:

brew tap qmx/homebrew-libsodium
brew install libsodium

RbNaCl gem

Once you have libsodium installed, add this line to your application's Gemfile:

gem 'rbnacl'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rbnacl

Documentation

RbNaCl's documentation can be found in the Wiki. The following features are supported:

  • Secret-key Encryption: authenticated symmetric encryption using a single key shared among parties
  • Public-key Encryption: securely send messages to a given public key which can only be decrypted by a secret key
  • Digital Signatures: sign messages with a private key which can be verified by a public one
  • Authenticators: create codes which can be used to check the authenticity of messages
  • Hash Functions: compute a secure, fixed-length code from a message which does not reveal the contents of the message

Additional power-user features are available. Please see the Wiki for further information.

Security Notes

NaCl itself has been expertly crafted to avoid a whole range of side-channel attacks, however the RbNaCl code itself has not been written with the same degree of expertise. While the code is straightforward it should be considered experimental until audited by professional cryptographers.

That said, it's probably still a million times better than OpenSSL...

Learn More

While NaCl has designed to be easier-than-usual to use for a crypto library, cryptography is an incredibly difficult subject and it's always helpful to know as much as you can about it before applying it to a particular use case. That said, the creator of NaCl, Dan Bernstein, has published a number of papers about NaCl. If you are interested in learning more about how NaCl works, it's recommended that you read them:

Have a general interest in cryptography? Check out the free course Coursera offers from Stanford University Professor Dan Boneh:

http://crypto-class.org

Contributing

  • Fork this repository on Github
  • Make your changes and send a pull request
  • If your changes look good, we'll merge 'em

License

Copyright (c) 2013 Tony Arcieri, Jonathan Stott. Distributed under the MIT License. See LICENSE.txt for further details.

rbnacl's People

Contributors

tarcieri avatar namelessjon avatar douglasdollars avatar razorinc avatar

Watchers

Pieter Hintjens avatar James Cloos avatar  avatar

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.