Chloride

Chloride provides a simple API over Java's crypto functionality. It uses Bouncy Castle to provide support for modern algorithms. The API is loosely modeled after NaCl and libsodium.

License

License

Categories

Categories

IDE Development Tools
GroupId

GroupId

com.jtdowney
ArtifactId

ArtifactId

chloride
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

Chloride
Chloride provides a simple API over Java's crypto functionality. It uses Bouncy Castle to provide support for modern algorithms. The API is loosely modeled after NaCl and libsodium.
Project URL

Project URL

https://github.com/jtdowney/chloride
Source Code Management

Source Code Management

https://github.com/jtdowney/chloride

Download chloride

How to add to project

<!-- https://jarcasting.com/artifacts/com.jtdowney/chloride/ -->
<dependency>
    <groupId>com.jtdowney</groupId>
    <artifactId>chloride</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.jtdowney/chloride/
implementation 'com.jtdowney:chloride:0.1.1'
// https://jarcasting.com/artifacts/com.jtdowney/chloride/
implementation ("com.jtdowney:chloride:0.1.1")
'com.jtdowney:chloride:jar:0.1.1'
<dependency org="com.jtdowney" name="chloride" rev="0.1.1">
  <artifact name="chloride" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.jtdowney', module='chloride', version='0.1.1')
)
libraryDependencies += "com.jtdowney" % "chloride" % "0.1.1"
[com.jtdowney/chloride "0.1.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.bouncycastle : bcprov-jdk15on jar [1.56,)

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

chloride

Build Status

Chloride provides a simple API over Java's crypto functionality. It uses Bouncy Castle to provide support for modern algorithms. The API is loosely modeled after NaCl and libsodium.

Algorithms

Under the hood, chloride uses NSA Suite B Cryptography. This means it uses AES-256-GCM to encrypt data and for asymmetric boxes it uses ECDH with curve P-256 for key agreement.

Requirements

  1. You need to install Bouncy Castle as a JCE provider.
  2. You need the Java Crypto Unlimited Strength Policy files.

Usage

Box (asymmetric encryption)

KeyPair pair1 = KeyPair.generate();
KeyPair pair2 = KeyPair.generate();
Box box1 = new Box(pair1.getPrivateKey(), pair2.getPublicKey());
Box box2 = new Box(pair2.getPrivateKey(), pair1.getPublicKey());

byte[] ciphertext = box1.encrypt("too many secrets".getBytes("UTF-8"));
byte[] plaintext = box2.decrypt(ciphertext);

Secret Box (symmetric encryption)

SecretKey key = SecretKey.generate();
SecretBox box = new SecretBox(key);
byte[] ciphertext = box.encrypt("too many secrets".getBytes("UTF-8"));
byte[] plaintext = box.decrypt(ciphertext);

Security

Chloride uses a random 96-bit nonce value for AES-GCM, which does raise issues if you're encrypting large amounts of data under the same key. That is because the chance of collision with a 96-bit value is much higher. This choice was made due to the specific circumstances on which Chloride was designed to be used. Please be aware of this limitation for your own systems.

If you've discovered a security bug in Chloride, please email John Downey.

Versions

Version
0.1.1
0.1.0