#encryption-decryption #supports #decrypting #json #data #passphrase #key-size

sjcl

Library which supports decrypting data that was encrypted using SJCL

7 releases (1 stable)

1.0.0 May 22, 2021
0.1.1 Apr 25, 2021
0.0.5 Apr 14, 2021
0.0.1 Mar 28, 2021

#1776 in Cryptography


Used in joplin-reader

MIT/Apache

33KB
684 lines

sjcl-rust

Library which supports decrypting and encrypting SJCL compatible blocks.

Features

  • Encryption & Decryption
  • Key sizes between 128- to 256-bit
  • AES-CCM
  • ⚠️ AES-OCB2 is deprecated and not supported

Usage

use sjcl::decrypt_raw;

let data = "{\"iv\":\"nJu7KZF2eEqMv403U2oc3w==\", \"v\":1, \"iter\":10000, \"ks\":256, \"ts\":64, \"mode\":\"ccm\", \"adata\":\"\", \"cipher\":\"aes\", \"salt\":\"mMmxX6SipEM=\", \"ct\":\"VwnKwpW1ah5HmdvwuFBthx0=\"}".to_string();
let password_phrase = "abcdefghi".to_string();

let plaintext = String::from_utf8(decrypt_json(data, password_phrase, None).unwrap())?;

lib.rs:

sjcl

Simple decrypt-only SJCL library.

Only supports AES-CCM so far, but OCB2 is deprecated AFAIK. To use you only need the result of a SJCL encrypted secret and the passphrase.

Usage

Decrypt a file loaded into a string:

use sjcl::decrypt_json;
use sjcl::SjclError;

let data = "{\"iv\":\"nJu7KZF2eEqMv403U2oc3w==\", \"v\":1, \"iter\":10000, \"ks\":256, \"ts\":64, \"mode\":\"ccm\", \"adata\":\"\", \"cipher\":\"aes\", \"salt\":\"mMmxX6SipEM=\", \"ct\":\"VwnKwpW1ah5HmdvwuFBthx0=\"}".to_string();
let password_phrase = "abcdefghi".to_string();
let plaintext = decrypt_json(data, password_phrase, None)?;
assert_eq!("test\ntest".to_string(), String::from_utf8(plaintext).unwrap());

Dependencies

~1.8–2.6MB
~53K SLoC