Salmon

Welcome to Salmon official web page

Salmon is an AES-256 CTR encryption library with built-in integrity, parallel operations, and seekable stream support.
The library provides a high level API for encrypting data, byte streams, and a virtual drive API for encrypted local and remote files.
Native libraries are optimized for Intel x86_64, ARM64, and GPU cards.

Features

Platforms

Operating Systems

Acceleration

Why use Salmon?

Comparison

Downloads

Salmon Downloads


Official Github Repository: Download

Samples

Salmon Core API:

// Simple encryption and decryption of byte array
byte[] key = Generator.getSecureRandomBytes(32); // Generate a secure key, keep this somewhere safe!
byte[] nonce = Generator.getSecureRandomBytes(8); // Generate a nonce, you must NOT reuse this again for encryption!
byte[] bytes = ..; // data you want to encrypt

// use 2 threads for encryption
Encryptor encryptor = new Encryptor(2);
byte[] encBytes = encryptor.encrypt(bytes, key, nonce);
encryptor.close();

// use 2 threads for decryption
// the nonce is already embedded
Decryptor decryptor = new Decryptor(2); 
byte[] decBytes = decryptor.decrypt(encBytes, key);
decryptor.close();

// Or encrypt a text string
nonce = Generator.getSecureRandomBytes(8); // always get a fresh nonce!
String encText = TextEncryptor.encryptString(text, key, nonce);

// Decrypt the encrypted string, no need to specify the nonce again since it's embedded in the data
String decText = TextDecryptor.decryptString(encText, key);

SalmonFS API:

// Create a file-based nonce sequencer. 
// Make sure this path is secure and excluded from your backups.
String sequencerPath = "c:\\users\\\\AppData\\Local\\\\salmon_sequencer.xml";
FileSequencer sequencer = new FileSequencer(new File(sequencerPath), new SequenceSerializer());

// create/open a virtual drive provided with a location and a text password
// Supported drives: Drive, HttpDrive, WSDrive, NodeDrive (node.js)
AesDrive drive = Drive.create(new File("c:\\path\\to\\your\\virtual\\drive"), password, sequencer);

// get root directory and list files
AesFile root = drive.getRoot();
AesFile[] files = root.listFiles();

// import files:
AesFileCommander commander = new AesFileCommander();
File[] newFiles = new File[]{new File("myfile.txt")};
commander.importFiles(newFiles, root);

// read a file:
AesFile file = root.getChild("myfile.txt");
RandomAccessStream stream = root.getInputStream();
stream.close();
For complete samples: Samples Code
For samples documentation: Samples Documentation

Live Demo

There is a live web demo you can try here: Live Web Demo

Benchmarks

JMH benchmarks

Salmon is almost 2x faster than OpenJDK 11 javax.crypto and 3x faster than Bouncy castle:

CPU: Intel i7 @2.00GHz
Data size: 32MB  
Threads: 1

Benchmark                                              Mode  Cnt   Score   Error  Units  
SalmonBenchmark.EncryptAndDecryptSalmonNativeAesIntr  thrpt       22.008          ops/s  
SalmonBenchmark.EncryptAndDecryptSysBouncyCastle      thrpt        6.457          ops/s  
SalmonBenchmark.EncryptAndDecryptSysDefault           thrpt       12.371          ops/s  
    

C# Benchmarks

Salmon is 2x faster than .NET 7 System.Security.Cryptography:
CPU: Intel i7 @2.00GHz
Data size: 32MB  
Threads: 1

EncryptAndDecryptPerfSysDefault (System.Security.Cryptography)  
Time ms:  
 enc: 682  
 dec: 548  
 Total: 1230  
  
EncryptAndDecryptPerfSalmonNativeAesIntrinsics  
Time ms:  
 enc time: 253  
 dec time: 253  
 Total: 506
 

Technical Specifications

Documentation

Salmon tech specs, development, and deployment guides: Documentation
There are plenty of README files under project folder with build instructions.
And to make things easier there are batch scripts provided to test, deploy, and generate docs: Scripts

Sequence Files

User sequencer files keep information about the sequence ranges so they need to be kept in a protected space. Someone who has write access to a sequencer file and repeated read access to your encrypted files can leak encrypted information about your files. Also make sure that you never backup and restore the nonce sequencer files! You should always create them under a directory that is exluded from your backups, this will prevent nonce reuse! More specifically:

Device Authorization

Data integrity

Functional Limitations

Source Code

The salmon project is hosted on GitHub: Source Code

License

Salmon is released under MIT Licence, see LICENSE
Make sure you read the LICENSE file and display proper attribution if you decide to use this software.
Dependencies are covered by their own license see NOTICE