Crate sjcl[][src]

Expand description

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());

Re-exports

pub use decryption::decrypt;
pub use decryption::decrypt_json;
pub use encryption::encrypt;

Modules

decryption
encryption

Structs

SjclBlock

SJCL result contains all params as well as either the plaintext or the ciphertext in the last element.

SjclParams

Parameter used to encrypt a block.

Enums

SjclError

Functions

truncate_iv

Utility function to trim the initialization vector to the proper size of the nonce. (See: SJCL/core.ccm.js)

Type Definitions

AesCcm128
AesCcm192
AesCcm256