Giter Club home page Giter Club logo

miscreant.rb's Introduction

miscreant.rb Latest Version Build Status Yard Docs MIT licensed Gitter Chat

The best crypto you've never heard of, brought to you by Phil Rogaway

Ruby implementation of Miscreant: Advanced symmetric encryption library which provides the AES-SIV (RFC 5297), AES-PMAC-SIV, and STREAM constructions. These algorithms are easy-to-use (or rather, hard-to-misuse) and support encryption of individual messages or message streams.

AES-SIV provides nonce-reuse misuse-resistance (NRMR): accidentally reusing a nonce with this construction is not a security catastrophe, unlike it is with more popular AES encryption modes like AES-GCM. With AES-SIV, the worst outcome of reusing a nonce is an attacker can see you've sent the same plaintext twice, as opposed to almost all other AES modes where it can facilitate chosen ciphertext attacks and/or full plaintext recovery.

For more information, see the toplevel README.md.

Help and Discussion

Have questions? Want to suggest a feature or change?

Security Notice

Though this library is written by cryptographic professionals, it has not undergone a thorough security audit, and cryptographic professionals are still humans that make mistakes.

USE AT YOUR OWN RISK

Requirements

This library is tested against the following MRI versions:

  • 2.5
  • 2.6

Other Ruby versions may work, but are not officially supported.

Installation

Add this line to your application's Gemfile:

gem "miscreant"

And then execute:

$ bundle

Or install it yourself as:

$ gem install miscreant

API

The Miscreant::AEAD class provides the main interface to the AES-SIV misuse resistant authenticated encryption function.

To make a new instance, pass in a binary-encoded 32-byte or 64-byte key. Note that these options are twice the size of what you might be expecting (AES-SIV uses two AES keys).

secret_key = Miscreant::AEAD.generate_key
encryptor = Miscreant::AEAD.new("AES-SIV", secret_key)

Encryption (#seal)

The Miscreant::AEAD#seal method encrypts a binary-encoded message along with a set of associated data message headers.

It's recommended to include a unique "nonce" value with each message. This prevents those who may be observing your ciphertexts from being able to tell if you encrypted the same message twice. However, unlike other cryptographic algorithms where using a nonce has catastrophic security implications such as key recovery, reusing a nonce with AES-SIV only leaks repeated ciphertexts to attackers.

Example:

message = "Hello, world!"
nonce = Miscreant::AEAD.generate_nonce
ciphertext = encryptor.seal(message, nonce: nonce)

Decryption (#open)

The Miscreant::AEAD#open method decrypts a binary-encoded ciphertext with the given key.

Example:

message = "Hello, world!"
nonce = Miscreant::AEAD.generate_nonce
ciphertext = encryptor.seal(message, nonce: nonce)
plaintext = encryptor.open(ciphertext, nonce: nonce)

Code of Conduct

We abide by the Contributor Covenant and ask that you do as well.

For more information, please see CODE_OF_CONDUCT.md.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/miscreant/miscreant

Copyright

Copyright (c) 2017-2019 The Miscreant Developers. See LICENSE.txt for further details.

miscreant.rb's People

Contributors

croaky avatar dependabot-preview[bot] avatar tarcieri avatar

Watchers

 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.